Blame lib/stddef.in.h

Packit 709fb3
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
Packit 709fb3
Packit 709fb3
   Copyright (C) 2009-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software; you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3, or (at your option)
Packit 709fb3
   any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
/* Written by Eric Blake.  */
Packit 709fb3
Packit 709fb3
/*
Packit 709fb3
 * POSIX 2008 <stddef.h> for platforms that have issues.
Packit 709fb3
 * <http://www.opengroup.org/susv3xbd/stddef.h.html>
Packit 709fb3
 */
Packit 709fb3
Packit 709fb3
#if __GNUC__ >= 3
Packit 709fb3
@PRAGMA_SYSTEM_HEADER@
Packit 709fb3
#endif
Packit 709fb3
@PRAGMA_COLUMNS@
Packit 709fb3
Packit 709fb3
#if defined __need_wchar_t || defined __need_size_t  \
Packit 709fb3
  || defined __need_ptrdiff_t || defined __need_NULL \
Packit 709fb3
  || defined __need_wint_t
Packit 709fb3
/* Special invocation convention inside gcc header files.  In
Packit 709fb3
   particular, gcc provides a version of <stddef.h> that blindly
Packit 709fb3
   redefines NULL even when __need_wint_t was defined, even though
Packit 709fb3
   wint_t is not normally provided by <stddef.h>.  Hence, we must
Packit 709fb3
   remember if special invocation has ever been used to obtain wint_t,
Packit 709fb3
   in which case we need to clean up NULL yet again.  */
Packit 709fb3
Packit 709fb3
# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
Packit 709fb3
#  ifdef __need_wint_t
Packit 709fb3
#   define _GL_STDDEF_WINT_T
Packit 709fb3
#  endif
Packit 709fb3
#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
Packit 709fb3
# endif
Packit 709fb3
Packit 709fb3
#else
Packit 709fb3
/* Normal invocation convention.  */
Packit 709fb3
Packit 709fb3
# ifndef _@GUARD_PREFIX@_STDDEF_H
Packit 709fb3
Packit 709fb3
/* The include_next requires a split double-inclusion guard.  */
Packit 709fb3
Packit 709fb3
#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
Packit 709fb3
Packit 709fb3
/* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */
Packit 709fb3
#  if (@REPLACE_NULL@ \
Packit 709fb3
       && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
Packit 709fb3
#   undef NULL
Packit 709fb3
#   ifdef __cplusplus
Packit 709fb3
   /* ISO C++ says that the macro NULL must expand to an integer constant
Packit 709fb3
      expression, hence '((void *) 0)' is not allowed in C++.  */
Packit 709fb3
#    if __GNUG__ >= 3
Packit 709fb3
    /* GNU C++ has a __null macro that behaves like an integer ('int' or
Packit 709fb3
       'long') but has the same size as a pointer.  Use that, to avoid
Packit 709fb3
       warnings.  */
Packit 709fb3
#     define NULL __null
Packit 709fb3
#    else
Packit 709fb3
#     define NULL 0L
Packit 709fb3
#    endif
Packit 709fb3
#   else
Packit 709fb3
#    define NULL ((void *) 0)
Packit 709fb3
#   endif
Packit 709fb3
#  endif
Packit 709fb3
Packit 709fb3
#  ifndef _@GUARD_PREFIX@_STDDEF_H
Packit 709fb3
#   define _@GUARD_PREFIX@_STDDEF_H
Packit 709fb3
Packit 709fb3
/* Some platforms lack wchar_t.  */
Packit 709fb3
#if !@HAVE_WCHAR_T@
Packit 709fb3
# define wchar_t int
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* Some platforms lack max_align_t.  The check for _GCC_MAX_ALIGN_T is
Packit 709fb3
   a hack in case the configure-time test was done with g++ even though
Packit 709fb3
   we are currently compiling with gcc.  */
Packit 709fb3
#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
Packit 709fb3
/* On the x86, the maximum storage alignment of double, long, etc. is 4,
Packit 709fb3
   but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
Packit 709fb3
   and the C11 standard allows this.  Work around this problem by
Packit 709fb3
   using __alignof__ (which returns 8 for double) rather than _Alignof
Packit 709fb3
   (which returns 4), and align each union member accordingly.  */
Packit 709fb3
# ifdef __GNUC__
Packit 709fb3
#  define _GL_STDDEF_ALIGNAS(type) \
Packit 709fb3
     __attribute__ ((__aligned__ (__alignof__ (type))))
Packit 709fb3
# else
Packit 709fb3
#  define _GL_STDDEF_ALIGNAS(type) /* */
Packit 709fb3
# endif
Packit 709fb3
typedef union
Packit 709fb3
{
Packit 709fb3
  char *__p _GL_STDDEF_ALIGNAS (char *);
Packit 709fb3
  double __d _GL_STDDEF_ALIGNAS (double);
Packit 709fb3
  long double __ld _GL_STDDEF_ALIGNAS (long double);
Packit 709fb3
  long int __i _GL_STDDEF_ALIGNAS (long int);
Packit 709fb3
} max_align_t;
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#  endif /* _@GUARD_PREFIX@_STDDEF_H */
Packit 709fb3
# endif /* _@GUARD_PREFIX@_STDDEF_H */
Packit 709fb3
#endif /* __need_XXX */