1 #include <android/api-level.h> 2 3 #if !__LP64__ && !defined(__arm__) || __ANDROID_API__ == 3 4 5 // This checks that simply including <wchar.h> with 6 // _WCHAR_IS_8BIT defined will provice an 8-bit wchar_t 7 // and 8-bit WCHAR_MIN/WCHAR_MAX. 8 9 // Force wchar_t to be 8 bits. 10 #define _WCHAR_IS_8BIT 11 #include <wchar.h> 12 13 #define CONCAT(x,y) CONCAT_(x,y) 14 #define CONCAT_(x,y) x ## y 15 16 #define STATIC_ASSERT(condition) \ 17 static char CONCAT(dummy_,__LINE__)[1 - 2*(!(condition))]; 18 19 #if defined(__arm__) || __ANDROID_API__ < 9 20 STATIC_ASSERT(sizeof(__WCHAR_TYPE__) == 1); 21 #else 22 STATIC_ASSERT(sizeof(__WCHAR_TYPE__) == 4); 23 #endif 24 25 // wchar_t is never redefined by <stddef.h> because it's a C++ keyword, 26 // unlike in C. 27 STATIC_ASSERT(sizeof(wchar_t) == 4); 28 29 // Since this is C++ code, and __STC_LIMIT_MACROS was not defined, the 30 // old behaviour on ARM was to define these constants to 8-bit values. 31 // Otherwise, always signed 32-bit values. 32 #ifdef __arm__ 33 STATIC_ASSERT(WCHAR_MIN == 0); 34 STATIC_ASSERT(WCHAR_MAX == 255); 35 #else 36 STATIC_ASSERT(WCHAR_MIN == 0x80000000); 37 STATIC_ASSERT(WCHAR_MAX == 0x7fffffff); 38 #endif 39 40 #endif