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: stdint.h


On Tue, 2005-09-20 at 17:29 -0400, Jeff Johnston wrote:
> Ralf Corsepius wrote:
> > On Tue, 2005-09-20 at 12:23 +0200, Corinna Vinschen wrote:
 
> >>- The condition, when to include limits.h and when not to include it,
> >>  seems not to be foolproof.
> > 
> > Yes, gcc-4 is not correctly taken into account, which (bogusly) causes
> > the compiler to fall back to the non-gcc-3 rules.
> > 
> 
> Still needs looking at.

See patch below.

Background:

Modern GCCs ( According to what I coded, GCC > 3.2 ) implicitly define
the defines this file tries to exploit. Including limits.h is meant to
be used as fall back for non-GNUC compilers and for old GCCs not having
these implicit defines.

This all is aimed at avoiding to include <limits.h> from inside of
stdint.h for several reasons:
* In the past, limits.h handling had been fragile during bootstrapping
GCC.
* In the past, limits.h also had tended to contain bogus values.
* Including limits.h in stdint.h would pollute the "name space of
defines being used."
* Speed. Inclusion of limits.h is comparatively expensive.
* My original plan was to include this file into GCC where it can fully
exploit GCC's internals. Meanwhile, though I still am not convinced
newlib (or more general: libc) is the appropriate place for
stdint.h/inttypes.h I have more or less abandoned this plan.


In other words, if portability and simplicity is the primary objective,
we can drop this magic and the __STDINT_EXP macro and try to
unconditionally include <limits.h>, instead. 

Ralf

2005-09-21  Ralf Corsepius <ralf.corsepius@rtems.org>

	* libc/include/stdint.h: Correct __STDINT_EXP macro incorrectly 
	handling GCC >= 4.

Index: newlib/libc/include/stdint.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdint.h,v
retrieving revision 1.3
diff -u -r1.3 stdint.h
--- newlib/libc/include/stdint.h	20 Sep 2005 21:21:51 -0000	1.3
+++ newlib/libc/include/stdint.h	21 Sep 2005 09:42:42 -0000
@@ -18,8 +18,10 @@
 extern "C" {
 #endif
 
-#if defined(__GNUC__) && (__GNUC__ >= 3 ) \
-  && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ) 
+#if defined(__GNUC__) && \
+  ( (__GNUC__ >= 4) || \
+    ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) )
+/* gcc > 3.2 implicitly defines the values we are interested */
 #define __STDINT_EXP(x) __##x##__
 #else
 #define __STDINT_EXP(x) x

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