From c7d8870875c093a88503cd18ade581e992f97975 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Fri, 11 Mar 2011 14:42:12 +0100 Subject: [PATCH] ndk: Fix stdint.h definitions for C++ Fix the stdint.h header for C++ inclusion. The limit and constant related macros should only be defined if __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined, respectively. Change-Id: I85b00ed857f40b9c17d530f1405f0f098c5f10f3 --- ndk/platforms/android-3/include/stdint.h | 48 ++++++++++++++---------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/ndk/platforms/android-3/include/stdint.h b/ndk/platforms/android-3/include/stdint.h index 237baa24c..e7914750f 100644 --- a/ndk/platforms/android-3/include/stdint.h +++ b/ndk/platforms/android-3/include/stdint.h @@ -41,11 +41,6 @@ # define __STDINT_MACROS #endif -/* the definitions of STDINT_LIMITS depend on those of STDINT_MACROS */ -#if defined __STDINT_LIMITS && !defined __STDINT_MACROS -# define __STDINT_MACROS -#endif - #if !defined __STRICT_ANSI__ || __STDC_VERSION__ >= 199901L # define __STDC_INT64__ #endif @@ -185,13 +180,14 @@ typedef uint64_t uint_fast64_t; # define UINT_FAST64_MAX UINT64_MAX #endif +#define __INT64_C(c) c ## LL +#define __UINT64_C(c) c ## ULL + #ifdef __STDINT_MACROS -# define __INT64_C(c) c ## LL # define INT64_C(c) __INT64_C(c) # define INT_LEAST64_C(c) INT64_C(c) # define INT_FAST64_C(c) INT64_C(c) -# define __UINT64_C(c) c ## ULL # define UINT64_C(c) __UINT64_C(c) # define UINT_LEAST64_C(c) UINT64_C(c) # define UINT_FAST64_C(c) UINT64_C(c) @@ -211,14 +207,20 @@ typedef uint64_t uint_fast64_t; typedef int intptr_t; typedef unsigned int uintptr_t; +#ifdef __STDINT_LIMITS # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX +# define PTRDIFF_MIN INT32_MIN +# define PTRDIFF_MAX INT32_MAX +#endif + +#ifdef __STDINT_MACROS # define INTPTR_C(c) INT32_C(c) # define UINTPTR_C(c) UINT32_C(c) # define PTRDIFF_C(c) INT32_C(c) -# define PTRDIFF_MIN INT32_MIN -# define PTRDIFF_MAX INT32_MAX +#endif + /* @@ -230,24 +232,32 @@ typedef unsigned int uintptr_t; typedef uint64_t uintmax_t; typedef int64_t intmax_t; -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX +#ifdef __STDINT_LIMITS +# define INTMAX_MIN INT64_MIN +# define INTMAX_MAX INT64_MAX +# define UINTMAX_MAX UINT64_MAX +#endif -#define INTMAX_C(c) INT64_C(c) -#define UINTMAX_C(c) UINT64_C(c) +#ifdef __STDINT_MACROS +# define INTMAX_C(c) INT64_C(c) +# define UINTMAX_C(c) UINT64_C(c) +#endif #else /* !__STDC_INT64__ */ typedef uint32_t uintmax_t; typedef int32_t intmax_t; -#define INTMAX_MIN INT32_MIN -#define INTMAX_MAX INT32_MAX -#define UINTMAX_MAX UINT32_MAX +#ifdef __STDINT_LIMITS +# define INTMAX_MIN INT32_MIN +# define INTMAX_MAX INT32_MAX +# define UINTMAX_MAX UINT32_MAX +#endif -#define INTMAX_C(c) INT32_C(c) -#define UINTMAX_C(c) UINT32_C(c) +#ifdef __STDINT_MACROS +# define INTMAX_C(c) INT32_C(c) +# define UINTMAX_C(c) UINT32_C(c) +#endif #endif /* !__STDC_INT64__ */