1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-16 10:50:49 -08:00

Update from gnulib

* cross/lib/stdalign.in.h (_GL_STDALIGN_H):
(_):
(__alignof_is_defined):
* cross/lib/vasnprintf.c:
* lib/gnulib.mk.in (ANDROID_MIN_SDK):
(HAVE_SPAWN_H):
(LIBGCCJIT_LIBS):
(NATIVE_COMPILATION_AOT):
(NEXT_AS_FIRST_DIRECTIVE_LIMITS_H):
(NEXT_LIMITS_H):
(SIZEOF_LONG):
(stdalign.h):
* ../../../../dev/null:
* lib/stdalign.in.h (_GL_STDALIGN_H):
(_):
(__alignof_is_defined):
* lib/vasnprintf.c:
* m4/gnulib-common.m4 (gl_COMMON_BODY):
* m4/stdalign.m4 (gl_ALIGNASOF):
* m4/stddef_h.m4: Update from gnulib.
This commit is contained in:
Po Lu 2023-01-28 14:33:58 +08:00
parent 8732a5bd78
commit 6f2a518f27
9 changed files with 285 additions and 3404 deletions

View file

@ -20,8 +20,22 @@
/* Define two obsolescent C11 macros, assuming alignas and alignof are /* Define two obsolescent C11 macros, assuming alignas and alignof are
either keywords or alignasof-defined macros. */ either keywords or alignasof-defined macros. */
#ifndef _GL_STDALIGN_H #ifndef _@GUARD_PREFIX@_STDALIGN_H
#define _GL_STDALIGN_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* We need to include the system's <stdalign.h> when it exists, because it might
define 'alignof' as a macro when it's not a keyword or compiler built-in. */
#if @HAVE_STDALIGN_H@
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_STDALIGN_H@
#endif
#ifndef _@GUARD_PREFIX@_STDALIGN_H
#define _@GUARD_PREFIX@_STDALIGN_H
#if (defined alignas \ #if (defined alignas \
|| (defined __STDC_VERSION__ && 202311 <= __STDC_VERSION__) \ || (defined __STDC_VERSION__ && 202311 <= __STDC_VERSION__) \
@ -31,4 +45,5 @@
#define __alignof_is_defined 1 #define __alignof_is_defined 1
#endif /* _GL_STDALIGN_H */ #endif /* _@GUARD_PREFIX@_STDALIGN_H */
#endif /* _@GUARD_PREFIX@_STDALIGN_H */

View file

@ -83,10 +83,10 @@
#include <stdio.h> /* snprintf(), sprintf() */ #include <stdio.h> /* snprintf(), sprintf() */
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */ #include <string.h> /* memcpy(), strlen() */
#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */
#include <errno.h> /* errno */ #include <errno.h> /* errno */
#include <limits.h> /* CHAR_BIT */ #include <limits.h> /* CHAR_BIT */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
#include <wchar.h>
#if HAVE_NL_LANGINFO #if HAVE_NL_LANGINFO
# include <langinfo.h> # include <langinfo.h>
#endif #endif

View file

@ -191,6 +191,7 @@ ANDROID_LIBS = @ANDROID_LIBS@
ANDROID_MIN_SDK = @ANDROID_MIN_SDK@ ANDROID_MIN_SDK = @ANDROID_MIN_SDK@
ANDROID_OBJ = @ANDROID_OBJ@ ANDROID_OBJ = @ANDROID_OBJ@
ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@ ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
APKSIGNER = @APKSIGNER@
APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
AR = @AR@ AR = @AR@
ARFLAGS = @ARFLAGS@ ARFLAGS = @ARFLAGS@
@ -1048,6 +1049,7 @@ HAVE_SLEEP = @HAVE_SLEEP@
HAVE_SPAWN_H = @HAVE_SPAWN_H@ HAVE_SPAWN_H = @HAVE_SPAWN_H@
HAVE_SQRTF = @HAVE_SQRTF@ HAVE_SQRTF = @HAVE_SQRTF@
HAVE_SQRTL = @HAVE_SQRTL@ HAVE_SQRTL = @HAVE_SQRTL@
HAVE_STDALIGN_H = @HAVE_STDALIGN_H@
HAVE_STDINT_H = @HAVE_STDINT_H@ HAVE_STDINT_H = @HAVE_STDINT_H@
HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPCPY = @HAVE_STPCPY@
HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@
@ -1132,6 +1134,7 @@ LIBGCCJIT_CFLAGS = @LIBGCCJIT_CFLAGS@
LIBGCCJIT_LIBS = @LIBGCCJIT_LIBS@ LIBGCCJIT_LIBS = @LIBGCCJIT_LIBS@
LIBGIF = @LIBGIF@ LIBGIF = @LIBGIF@
LIBGMP = @LIBGMP@ LIBGMP = @LIBGMP@
LIBGMP_CFLAGS = @LIBGMP_CFLAGS@
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@ LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
@ -1198,10 +1201,13 @@ NANOSLEEP_LIB = @NANOSLEEP_LIB@
NATIVE_COMPILATION_AOT = @NATIVE_COMPILATION_AOT@ NATIVE_COMPILATION_AOT = @NATIVE_COMPILATION_AOT@
NDK_BUILD_ABI = @NDK_BUILD_ABI@ NDK_BUILD_ABI = @NDK_BUILD_ABI@
NDK_BUILD_ANDROID_MK = @NDK_BUILD_ANDROID_MK@ NDK_BUILD_ANDROID_MK = @NDK_BUILD_ANDROID_MK@
NDK_BUILD_ANY_CXX_MODULE = @NDK_BUILD_ANY_CXX_MODULE@
NDK_BUILD_AR = @NDK_BUILD_AR@ NDK_BUILD_AR = @NDK_BUILD_AR@
NDK_BUILD_ARCH = @NDK_BUILD_ARCH@ NDK_BUILD_ARCH = @NDK_BUILD_ARCH@
NDK_BUILD_CC = @NDK_BUILD_CC@ NDK_BUILD_CC = @NDK_BUILD_CC@
NDK_BUILD_CXX_SHARED = @NDK_BUILD_CXX_SHARED@
NDK_BUILD_MODULES = @NDK_BUILD_MODULES@ NDK_BUILD_MODULES = @NDK_BUILD_MODULES@
NDK_BUILD_NASM = @NDK_BUILD_NASM@
NDK_BUILD_SDK = @NDK_BUILD_SDK@ NDK_BUILD_SDK = @NDK_BUILD_SDK@
NEXT_ASSERT_H = @NEXT_ASSERT_H@ NEXT_ASSERT_H = @NEXT_ASSERT_H@
NEXT_AS_FIRST_DIRECTIVE_ASSERT_H = @NEXT_AS_FIRST_DIRECTIVE_ASSERT_H@ NEXT_AS_FIRST_DIRECTIVE_ASSERT_H = @NEXT_AS_FIRST_DIRECTIVE_ASSERT_H@
@ -1214,6 +1220,7 @@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@
NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@ NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = @NEXT_AS_FIRST_DIRECTIVE_LIMITS_H@
NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@
NEXT_AS_FIRST_DIRECTIVE_STDALIGN_H = @NEXT_AS_FIRST_DIRECTIVE_STDALIGN_H@
NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@
NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@ NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@ NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
@ -1235,6 +1242,7 @@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@
NEXT_LIMITS_H = @NEXT_LIMITS_H@ NEXT_LIMITS_H = @NEXT_LIMITS_H@
NEXT_MATH_H = @NEXT_MATH_H@ NEXT_MATH_H = @NEXT_MATH_H@
NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@
NEXT_STDALIGN_H = @NEXT_STDALIGN_H@
NEXT_STDDEF_H = @NEXT_STDDEF_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@
NEXT_STDINT_H = @NEXT_STDINT_H@ NEXT_STDINT_H = @NEXT_STDINT_H@
NEXT_STDIO_H = @NEXT_STDIO_H@ NEXT_STDIO_H = @NEXT_STDIO_H@
@ -1560,6 +1568,7 @@ SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
SIZEOF_LONG = @SIZEOF_LONG@ SIZEOF_LONG = @SIZEOF_LONG@
SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
SMALL_JA_DIC = @SMALL_JA_DIC@ SMALL_JA_DIC = @SMALL_JA_DIC@
SQLITE3_CFLAGS = @SQLITE3_CFLAGS@
SQLITE3_LIBS = @SQLITE3_LIBS@ SQLITE3_LIBS = @SQLITE3_LIBS@
STDALIGN_H = @STDALIGN_H@ STDALIGN_H = @STDALIGN_H@
STDCKDINT_H = @STDCKDINT_H@ STDCKDINT_H = @STDCKDINT_H@
@ -3767,7 +3776,14 @@ BUILT_SOURCES += $(STDALIGN_H)
# doesn't have one that works. # doesn't have one that works.
ifneq (,$(GL_GENERATE_STDALIGN_H_CONDITION)) ifneq (,$(GL_GENERATE_STDALIGN_H_CONDITION))
stdalign.h: stdalign.in.h $(top_builddir)/config.status stdalign.h: stdalign.in.h $(top_builddir)/config.status
$(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h $(gl_V_at)$(SED_HEADER_STDOUT) \
-e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''HAVE_STDALIGN_H''@|$(HAVE_STDALIGN_H)|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDALIGN_H''@|$(NEXT_STDALIGN_H)|g' \
$(srcdir)/stdalign.in.h > $@-t
$(AM_V_at)mv $@-t $@ $(AM_V_at)mv $@-t $@
else else
stdalign.h: $(top_builddir)/config.status stdalign.h: $(top_builddir)/config.status

3242
lib/math.h

File diff suppressed because it is too large Load diff

View file

@ -20,8 +20,22 @@
/* Define two obsolescent C11 macros, assuming alignas and alignof are /* Define two obsolescent C11 macros, assuming alignas and alignof are
either keywords or alignasof-defined macros. */ either keywords or alignasof-defined macros. */
#ifndef _GL_STDALIGN_H #ifndef _@GUARD_PREFIX@_STDALIGN_H
#define _GL_STDALIGN_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* We need to include the system's <stdalign.h> when it exists, because it might
define 'alignof' as a macro when it's not a keyword or compiler built-in. */
#if @HAVE_STDALIGN_H@
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_STDALIGN_H@
#endif
#ifndef _@GUARD_PREFIX@_STDALIGN_H
#define _@GUARD_PREFIX@_STDALIGN_H
#if (defined alignas \ #if (defined alignas \
|| (defined __STDC_VERSION__ && 202311 <= __STDC_VERSION__) \ || (defined __STDC_VERSION__ && 202311 <= __STDC_VERSION__) \
@ -31,4 +45,5 @@
#define __alignof_is_defined 1 #define __alignof_is_defined 1
#endif /* _GL_STDALIGN_H */ #endif /* _@GUARD_PREFIX@_STDALIGN_H */
#endif /* _@GUARD_PREFIX@_STDALIGN_H */

View file

@ -83,6 +83,7 @@
#include <stdio.h> /* snprintf(), sprintf() */ #include <stdio.h> /* snprintf(), sprintf() */
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
#include <string.h> /* memcpy(), strlen() */ #include <string.h> /* memcpy(), strlen() */
#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */
#include <errno.h> /* errno */ #include <errno.h> /* errno */
#include <limits.h> /* CHAR_BIT */ #include <limits.h> /* CHAR_BIT */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */

View file

@ -1,4 +1,4 @@
# gnulib-common.m4 serial 77 # gnulib-common.m4 serial 78
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
@ -124,29 +124,35 @@ AC_DEFUN([gl_COMMON_BODY], [
by the Nth argument of the function is the size of the returned memory block. by the Nth argument of the function is the size of the returned memory block.
*/ */
/* Applies to: function, pointer to function, function types. */ /* Applies to: function, pointer to function, function types. */
#if _GL_HAS_ATTRIBUTE (alloc_size) #ifndef _GL_ATTRIBUTE_ALLOC_SIZE
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) # if _GL_HAS_ATTRIBUTE (alloc_size)
#else # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) # else
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
# endif
#endif #endif
/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
function and report an error if it cannot do so. */ function and report an error if it cannot do so. */
/* Applies to: function. */ /* Applies to: function. */
#if _GL_HAS_ATTRIBUTE (always_inline) #ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) # if _GL_HAS_ATTRIBUTE (always_inline)
#else # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
# define _GL_ATTRIBUTE_ALWAYS_INLINE # else
# define _GL_ATTRIBUTE_ALWAYS_INLINE
# endif
#endif #endif
/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
in stack traces when debugging. The compiler should omit the function from in stack traces when debugging. The compiler should omit the function from
stack traces. */ stack traces. */
/* Applies to: function. */ /* Applies to: function. */
#if _GL_HAS_ATTRIBUTE (artificial) #ifndef _GL_ATTRIBUTE_ARTIFICIAL
# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) # if _GL_HAS_ATTRIBUTE (artificial)
#else # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
# define _GL_ATTRIBUTE_ARTIFICIAL # else
# define _GL_ATTRIBUTE_ARTIFICIAL
# endif
#endif #endif
/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ /* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
@ -154,14 +160,16 @@ AC_DEFUN([gl_COMMON_BODY], [
/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
<https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
#if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ #ifndef _GL_ATTRIBUTE_COLD
# ifndef __SUNPRO_C # if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) # ifndef __SUNPRO_C
# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
# else
# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
# endif
# else # else
# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) # define _GL_ATTRIBUTE_COLD
# endif # endif
#else
# define _GL_ATTRIBUTE_COLD
#endif #endif
/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
@ -171,10 +179,12 @@ AC_DEFUN([gl_COMMON_BODY], [
forever, and does not call longjmp. forever, and does not call longjmp.
(This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (const) #ifndef _GL_ATTRIBUTE_CONST
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) # if _GL_HAS_ATTRIBUTE (const)
#else # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
# define _GL_ATTRIBUTE_CONST # else
# define _GL_ATTRIBUTE_CONST
# endif
#endif #endif
/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
@ -183,10 +193,12 @@ AC_DEFUN([gl_COMMON_BODY], [
_GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
can be freed via 'free'; it can be used only after declaring 'free'. */ can be freed via 'free'; it can be used only after declaring 'free'. */
/* Applies to: functions. Cannot be used on inline functions. */ /* Applies to: functions. Cannot be used on inline functions. */
#if _GL_GNUC_PREREQ (11, 0) #ifndef _GL_ATTRIBUTE_DEALLOC
# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) # if _GL_GNUC_PREREQ (11, 0)
#else # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
# define _GL_ATTRIBUTE_DEALLOC(f, i) # else
# define _GL_ATTRIBUTE_DEALLOC(f, i)
# endif
#endif #endif
/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue /* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
to use this earlier definition, since <stdlib.h> may not have been included to use this earlier definition, since <stdlib.h> may not have been included
@ -210,16 +222,18 @@ AC_DEFUN([gl_COMMON_BODY], [
- enumeration, enumeration item, - enumeration, enumeration item,
- typedef, - typedef,
in C++ also: namespace, class, template specialization. */ in C++ also: namespace, class, template specialization. */
#ifdef __has_c_attribute
# if __has_c_attribute (__deprecated__)
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
# endif
#endif
#if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef _GL_ATTRIBUTE_DEPRECATED #ifndef _GL_ATTRIBUTE_DEPRECATED
# define _GL_ATTRIBUTE_DEPRECATED # ifdef __has_c_attribute
# if __has_c_attribute (__deprecated__)
# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
# endif
# endif
# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
# endif
# ifndef _GL_ATTRIBUTE_DEPRECATED
# define _GL_ATTRIBUTE_DEPRECATED
# endif
#endif #endif
/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and /* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
@ -227,24 +241,28 @@ AC_DEFUN([gl_COMMON_BODY], [
_GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
the function call is not optimized away. */ the function call is not optimized away. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (error) #if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING)
# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) # if _GL_HAS_ATTRIBUTE (error)
# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
#elif _GL_HAS_ATTRIBUTE (diagnose_if) # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error"))) # elif _GL_HAS_ATTRIBUTE (diagnose_if)
# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning"))) # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
#else # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
# define _GL_ATTRIBUTE_ERROR(msg) # else
# define _GL_ATTRIBUTE_WARNING(msg) # define _GL_ATTRIBUTE_ERROR(msg)
# define _GL_ATTRIBUTE_WARNING(msg)
# endif
#endif #endif
/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain /* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
visible to debuggers etc., even with '-fwhole-program'. */ visible to debuggers etc., even with '-fwhole-program'. */
/* Applies to: functions, variables. */ /* Applies to: functions, variables. */
#if _GL_HAS_ATTRIBUTE (externally_visible) #ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) # if _GL_HAS_ATTRIBUTE (externally_visible)
#else # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE # else
# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
# endif
#endif #endif
/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if /* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
@ -252,16 +270,18 @@ AC_DEFUN([gl_COMMON_BODY], [
'default' label. The compiler should not warn in this case. */ 'default' label. The compiler should not warn in this case. */
/* Applies to: Empty statement (;), inside a 'switch' statement. */ /* Applies to: Empty statement (;), inside a 'switch' statement. */
/* Always expands to something. */ /* Always expands to something. */
#ifdef __has_c_attribute
# if __has_c_attribute (__fallthrough__)
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
# endif
#endif
#if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
#endif
#ifndef _GL_ATTRIBUTE_FALLTHROUGH #ifndef _GL_ATTRIBUTE_FALLTHROUGH
# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) # ifdef __has_c_attribute
# if __has_c_attribute (__fallthrough__)
# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
# endif
# endif
# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
# endif
# ifndef _GL_ATTRIBUTE_FALLTHROUGH
# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
# endif
#endif #endif
/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) /* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
@ -275,10 +295,12 @@ AC_DEFUN([gl_COMMON_BODY], [
If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
are suitable for the format string. */ are suitable for the format string. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (format) #ifndef _GL_ATTRIBUTE_FORMAT
# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) # if _GL_HAS_ATTRIBUTE (format)
#else # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
# define _GL_ATTRIBUTE_FORMAT(spec) # else
# define _GL_ATTRIBUTE_FORMAT(spec)
# endif
#endif #endif
/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other /* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
@ -286,19 +308,23 @@ AC_DEFUN([gl_COMMON_BODY], [
exception handling. This declaration lets the compiler optimize that unit exception handling. This declaration lets the compiler optimize that unit
more aggressively. */ more aggressively. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (leaf) #ifndef _GL_ATTRIBUTE_LEAF
# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) # if _GL_HAS_ATTRIBUTE (leaf)
#else # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
# define _GL_ATTRIBUTE_LEAF # else
# define _GL_ATTRIBUTE_LEAF
# endif
#endif #endif
/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
allocated memory. */ allocated memory. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (malloc) #ifndef _GL_ATTRIBUTE_MALLOC
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) # if _GL_HAS_ATTRIBUTE (malloc)
#else # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
# define _GL_ATTRIBUTE_MALLOC # else
# define _GL_ATTRIBUTE_MALLOC
# endif
#endif #endif
/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the /* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
@ -306,10 +332,12 @@ AC_DEFUN([gl_COMMON_BODY], [
strict aliasing optimization. */ strict aliasing optimization. */
/* Applies to: types. */ /* Applies to: types. */
/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
#if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C #ifndef _GL_ATTRIBUTE_MAY_ALIAS
# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) # if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
#else # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
# define _GL_ATTRIBUTE_MAY_ALIAS # else
# define _GL_ATTRIBUTE_MAY_ALIAS
# endif
#endif #endif
/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
@ -324,13 +352,15 @@ AC_DEFUN([gl_COMMON_BODY], [
/* In C++ and C23, this is spelled [[__maybe_unused__]]. /* In C++ and C23, this is spelled [[__maybe_unused__]].
GCC's syntax is __attribute__ ((__unused__)). GCC's syntax is __attribute__ ((__unused__)).
clang supports both syntaxes. */ clang supports both syntaxes. */
#ifdef __has_c_attribute
# if __has_c_attribute (__maybe_unused__)
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
# endif
#endif
#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED # ifdef __has_c_attribute
# if __has_c_attribute (__maybe_unused__)
# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
# endif
# endif
# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
# endif
#endif #endif
/* Alternative spelling of this macro, for convenience and for /* Alternative spelling of this macro, for convenience and for
compatibility with glibc/include/libc-symbols.h. */ compatibility with glibc/include/libc-symbols.h. */
@ -342,25 +372,29 @@ AC_DEFUN([gl_COMMON_BODY], [
discard the return value. The compiler may warn if the caller does not use discard the return value. The compiler may warn if the caller does not use
the return value, unless the caller uses something like ignore_value. */ the return value, unless the caller uses something like ignore_value. */
/* Applies to: function, enumeration, class. */ /* Applies to: function, enumeration, class. */
#ifdef __has_c_attribute
# if __has_c_attribute (__nodiscard__)
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
# endif
#endif
#if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
#endif
#ifndef _GL_ATTRIBUTE_NODISCARD #ifndef _GL_ATTRIBUTE_NODISCARD
# define _GL_ATTRIBUTE_NODISCARD # ifdef __has_c_attribute
# if __has_c_attribute (__nodiscard__)
# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
# endif
# endif
# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
# endif
# ifndef _GL_ATTRIBUTE_NODISCARD
# define _GL_ATTRIBUTE_NODISCARD
# endif
#endif #endif
/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the /* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
function. */ function. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (noinline) #ifndef _GL_ATTRIBUTE_NOINLINE
# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) # if _GL_HAS_ATTRIBUTE (noinline)
#else # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
# define _GL_ATTRIBUTE_NOINLINE # else
# define _GL_ATTRIBUTE_NOINLINE
# endif
#endif #endif
/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... /* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
@ -368,20 +402,24 @@ AC_DEFUN([gl_COMMON_BODY], [
_GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
null. */ null. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (nonnull) #ifndef _GL_ATTRIBUTE_NONNULL
# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) # if _GL_HAS_ATTRIBUTE (nonnull)
#else # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
# define _GL_ATTRIBUTE_NONNULL(args) # else
# define _GL_ATTRIBUTE_NONNULL(args)
# endif
#endif #endif
/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
not meant to be NUL-terminated. */ not meant to be NUL-terminated. */
/* Applies to: struct/union members and variables that are arrays of element /* Applies to: struct/union members and variables that are arrays of element
type '[[un]signed] char'. */ type '[[un]signed] char'. */
#if _GL_HAS_ATTRIBUTE (nonstring) #ifndef _GL_ATTRIBUTE_NONSTRING
# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) # if _GL_HAS_ATTRIBUTE (nonstring)
#else # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
# define _GL_ATTRIBUTE_NONSTRING # else
# define _GL_ATTRIBUTE_NONSTRING
# endif
#endif #endif
/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
@ -389,10 +427,12 @@ AC_DEFUN([gl_COMMON_BODY], [
/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
*/ */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus #ifndef _GL_ATTRIBUTE_NOTHROW
# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) # if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
#else # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
# define _GL_ATTRIBUTE_NOTHROW # else
# define _GL_ATTRIBUTE_NOTHROW
# endif
#endif #endif
/* _GL_ATTRIBUTE_PACKED declares: /* _GL_ATTRIBUTE_PACKED declares:
@ -401,10 +441,12 @@ AC_DEFUN([gl_COMMON_BODY], [
minimizing the memory required. */ minimizing the memory required. */
/* Applies to: struct members, struct, union, /* Applies to: struct members, struct, union,
in C++ also: class. */ in C++ also: class. */
#if _GL_HAS_ATTRIBUTE (packed) #ifndef _GL_ATTRIBUTE_PACKED
# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) # if _GL_HAS_ATTRIBUTE (packed)
#else # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
# define _GL_ATTRIBUTE_PACKED # else
# define _GL_ATTRIBUTE_PACKED
# endif
#endif #endif
/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
@ -414,19 +456,23 @@ AC_DEFUN([gl_COMMON_BODY], [
observable state, and always returns exactly once. observable state, and always returns exactly once.
(This attribute is looser than _GL_ATTRIBUTE_CONST.) */ (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (pure) #ifndef _GL_ATTRIBUTE_PURE
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) # if _GL_HAS_ATTRIBUTE (pure)
#else # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
# define _GL_ATTRIBUTE_PURE # else
# define _GL_ATTRIBUTE_PURE
# endif
#endif #endif
/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is /* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
a non-NULL pointer. */ a non-NULL pointer. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (returns_nonnull) #ifndef _GL_ATTRIBUTE_RETURNS_NONNULL
# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) # if _GL_HAS_ATTRIBUTE (returns_nonnull)
#else # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
# define _GL_ATTRIBUTE_RETURNS_NONNULL # else
# define _GL_ATTRIBUTE_RETURNS_NONNULL
# endif
#endif #endif
/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a /* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
@ -434,17 +480,21 @@ AC_DEFUN([gl_COMMON_BODY], [
_GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
_GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
/* Applies to: functions. */ /* Applies to: functions. */
#if _GL_HAS_ATTRIBUTE (sentinel) #ifndef _GL_ATTRIBUTE_SENTINEL
# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) # if _GL_HAS_ATTRIBUTE (sentinel)
#else # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
# define _GL_ATTRIBUTE_SENTINEL(pos) # else
# define _GL_ATTRIBUTE_SENTINEL(pos)
# endif
#endif #endif
/* A helper macro. Don't use it directly. */ /* A helper macro. Don't use it directly. */
#if _GL_HAS_ATTRIBUTE (unused) #ifndef _GL_ATTRIBUTE_UNUSED
# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # if _GL_HAS_ATTRIBUTE (unused)
#else # define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# define _GL_ATTRIBUTE_UNUSED # else
# define _GL_ATTRIBUTE_UNUSED
# endif
#endif #endif
]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
@ -455,10 +505,12 @@ AC_DEFUN([gl_COMMON_BODY], [
/* Applies to: label (both in C and C++). */ /* Applies to: label (both in C and C++). */
/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' /* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
syntax. But clang does. */ syntax. But clang does. */
#if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ #ifndef _GL_UNUSED_LABEL
# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED # if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
#else # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
# define _GL_UNUSED_LABEL # else
# define _GL_UNUSED_LABEL
# endif
#endif #endif
]) ])
AH_VERBATIM([async_safe], AH_VERBATIM([async_safe],

View file

@ -71,7 +71,8 @@ AC_DEFUN([gl_ALIGNASOF],
[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof [#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
# if HAVE_STDALIGN_H # if HAVE_STDALIGN_H
# include <stdalign.h> # include <stdalign.h>
# else # endif
/* ISO C23 alignas and alignof for platforms that lack it. /* ISO C23 alignas and alignof for platforms that lack it.
References: References:
@ -99,26 +100,32 @@ AC_DEFUN([gl_ALIGNASOF],
/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 /* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
clang versions < 8.0.0 have the same bug. */ clang versions < 8.0.0 have the same bug. */
# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ # if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
|| (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
&& !defined __clang__) \ && !defined __clang__) \
|| (defined __clang__ && __clang_major__ < 8)) || (defined __clang__ && __clang_major__ < 8))
# ifdef __cplusplus # undef/**/_Alignof
# if (201103 <= __cplusplus || defined _MSC_VER) # ifdef __cplusplus
# define _Alignof(type) alignof (type) # if (201103 <= __cplusplus || defined _MSC_VER)
# else # define _Alignof(type) alignof (type)
template <class __t> struct __alignof_helper { char __a; __t __b; }; # else
# define _Alignof(type) offsetof (__alignof_helper<type>, __b) template <class __t> struct __alignof_helper { char __a; __t __b; };
# define _GL_STDALIGN_NEEDS_STDDEF 1 # define _Alignof(type) offsetof (__alignof_helper<type>, __b)
# endif # define _GL_STDALIGN_NEEDS_STDDEF 1
# endif
# else
# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
# else # else
# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
# define _GL_STDALIGN_NEEDS_STDDEF 1 # define _GL_STDALIGN_NEEDS_STDDEF 1
# endif # endif
# endif # endif
# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) # endif
# define alignof _Alignof # if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
# endif # undef/**/alignof
# define alignof _Alignof
# endif
/* alignas (A), also known as _Alignas (A), aligns a variable or type /* alignas (A), also known as _Alignas (A), aligns a variable or type
to the alignment A, where A is an integer constant expression. For to the alignment A, where A is an integer constant expression. For
@ -144,6 +151,7 @@ AC_DEFUN([gl_ALIGNASOF],
- alignas (TYPE) is equivalent to alignas (alignof (TYPE)). - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
*/ */
# if !HAVE_STDALIGN_H
# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 # if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) # if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
# define _Alignas(a) alignas (a) # define _Alignas(a) alignas (a)
@ -165,9 +173,10 @@ AC_DEFUN([gl_ALIGNASOF],
|| (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
# define alignas _Alignas # define alignas _Alignas
# endif # endif
# if _GL_STDALIGN_NEEDS_STDDEF # endif
# include <stddef.h>
# endif # if _GL_STDALIGN_NEEDS_STDDEF
# include <stddef.h>
# endif # endif
#endif]) #endif])
]) ])
@ -175,9 +184,17 @@ AC_DEFUN([gl_ALIGNASOF],
AC_DEFUN([gl_STDALIGN_H], AC_DEFUN([gl_STDALIGN_H],
[ [
AC_REQUIRE([gl_ALIGNASOF]) AC_REQUIRE([gl_ALIGNASOF])
GL_GENERATE_STDALIGN_H=false if test "$gl_cv_header_working_stdalign_h" = no; then
AS_IF([test "$gl_cv_header_working_stdalign_h" = no], GL_GENERATE_STDALIGN_H=true
[GL_GENERATE_STDALIGN_H=true]) else
GL_GENERATE_STDALIGN_H=false
fi
AC_CHECK_HEADERS_ONCE([stdalign.h]) gl_CHECK_NEXT_HEADERS([stdalign.h])
if test $ac_cv_header_stdalign_h = yes; then
HAVE_STDALIGN_H=1
else
HAVE_STDALIGN_H=0
fi
AC_SUBST([HAVE_STDALIGN_H])
]) ])

View file

@ -1,4 +1,4 @@
# stddef_h.m4 serial 12 # stddef_h.m4 serial 13
dnl Copyright (C) 2009-2023 Free Software Foundation, Inc. dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
@ -22,7 +22,14 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
[gl_cv_type_max_align_t], [gl_cv_type_max_align_t],
[AC_COMPILE_IFELSE( [AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#include <stddef.h> [[/* On FreeBSD 12.0/x86, max_align_t defined by <stddef.h> has
the correct alignment with the default (wrong) definition of
_Alignof, but a wrong alignment as soon as we activate an
ISO C compliant _Alignof definition. */
#if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus
#define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
#endif
#include <stddef.h>
unsigned int s = sizeof (max_align_t); unsigned int s = sizeof (max_align_t);
#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1]; int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];