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