diff options
Diffstat (limited to 'ndk/platforms/android-3/include')
| -rw-r--r-- | ndk/platforms/android-3/include/inttypes.h | 22 | ||||
| -rw-r--r-- | ndk/platforms/android-3/include/malloc.h | 2 | ||||
| -rw-r--r-- | ndk/platforms/android-3/include/stdint.h | 35 | ||||
| -rw-r--r-- | ndk/platforms/android-3/include/sys/cdefs.h | 31 | ||||
| -rw-r--r-- | ndk/platforms/android-3/include/sys/un.h | 3 | ||||
| -rw-r--r-- | ndk/platforms/android-3/include/wchar.h | 36 |
6 files changed, 108 insertions, 21 deletions
diff --git a/ndk/platforms/android-3/include/inttypes.h b/ndk/platforms/android-3/include/inttypes.h index 81d23152e..73b22db44 100644 --- a/ndk/platforms/android-3/include/inttypes.h +++ b/ndk/platforms/android-3/include/inttypes.h @@ -56,7 +56,7 @@ #define PRIdFAST64 "lld" /* int_fast64_t */ #define PRIdMAX "jd" /* intmax_t */ -#define PRIdPTR "ld" /* intptr_t */ +#define PRIdPTR "d" /* intptr_t */ #define PRIi8 "i" /* int8_t */ #define PRIi16 "i" /* int16_t */ @@ -74,7 +74,7 @@ #define PRIiFAST64 "lli" /* int_fast64_t */ #define PRIiMAX "ji" /* intmax_t */ -#define PRIiPTR "li" /* intptr_t */ +#define PRIiPTR "i" /* intptr_t */ /* fprintf macros for unsigned integers */ #define PRIo8 "o" /* int8_t */ @@ -93,7 +93,7 @@ #define PRIoFAST64 "llo" /* int_fast64_t */ #define PRIoMAX "jo" /* intmax_t */ -#define PRIoPTR "lo" /* intptr_t */ +#define PRIoPTR "o" /* intptr_t */ #define PRIu8 "u" /* uint8_t */ #define PRIu16 "u" /* uint16_t */ @@ -111,7 +111,7 @@ #define PRIuFAST64 "llu" /* uint_fast64_t */ #define PRIuMAX "ju" /* uintmax_t */ -#define PRIuPTR "lu" /* uintptr_t */ +#define PRIuPTR "u" /* uintptr_t */ #define PRIx8 "x" /* uint8_t */ #define PRIx16 "x" /* uint16_t */ @@ -129,7 +129,7 @@ #define PRIxFAST64 "llx" /* uint_fast64_t */ #define PRIxMAX "jx" /* uintmax_t */ -#define PRIxPTR "lx" /* uintptr_t */ +#define PRIxPTR "x" /* uintptr_t */ #define PRIX8 "X" /* uint8_t */ #define PRIX16 "X" /* uint16_t */ @@ -147,7 +147,7 @@ #define PRIXFAST64 "llX" /* uint_fast64_t */ #define PRIXMAX "jX" /* uintmax_t */ -#define PRIXPTR "lX" /* uintptr_t */ +#define PRIXPTR "X" /* uintptr_t */ /* fscanf macros for signed integers */ #define SCNd8 "hhd" /* int8_t */ @@ -166,7 +166,7 @@ #define SCNdFAST64 "lld" /* int_fast64_t */ #define SCNdMAX "jd" /* intmax_t */ -#define SCNdPTR "ld" /* intptr_t */ +#define SCNdPTR "d" /* intptr_t */ #define SCNi8 "hhi" /* int8_t */ #define SCNi16 "hi" /* int16_t */ @@ -184,7 +184,7 @@ #define SCNiFAST64 "lli" /* int_fast64_t */ #define SCNiMAX "ji" /* intmax_t */ -#define SCNiPTR "li" /* intptr_t */ +#define SCNiPTR "i" /* intptr_t */ /* fscanf macros for unsigned integers */ #define SCNo8 "hho" /* uint8_t */ @@ -203,7 +203,7 @@ #define SCNoFAST64 "llo" /* uint_fast64_t */ #define SCNoMAX "jo" /* uintmax_t */ -#define SCNoPTR "lo" /* uintptr_t */ +#define SCNoPTR "o" /* uintptr_t */ #define SCNu8 "hhu" /* uint8_t */ #define SCNu16 "hu" /* uint16_t */ @@ -221,7 +221,7 @@ #define SCNuFAST64 "llu" /* uint_fast64_t */ #define SCNuMAX "ju" /* uintmax_t */ -#define SCNuPTR "lu" /* uintptr_t */ +#define SCNuPTR "u" /* uintptr_t */ #define SCNx8 "hhx" /* uint8_t */ #define SCNx16 "hx" /* uint16_t */ @@ -239,7 +239,7 @@ #define SCNxFAST64 "llx" /* uint_fast64_t */ #define SCNxMAX "jx" /* uintmax_t */ -#define SCNxPTR "lx" /* uintptr_t */ +#define SCNxPTR "x" /* uintptr_t */ #endif /* __cplusplus || __STDC_FORMAT_MACROS */ diff --git a/ndk/platforms/android-3/include/malloc.h b/ndk/platforms/android-3/include/malloc.h index ec21926c9..49a10e642 100644 --- a/ndk/platforms/android-3/include/malloc.h +++ b/ndk/platforms/android-3/include/malloc.h @@ -33,7 +33,7 @@ extern void* realloc(void *, size_t); extern void free(void *); extern void* memalign(size_t alignment, size_t bytesize); -extern size_t malloc_usable_size(void*); +extern size_t malloc_usable_size(const void*); extern void* valloc(size_t bytesize); extern void* pvalloc(size_t bytesize); diff --git a/ndk/platforms/android-3/include/stdint.h b/ndk/platforms/android-3/include/stdint.h index c3e29dde7..54ea026d5 100644 --- a/ndk/platforms/android-3/include/stdint.h +++ b/ndk/platforms/android-3/include/stdint.h @@ -66,7 +66,7 @@ typedef uint8_t uint_fast8_t; # define INT_FAST8_MIN INT8_MIN # define INT_FAST8_MAX INT8_MAX -# define UINT8_MAX (255U) +# define UINT8_MAX (255) # define UINT_LEAST8_MAX UINT8_MAX # define UINT_FAST8_MAX UINT8_MAX #endif @@ -76,7 +76,7 @@ typedef uint8_t uint_fast8_t; # define INT_LEAST8_C(c) INT8_C(c) # define INT_FAST8_C(c) INT8_C(c) -# define UINT8_C(c) c ## U +# define UINT8_C(c) c # define UINT_LEAST8_C(c) UINT8_C(c) # define UINT_FAST8_C(c) UINT8_C(c) #endif @@ -99,7 +99,7 @@ typedef uint32_t uint_fast16_t; # define INT_FAST16_MIN INT32_MIN # define INT_FAST16_MAX INT32_MAX -# define UINT16_MAX (65535U) +# define UINT16_MAX (65535) # define UINT_LEAST16_MAX UINT16_MAX # define UINT_FAST16_MAX UINT32_MAX #endif @@ -109,7 +109,7 @@ typedef uint32_t uint_fast16_t; # define INT_LEAST16_C(c) INT16_C(c) # define INT_FAST16_C(c) INT32_C(c) -# define UINT16_C(c) c ## U +# define UINT16_C(c) c # define UINT_LEAST16_C(c) UINT16_C(c) # define UINT_FAST16_C(c) UINT32_C(c) #endif @@ -226,6 +226,33 @@ typedef int64_t intmax_t; # define UINTMAX_C(c) UINT64_C(c) #endif +/* Limits of sig_atomic_t. */ +#ifdef __STDINT_LIMITS +# define SIG_ATOMIC_MIN INT32_MIN +# define SIG_ATOMIC_MAX INT32_MAX +#endif + +/* Limits of wchar_t. */ +#ifdef __STDINT_LIMITS + /* Also possibly defined in <wchar.h> */ +# ifndef WCHAR_MIN +# define WCHAR_MIN INT32_MIN +# define WCHAR_MAX INT32_MAX +# endif +#endif + +/* Limits of wint_t. */ +#ifdef __STDINT_LIMITS +# define WINT_MIN INT32_MIN +# define WINT_MAX INT32_MAX +#endif + +/* size_t is defined by the GCC-specific <stddef.h> */ +#ifndef _SSIZE_T_DEFINED_ +#define _SSIZE_T_DEFINED_ +typedef long int ssize_t; +#endif + #define _BITSIZE 32 /* Keep the kernel from trying to define these types... */ diff --git a/ndk/platforms/android-3/include/sys/cdefs.h b/ndk/platforms/android-3/include/sys/cdefs.h index 27c575c87..88ce720b2 100644 --- a/ndk/platforms/android-3/include/sys/cdefs.h +++ b/ndk/platforms/android-3/include/sys/cdefs.h @@ -37,11 +37,36 @@ #ifndef _SYS_CDEFS_H_ #define _SYS_CDEFS_H_ - -/* our implementation of wchar_t is only 8-bit - die die non-portable code */ +/* In previous NDK releases, wchar_t was defined as 'unsigned char' + * when targetting API level < 9 (i.e. Froyo or older). + * + * This is no longer the case, but you can define _WCHAR_IS_8BIT + * at compile time to restore the old behaviour. + * + * The reason for this redefine is purely historical. Until Android 2.3, + * i.e. API level 9, there was absolutely no official support for wchar_t + * in the C library, but compiling GCC and the GNU libstdc++ required a + * working <wchar.h>. + * + * To allow this while keeping the C library small, wchar_t was redefined + * explicitely as an 8-bit unsigned integer (which is perfectly allowed + * by the standard) and a very small set of wcs-xxx functions provided + * as wrappers around the corresponding str-xxx ones. + * + * Starting with API level 9, wchar_t is properly defined as a 32-bit + * type (as mandated by the compiler itself), and the lines below + * were removed (see $NDK/platforms/android-9/include/sys/cdefs.h). + * + * Note that this only affects C source compilation. For C++, wchar_t + * is a compiler keyboard that cannot be redefined and is always 32-bit. + * + * On the other hand, _WCHAR_IS_8BIT also affects the definition of + * WCHAR_MIN, WCHAR_MAX and WEOF (see <wchar.h> comments). + */ +#ifdef _WCHAR_IS_8BIT #undef __WCHAR_TYPE__ #define __WCHAR_TYPE__ unsigned char - +#endif /* * Macro to test if we're using a GNU C compiler of a specific vintage diff --git a/ndk/platforms/android-3/include/sys/un.h b/ndk/platforms/android-3/include/sys/un.h index 973861f10..f89ead313 100644 --- a/ndk/platforms/android-3/include/sys/un.h +++ b/ndk/platforms/android-3/include/sys/un.h @@ -28,6 +28,9 @@ #ifndef _SYS_UN_H_ #define _SYS_UN_H_ +#include <sys/_types.h> +typedef __sa_family_t sa_family_t; + #include <linux/un.h> #endif /* _SYS_UN_H_ */ diff --git a/ndk/platforms/android-3/include/wchar.h b/ndk/platforms/android-3/include/wchar.h index 9a6ce1de8..836ad30e1 100644 --- a/ndk/platforms/android-3/include/wchar.h +++ b/ndk/platforms/android-3/include/wchar.h @@ -70,9 +70,41 @@ typedef enum { WC_TYPE_MAX } wctype_t; -#define WCHAR_MAX 255 -#define WCHAR_MIN 0 +/* TECHNICAL NOTE: This is tricky! + * + * Due to the following inclusion chain: + * <wchar.h> -> <stdio.h> -> <sys/types.h> -> <stdint.h> + * + * WCHAR_MIN / WCHAR_MAX will already be defined to INT32_MIN / INT32_MAX + * when reaching this line in the following cases: + * - Compiling C source code. + * - Compiling C++ source code AND having __STDC_LIMIT_MACROS defined. + * + * When _WCHAR_IS_8BIT is defined, it should emulate the old behaviour. + * which was to (conditionally) set the values to 0 and 255, respectively. + */ +#ifndef WCHAR_MAX +# ifdef _WCHAR_IS_8BIT +# define WCHAR_MAX 255 +# define WCHAR_MIN 0 +# else +/* Same values as INT32_MIN/INT32_MAX, without including <stdint.h> */ +# define WCHAR_MAX (2147483647) +# define WCHAR_MIN (-1-2147483647) +# endif +#endif + +/* Similarly, WEOF used to be defined as simply -1, which is + * invalid (the standard mandates that the expression must have wint_t + * type). There is no difference in C, but there is one in C++!! + * + * Revert to the old broken behaviour is _WCHAR_IS_8BIT is defined. + */ +#ifdef _WCHAR_IS_8BIT #define WEOF (-1) +#else +#define WEOF ((wint_t)-1) +#endif extern wint_t btowc(int); extern int fwprintf(FILE *, const wchar_t *, ...); |
