This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New stddef.h, please test
- To: egcs-patches at cygnus dot com
- Subject: New stddef.h, please test
- From: Zack Weinberg <zack at rabi dot columbia dot edu>
- Date: Sun, 31 Jan 1999 21:15:24 -0500
I have rewritten stddef.h. The new version is easier to read, doesn't
defeat the multiple include optimization in cpplib, is namespace clean
under -ansi (wint_t is not allowed per C89/C9x), and should still
cooperate with all the myriad system libraries it needs to.
The patch is unreadable, so I've just attached the new file. It
should drop into ginclude/ and cause no problems. Please test it.
zw
== cut here ==
/* ISO C 9x section 7.1.6: COMMON DEFINITIONS */
#ifndef _STDDEF_H
# if defined __need_size_t || defined __need_wchar_t \
|| defined __need_ptrdiff_t || defined __need_NULL \
|| defined __need_wint_t
/* Just do one thing. */
# define __Need
# endif
/* On Net2 derivatives, make sure machine/ansi.h is included. */
# if defined __BSD_NET2__ || defined ____386BSD____ \
|| defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
# include <machine/ansi.h>
# endif
/* Now check if some of the work has already been done. */
# if defined _ANSI_H_ || defined _MACHINE_ANSI_H_
# if !defined _SIZE_T_ && !defined _BSD_SIZE_T_
# define __size_t_defined
# endif
# if !defined _PTRDIFF_T_ && !defined _BSD_PTRDIFF_T_
# define __ptrdiff_t_defined
# endif
# if !defined _WCHAR_T_ && !defined _BSD_WCHAR_T_
# define __wchar_t_defined
# endif
# endif /* ansi.h */
# if defined _SIZE_T || defined _SYS_SIZE_T_H || defined _T_SIZE_ \
|| defined _T_SIZE || defined __SIZE_T || defined _SIZE_T_DEFINED_ \
|| defined _SIZE_T_DEFINED || defined ___int_size_t_h \
|| defined __INT_SIZE_T_H || defined _GCC_SIZE_T \
|| defined _SIZET_ || defined __size_t || defined __sys_stdtypes_h
# define __size_t_defined
# endif
# if defined _PTRDIFF_T || defined _SYS_PTRDIFF_T_H || defined _T_PTRDIFF_ \
|| defined _T_PTRDIFF || defined __PTRDIFF_T || defined _PTRDIFF_T_DEFINED_ \
|| defined _PTRDIFF_T_DEFINED || defined ___int_ptrdiff_t_h \
|| defined __INT_PTRDIFF_T_H || defined _GCC_PTRDIFF_T \
|| defined _PTRDIFFT_ || defined __ptrdiff_t || defined __sys_stdtypes_h
# define __ptrdiff_t_defined
# endif
# if defined _WCHAR_T || defined _SYS_WCHAR_T_H || defined _T_WCHAR_ \
|| defined _T_WCHAR || defined __WCHAR_T || defined _WCHAR_T_DEFINED_ \
|| defined _WCHAR_T_DEFINED || defined ___int_wchar_t_h \
|| defined __INT_WCHAR_T_H || defined _GCC_WCHAR_T \
|| defined _WCHART_ || defined __wchar_t || defined __sys_stdtypes_h
# define __wchar_t_defined
# endif
# ifndef __size_t_defined
# if !defined __Need || defined __need_size_t
# define __size_t_defined
# ifdef _TYPE_size_t
_TYPE_size_t;
# undef _TYPE_size_t
# else
# ifndef __SIZE_TYPE__
# define __SIZE_TYPE__ long unsigned int
# endif
typedef __SIZE_TYPE__ size_t;
# endif
# undef _SIZE_T_
# undef _BSD_SIZE_T_
# define _SIZE_T
# define _SYS_SIZE_T_H
# define _T_SIZE_
# define _T_SIZE
# define __SIZE_T
# define _SIZE_T_DEFINED_
# define _SIZE_T_DEFINED
# define ___int_size_t_h
# define __INT_SIZE_T_H
# define _GCC_SIZE_T
# define _SIZET_
# define __size_t
# endif /* need size_t */
# endif /* size_t defined */
# undef __need_size_t
# ifndef __wchar_t_defined
# if !defined __Need || defined __need_wchar_t
# define __wchar_t_defined
# ifdef _TYPE_wchar_t
_TYPE_wchar_t;
# else
# ifndef __WCHAR_TYPE__
# define __WCHAR_TYPE__ int
# endif
# ifndef __cplusplus /* C++ doesn't want wchar_t in stddef.h ? */
typedef __WCHAR_TYPE__ wchar_t;
# endif
# endif
/* Some BSDs assume that rune_t is defined iff wchar_t is. */
# ifdef _BSD_RUNE_T_
# if !defined _ANSI_SOURCE && !defined _POSIX_SOURCE
typedef _BSD_RUNE_T_ rune_t;
# endif
# endif
# undef _WCHAR_T_
# undef _BSD_WCHAR_T_
# define _WCHAR_T
# define _SYS_WCHAR_T_H
# define _T_WCHAR_
# define _T_WCHAR
# define __WCHAR_T
# define _WCHAR_T_DEFINED_
# define _WCHAR_T_DEFINED
# define _WCHAR_T_H
# define ___int_wchar_t_h
# define __INT_WCHAR_T_H
# define _GCC_WCHAR_T
# define _WCHART_
# define __wchar_t
# endif /* need wchar_t */
# endif /* wchar_t defined */
# undef __need_wchar_t
# ifndef __ptrdiff_t_defined
# if !defined __Need || defined __need_ptrdiff_t
# define __ptrdiff_t_defined
# ifdef _TYPE_ptrdiff_t
_TYPE_ptrdiff_t;
# else
# ifndef __PTRDIFF_TYPE__
# define __PTRDIFF_TYPE__ long int
# endif
typedef __PTRDIFF_TYPE__ ptrdiff_t;
# endif
# undef _PTRDIFF_T_
# undef _BSD_PTRDIFF_T_
# define _PTRDIFF_T
# define _SYS_PTRDIFF_T_H
# define _T_PTRDIFF_
# define _T_PTRDIFF
# define __PTRDIFF_T
# define _PTRDIFF_T_DEFINED_
# define _PTRDIFF_T_DEFINED
# define ___int_ptrdiff_t_h
# define __INT_PTRDIFF_T_H
# define _GCC_PTRDIFF_T
# define _PTRDIFFT_
# define __ptrdiff_t
# endif /* need ptrdiff_t */
# endif /* ptrdiff_t defined */
# undef __need_ptrdiff_t
# ifndef __NULL_defined
# if !defined __Need || defined __need_NULL
# define __NULL_defined
# undef NULL /* In case someone else defined it. */
# ifdef __GNUG__
# define NULL __null
# else
# define NULL ((void *)0)
# endif /* G++ */
# endif /* want NULL */
# endif /* NULL defined */
# undef __need_NULL
/* Both C89 and C9x say stddef.h does not define wint_t. */
# ifndef __wint_t_defined
# if (defined __Need && defined __need_wint_t) || !defined __STRICT_ANSI__
# define __wint_t_defined
# define _WINT_T
# ifndef __WINT_TYPE__
# define __WINT_TYPE__ unsigned int
# endif
typedef __WINT_TYPE__ wint_t;
# endif /* want wint_t */
# endif /* wint_t defined */
# undef __need_wint_t
# ifdef __Need
# undef __Need
# else /* No special needs. */
# define _STDDEF_H
/* snaroff@next.com says the NeXT needs this. */
# define _ANSI_STDDEF_H
/* Irix 5.1 needs this. */
# define __STDDEF_H__
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
# endif /* No special needs */
#endif /* !_STDDEF_H */