This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add and use __INTTYPES_EXP()


2011-11-22  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* libc/include/inttypes.h: Add and use __INTTYPES_EXP().

The change

2012-02-07  Corinna Vinschen  <vinschen@redhat.com>

	* libc/include/inttypes.h: Redefine pointer type macros.

cvs diff -u -r 1.4  newlib/libc/include/inttypes.h
Index: newlib/libc/include/inttypes.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/inttypes.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- newlib/libc/include/inttypes.h      19 Jan 2009 22:02:06 -0000 1.4
+++ newlib/libc/include/inttypes.h      7 Feb 2012 16:42:20 -0000 1.5
@@ -242,15 +242,15 @@
 #define SCNxMAX                __SCNMAX(x)

 /* ptr types */
-#if __have_long64
-#define __PRIPTR(x) __STRINGIFY(l##x)
-#define __SCNPTR(x) __STRINGIFY(l##x)
-#elif __have_longlong64
-#define __PRIPTR(x) __STRINGIFY(ll##x)
-#define __SCNPTR(x) __STRINGIFY(ll##x)
+#if PTRDIFF_MAX <= __STDINT_EXP(INT_MAX)
+# define __PRIPTR(x) __STRINGIFY(x)
+# define __SCNPTR(x) __STRINGIFY(x)
+#elif PTRDIFF_MAX <= __STDINT_EXP(LONG_MAX) ||
!defined(__have_longlong64)
+# define __PRIPTR(x) __STRINGIFY(l##x)
+# define __SCNPTR(x) __STRINGIFY(l##x)
 #else
-#define __PRIPTR(x) __STRINGIFY(x)
-#define __SCNPTR(x) __STRINGIFY(x)
+# define __PRIPTR(x) __STRINGIFY(ll##x)
+# define __SCNPTR(x) __STRINGIFY(ll##x)
 #endif

 #define PRIdPTR                __PRIPTR(d)

introduces __STDINT_EXP() in inttypes.h.  If we use the GCC provided
stdint.h, then this results in:

inttypes.h:245:32: error: missing binary operator before token "("
inttypes.h:248:34: error: missing binary operator before token "("
---
 newlib/libc/include/inttypes.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h
index f3943cb..4ab1bd5 100644
--- a/newlib/libc/include/inttypes.h
+++ b/newlib/libc/include/inttypes.h
@@ -17,6 +17,14 @@
 #define __need_wchar_t
 #include <stddef.h>
 
+#if defined(__GNUC__) && (__GNUC__ >= 3 ) \
+  && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ) 
+#define __INTTYPES_EXP(x) __##x##__
+#else
+#define __INTTYPES_EXP(x) x
+#include <limits.h>
+#endif
+
 #define __STRINGIFY(a) #a
 
 /* 8-bit types */
@@ -242,10 +250,10 @@
 #define SCNxMAX		__SCNMAX(x)
 
 /* ptr types */
-#if PTRDIFF_MAX <= __STDINT_EXP(INT_MAX)
+#if PTRDIFF_MAX <= __INTTYPES_EXP(INT_MAX)
 # define __PRIPTR(x) __STRINGIFY(x)
 # define __SCNPTR(x) __STRINGIFY(x)
-#elif PTRDIFF_MAX <= __STDINT_EXP(LONG_MAX) || !defined(__have_longlong64)
+#elif PTRDIFF_MAX <= __INTTYPES_EXP(LONG_MAX) || !defined(__have_longlong64)
 # define __PRIPTR(x) __STRINGIFY(l##x)
 # define __SCNPTR(x) __STRINGIFY(l##x)
 #else
-- 
1.7.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]