Blame gl/stddef.in.h

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