[RFA:] stdint.h take 2: Add INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX
Hans-Peter Nilsson
hans-peter.nilsson@axis.com
Wed Apr 15 23:08:00 GMT 2009
> Date: Wed, 8 Apr 2009 22:03:16 +0200
> From: Hans-Peter Nilsson <hp@axis.com>
> (now testing the patch instrumented to trig the !defined
> __PTRDIFF_TYPE__ path)
...which of course showed a flaw: only __LONG_MAX__ was available.
(Presumably noticeable only with non-gcc or gcc < 3.2.)
* libc/include/stdint.h (INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX): Define.
Index: newlib/libc/include/stdint.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdint.h,v
retrieving revision 1.13
diff -u -p -r1.13 stdint.h
--- newlib/libc/include/stdint.h 19 Jan 2009 22:02:06 -0000 1.13
+++ newlib/libc/include/stdint.h 9 Apr 2009 20:54:03 -0000
@@ -242,6 +242,9 @@ typedef uint64_t uint_least32_t;
#if defined(__PTRDIFF_TYPE__)
typedef signed __PTRDIFF_TYPE__ intptr_t;
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
+#define INTPTR_MAX PTRDIFF_MAX
+#define INTPTR_MIN PTRDIFF_MIN
+#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
#else
/*
* Fallback to hardcoded values,
@@ -249,6 +252,9 @@ typedef unsigned __PTRDIFF_TYPE__ uintpt
*/
typedef signed long intptr_t;
typedef unsigned long uintptr_t;
+#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
+#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
+#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
#endif
/* Limits of Specified-Width Integer Types */
brgds, H-P
More information about the Newlib
mailing list