[RFA:] stdint.h: Add INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Wed Apr 8 20:13:00 GMT 2009


As required when the types are available.

Regtested cris-elf where it fixes
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39644> (an
assumption that the macros are available).  See also
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=448>.

(now testing the patch instrumented to trig the !defined
__PTRDIFF_TYPE__ path)

Ok to commit?

	* 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	8 Apr 2009 09:48:53 -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_MIN)
+#define UINTPTR_MAX __STDINT_EXP(ULONG_MAX)
 #endif
 
 /* Limits of Specified-Width Integer Types */

brgds, H-P



More information about the Newlib mailing list