1 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 2 3 Copyright (C) 2009-2018 Free Software Foundation, Inc. 4 5 This program is free software: you can redistribute it and/or 6 modify it under the terms of either: 7 8 * the GNU Lesser General Public License as published by the Free 9 Software Foundation; either version 3 of the License, or (at your 10 option) any later version. 11 12 or 13 14 * the GNU General Public License as published by the Free 15 Software Foundation; either version 2 of the License, or (at your 16 option) any later version. 17 18 or both in parallel, as here. 19 This program is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 GNU General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, see <https://www.gnu.org/licenses/>. */ 26 27 /* Written by Eric Blake. */ 28 29 /* 30 * POSIX 2008 <stddef.h> for platforms that have issues. 31 * <http://www.opengroup.org/susv3xbd/stddef.h.html> 32 */ 33 34 #if __GNUC__ >= 3 35 @PRAGMA_SYSTEM_HEADER@ 36 #endif 37 @PRAGMA_COLUMNS@ 38 39 #if defined __need_wchar_t || defined __need_size_t \ 40 || defined __need_ptrdiff_t || defined __need_NULL \ 41 || defined __need_wint_t 42 /* Special invocation convention inside gcc header files. In 43 particular, gcc provides a version of <stddef.h> that blindly 44 redefines NULL even when __need_wint_t was defined, even though 45 wint_t is not normally provided by <stddef.h>. Hence, we must 46 remember if special invocation has ever been used to obtain wint_t, 47 in which case we need to clean up NULL yet again. */ 48 49 # if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 50 # ifdef __need_wint_t 51 # define _GL_STDDEF_WINT_T 52 # endif 53 # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 54 # endif 55 56 #else 57 /* Normal invocation convention. */ 58 59 # ifndef _@GUARD_PREFIX@_STDDEF_H 60 61 /* The include_next requires a split double-inclusion guard. */ 62 63 # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 64 65 /* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 66 # if (@REPLACE_NULL@ \ 67 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T)) 68 # undef NULL 69 # ifdef __cplusplus 70 /* ISO C++ says that the macro NULL must expand to an integer constant 71 expression, hence '((void *) 0)' is not allowed in C++. */ 72 # if __GNUG__ >= 3 73 /* GNU C++ has a __null macro that behaves like an integer ('int' or 74 'long') but has the same size as a pointer. Use that, to avoid 75 warnings. */ 76 # define NULL __null 77 # else 78 # define NULL 0L 79 # endif 80 # else 81 # define NULL ((void *) 0) 82 # endif 83 # endif 84 85 # ifndef _@GUARD_PREFIX@_STDDEF_H 86 # define _@GUARD_PREFIX@_STDDEF_H 87 88 /* Some platforms lack wchar_t. */ 89 #if !@HAVE_WCHAR_T@ 90 # define wchar_t int 91 #endif 92 93 /* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is 94 a hack in case the configure-time test was done with g++ even though 95 we are currently compiling with gcc. */ 96 #if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T) 97 # if !GNULIB_defined_max_align_t 98 /* On the x86, the maximum storage alignment of double, long, etc. is 4, 99 but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8, 100 and the C11 standard allows this. Work around this problem by 101 using __alignof__ (which returns 8 for double) rather than _Alignof 102 (which returns 4), and align each union member accordingly. */ 103 # ifdef __GNUC__ 104 # define _GL_STDDEF_ALIGNAS(type) \ 105 __attribute__ ((__aligned__ (__alignof__ (type)))) 106 # else 107 # define _GL_STDDEF_ALIGNAS(type) /* */ 108 # endif 109 typedef union 110 { 111 char *__p _GL_STDDEF_ALIGNAS (char *); 112 double __d _GL_STDDEF_ALIGNAS (double); 113 long double __ld _GL_STDDEF_ALIGNAS (long double); 114 long int __i _GL_STDDEF_ALIGNAS (long int); 115 } rpl_max_align_t; 116 # define max_align_t rpl_max_align_t 117 # define GNULIB_defined_max_align_t 1 118 # endif 119 #endif 120 121 # endif /* _@GUARD_PREFIX@_STDDEF_H */ 122 # endif /* _@GUARD_PREFIX@_STDDEF_H */ 123 #endif /* __need_XXX */ 124