This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: GCC headers and DJGPP port


Zack Weinberg wrote:
> 
> On Thu, Jul 20, 2000 at 08:25:40AM -0700, Bruce Korb wrote:
> ...
> > The amusing thing about that is that stddef.h is not platform
> > specific, even though the SIZE_TYPE, PTRDIFF_TYPE and WCHAR_TYPE
> > defines are.  I'm thinking that fixincludes should do its thing
> > on the GCC-supplied stddef.h since fixincludes replaces these
> > typedefs with platform-specific changes (as of today :-).
> 
> Our stddef.h uses the magic __SIZE_TYPE__, __PTRDIFF_TYPE__, and
> __WCHAR_TYPE__ defines, which are set by cpp to the values of the
> SIZE_TYPE, etc. defines in tm.h.  And fixincludes should too.

fixincludes did not ever do so, prior to today, that is.  :-)
I grepped the CVS source for stddef.h and found absolutely no
reference to "__PTRDIFF_TYPE__", except the three below.  Also,
there was no reference to "PTRDIFF_TYPE" at all, period.

> #ifndef _GCC_PTRDIFF_T
>   ...
> #ifndef __PTRDIFF_TYPE__
> #define __PTRDIFF_TYPE__ long int
> #endif
> typedef __PTRDIFF_TYPE__ ptrdiff_t;
> #endif /* _GCC_PTRDIFF_T */

Notice the hard-wired define to "long int".  Not good.
I would suggest the following:

1.  If a target has a stddef.h, use it, filtered through fixincludes.
2.  If not, provide one -- *ALSO* filtered through fixincludes
3.  In the provided one, replace all the SIZE_T, WCHAR_T and PTRDIFF_T
    junk with:

      typedef DUMMY ptrdiff_t;
      typedef DUMMY size_t;
      typedef DUMMY wchar_t;

    allowing fixincludes to clean it up in a platform-specific manner.
    The fixed result would look like any other fixup of these typedefs
    that fixinc does.  viz.:

      #ifndef __PTRDIFF_TYPE__
      #define __PTRDIFF_TYPE__ XXX
      #endif
      #if !defined(_GCC_PTRDIFF_T)
      #define _GCC_PTRDIFF_T
      typedef __PTRDIFF_TYPE__ ptrdiff_t;
      #endif

      #ifndef __SIZE_TYPE__
      #define __SIZE_TYPE__ YYY
      #endif
      #if !defined(_GCC_SIZE_T)
      #define _GCC_SIZE_T
      typedef __SIZE_TYPE__ size_t;
      #endif

      #ifndef __WCHAR_TYPE__
      #define __WCHAR_TYPE__ ZZZ
      #endif
      #if !defined(_GCC_WCHAR_T) && ! defined(__cplusplus)
      #define _GCC_WCHAR_T
      typedef __WCHAR_TYPE__ wchar_t;
      #endif

    except that the `XXX', `YYY', and `ZZZ' would be the strings
    obtained from the "tm.h" header file inclusion.

> I sent in a patch over a year ago that drastically simplified our
> stddef.h, but no one ever reviewed it.
> http://gcc.gnu.org/ml/gcc-patches/1999-01/msg00655.html.

This should be simpler, still ;-)

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