Build: enable C++20 and updated all compiler requirements

* ported some header and cmake updates from master branch
This commit is contained in:
Ovahlord committed 2023-07-04 23:49:57 +02:00
1 parent 185c80dd96
commit f34534465a
67 files changed
+792 -134

No files matched your search

-1
View File
@@ -8,7 +8,6 @@
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
set(g3dlib_STAT_SRCS
source/AABox.cpp
source/Any.cpp
+20
View File
@@ -0,0 +1,20 @@
diff --git a/dep/g3dlite/include/G3D/Array.h b/dep/g3dlite/include/G3D/Array.h
index c562f5c920f7..c86b20fd7e97 100644
--- a/dep/g3dlite/include/G3D/Array.h
+++ b/dep/g3dlite/include/G3D/Array.h
@@ -346,6 +346,7 @@ class Array {
/** Resizes this to match the size of \a other and then copies the data from other using memcpy. This is only safe for POD types */
void copyPOD(const Array<T>& other) {
+ static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "copyPOD called on non-POD type");
if (numAllocated < other.num) {
m_memoryManager->free(data);
data = NULL;
@@ -364,6 +365,7 @@ class Array {
/** Resizes this to just barely match the size of \a other + itself and then copies the data to the end of the array from other using memcpy.
This is only safe for POD types */
void appendPOD(const Array<T>& other) {
+ static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "appendPOD called on non-POD type");
const size_t oldSize = num;
num += other.num;
if (numAllocated < num) {
+13
View File
@@ -0,0 +1,13 @@
diff --git a/dep/g3dlite/source/fileutils.cpp b/dep/g3dlite/source/fileutils.cpp
index 2788adad3bcd..f5310084cec7 100644
--- a/dep/g3dlite/source/fileutils.cpp
+++ b/dep/g3dlite/source/fileutils.cpp
@@ -490,7 +490,7 @@ void parseFilename(
}
- } else if ((f.size() >= 2) & isSlash(f[0]) && isSlash(f[1])) {
+ } else if ((f.size() >= 2) && isSlash(f[0]) && isSlash(f[1])) {
// e.g. //foo
root = f.substr(0, 2);
+192
View File
@@ -0,0 +1,192 @@
diff --git a/dep/g3dlite/include/G3D/AtomicInt32.h b/dep/g3dlite/include/G3D/AtomicInt32.h
index 7b56e001ae29..9824d426d741 100644
--- a/dep/g3dlite/include/G3D/AtomicInt32.h
+++ b/dep/g3dlite/include/G3D/AtomicInt32.h
@@ -76,12 +76,16 @@ class AtomicInt32 {
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
- int32 old;
- asm volatile ("lock; xaddl %0,%1"
- : "=r"(old), "=m"(m_value) /* outputs */
- : "0"(x), "m"(m_value) /* inputs */
- : "memory", "cc");
- return old;
+# if defined(__aarch64__)
+ return __sync_fetch_and_add(&m_value, x);
+# else
+ int32 old;
+ asm volatile ("lock; xaddl %0,%1"
+ : "=r"(old), "=m"(m_value) /* outputs */
+ : "0"(x), "m"(m_value) /* inputs */
+ : "memory", "cc");
+ return old;
+# endif
# elif defined(G3D_OSX)
@@ -115,14 +119,18 @@ class AtomicInt32 {
// Note: returns the newly decremented value
return InterlockedDecrement(&m_value);
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
- unsigned char nz;
-
- asm volatile ("lock; decl %1;\n\t"
- "setnz %%al"
- : "=a" (nz)
- : "m" (m_value)
- : "memory", "cc");
- return nz;
+# if defined(__aarch64__)
+ return __sync_sub_and_fetch(&m_value, 1);
+# else
+ unsigned char nz;
+
+ asm volatile ("lock; decl %1;\n\t"
+ "setnz %%al"
+ : "=a" (nz)
+ : "m" (m_value)
+ : "memory", "cc");
+ return nz;
+# endif
# elif defined(G3D_OSX)
// Note: returns the newly decremented value
return OSAtomicDecrement32(&m_value);
@@ -143,17 +151,21 @@ class AtomicInt32 {
# if defined(G3D_WINDOWS)
return InterlockedCompareExchange(&m_value, exchange, comperand);
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX)
- // Based on Apache Portable Runtime
- // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx
- int32 ret;
- asm volatile ("lock; cmpxchgl %1, %2"
- : "=a" (ret)
- : "r" (exchange), "m" (m_value), "0"(comperand)
- : "memory", "cc");
- return ret;
-
- // Note that OSAtomicCompareAndSwap32 does not return a useful value for us
- // so it can't satisfy the cmpxchgl contract.
+# if defined(__aarch64__)
+ return __sync_val_compare_and_swap(&m_value, comperand, exchange);
+# else
+ // Based on Apache Portable Runtime
+ // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx
+ int32 ret;
+ asm volatile ("lock; cmpxchgl %1, %2"
+ : "=a" (ret)
+ : "r" (exchange), "m" (m_value), "0"(comperand)
+ : "memory", "cc");
+ return ret;
+
+ // Note that OSAtomicCompareAndSwap32 does not return a useful value for us
+ // so it can't satisfy the cmpxchgl contract.
+# endif
# endif
}
diff --git a/dep/g3dlite/include/G3D/System.h b/dep/g3dlite/include/G3D/System.h
index 4624dd916474..9ed88957d755 100644
--- a/dep/g3dlite/include/G3D/System.h
+++ b/dep/g3dlite/include/G3D/System.h
@@ -21,6 +21,10 @@
#include "G3D/FileNotFound.h"
#include <string>
+#if defined(__aarch64__)
+#include <sys/time.h>
+#endif
+
#ifdef G3D_OSX
#define Zone OSX_Zone
# include <CoreServices/CoreServices.h>
@@ -497,15 +501,37 @@ class System {
#elif defined(G3D_LINUX)
inline uint64 System::getCycleCount() {
- uint32 timehi, timelo;
+# if defined(__aarch64__)
+# if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount
+ uint32_t pmccntr;
+ uint32_t pmuseren;
+ uint32_t pmcntenset;
+ // Read the user mode perf monitor counter access permissions.
+ __asm__ __volatile__("mrc p15, 0, %w0, c9, c14, 0" : "=r"(pmuseren));
+ if (pmuseren & 1) { // Allows reading perfmon counters for user mode code.
+ __asm__ __volatile__("mrc p15, 0, %w0, c9, c12, 1" : "=r"(pmcntenset));
+ if (pmcntenset & 0x80000000ul) { // Is it counting?
+ __asm__ __volatile__("mrc p15, 0, %w0, c9, c13, 0" : "=r"(pmccntr));
+ // The counter is set up to count every 64th cycle
+ return static_cast<uint64>(pmccntr) * 64; // Should optimize to << 6
+ }
+ }
+# endif
- __asm__ __volatile__ (
- "rdtsc "
- : "=a" (timelo),
- "=d" (timehi)
- : );
+ struct timeval tv;
+ gettimeofday(&tv, nullptr);
+ return static_cast<uint64>(tv.tv_sec) * 1000000 + tv.tv_usec;
+# else
+ uint32 timehi, timelo;
+
+ __asm__ __volatile__ (
+ "rdtsc "
+ : "=a" (timelo),
+ "=d" (timehi)
+ : );
- return ((uint64)timehi << 32) + (uint64)timelo;
+ return ((uint64)timehi << 32) + (uint64)timelo;
+# endif
}
#elif defined(G3D_OSX)
diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h
index 439495ab1315..d043f21491ad 100644
--- a/dep/g3dlite/include/G3D/platform.h
+++ b/dep/g3dlite/include/G3D/platform.h
@@ -273,7 +273,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\
# define __stdcall __attribute__((stdcall))
# endif
-# elif defined(__x86_64__)
+# elif defined(__x86_64__) || defined(__arm) || defined(__aarch64__)
# ifndef __cdecl
# define __cdecl
diff --git a/dep/g3dlite/source/System.cpp b/dep/g3dlite/source/System.cpp
index b841e23c497e..4a75d320b8d3 100644
--- a/dep/g3dlite/source/System.cpp
+++ b/dep/g3dlite/source/System.cpp
@@ -79,8 +79,9 @@
#endif
// SIMM include
+#if !defined(__aarch64__)
#include <xmmintrin.h>
-
+#endif
namespace G3D {
@@ -1697,6 +1698,16 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui
edx = regs[3];
}
+#elif defined(__aarch64__) || defined(G3D_OSX) && ! defined(G3D_OSX_INTEL)
+
+// non-x86 CPU; no CPUID
+void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) {
+ eax = 0;
+ ebx = 0;
+ ecx = 0;
+ edx = 0;
+}
+
#else
// See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
+24 -11
View File
@@ -1,12 +1,25 @@
diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h
index 1c42513b45..05d9b11ed5 100644
--- a/dep/g3dlite/include/G3D/Vector3.h
+++ b/dep/g3dlite/include/G3D/Vector3.h
@@ -128,7 +128,6 @@ public:
Axis primaryAxis() const;
diff --git a/dep/g3dlite/include/G3D/g3dmath.h b/dep/g3dlite/include/G3D/g3dmath.h
index 54cc6ed370..002cd3858d 100644
--- a/dep/g3dlite/include/G3D/g3dmath.h
+++ b/dep/g3dlite/include/G3D/g3dmath.h
@@ -27,6 +27,7 @@
#include "G3D/platform.h"
#include <ctype.h>
#include <float.h>
+#include <algorithm>
#include <limits>
#include <stdlib.h>
#include <stdint.h>
diff --git a/dep/g3dlite/source/debugAssert.cpp b/dep/g3dlite/source/debugAssert.cpp
index cfccf9a0cc..3c3e43a0af 100644
--- a/dep/g3dlite/source/debugAssert.cpp
+++ b/dep/g3dlite/source/debugAssert.cpp
@@ -99,7 +99,7 @@ static void createErrorMessage(
}
// assignment and comparison
- Vector3& operator=(const Vector3& rkVector) = default;
Vector3& operator=(const Any& a);
bool operator== (const Vector3& rkVector) const;
bool operator!= (const Vector3& rkVector) const;
// Make sure the message got translated into something.
- LPTSTR realLastErr;
+ LPCTSTR realLastErr;
if (NULL != formatMsg) {
realLastErr = formatMsg;
} else {
+12
View File
@@ -0,0 +1,12 @@
diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h
index 1c42513b45..05d9b11ed5 100644
--- a/dep/g3dlite/include/G3D/Vector3.h
+++ b/dep/g3dlite/include/G3D/Vector3.h
@@ -128,7 +128,6 @@ public:
Axis primaryAxis() const;
// assignment and comparison
- Vector3& operator=(const Vector3& rkVector) = default;
Vector3& operator=(const Any& a);
bool operator== (const Vector3& rkVector) const;
bool operator!= (const Vector3& rkVector) const;
+288
View File
@@ -0,0 +1,288 @@
diff --git a/dep/g3dlite/include/G3D/AABox.h b/dep/g3dlite/include/G3D/AABox.h
index 7a47ea63aa..97a47cf986 100644
--- a/dep/g3dlite/include/G3D/AABox.h
+++ b/dep/g3dlite/include/G3D/AABox.h
@@ -17,14 +17,14 @@
#include "G3D/platform.h"
#include "G3D/debug.h"
-#include "G3D/Array.h"
-#include "G3D/Plane.h"
-#include "G3D/Sphere.h"
#include "G3D/Vector3.h"
namespace G3D {
class Any;
+template <class T, size_t MIN_ELEMENTS> class Array;
+class Plane;
+class Sphere;
/**
An axis-aligned box.
@@ -221,7 +221,7 @@ public:
*/
bool culledBy
- (const Array<Plane>& plane,
+ (const Array<Plane, 10>& plane,
int32& cullingPlaneIndex,
const uint32 testMask,
uint32& childMask) const;
@@ -230,7 +230,7 @@ public:
Conservative culling test that does not produce a mask for children.
*/
bool culledBy
- (const Array<Plane>& plane,
+ (const Array<Plane, 10>& plane,
int32& cullingPlaneIndex = dummy,
const uint32 testMask = 0xFFFFFFFF) const;
diff --git a/dep/g3dlite/include/G3D/AtomicInt32.h b/dep/g3dlite/include/G3D/AtomicInt32.h
index 9824d426d7..51561e3dcc 100644
--- a/dep/g3dlite/include/G3D/AtomicInt32.h
+++ b/dep/g3dlite/include/G3D/AtomicInt32.h
@@ -12,7 +12,9 @@
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
-#if defined(G3D_OSX)
+#if defined(G3D_WINDOWS)
+# include <Windows.h>
+#elif defined(G3D_OSX)
# include <libkern/OSAtomic.h>
#endif
diff --git a/dep/g3dlite/include/G3D/HashTrait.h b/dep/g3dlite/include/G3D/HashTrait.h
index 1de3777bae..6199f4504e 100644
--- a/dep/g3dlite/include/G3D/HashTrait.h
+++ b/dep/g3dlite/include/G3D/HashTrait.h
@@ -13,7 +13,6 @@
#define G3D_HashTrait_h
#include "G3D/platform.h"
-#include "G3D/Crypto.h"
#include "G3D/g3dmath.h"
#include "G3D/uint128.h"
#include <typeinfo>
diff --git a/dep/g3dlite/include/G3D/Random.h b/dep/g3dlite/include/G3D/Random.h
index 9d911806a9..359755044a 100644
--- a/dep/g3dlite/include/G3D/Random.h
+++ b/dep/g3dlite/include/G3D/Random.h
@@ -159,6 +159,7 @@ public:
static Random& common();
};
+Random& commonRandom();
}
#endif
diff --git a/dep/g3dlite/include/G3D/System.h b/dep/g3dlite/include/G3D/System.h
index 9ed88957d7..81c83527c9 100644
--- a/dep/g3dlite/include/G3D/System.h
+++ b/dep/g3dlite/include/G3D/System.h
@@ -21,6 +21,10 @@
#include "G3D/FileNotFound.h"
#include <string>
+#ifdef G3D_WINDOWS
+#include <Windows.h>
+#endif
+
#if defined(__aarch64__)
#include <sys/time.h>
#endif
diff --git a/dep/g3dlite/include/G3D/Vector2.h b/dep/g3dlite/include/G3D/Vector2.h
index 65cf7fa8f2..696889d630 100644
--- a/dep/g3dlite/include/G3D/Vector2.h
+++ b/dep/g3dlite/include/G3D/Vector2.h
@@ -19,20 +19,21 @@
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
-#include "G3D/Table.h"
#include "G3D/HashTrait.h"
#include "G3D/Vector2int16.h"
#include "G3D/Vector2unorm16.h"
-#include "G3D/Random.h"
namespace G3D {
+class Random;
class Vector2;
class Vector3;
class Vector4;
class Vector2int32;
class Any;
+Random& commonRandom();
+
/**
Do not subclass-- this implementation makes assumptions about the
memory layout.
@@ -210,7 +211,7 @@ public:
}
/** Uniformly distributed random vector on the unit sphere */
- static Vector2 random(Random& r = Random::common());
+ static Vector2 random(Random& r = commonRandom());
// Special values.
// Intentionally not inlined: see Matrix3::identity() for details.
diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h
index 05d9b11ed5..c79f70b916 100644
--- a/dep/g3dlite/include/G3D/Vector3.h
+++ b/dep/g3dlite/include/G3D/Vector3.h
@@ -17,9 +17,7 @@
#include "G3D/platform.h"
#include "G3D/g3dmath.h"
-#include "G3D/Random.h"
#include "G3D/Vector2.h"
-#include "G3D/Table.h"
#include "G3D/HashTrait.h"
#include "G3D/PositionTrait.h"
#include "G3D/Vector2.h"
@@ -365,7 +363,7 @@ public:
Distribution rendered by G3D::DirectionHistogram:
\image html vector3-random.png
*/
- static Vector3 random(Random& r = Random::common());
+ static Vector3 random(Random& r = commonRandom());
/** \brief Random unit vector, distributed according to \f$\max(\cos \theta,0)\f$.
@@ -380,9 +378,9 @@ public:
@cite Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24
*/
- static Vector3 cosHemiRandom(const Vector3& n, Random& r = Random::common());
+ static Vector3 cosHemiRandom(const Vector3& n, Random& r = commonRandom());
- static Vector3 cosSphereRandom(const Vector3& n, Random& r = Random::common());
+ static Vector3 cosSphereRandom(const Vector3& n, Random& r = commonRandom());
/** \brief Random unit vector, distributed according to \f$\max(\cos^k \theta,0)\f$.
@@ -397,7 +395,7 @@ public:
@cite Ashikhmin and Shirley, An anisotropic Phong BRDF model, Journal of Graphics Tools, 2002
*/
- static Vector3 cosPowHemiRandom(const Vector3& n, const float k, Random& r = Random::common());
+ static Vector3 cosPowHemiRandom(const Vector3& n, const float k, Random& r = commonRandom());
/**
\brief Random vector distributed over the hemisphere about normal.
@@ -405,7 +403,7 @@ public:
Distribution rendered by G3D::DirectionHistogram:
\image html vector3-hemirandom.png
*/
- static Vector3 hemiRandom(const Vector3& normal, Random& r = Random::common());
+ static Vector3 hemiRandom(const Vector3& normal, Random& r = commonRandom());
inline float sum() const {
return x + y + z;
diff --git a/dep/g3dlite/include/G3D/Vector4.h b/dep/g3dlite/include/G3D/Vector4.h
index 24521efc93..0f0ea459df 100644
--- a/dep/g3dlite/include/G3D/Vector4.h
+++ b/dep/g3dlite/include/G3D/Vector4.h
@@ -19,7 +19,6 @@
#include "G3D/g3dmath.h"
#include "G3D/Vector3.h"
#include "G3D/Vector2.h"
-#include "G3D/Table.h"
#include "G3D/HashTrait.h"
#include "G3D/PositionTrait.h"
#include <string>
diff --git a/dep/g3dlite/include/G3D/debugAssert.h b/dep/g3dlite/include/G3D/debugAssert.h
index edff671061..197312bd12 100644
--- a/dep/g3dlite/include/G3D/debugAssert.h
+++ b/dep/g3dlite/include/G3D/debugAssert.h
@@ -32,6 +32,7 @@
#include <cstdlib>
#ifdef _MSC_VER
+#include <intrin.h>
// conditional expression is constant
# pragma warning (disable : 4127)
#endif
@@ -116,7 +117,7 @@ namespace _internal {
#ifdef G3D_DEBUG
# if defined(_MSC_VER)
-# define rawBreak() ::DebugBreak();
+# define rawBreak() ::__debugbreak();
# elif defined(__i386__)
// gcc on intel
# define rawBreak() __asm__ __volatile__ ( "int $3" );
diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h
index d043f21491..9202fe41d0 100644
--- a/dep/g3dlite/include/G3D/platform.h
+++ b/dep/g3dlite/include/G3D/platform.h
@@ -190,6 +190,7 @@ These control the version of Winsock used by G3D.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_Compiler_Reference.asp
//
+#if 0
// DLL runtime
#ifndef _DLL
#define _DLL
@@ -227,6 +228,8 @@ These control the version of Winsock used by G3D.
# undef WIN32_LEAN_AND_MEAN
# undef NOMINMAX
+#endif // 0
+
# ifdef _G3D_INTERNAL_HIDE_WINSOCK_
# undef _G3D_INTERNAL_HIDE_WINSOCK_
# undef _WINSOCKAPI_
diff --git a/dep/g3dlite/source/Random.cpp b/dep/g3dlite/source/Random.cpp
index cbfa07dec0..a31d52a557 100644
--- a/dep/g3dlite/source/Random.cpp
+++ b/dep/g3dlite/source/Random.cpp
@@ -227,4 +227,9 @@ void Random::sphere(float& x, float& y, float& z) {
z *= s;
}
+Random& commonRandom()
+{
+ return Random::common();
+}
+
} // G3D
diff --git a/dep/g3dlite/source/Vector2.cpp b/dep/g3dlite/source/Vector2.cpp
index a6edea9a83..194cd3090d 100644
--- a/dep/g3dlite/source/Vector2.cpp
+++ b/dep/g3dlite/source/Vector2.cpp
@@ -23,6 +23,7 @@
#include "G3D/TextInput.h"
#include "G3D/TextOutput.h"
#include "G3D/Any.h"
+#include "G3D/Random.h"
namespace G3D {
diff --git a/dep/g3dlite/source/Vector3.cpp b/dep/g3dlite/source/Vector3.cpp
index e2d9643e5c..ccbf7d6a0b 100644
--- a/dep/g3dlite/source/Vector3.cpp
+++ b/dep/g3dlite/source/Vector3.cpp
@@ -28,6 +28,7 @@
#include "G3D/Vector4.h"
#include "G3D/Vector3int32.h"
#include "G3D/Any.h"
+#include "G3D/Random.h"
namespace G3D {
diff --git a/dep/g3dlite/source/debugAssert.cpp b/dep/g3dlite/source/debugAssert.cpp
index 3c3e43a0af..ff843fb7ee 100644
--- a/dep/g3dlite/source/debugAssert.cpp
+++ b/dep/g3dlite/source/debugAssert.cpp
@@ -23,6 +23,7 @@
#include <cstdlib>
#ifdef _MSC_VER
+#include <Windows.h>
// disable: "C++ exception handler used"
# pragma warning (push)
# pragma warning (disable : 4530)
+14
View File
@@ -0,0 +1,14 @@
diff --git a/dep/g3dlite/source/FileSystem.cpp b/dep/g3dlite/source/FileSystem.cpp
index 06e6ff00a5e3..0898af795348 100644
--- a/dep/g3dlite/source/FileSystem.cpp
+++ b/dep/g3dlite/source/FileSystem.cpp
@@ -35,6 +35,9 @@
# include <fnmatch.h>
# include <unistd.h>
# define _getcwd getcwd
+# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# define stat64 stat
+# endif
# define _stat stat
# define stricmp strcasecmp
# define strnicmp strncasecmp
+13
View File
@@ -0,0 +1,13 @@
diff --git a/dep/g3dlite/source/FileSystem.cpp b/dep/g3dlite/source/FileSystem.cpp
index 0898af7953..ff5da02344 100644
--- a/dep/g3dlite/source/FileSystem.cpp
+++ b/dep/g3dlite/source/FileSystem.cpp
@@ -35,7 +35,7 @@
# include <fnmatch.h>
# include <unistd.h>
# define _getcwd getcwd
-# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
# define stat64 stat
# endif
# define _stat stat
+8
View File
@@ -17,3 +17,11 @@ G3D-v9.0 hotfix4.diff - 2015-07-02 - backport G3D10 fix
G3D-v9.0 hotfix5.diff - 2015-07-31 - fix MSVC 2015 warning: dep/g3dlite/include/G3D/Quat.h(352): warning C4458: declaration of 'x' hides class member
G3D-v9.0 hotfix6.diff - 2015-11-04 - fix adding std::shared_ptr, std::weak_ptr, std::dynamic_pointer_cast, std::static_pointer_cast and std::enable_shared_from_this to global namespace
G3D-v9.0 hotfix7.diff - 2016-10-10 - fix warning on clang 3.8 backported from G3D 10
G3D-v9.0 hotfix8.diff - 2017-03-07 - fix MSVC 2017 build
G3D-v9.0 hotfix9.diff - 2020-07-13 - warning fixes
G3D-v9.0 hotfix10.diff - 2017-11-11 - static analysis issue fix
G3D-v9.0 hotfix11.diff - 2017-11-11 - static analysis issue fix
G3D-v9.0 hotfix12.diff - 2020-02-23 - ARM64 build fix
G3D-v9.0 hotfix13.diff - 2020-08-04 - MSVC build fix with /permissive-
G3D-v9.0 hotfix14.diff - 2022-01-16 - warning fixes
G3D-v9.0 hotfix16.diff - 2022-02-11 - Fix *BSD compile errors
+2 -2
View File
@@ -346,7 +346,7 @@ public:
/** Resizes this to match the size of \a other and then copies the data from other using memcpy. This is only safe for POD types */
void copyPOD(const Array<T>& other) {
static_assert(std::is_pod<T>::value, "copyPOD called on non-POD type");
static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "copyPOD called on non-POD type");
if (numAllocated < other.num) {
m_memoryManager->free(data);
data = NULL;
@@ -365,7 +365,7 @@ public:
/** Resizes this to just barely match the size of \a other + itself and then copies the data to the end of the array from other using memcpy.
This is only safe for POD types */
void appendPOD(const Array<T>& other) {
static_assert(std::is_pod<T>::value, "appendPOD called on non-POD type");
static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "appendPOD called on non-POD type");
const size_t oldSize = num;
num += other.num;
if (numAllocated < num) {
+35 -23
View File
@@ -76,12 +76,16 @@ public:
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
int32 old;
asm volatile ("lock; xaddl %0,%1"
: "=r"(old), "=m"(m_value) /* outputs */
: "0"(x), "m"(m_value) /* inputs */
: "memory", "cc");
return old;
# if defined(__aarch64__)
return __sync_fetch_and_add(&m_value, x);
# else
int32 old;
asm volatile ("lock; xaddl %0,%1"
: "=r"(old), "=m"(m_value) /* outputs */
: "0"(x), "m"(m_value) /* inputs */
: "memory", "cc");
return old;
# endif
# elif defined(G3D_OSX)
@@ -115,14 +119,18 @@ public:
// Note: returns the newly decremented value
return InterlockedDecrement(&m_value);
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD)
unsigned char nz;
# if defined(__aarch64__)
return __sync_sub_and_fetch(&m_value, 1);
# else
unsigned char nz;
asm volatile ("lock; decl %1;\n\t"
"setnz %%al"
: "=a" (nz)
: "m" (m_value)
: "memory", "cc");
return nz;
asm volatile ("lock; decl %1;\n\t"
"setnz %%al"
: "=a" (nz)
: "m" (m_value)
: "memory", "cc");
return nz;
# endif
# elif defined(G3D_OSX)
// Note: returns the newly decremented value
return OSAtomicDecrement32(&m_value);
@@ -143,17 +151,21 @@ public:
# if defined(G3D_WINDOWS)
return InterlockedCompareExchange(&m_value, exchange, comperand);
# elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX)
// Based on Apache Portable Runtime
// http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx
int32 ret;
asm volatile ("lock; cmpxchgl %1, %2"
: "=a" (ret)
: "r" (exchange), "m" (m_value), "0"(comperand)
: "memory", "cc");
return ret;
# if defined(__aarch64__)
return __sync_val_compare_and_swap(&m_value, comperand, exchange);
# else
// Based on Apache Portable Runtime
// http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx
int32 ret;
asm volatile ("lock; cmpxchgl %1, %2"
: "=a" (ret)
: "r" (exchange), "m" (m_value), "0"(comperand)
: "memory", "cc");
return ret;
// Note that OSAtomicCompareAndSwap32 does not return a useful value for us
// so it can't satisfy the cmpxchgl contract.
// Note that OSAtomicCompareAndSwap32 does not return a useful value for us
// so it can't satisfy the cmpxchgl contract.
# endif
# endif
}
+1 -1
View File
@@ -349,7 +349,7 @@ public:
// "You might be tempted to write [...] them as inline functions
// inside their respective header files, but this is something you
// must definitely not do. An inline function can be duplicated
// in every file in which it appears œóõ½ and this duplication
// in every file in which it appears and this duplication
// includes the static object definition. Because inline functions
// automatically default to internal linkage, this would result in
// having multiple static objects across the various translation
+1 -1
View File
@@ -36,7 +36,7 @@ private:
/** The following are for the "ray slope" optimization from
"Fast Ray / Axis-Aligned Bounding Box Overlap Tests using Ray Slopes"
by Martin Eisemann, Thorsten Grosch, Stefan M�üller and Marcus Magnor
by Martin Eisemann, Thorsten Grosch, Stefan Müller and Marcus Magnor
Computer Graphics Lab, TU Braunschweig, Germany and
University of Koblenz-Landau, Germany */
enum Classification {MMM, MMP, MPM, MPP, PMM, PMP, PPM, PPP, POO, MOO, OPO, OMO, OOP, OOM, OMM, OMP, OPM, OPP, MOM, MOP, POM, POP, MMO, MPO, PMO, PPO};
+33 -7
View File
@@ -21,6 +21,10 @@
#include "G3D/FileNotFound.h"
#include <string>
#if defined(__aarch64__)
#include <sys/time.h>
#endif
#ifdef G3D_OSX
#define Zone OSX_Zone
# include <CoreServices/CoreServices.h>
@@ -497,15 +501,37 @@ public:
#elif defined(G3D_LINUX)
inline uint64 System::getCycleCount() {
uint32 timehi, timelo;
# if defined(__aarch64__)
# if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount
uint32_t pmccntr;
uint32_t pmuseren;
uint32_t pmcntenset;
// Read the user mode perf monitor counter access permissions.
__asm__ __volatile__("mrc p15, 0, %w0, c9, c14, 0" : "=r"(pmuseren));
if (pmuseren & 1) { // Allows reading perfmon counters for user mode code.
__asm__ __volatile__("mrc p15, 0, %w0, c9, c12, 1" : "=r"(pmcntenset));
if (pmcntenset & 0x80000000ul) { // Is it counting?
__asm__ __volatile__("mrc p15, 0, %w0, c9, c13, 0" : "=r"(pmccntr));
// The counter is set up to count every 64th cycle
return static_cast<uint64>(pmccntr) * 64; // Should optimize to << 6
}
}
# endif
__asm__ __volatile__ (
"rdtsc "
: "=a" (timelo),
"=d" (timehi)
: );
struct timeval tv;
gettimeofday(&tv, nullptr);
return static_cast<uint64>(tv.tv_sec) * 1000000 + tv.tv_usec;
# else
uint32 timehi, timelo;
return ((uint64)timehi << 32) + (uint64)timelo;
__asm__ __volatile__ (
"rdtsc "
: "=a" (timelo),
"=d" (timehi)
: );
return ((uint64)timehi << 32) + (uint64)timelo;
# endif
}
#elif defined(G3D_OSX)
+1
View File
@@ -27,6 +27,7 @@
#include "G3D/platform.h"
#include <ctype.h>
#include <float.h>
#include <algorithm>
#include <limits>
#include <stdlib.h>
#include <stdint.h>
+1 -1
View File
@@ -273,7 +273,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\
# define __stdcall __attribute__((stdcall))
# endif
# elif defined(__x86_64__)
# elif defined(__x86_64__) || defined(__arm) || defined(__aarch64__)
# ifndef __cdecl
# define __cdecl
+3
View File
@@ -35,6 +35,9 @@
# include <fnmatch.h>
# include <unistd.h>
# define _getcwd getcwd
# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define stat64 stat
# endif
# define _stat stat
# define stricmp strcasecmp
# define strnicmp strncasecmp
+12 -1
View File
@@ -79,8 +79,9 @@
#endif
// SIMM include
#if !defined(__aarch64__)
#include <xmmintrin.h>
#endif
namespace G3D {
@@ -1697,6 +1698,16 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui
edx = regs[3];
}
#elif defined(__aarch64__) || defined(G3D_OSX) && ! defined(G3D_OSX_INTEL)
// non-x86 CPU; no CPUID
void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) {
eax = 0;
ebx = 0;
ecx = 0;
edx = 0;
}
#else
// See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
+1 -1
View File
@@ -99,7 +99,7 @@ static void createErrorMessage(
}
// Make sure the message got translated into something.
LPTSTR realLastErr;
LPCTSTR realLastErr;
if (NULL != formatMsg) {
realLastErr = formatMsg;
} else {