Browse Source

Restore Urho3D tweaks to as_config.h and earlier ifdef check for C++11 features.

Lasse Öörni 9 years ago
parent
commit
e22de44be5

+ 8 - 7
Source/ThirdParty/AngelScript/include/angelscript.h

@@ -419,14 +419,15 @@ typedef asIScriptContext *(*asREQUESTCONTEXTFUNC_t)(asIScriptEngine *, void *);
 typedef void (*asRETURNCONTEXTFUNC_t)(asIScriptEngine *, asIScriptContext *, void *);
 
 // Check if the compiler can use C++11 features
+// Urho3D: restored earlier ifdef
 #if !defined(_MSC_VER) || _MSC_VER >= 1700   // MSVC 2012
- #if !defined(__GNUC__) || defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)  // gnuc 4.7 or clang
-  #if !(defined(__GNUC__) && defined(__cplusplus) && __cplusplus < 201103L) // gnuc and clang require compiler flag -std=c++11
-   #if !defined(__SUNPRO_CC) // Oracle Solaris Studio
-    #define AS_CAN_USE_CPP11 1
-   #endif
-  #endif
- #endif
+#if !defined(__GNUC__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)  // gnuc 4.7
+#if !(defined(__GNUC__) && defined(__cplusplus) && __cplusplus < 201103L) // g++ -std=c++11
+#if !defined(__SUNPRO_CC)
+#define AS_CAN_USE_CPP11 1
+#endif
+#endif
+#endif
 #endif
 
 // This macro does basically the same thing as offsetof defined in stddef.h, but

+ 83 - 63
Source/ThirdParty/AngelScript/source/as_config.h

@@ -28,6 +28,7 @@
    [email protected]
 */
 
+// Modified by Yao Wei Tjong and Skrylar for Urho3D
 
 
 //
@@ -606,8 +607,7 @@
 
 // GNU C (and MinGW or Cygwin on Windows)
 // Use the following command to determine predefined macros: echo . | g++ -dM -E -
-// MSVC2015 can now use CLang too, but it shouldn't go in here
-#if (defined(__GNUC__) && !defined(__SNC__) && !defined(_MSC_VER)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
+#if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
 	#define GNU_STYLE_VIRTUAL_METHOD
 	#define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))
 	#define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
@@ -804,12 +804,13 @@
 
 			// As of version 4.7 MinGW changed the ABI, presumably
 			// to be better aligned with how MSVC works
+			// Urho3D: also check for Clang version and use the same workaround
 			#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
 				#define AS_MINGW47
 			#endif
-		
-			#if (__clang_major__ == 3 && __clang_minor__ > 4) || __clang_major > 3
-				#define AS_MINGW47
+
+			#if (__clang_major__ == 3 && __clang_minor__ > 4)
+			    #define AS_MINGW47
 			#endif
 
 			#ifdef AS_MINGW47
@@ -841,7 +842,6 @@
 		#define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
 
 		#if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
-			// x86 32bit
 			#define THISCALL_RETURN_SIMPLE_IN_MEMORY
 			#define CDECL_RETURN_SIMPLE_IN_MEMORY
 			#define STDCALL_RETURN_SIMPLE_IN_MEMORY
@@ -850,8 +850,9 @@
 			#define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
 			#define AS_X86
 			#undef AS_NO_THISCALL_FUNCTOR_METHOD
-		#elif defined(__x86_64__)
-			// x86 64bit
+
+		// Urho3D - use __aarch64__ instead of __arm64__ because GCC only emits the former
+		#elif defined(__LP64__) && !defined(__aarch64__)
 			#define AS_X64_GCC
 			#undef AS_NO_THISCALL_FUNCTOR_METHOD
 			#define HAS_128_BIT_PRIMITIVES
@@ -861,56 +862,60 @@
 			// STDCALL is not available on 64bit Linux
 			#undef STDCALL
 			#define STDCALL
-		#elif defined(__ARMEL__) || defined(__arm__) || defined(__aarch64__) || defined(__AARCH64EL__)
-			// arm 
 
-			// The assembler code currently doesn't support arm v4, nor 64bit (v8)
-			#if !defined(__ARM_ARCH_4__) && !defined(__ARM_ARCH_4T__) && !defined(__LP64__)
-				#define AS_ARM
+		// Urho3D - Add support for aarch64-linux-gnu
+		#elif defined(__aarch64__)
+			// AngelScript currently doesn't support native calling
+			// for 64bit ARM processors so it's necessary to turn on
+			// portability mode
+			#define AS_MAX_PORTABILITY
+			// STDCALL is not available on ARM
+			#undef STDCALL
+			#define STDCALL
 
-				// TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
-				#define AS_NO_EXCEPTIONS
+		#elif (defined(__ARMEL__) || defined(__arm__)) && !(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__))
+			#define AS_ARM
 
-				#undef STDCALL
-				#define STDCALL
+			// TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
+			#define AS_NO_EXCEPTIONS
 
-				#define CDECL_RETURN_SIMPLE_IN_MEMORY
-				#define STDCALL_RETURN_SIMPLE_IN_MEMORY
-				#define THISCALL_RETURN_SIMPLE_IN_MEMORY
+			#undef STDCALL
+			#define STDCALL
 
-				#undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
-				#undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
-				#undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
+			#define CDECL_RETURN_SIMPLE_IN_MEMORY
+			#define STDCALL_RETURN_SIMPLE_IN_MEMORY
+			#define THISCALL_RETURN_SIMPLE_IN_MEMORY
 
-				#define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
-				#define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
-				#define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
+			#undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
+			#undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
+			#undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
 
-				#ifndef AS_MAX_PORTABILITY
-				// Make a few checks against incompatible ABI combinations
-				#if defined(__FAST_MATH__) && __FAST_MATH__ == 1
-					#error -ffast-math is not supported with native calling conventions
-				#endif
-				#endif
+			#define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
+			#define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
+			#define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
 
-				// Verify if soft-float or hard-float ABI is used
-				#if defined(__SOFTFP__) && __SOFTFP__ == 1
-					// -ffloat-abi=softfp or -ffloat-abi=soft
-					#define AS_SOFTFP
-				#endif
+			#ifndef AS_MAX_PORTABILITY
+			// Make a few checks against incompatible ABI combinations
+			#if defined(__FAST_MATH__) && __FAST_MATH__ == 1
+				#error -ffast-math is not supported with native calling conventions
+			#endif
+			#endif
 
-				// Tested with both hard float and soft float abi
-				#undef AS_NO_THISCALL_FUNCTOR_METHOD
+			// Verify if soft-float or hard-float ABI is used
+			#if defined(__SOFTFP__) && __SOFTFP__ == 1
+				// -ffloat-abi=softfp or -ffloat-abi=soft
+				#define AS_SOFTFP
 			#endif
 
+			// Tested with both hard float and soft float abi
+			#undef AS_NO_THISCALL_FUNCTOR_METHOD
+
 		#elif defined(__mips__)
-			// mips
 			#define AS_MIPS
 			#undef STDCALL
 			#define STDCALL
 
 			#ifdef _ABIO32
-				// 32bit O32 ABI
 				#define AS_MIPS
 
 				// All structures are returned in memory regardless of size or complexity
@@ -925,13 +930,6 @@
 				// For other ABIs the native calling convention is not available (yet)
 				#define AS_MAX_PORTABILITY
 			#endif
-		#elif defined(__PPC64__)
-			// PPC 64bit
-
-			// The code in as_callfunc_ppc_64.cpp was built for PS3 and XBox 360, that 
-			// although use 64bit PPC only uses 32bit pointers.
-			// TODO: Add support for native calling conventions on Linux with PPC 64bit
-			#define AS_MAX_PORTABILITY
 		#else
 			#define AS_MAX_PORTABILITY
 		#endif
@@ -1060,7 +1058,25 @@
 			#define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
 			#define AS_X86
 			#undef AS_NO_THISCALL_FUNCTOR_METHOD
-		#elif defined(__mips__)
+// Urho3D - Add support for Android Intel x86_64 and Android ARM 64bit
+		#elif defined(__LP64__) && !defined(__aarch64__)
+			// Android Intel x86_64 (same config as Linux x86_64). Tested with Intel x86_64 Atom System Image.
+			#define AS_X64_GCC
+			#undef AS_NO_THISCALL_FUNCTOR_METHOD
+			#define HAS_128_BIT_PRIMITIVES
+			#define SPLIT_OBJS_BY_MEMBER_TYPES
+			#define AS_LARGE_OBJS_PASSED_BY_REF
+			#define AS_LARGE_OBJ_MIN_SIZE 5
+			// STDCALL is not available on 64bit Linux
+			#undef STDCALL
+			#define STDCALL
+        #elif defined(__aarch64__)
+			// Doesn't support native calling for Android ARM 64bit yet
+			#define AS_MAX_PORTABILITY
+			// STDCALL is not available on ARM
+			#undef STDCALL
+			#define STDCALL
+        #elif defined(__mips__)
 			#define AS_MIPS
 			#undef STDCALL
 			#define STDCALL
@@ -1114,7 +1130,7 @@
 			// Support native calling conventions on Intel 32bit CPU
 			#define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
 			#define AS_X86
-		#elif defined(__x86_64__)
+		#elif (defined(__x86_64__) || defined(__LP64__))
 			#define AS_X64_GCC
 			#define HAS_128_BIT_PRIMITIVES
 			#define SPLIT_OBJS_BY_MEMBER_TYPES
@@ -1174,20 +1190,23 @@
 // Detect target hardware
 //------------------------------------------------
 
-// Big endian CPU target?
-// see: http://sourceforge.net/p/predef/wiki/Endianness/
-#if !defined(AS_BIG_ENDIAN) && \
-	defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
-	defined(__BIG_ENDIAN__) || \
-	defined(__ARMEB__) || \
-	defined(__THUMBEB__) || \
-	defined(__AARCH64EB__) || \
-	defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
-		#define AS_BIG_ENDIAN
+// X86, Intel, AMD, etc, i.e. most PCs
+#if defined(__i386__) || defined(_M_IX86)
+	// Nothing special here
+#endif
+
+// PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
+#if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
+	#define AS_BIG_ENDIAN
+
+	// Gamecube
+	#if defined(_GC)
+		#define AS_USE_DOUBLE_AS_FLOAT
+	#endif
 #endif
 
-// Dreamcast and Gamecube use only 32bit floats, so treat doubles as floats
-#if defined(__SH4_SINGLE_ONLY__) || defined(_GC)
+// Dreamcast console
+#ifdef __SH4_SINGLE_ONLY__
 	#define AS_USE_DOUBLE_AS_FLOAT	// use 32bit floats instead of doubles
 #endif
 
@@ -1214,7 +1233,8 @@
 
 
 // The assert macro
-#if defined(ANDROID)
+// Urho3D - use __ANDROID__ define emitted by all Android compiler toolchains
+#if defined(ANDROID) || defined(__ANDROID__)
 	#if defined(AS_DEBUG)
 		#include <android/log.h>
 		#include <stdlib.h>