mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-08 17:22:05 +03:00
alignasof: new module
This splits off support for the C23 keywords alignas and alignof, from the now-deprecated stdalign module. The latter now merely provides C11 support. * MODULES.html.sh, NEWS, doc/gnulib.texi: * doc/posix-headers/stdalign.texi: Document the change. * lib/stdalign.in.h: Remove most of the definitions (which are now supplied by the alignasof module), leaving only __alignas_is_defined and __alignof_is_defined. * modules/alignasof, modules/alignasof-tests: New files. * m4/stdalign.m4 (gl_ALIGNASOF): New macro, with most of the contents of the old gl_STDALIGN_H. Do not define __alignas_is_defined or __alignof_is_defined. (gl_STDALIGN_H): Rely on gl_ALIGNASOF for most of the work. * modules/alignalloc, modules/alignof, modules/argp: * modules/crypto/md4-buffer, modules/crypto/md5-buffer: * modules/crypto/sha1-buffer, modules/crypto/sha256-buffer: * modules/crypto/sha512-buffer, modules/crypto/sm3-buffer: * modules/fts, modules/rawmemchr, modules/relocatable-prog-wrapper: * modules/stddef-tests, modules/sys_socket: Depend on alignasof, not stdalign. * modules/stdalign: Deprecate. Depend on alignasof. * modules/stdalign-tests: Move most contents to the new module alignasof-tests, and depend on that.
This commit is contained in:
27
ChangeLog
27
ChangeLog
@@ -1,3 +1,30 @@
|
|||||||
|
2023-01-15 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
alignasof: new module
|
||||||
|
This splits off support for the C23 keywords alignas and alignof,
|
||||||
|
from the now-deprecated stdalign module. The latter now merely
|
||||||
|
provides C11 support.
|
||||||
|
* MODULES.html.sh, NEWS, doc/gnulib.texi:
|
||||||
|
* doc/posix-headers/stdalign.texi: Document the change.
|
||||||
|
* lib/stdalign.in.h: Remove most of the definitions (which are now
|
||||||
|
supplied by the alignasof module), leaving only
|
||||||
|
__alignas_is_defined and __alignof_is_defined.
|
||||||
|
* modules/alignasof, modules/alignasof-tests: New files.
|
||||||
|
* m4/stdalign.m4 (gl_ALIGNASOF): New macro, with
|
||||||
|
most of the contents of the old gl_STDALIGN_H.
|
||||||
|
Do not define __alignas_is_defined or __alignof_is_defined.
|
||||||
|
(gl_STDALIGN_H): Rely on gl_ALIGNASOF for most of the work.
|
||||||
|
* modules/alignalloc, modules/alignof, modules/argp:
|
||||||
|
* modules/crypto/md4-buffer, modules/crypto/md5-buffer:
|
||||||
|
* modules/crypto/sha1-buffer, modules/crypto/sha256-buffer:
|
||||||
|
* modules/crypto/sha512-buffer, modules/crypto/sm3-buffer:
|
||||||
|
* modules/fts, modules/rawmemchr, modules/relocatable-prog-wrapper:
|
||||||
|
* modules/stddef-tests, modules/sys_socket:
|
||||||
|
Depend on alignasof, not stdalign.
|
||||||
|
* modules/stdalign: Deprecate. Depend on alignasof.
|
||||||
|
* modules/stdalign-tests: Move most contents to the new module
|
||||||
|
alignasof-tests, and depend on that.
|
||||||
|
|
||||||
2023-01-15 Bruno Haible <bruno@clisp.org>
|
2023-01-15 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
fpending: Fix compilation error with NDK ≥ r14b and Android API < 23.
|
fpending: Fix compilation error with NDK ≥ r14b and Android API < 23.
|
||||||
|
@@ -2383,6 +2383,7 @@ func_all_modules ()
|
|||||||
func_echo "$element"
|
func_echo "$element"
|
||||||
|
|
||||||
func_begin_table
|
func_begin_table
|
||||||
|
func_module alignasof
|
||||||
func_module stdckdint
|
func_module stdckdint
|
||||||
func_end_table
|
func_end_table
|
||||||
|
|
||||||
|
2
NEWS
2
NEWS
@@ -74,6 +74,8 @@ User visible incompatible changes
|
|||||||
|
|
||||||
Date Modules Changes
|
Date Modules Changes
|
||||||
|
|
||||||
|
2023-01-15 stdalign This module is deprecated. Use alignasof instead.
|
||||||
|
|
||||||
2023-01-07 timer_time Link with $(TIMER_TIME_LIB) instead of
|
2023-01-07 timer_time Link with $(TIMER_TIME_LIB) instead of
|
||||||
$(LIB_TIMER_TIME).
|
$(LIB_TIMER_TIME).
|
||||||
|
|
||||||
|
@@ -873,10 +873,10 @@ substituted by Gnulib.
|
|||||||
@node alignof
|
@node alignof
|
||||||
@section @code{alignof} and @code{alignas}
|
@section @code{alignof} and @code{alignas}
|
||||||
|
|
||||||
Gnulib module: stdalign
|
Gnulib module: alignasof
|
||||||
|
|
||||||
The @code{stdalign} module arranges for @code{alignas}, @code{alignof}, and
|
The @code{alignasof} module arranges for @code{alignas} and @code{alignof}
|
||||||
@code{<stdalign.h>} to be more like standard C@. @xref{stdalign.h}.
|
to be more like standard C@.
|
||||||
|
|
||||||
Portability problems fixed by Gnulib:
|
Portability problems fixed by Gnulib:
|
||||||
@itemize
|
@itemize
|
||||||
@@ -886,6 +886,7 @@ Pre-C11 platforms lack @code{alignas} and @code{alignof}.
|
|||||||
@item
|
@item
|
||||||
On pre-C23 platforms, @code{<stdalign.h>} must be included before
|
On pre-C23 platforms, @code{<stdalign.h>} must be included before
|
||||||
using @code{alignas} or @code{alignof}.
|
using @code{alignas} or @code{alignof}.
|
||||||
|
@xref{stdalign.h}.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
Portability problems not fixed by Gnulib:
|
Portability problems not fixed by Gnulib:
|
||||||
|
@@ -1,15 +1,17 @@
|
|||||||
@node stdalign.h
|
@node stdalign.h
|
||||||
@section @file{stdalign.h}
|
@section @file{stdalign.h}
|
||||||
|
|
||||||
POSIX specification:@* Not in POSIX yet, but we expect it will be.
|
POSIX specification:@* Not in POSIX yet, but we expect it will be,
|
||||||
ISO C11 (latest free draft
|
at least temporarily until it becomes obsolete due to its phasing
|
||||||
@url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf})
|
out starting in C23.
|
||||||
|
ISO C23 (latest free draft
|
||||||
|
@url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf})
|
||||||
sections 6.5.3.4, 6.7.5, 7.15.
|
sections 6.5.3.4, 6.7.5, 7.15.
|
||||||
C++11 (latest free draft
|
C++11 (latest free draft
|
||||||
@url{http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf})
|
@url{http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf})
|
||||||
section 18.10.
|
section 18.10.
|
||||||
|
|
||||||
Gnulib module: stdalign
|
Gnulib module: alignasof
|
||||||
|
|
||||||
Portability problems fixed by Gnulib:
|
Portability problems fixed by Gnulib:
|
||||||
@itemize
|
@itemize
|
||||||
@@ -17,6 +19,10 @@ Portability problems fixed by Gnulib:
|
|||||||
On older C platforms @code{<stdalign.h>} must be included before using
|
On older C platforms @code{<stdalign.h>} must be included before using
|
||||||
@code{alignas} or @code{alignof}. For example, GCC versions before 13 do not
|
@code{alignas} or @code{alignof}. For example, GCC versions before 13 do not
|
||||||
support these keywords, which were standardized by C23.
|
support these keywords, which were standardized by C23.
|
||||||
|
On C23 and later platforms, @code{<stdalign.h>} has no effect and need
|
||||||
|
not be included. (Gnulib-using code should not include
|
||||||
|
@code{<stdalign.h>} without also employing Gnulib's now-deprecated
|
||||||
|
@code{stdalign} module.)
|
||||||
@item
|
@item
|
||||||
This header file is missing on many platforms:
|
This header file is missing on many platforms:
|
||||||
FreeBSD 6.4, NetBSD 7.1, OpenBSD 6.7, Minix 3.3.0, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, mingw, MSVC 14, Android 9.0.
|
FreeBSD 6.4, NetBSD 7.1, OpenBSD 6.7, Minix 3.3.0, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.3, mingw, MSVC 14, Android 9.0.
|
||||||
@@ -30,6 +36,15 @@ Older C platforms might not support the obsolescent
|
|||||||
@code{_Alignas} and @code{_Alignof} keywords or macros.
|
@code{_Alignas} and @code{_Alignof} keywords or macros.
|
||||||
This portability problem should not matter with code using this module,
|
This portability problem should not matter with code using this module,
|
||||||
as such code should use @code{alignas} and @code{alignof} instead.
|
as such code should use @code{alignas} and @code{alignof} instead.
|
||||||
|
@item
|
||||||
|
In C11 and C17, @code{<stdalign.h>} defines the macros
|
||||||
|
@code{__alignas_is_defined} and
|
||||||
|
@code{__alignof_is_defined} to 1.
|
||||||
|
In C23, these macros are not defined.
|
||||||
|
This portability problem should not matter with code using Gnulib's
|
||||||
|
@code{alignasof} module, as such code should use @code{alignas} and
|
||||||
|
@code{alignof} without checking these two macros. (Gnulib's
|
||||||
|
now-deprecated @code{stdalign} module defines these two macros.)
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
Portability problems not fixed by Gnulib:
|
Portability problems not fixed by Gnulib:
|
||||||
@@ -66,14 +81,6 @@ external variables that are declared close together with
|
|||||||
@code{alignas}. The bug is fixed in Sun C 5.15, also known as Oracle
|
@code{alignas}. The bug is fixed in Sun C 5.15, also known as Oracle
|
||||||
Developer Studio 12.6 (2017).
|
Developer Studio 12.6 (2017).
|
||||||
@item
|
@item
|
||||||
@code{<stdalign.h>} must be #included before @code{_Alignas} and
|
|
||||||
@code{_Alignof} can be used.
|
|
||||||
@item
|
|
||||||
In C11 and C17, @code{<stdalign.h>} defines the macros
|
|
||||||
@code{__alignas_is_defined} and
|
|
||||||
@code{__alignof_is_defined} to 1.
|
|
||||||
In C23, these macros are not defined.
|
|
||||||
@item
|
|
||||||
You cannot assume that @code{alignas} and @code{alignof} are reserved words;
|
You cannot assume that @code{alignas} and @code{alignof} are reserved words;
|
||||||
they might be macros.
|
they might be macros.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
@@ -17,117 +17,18 @@
|
|||||||
|
|
||||||
/* Written by Paul Eggert and Bruno Haible. */
|
/* Written by Paul Eggert and Bruno Haible. */
|
||||||
|
|
||||||
|
/* Define two obsolescent C11 macros, assuming alignas and alignof are
|
||||||
|
either keywords or alignasof-defined macros. */
|
||||||
|
|
||||||
#ifndef _GL_STDALIGN_H
|
#ifndef _GL_STDALIGN_H
|
||||||
#define _GL_STDALIGN_H
|
#define _GL_STDALIGN_H
|
||||||
|
|
||||||
/* ISO C11 <stdalign.h> for platforms that lack it.
|
|
||||||
|
|
||||||
References:
|
|
||||||
ISO C11 (latest free draft
|
|
||||||
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
|
|
||||||
sections 6.5.3.4, 6.7.5, 7.15.
|
|
||||||
C++11 (latest free draft
|
|
||||||
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
|
|
||||||
section 18.10. */
|
|
||||||
|
|
||||||
/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
|
|
||||||
requirement of a structure member (i.e., slot or field) that is of
|
|
||||||
type TYPE, as an integer constant expression.
|
|
||||||
|
|
||||||
This differs from GCC's and clang's __alignof__ operator, which can
|
|
||||||
yield a better-performing alignment for an object of that type. For
|
|
||||||
example, on x86 with GCC and on Linux/x86 with clang,
|
|
||||||
__alignof__ (double) and __alignof__ (long long) are 8, whereas
|
|
||||||
alignof (double) and alignof (long long) are 4 unless the option
|
|
||||||
'-malign-double' is used.
|
|
||||||
|
|
||||||
The result cannot be used as a value for an 'enum' constant, if you
|
|
||||||
want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
|
|
||||||
|
|
||||||
/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
|
|
||||||
standard headers, defines conflicting implementations of _Alignas
|
|
||||||
and _Alignof that are no better than ours; override them. */
|
|
||||||
#undef _Alignas
|
|
||||||
#undef _Alignof
|
|
||||||
|
|
||||||
/* 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>.
|
|
||||||
clang versions < 8.0.0 have the same bug. */
|
|
||||||
#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
|
|
||||||
|| (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
|
|
||||||
&& !defined __clang__) \
|
|
||||||
|| (defined __clang__ && __clang_major__ < 8))
|
|
||||||
# ifdef __cplusplus
|
|
||||||
# if (201103 <= __cplusplus || defined _MSC_VER)
|
|
||||||
# define _Alignof(type) alignof (type)
|
|
||||||
# else
|
|
||||||
template <class __t> struct __alignof_helper { char __a; __t __b; };
|
|
||||||
# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
|
|
||||||
# define _GL_STDALIGN_NEEDS_STDDEF 1
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
|
|
||||||
# define _GL_STDALIGN_NEEDS_STDDEF 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
|
|
||||||
# define alignof _Alignof
|
|
||||||
#endif
|
|
||||||
#define __alignof_is_defined 1
|
|
||||||
|
|
||||||
/* alignas (A), also known as _Alignas (A), aligns a variable or type
|
|
||||||
to the alignment A, where A is an integer constant expression. For
|
|
||||||
example:
|
|
||||||
|
|
||||||
int alignas (8) foo;
|
|
||||||
struct s { int a; int alignas (8) bar; };
|
|
||||||
|
|
||||||
aligns the address of FOO and the offset of BAR to be multiples of 8.
|
|
||||||
|
|
||||||
A should be a power of two that is at least the type's alignment
|
|
||||||
and at most the implementation's alignment limit. This limit is
|
|
||||||
2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
|
|
||||||
to MSVC through at least version 10.0, A should be an integer
|
|
||||||
constant, as MSVC does not support expressions such as 1 << 3.
|
|
||||||
To be portable to Sun C 5.11, do not align auto variables to
|
|
||||||
anything stricter than their default alignment.
|
|
||||||
|
|
||||||
The following C11 requirements are not supported here:
|
|
||||||
|
|
||||||
- If A is zero, alignas has no effect.
|
|
||||||
- alignas can be used multiple times; the strictest one wins.
|
|
||||||
- alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
|
|
||||||
# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
|
|
||||||
# define _Alignas(a) alignas (a)
|
|
||||||
# elif (!defined __attribute__ \
|
|
||||||
&& ((defined __APPLE__ && defined __MACH__ \
|
|
||||||
? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
|
|
||||||
: __GNUC__ && !defined __ibmxl__) \
|
|
||||||
|| (4 <= __clang_major__) \
|
|
||||||
|| (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
|
|
||||||
|| __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
|
|
||||||
# define _Alignas(a) __attribute__ ((__aligned__ (a)))
|
|
||||||
# elif 1300 <= _MSC_VER
|
|
||||||
# define _Alignas(a) __declspec (align (a))
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if ((defined _Alignas \
|
|
||||||
&& !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
|
|
||||||
|| (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
|
|
||||||
# define alignas _Alignas
|
|
||||||
#endif
|
|
||||||
#if (defined alignas \
|
#if (defined alignas \
|
||||||
|
|| (defined __STDC_VERSION__ && 202311 <= __STDC_VERSION__) \
|
||||||
|| (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
|
|| (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
|
||||||
# define __alignas_is_defined 1
|
# define __alignas_is_defined 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Include <stddef.h> if needed for offsetof. */
|
#define __alignof_is_defined 1
|
||||||
#if _GL_STDALIGN_NEEDS_STDDEF
|
|
||||||
# include <stddef.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _GL_STDALIGN_H */
|
#endif /* _GL_STDALIGN_H */
|
||||||
|
@@ -5,9 +5,11 @@ 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,
|
||||||
dnl with or without modifications, as long as this notice is preserved.
|
dnl with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
dnl Written by Paul Eggert and Bruno Haible.
|
||||||
|
|
||||||
# Prepare for substituting <stdalign.h> if it is not supported.
|
# Prepare for substituting <stdalign.h> if it is not supported.
|
||||||
|
|
||||||
AC_DEFUN([gl_STDALIGN_H],
|
AC_DEFUN([gl_ALIGNASOF],
|
||||||
[
|
[
|
||||||
AC_CACHE_CHECK([for alignas and alignof],
|
AC_CACHE_CHECK([for alignas and alignof],
|
||||||
[gl_cv_header_working_stdalign_h],
|
[gl_cv_header_working_stdalign_h],
|
||||||
@@ -58,16 +60,11 @@ AC_DEFUN([gl_STDALIGN_H],
|
|||||||
test "$gl_cv_header_working_stdalign_h" != no && break
|
test "$gl_cv_header_working_stdalign_h" != no && break
|
||||||
done])
|
done])
|
||||||
|
|
||||||
GL_GENERATE_STDALIGN_H=false
|
|
||||||
AS_CASE([$gl_cv_header_working_stdalign_h],
|
AS_CASE([$gl_cv_header_working_stdalign_h],
|
||||||
[no],
|
|
||||||
[GL_GENERATE_STDALIGN_H=true],
|
|
||||||
[yes*keyword*],
|
[yes*keyword*],
|
||||||
[AC_DEFINE([HAVE_C_ALIGNASOF], [1],
|
[AC_DEFINE([HAVE_C_ALIGNASOF], [1],
|
||||||
[Define to 1 if the alignas and alignof keywords work.])])
|
[Define to 1 if the alignas and alignof keywords work.])])
|
||||||
|
|
||||||
AC_CHECK_HEADERS_ONCE([stdalign.h])
|
|
||||||
|
|
||||||
dnl The "zz" puts this toward config.h's end, to avoid potential
|
dnl The "zz" puts this toward config.h's end, to avoid potential
|
||||||
dnl collisions with other definitions.
|
dnl collisions with other definitions.
|
||||||
AH_VERBATIM([zzalignas],
|
AH_VERBATIM([zzalignas],
|
||||||
@@ -75,11 +72,33 @@ AC_DEFUN([gl_STDALIGN_H],
|
|||||||
# if HAVE_STDALIGN_H
|
# if HAVE_STDALIGN_H
|
||||||
# include <stdalign.h>
|
# include <stdalign.h>
|
||||||
# else
|
# else
|
||||||
/* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */
|
/* ISO C23 alignas and alignof for platforms that lack it.
|
||||||
# ifndef _GL_STDALIGN_H
|
|
||||||
# define _GL_STDALIGN_H
|
References:
|
||||||
# undef _Alignas
|
ISO C23 (latest free draft
|
||||||
# undef _Alignof
|
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf>)
|
||||||
|
sections 6.5.3.4, 6.7.5, 7.15.
|
||||||
|
C++11 (latest free draft
|
||||||
|
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
|
||||||
|
section 18.10. */
|
||||||
|
|
||||||
|
/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
|
||||||
|
requirement of a structure member (i.e., slot or field) that is of
|
||||||
|
type TYPE, as an integer constant expression.
|
||||||
|
|
||||||
|
This differs from GCC's and clang's __alignof__ operator, which can
|
||||||
|
yield a better-performing alignment for an object of that type. For
|
||||||
|
example, on x86 with GCC and on Linux/x86 with clang,
|
||||||
|
__alignof__ (double) and __alignof__ (long long) are 8, whereas
|
||||||
|
alignof (double) and alignof (long long) are 4 unless the option
|
||||||
|
'-malign-double' is used.
|
||||||
|
|
||||||
|
The result cannot be used as a value for an 'enum' constant, if you
|
||||||
|
want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
|
||||||
|
|
||||||
|
/* 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>.
|
||||||
|
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__) \
|
||||||
@@ -100,7 +119,31 @@ AC_DEFUN([gl_STDALIGN_H],
|
|||||||
# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
|
# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
|
||||||
# define alignof _Alignof
|
# define alignof _Alignof
|
||||||
# endif
|
# endif
|
||||||
# define __alignof_is_defined 1
|
|
||||||
|
/* alignas (A), also known as _Alignas (A), aligns a variable or type
|
||||||
|
to the alignment A, where A is an integer constant expression. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
int alignas (8) foo;
|
||||||
|
struct s { int a; int alignas (8) bar; };
|
||||||
|
|
||||||
|
aligns the address of FOO and the offset of BAR to be multiples of 8.
|
||||||
|
|
||||||
|
A should be a power of two that is at least the type's alignment
|
||||||
|
and at most the implementation's alignment limit. This limit is
|
||||||
|
2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
|
||||||
|
to MSVC through at least version 10.0, A should be an integer
|
||||||
|
constant, as MSVC does not support expressions such as 1 << 3.
|
||||||
|
To be portable to Sun C 5.11, do not align auto variables to
|
||||||
|
anything stricter than their default alignment.
|
||||||
|
|
||||||
|
The following C23 requirements are not supported here:
|
||||||
|
|
||||||
|
- If A is zero, alignas has no effect.
|
||||||
|
- alignas can be used multiple times; the strictest one wins.
|
||||||
|
- alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
|
||||||
|
|
||||||
|
*/
|
||||||
# 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)
|
||||||
@@ -117,18 +160,24 @@ AC_DEFUN([gl_STDALIGN_H],
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if ((defined _Alignas \
|
# if ((defined _Alignas \
|
||||||
&& !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
|
&& !(defined __cplusplus \
|
||||||
|
&& (201103 <= __cplusplus || defined _MSC_VER))) \
|
||||||
|| (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
|
|| (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
|
||||||
# define alignas _Alignas
|
# define alignas _Alignas
|
||||||
# endif
|
# endif
|
||||||
# if (defined alignas \
|
|
||||||
|| (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
|
|
||||||
# define __alignas_is_defined 1
|
|
||||||
# endif
|
|
||||||
# if _GL_STDALIGN_NEEDS_STDDEF
|
# if _GL_STDALIGN_NEEDS_STDDEF
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# endif
|
# endif
|
||||||
# endif /* _GL_STDALIGN_H */
|
|
||||||
# endif
|
# endif
|
||||||
#endif])
|
#endif])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([gl_STDALIGN_H],
|
||||||
|
[
|
||||||
|
AC_REQUIRE([gl_ALIGNASOF])
|
||||||
|
GL_GENERATE_STDALIGN_H=false
|
||||||
|
AS_IF([test "$gl_cv_header_working_stdalign_h" = no],
|
||||||
|
[GL_GENERATE_STDALIGN_H=true])
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS_ONCE([stdalign.h])
|
||||||
|
])
|
||||||
|
@@ -7,12 +7,12 @@ lib/alignalloc.c
|
|||||||
m4/alignalloc.m4
|
m4/alignalloc.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
assert-h
|
assert-h
|
||||||
extensions
|
extensions
|
||||||
extern-inline
|
extern-inline
|
||||||
idx
|
idx
|
||||||
posix_memalign
|
posix_memalign
|
||||||
stdalign
|
|
||||||
stdckdint
|
stdckdint
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
|
18
modules/alignasof
Normal file
18
modules/alignasof
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
Description:
|
||||||
|
alignas and alignof that are like C23 and C++11.
|
||||||
|
|
||||||
|
Files:
|
||||||
|
m4/stdalign.m4
|
||||||
|
|
||||||
|
configure.ac:
|
||||||
|
gl_ALIGNASOF
|
||||||
|
|
||||||
|
Makefile.am:
|
||||||
|
|
||||||
|
Include:
|
||||||
|
|
||||||
|
License:
|
||||||
|
LGPLv2+
|
||||||
|
|
||||||
|
Maintainer:
|
||||||
|
all
|
13
modules/alignasof-tests
Normal file
13
modules/alignasof-tests
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Files:
|
||||||
|
tests/test-stdalign.c
|
||||||
|
tests/macros.h
|
||||||
|
|
||||||
|
Depends-on:
|
||||||
|
assert-h
|
||||||
|
stdint
|
||||||
|
|
||||||
|
configure.ac:
|
||||||
|
|
||||||
|
Makefile.am:
|
||||||
|
TESTS += test-stdalign
|
||||||
|
check_PROGRAMS += test-stdalign
|
@@ -5,7 +5,7 @@ Files:
|
|||||||
lib/alignof.h
|
lib/alignof.h
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
stdalign
|
alignasof
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ lib/argp-xinl.c
|
|||||||
m4/argp.m4
|
m4/argp.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
alloca
|
alloca
|
||||||
basename-lgpl
|
basename-lgpl
|
||||||
extern-inline
|
extern-inline
|
||||||
@@ -31,7 +32,6 @@ strcase
|
|||||||
extensions
|
extensions
|
||||||
vsnprintf
|
vsnprintf
|
||||||
sleep
|
sleep
|
||||||
stdalign
|
|
||||||
stdbool
|
stdbool
|
||||||
stdio
|
stdio
|
||||||
strerror
|
strerror
|
||||||
|
@@ -7,8 +7,8 @@ lib/md4.c
|
|||||||
m4/md4.m4
|
m4/md4.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -9,10 +9,10 @@ m4/gl-openssl.m4
|
|||||||
m4/md5.m4
|
m4/md5.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
c99
|
c99
|
||||||
extern-inline
|
extern-inline
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -9,10 +9,10 @@ m4/gl-openssl.m4
|
|||||||
m4/sha1.m4
|
m4/sha1.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
c99
|
c99
|
||||||
extern-inline
|
extern-inline
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -9,10 +9,10 @@ m4/gl-openssl.m4
|
|||||||
m4/sha256.m4
|
m4/sha256.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
c99
|
c99
|
||||||
extern-inline
|
extern-inline
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -9,10 +9,10 @@ m4/gl-openssl.m4
|
|||||||
m4/sha512.m4
|
m4/sha512.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
c99
|
c99
|
||||||
extern-inline
|
extern-inline
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
u64
|
u64
|
||||||
|
|
||||||
|
@@ -7,10 +7,10 @@ lib/sm3.c
|
|||||||
m4/sm3.m4
|
m4/sm3.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
byteswap
|
byteswap
|
||||||
c99
|
c99
|
||||||
extern-inline
|
extern-inline
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -8,6 +8,7 @@ lib/fts-cycle.c
|
|||||||
m4/fts.m4
|
m4/fts.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
attribute
|
attribute
|
||||||
c99
|
c99
|
||||||
closedir
|
closedir
|
||||||
@@ -28,7 +29,6 @@ openat-h
|
|||||||
opendir
|
opendir
|
||||||
opendirat
|
opendirat
|
||||||
readdir
|
readdir
|
||||||
stdalign
|
|
||||||
stdbool
|
stdbool
|
||||||
stddef
|
stddef
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@ lib/rawmemchr.valgrind
|
|||||||
m4/rawmemchr.m4
|
m4/rawmemchr.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
assert-h
|
assert-h
|
||||||
extensions
|
extensions
|
||||||
stdalign
|
|
||||||
stdint
|
stdint
|
||||||
string
|
string
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ m4/relocatable-lib.m4
|
|||||||
m4/setenv.m4
|
m4/setenv.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
assert-h
|
assert-h
|
||||||
c99
|
c99
|
||||||
double-slash-root
|
double-slash-root
|
||||||
@@ -64,7 +65,6 @@ largefile
|
|||||||
libc-config
|
libc-config
|
||||||
pathmax
|
pathmax
|
||||||
ssize_t
|
ssize_t
|
||||||
stdalign
|
|
||||||
stdbool
|
stdbool
|
||||||
stddef
|
stddef
|
||||||
stdckdint
|
stdckdint
|
||||||
|
@@ -1,11 +1,16 @@
|
|||||||
Description:
|
Description:
|
||||||
alignas and alignof that are like C23 and C++11.
|
alignas and alignof that are like C23 and C++11.
|
||||||
|
|
||||||
|
Notice:
|
||||||
|
The stdalign module is deprecated.
|
||||||
|
New code should use the alignasof module, and not include <stdalign.h>.
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
lib/stdalign.in.h
|
lib/stdalign.in.h
|
||||||
m4/stdalign.m4
|
m4/stdalign.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
gen-header
|
gen-header
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
@@ -35,4 +40,4 @@ License:
|
|||||||
LGPLv2+
|
LGPLv2+
|
||||||
|
|
||||||
Maintainer:
|
Maintainer:
|
||||||
Paul Eggert
|
all
|
||||||
|
@@ -1,14 +1,9 @@
|
|||||||
Files:
|
Files:
|
||||||
tests/test-stdalign.c
|
|
||||||
tests/macros.h
|
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
assert-h
|
alignasof-tests
|
||||||
stdint
|
|
||||||
stdalign-c++-tests
|
stdalign-c++-tests
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
|
||||||
Makefile.am:
|
Makefile.am:
|
||||||
TESTS += test-stdalign
|
|
||||||
check_PROGRAMS += test-stdalign
|
|
||||||
|
@@ -2,8 +2,8 @@ Files:
|
|||||||
tests/test-stddef.c
|
tests/test-stddef.c
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasof
|
||||||
assert-h
|
assert-h
|
||||||
stdalign
|
|
||||||
stddef-c++-tests
|
stddef-c++-tests
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
@@ -8,6 +8,7 @@ m4/sys_socket_h.m4
|
|||||||
m4/sockpfaf.m4
|
m4/sockpfaf.m4
|
||||||
|
|
||||||
Depends-on:
|
Depends-on:
|
||||||
|
alignasf
|
||||||
errno
|
errno
|
||||||
extern-inline
|
extern-inline
|
||||||
gen-header
|
gen-header
|
||||||
@@ -17,7 +18,6 @@ snippet/c++defs
|
|||||||
snippet/warn-on-use
|
snippet/warn-on-use
|
||||||
socklen
|
socklen
|
||||||
ssize_t
|
ssize_t
|
||||||
stdalign
|
|
||||||
sys_uio
|
sys_uio
|
||||||
|
|
||||||
configure.ac:
|
configure.ac:
|
||||||
|
Reference in New Issue
Block a user