Blame gl/stddef.in.h

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