Blame lib/stddef.in.h

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