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 v2] Add and use __INTTYPES_EXP()


2012-11-23  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..a993bd4 100644
--- a/newlib/libc/include/inttypes.h
+++ b/newlib/libc/include/inttypes.h
@@ -13,10 +13,18 @@
 #ifndef _INTTYPES_H
 #define _INTTYPES_H
 
+#include <sys/features.h>
 #include <stdint.h>
 #define __need_wchar_t
 #include <stddef.h>
 
+#if __GNUC_PREREQ(3, 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]