(root)/
gettext-0.22.4/
gettext-tools/
libgettextpo/
stddef.in.h
       1  /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
       2  
       3     Copyright (C) 2009-2023 Free Software Foundation, Inc.
       4  
       5     This file is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU Lesser General Public License as
       7     published by the Free Software Foundation; either version 2.1 of the
       8     License, or (at your option) any later version.
       9  
      10     This file is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13     GNU Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  /* Written by Eric Blake.  */
      19  
      20  /*
      21   * POSIX 2008 and ISO C 23 <stddef.h> for platforms that have issues.
      22   * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
      23   */
      24  
      25  #if __GNUC__ >= 3
      26  @PRAGMA_SYSTEM_HEADER@
      27  #endif
      28  @PRAGMA_COLUMNS@
      29  
      30  #if defined __need_wchar_t || defined __need_size_t  \
      31    || defined __need_ptrdiff_t || defined __need_NULL \
      32    || defined __need_wint_t
      33  /* Special invocation convention inside gcc header files.  In
      34     particular, gcc provides a version of <stddef.h> that blindly
      35     redefines NULL even when __need_wint_t was defined, even though
      36     wint_t is not normally provided by <stddef.h>.  Hence, we must
      37     remember if special invocation has ever been used to obtain wint_t,
      38     in which case we need to clean up NULL yet again.  */
      39  
      40  # if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _@GUARD_PREFIX@_STDDEF_WINT_T)
      41  #  ifdef __need_wint_t
      42  #   define _@GUARD_PREFIX@_STDDEF_WINT_T
      43  #  endif
      44  #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
      45     /* On TinyCC, make sure that the macros that indicate the special invocation
      46        convention get undefined.  */
      47  #  undef __need_wchar_t
      48  #  undef __need_size_t
      49  #  undef __need_ptrdiff_t
      50  #  undef __need_NULL
      51  #  undef __need_wint_t
      52  # endif
      53  
      54  #else
      55  /* Normal invocation convention.  */
      56  
      57  # ifndef _@GUARD_PREFIX@_STDDEF_H
      58  
      59  /* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
      60     type with alignment 4, but 'long' has alignment 8.  */
      61  #  if defined _AIX && defined __LP64__ && !@HAVE_MAX_ALIGN_T@
      62  #   if !GNULIB_defined_max_align_t
      63  #    ifdef _MAX_ALIGN_T
      64  /* /usr/include/stddef.h has already defined max_align_t.  Override it.  */
      65  typedef long rpl_max_align_t;
      66  #     define max_align_t rpl_max_align_t
      67  #    else
      68  /* Prevent /usr/include/stddef.h from defining max_align_t.  */
      69  typedef long max_align_t;
      70  #     define _MAX_ALIGN_T
      71  #    endif
      72  #    define __CLANG_MAX_ALIGN_T_DEFINED
      73  #    define GNULIB_defined_max_align_t 1
      74  #   endif
      75  #  endif
      76  
      77  /* The include_next requires a split double-inclusion guard.  */
      78  
      79  #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
      80  
      81  /* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */
      82  #  if (@REPLACE_NULL@ \
      83         && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _@GUARD_PREFIX@_STDDEF_WINT_T))
      84  #   undef NULL
      85  #   ifdef __cplusplus
      86     /* ISO C++ says that the macro NULL must expand to an integer constant
      87        expression, hence '((void *) 0)' is not allowed in C++.  */
      88  #    if __GNUG__ >= 3
      89      /* GNU C++ has a __null macro that behaves like an integer ('int' or
      90         'long') but has the same size as a pointer.  Use that, to avoid
      91         warnings.  */
      92  #     define NULL __null
      93  #    else
      94  #     define NULL 0L
      95  #    endif
      96  #   else
      97  #    define NULL ((void *) 0)
      98  #   endif
      99  #  endif
     100  
     101  #  ifndef _@GUARD_PREFIX@_STDDEF_H
     102  #   define _@GUARD_PREFIX@_STDDEF_H
     103  
     104  /* This file uses _Noreturn, _GL_ATTRIBUTE_NOTHROW.  */
     105  #if !_GL_CONFIG_H_INCLUDED
     106   #error "Please include config.h first."
     107  #endif
     108  
     109  /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
     110   */
     111  #ifndef _GL_ATTRIBUTE_NOTHROW
     112  # if defined __cplusplus
     113  #  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
     114  #   if __cplusplus >= 201103L
     115  #    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
     116  #   else
     117  #    define _GL_ATTRIBUTE_NOTHROW throw ()
     118  #   endif
     119  #  else
     120  #   define _GL_ATTRIBUTE_NOTHROW
     121  #  endif
     122  # else
     123  #  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
     124  #   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
     125  #  else
     126  #   define _GL_ATTRIBUTE_NOTHROW
     127  #  endif
     128  # endif
     129  #endif
     130  
     131  /* Some platforms lack wchar_t.  */
     132  #if !@HAVE_WCHAR_T@
     133  # define wchar_t int
     134  #endif
     135  
     136  /* Some platforms lack max_align_t.  The check for _GCC_MAX_ALIGN_T is
     137     a hack in case the configure-time test was done with g++ even though
     138     we are currently compiling with gcc.
     139     On MSVC, max_align_t is defined only in C++ mode, after <cstddef> was
     140     included.  Its definition is good since it has an alignment of 8 (on x86
     141     and x86_64).
     142     Similarly on OS/2 kLIBC.  */
     143  #if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \
     144      && defined __cplusplus
     145  # include <cstddef>
     146  #else
     147  # if ! (@HAVE_MAX_ALIGN_T@ || (defined _GCC_MAX_ALIGN_T && !defined __clang__))
     148  #  if !GNULIB_defined_max_align_t
     149  /* On the x86, the maximum storage alignment of double, long, etc. is 4,
     150     but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
     151     and the C11 standard allows this.  Work around this problem by
     152     using __alignof__ (which returns 8 for double) rather than _Alignof
     153     (which returns 4), and align each union member accordingly.  */
     154  #   if defined __GNUC__ || (__clang_major__ >= 4)
     155  #    define _GL_STDDEF_ALIGNAS(type) \
     156         __attribute__ ((__aligned__ (__alignof__ (type))))
     157  #   else
     158  #    define _GL_STDDEF_ALIGNAS(type) /* */
     159  #   endif
     160  typedef union
     161  {
     162    char *__p _GL_STDDEF_ALIGNAS (char *);
     163    double __d _GL_STDDEF_ALIGNAS (double);
     164    long double __ld _GL_STDDEF_ALIGNAS (long double);
     165    long int __i _GL_STDDEF_ALIGNAS (long int);
     166  } rpl_max_align_t;
     167  #   define max_align_t rpl_max_align_t
     168  #   define __CLANG_MAX_ALIGN_T_DEFINED
     169  #   define GNULIB_defined_max_align_t 1
     170  #  endif
     171  # endif
     172  #endif
     173  
     174  /* ISO C 23 ยง 7.21.1 The unreachable macro  */
     175  #ifndef unreachable
     176  
     177  /* Code borrowed from verify.h.  */
     178  # ifndef _GL_HAS_BUILTIN_UNREACHABLE
     179  #  if defined __clang_major__ && __clang_major__ < 5
     180  #   define _GL_HAS_BUILTIN_UNREACHABLE 0
     181  #  elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
     182  #   define _GL_HAS_BUILTIN_UNREACHABLE 1
     183  #  elif defined __has_builtin
     184  #   define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
     185  #  else
     186  #   define _GL_HAS_BUILTIN_UNREACHABLE 0
     187  #  endif
     188  # endif
     189  
     190  # if _GL_HAS_BUILTIN_UNREACHABLE
     191  #  define unreachable() __builtin_unreachable ()
     192  # elif 1200 <= _MSC_VER
     193  #  define unreachable() __assume (0)
     194  # else
     195  /* Declare abort(), without including <stdlib.h>.  */
     196  extern
     197  #  if defined __cplusplus
     198  "C"
     199  #  endif
     200  _Noreturn
     201  void abort (void)
     202  #  if defined __cplusplus && (__GLIBC__ >= 2)
     203  _GL_ATTRIBUTE_NOTHROW
     204  #  endif
     205  ;
     206  #  define unreachable() abort ()
     207  # endif
     208  
     209  #endif
     210  
     211  #  endif /* _@GUARD_PREFIX@_STDDEF_H */
     212  # endif /* _@GUARD_PREFIX@_STDDEF_H */
     213  #endif /* __need_XXX */