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]

Re: [patch] stdint.h: intmax_t/uintmax_t improvements


On Mon, 2005-10-03 at 13:04 -0400, Jeff Johnston wrote:
> Patch checked in.
Thanks.

>  I fixed up the spelling of appropriate.
Grumble, I don't know how many times I fixed it in my sources ;)
 
>   I still have to go back and look at the fast types patch..
>  i.e. I haven't forgotten about it.
Don't fret about it - I have a newer version pending which I plan to
submit when the patch below should be applied and unless my tests reveal
these changes break something, nastily. 

For now, I'm trying to gradually feed you with smaller chunks, instead
of pushing everything at once ;)

Next patch enclosed below ...

Ralf

2005-10-04  Ralf Corsepius <ralf.corsepius@rtems.org>

	* libc/include/stdint.h: 
	Move magic to set __have_long* to the beginning.
	Use #if __have* instead of #if defined(__have*).
	Minor typo fixes.


Index: stdint.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdint.h,v
retrieving revision 1.5
diff -u -r1.5 stdint.h
--- stdint.h	3 Oct 2005 17:02:48 -0000	1.5
+++ stdint.h	4 Oct 2005 03:34:45 -0000
@@ -28,6 +28,20 @@
 #include <limits.h>
 #endif
 
+/* Check if "long long" is 64bit wide */
+/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
+#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
+  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
+#define __have_longlong64 1
+#endif
+
+/* Check if "long" is 64bit or 32bit wide */
+#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
+#define __have_long64 1
+#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff
+#define __have_long32 1
+#endif
+
 #if __STDINT_EXP(SCHAR_MAX) == 0x7f
 typedef signed char int8_t ;
 typedef unsigned char uint8_t ;
@@ -74,7 +88,6 @@
 typedef signed long int32_t;
 typedef unsigned long uint32_t;
 #define __int32_t_defined 1
-#define __have_long32 1
 #elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL
 typedef signed short int32_t;
 typedef unsigned short uint32_t;
@@ -103,21 +116,14 @@
 #endif
 #endif
 
-#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
+#if __have_long64
 typedef signed long int64_t;
 typedef unsigned long uint64_t;
 #define __int64_t_defined 1
-#define __have_long64 1
-#elif  defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff)
-typedef signed long long int64_t;
-typedef unsigned long long uint64_t;
-#define __int64_t_defined 1
-#define __have_longlong64 1
-#elif  defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff)
+#elif __have_longlong64
 typedef signed long long int64_t;
 typedef unsigned long long uint64_t;
 #define __int64_t_defined 1
-#define __have_longlong64 1
 #elif  __STDINT_EXP(INT_MAX) > 0x7fffffff
 typedef signed int int64_t;
 typedef unsigned int uint64_t;
@@ -163,9 +169,9 @@
   typedef __UINTMAX_TYPE__ uintmax_t;
 #elif __have_longlong64
   typedef unsigned long long uintmax_t;
- #else
+#else
   typedef unsigned long uintmax_t;
- #endif
+#endif
 
 /*
  * GCC doesn't provide an appropriate macro for [u]intptr_t
@@ -232,7 +238,7 @@
 #define INT64_MIN 	(-9223372036854775807L-1L)
 #define INT64_MAX 	 9223372036854775807L
 #define UINT64_MAX 	18446744073709551615U
-#elif defined(__have_longlong64)
+#elif __have_longlong64
 #define INT64_MIN 	(-9223372036854775807LL-1LL)
 #define INT64_MAX 	 9223372036854775807LL
 #define UINT64_MAX 	18446744073709551615ULL
@@ -244,7 +250,7 @@
 #define INT_LEAST64_MIN  (-9223372036854775807L-1L)
 #define INT_LEAST64_MAX  9223372036854775807L
 #define UINT_LEAST64_MAX 18446744073709551615U
-#elif defined(__have_longlong64)
+#elif __have_longlong64
 #define INT_LEAST64_MIN  (-9223372036854775807LL-1LL)
 #define INT_LEAST64_MAX  9223372036854775807LL
 #define UINT_LEAST64_MAX 18446744073709551615ULL

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