libc: <stdint.h>: Proper C++

This patch prevents the definition of various macros when <stdint.h> is
included from C++. The ISO C99 standard mentions that when this header
is included from a C++ source file, limit and constant related macros
should only be defined when asked explicitely by defining
__STDC_LIMIT_MACROS and __STD_CONSTANT_MACROS, respectively.

The <stdint.h> lacked the proper #ifdef .. #endif blocks for the
following macros:

    INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX
    INTMAX_MIN, INTMAX_MAX, UINTMAX_MAX,
    INPTR_C, UINTPR_C, PTRDIFF_C, INTMAX_C, UINTMAX_C

This is intended to fix http://code.google.com/p/android/issues/detail?id=14380
after we copy this file to development/ndk/platforms/android-3/include/

Change-Id: Ia77e0822edfaaf568ea599d7de673b310eeeaa4a
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index 237baa2..a889f15 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -211,14 +211,20 @@
 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 +236,32 @@
 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)
+#ifndef __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__ */