Blame gl/stdalign.in.h

Packit Service 4684c1
/* A substitute for ISO C11 <stdalign.h>.
Packit Service 4684c1
Packit Service 4684c1
   Copyright 2011-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software; you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 2.1, or (at your option)
Packit Service 4684c1
   any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU Lesser General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU Lesser General Public License
Packit Service 4684c1
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Paul Eggert and Bruno Haible.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef _GL_STDALIGN_H
Packit Service 4684c1
#define _GL_STDALIGN_H
Packit Service 4684c1
Packit Service 4684c1
/* ISO C11 <stdalign.h> for platforms that lack it.
Packit Service 4684c1
Packit Service 4684c1
   References:
Packit Service 4684c1
   ISO C11 (latest free draft
Packit Service 4684c1
   <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
Packit Service 4684c1
   sections 6.5.3.4, 6.7.5, 7.15.
Packit Service 4684c1
   C++11 (latest free draft
Packit Service 4684c1
   <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
Packit Service 4684c1
   section 18.10. */
Packit Service 4684c1
Packit Service 4684c1
/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
Packit Service 4684c1
   requirement of a structure member (i.e., slot or field) that is of
Packit Service 4684c1
   type TYPE, as an integer constant expression.
Packit Service 4684c1
Packit Service 4684c1
   This differs from GCC's __alignof__ operator, which can yield a
Packit Service 4684c1
   better-performing alignment for an object of that type.  For
Packit Service 4684c1
   example, on x86 with GCC, __alignof__ (double) and __alignof__
Packit Service 4684c1
   (long long) are 8, whereas alignof (double) and alignof (long long)
Packit Service 4684c1
   are 4 unless the option '-malign-double' is used.
Packit Service 4684c1
Packit Service 4684c1
   The result cannot be used as a value for an 'enum' constant, if you
Packit Service 4684c1
   want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
Packit Service 4684c1
Packit Service 4684c1
   Include <stddef.h> for offsetof.  */
Packit Service 4684c1
#include <stddef.h>
Packit Service 4684c1
Packit Service 4684c1
/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
Packit Service 4684c1
   standard headers, defines conflicting implementations of _Alignas
Packit Service 4684c1
   and _Alignof that are no better than ours; override them.  */
Packit Service 4684c1
#undef _Alignas
Packit Service 4684c1
#undef _Alignof
Packit Service 4684c1
Packit Service 4684c1
/* GCC releases before GCC 4.9 had a bug in _Alignof.  See GCC bug 52023
Packit Service 4684c1
   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.  */
Packit Service 4684c1
#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
Packit Service 4684c1
     || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9)))
Packit Service 4684c1
# ifdef __cplusplus
Packit Service 4684c1
#  if 201103 <= __cplusplus
Packit Service 4684c1
#   define _Alignof(type) alignof (type)
Packit Service 4684c1
#  else
Packit Service 4684c1
   template <class __t> struct __alignof_helper { char __a; __t __b; };
Packit Service 4684c1
#   define _Alignof(type) offsetof (__alignof_helper<type>, __b)
Packit Service 4684c1
#  endif
Packit Service 4684c1
# else
Packit Service 4684c1
#  define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
Packit Service 4684c1
# endif
Packit Service 4684c1
#endif
Packit Service 4684c1
#if ! (defined __cplusplus && 201103 <= __cplusplus)
Packit Service 4684c1
# define alignof _Alignof
Packit Service 4684c1
#endif
Packit Service 4684c1
#define __alignof_is_defined 1
Packit Service 4684c1
Packit Service 4684c1
/* alignas (A), also known as _Alignas (A), aligns a variable or type
Packit Service 4684c1
   to the alignment A, where A is an integer constant expression.  For
Packit Service 4684c1
   example:
Packit Service 4684c1
Packit Service 4684c1
      int alignas (8) foo;
Packit Service 4684c1
      struct s { int a; int alignas (8) bar; };
Packit Service 4684c1
Packit Service 4684c1
   aligns the address of FOO and the offset of BAR to be multiples of 8.
Packit Service 4684c1
Packit Service 4684c1
   A should be a power of two that is at least the type's alignment
Packit Service 4684c1
   and at most the implementation's alignment limit.  This limit is
Packit Service 4684c1
   2**28 on typical GNUish hosts, and 2**13 on MSVC.  To be portable
Packit Service 4684c1
   to MSVC through at least version 10.0, A should be an integer
Packit Service 4684c1
   constant, as MSVC does not support expressions such as 1 << 3.
Packit Service 4684c1
   To be portable to Sun C 5.11, do not align auto variables to
Packit Service 4684c1
   anything stricter than their default alignment.
Packit Service 4684c1
Packit Service 4684c1
   The following C11 requirements are not supported here:
Packit Service 4684c1
Packit Service 4684c1
     - If A is zero, alignas has no effect.
Packit Service 4684c1
     - alignas can be used multiple times; the strictest one wins.
Packit Service 4684c1
     - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
Packit Service 4684c1
Packit Service 4684c1
   */
Packit Service 4684c1
Packit Service 4684c1
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
Packit Service 4684c1
# if defined __cplusplus && 201103 <= __cplusplus
Packit Service 4684c1
#  define _Alignas(a) alignas (a)
Packit Service 4684c1
# elif ((defined __APPLE__ && defined __MACH__                  \
Packit Service 4684c1
         ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__)                 \
Packit Service 4684c1
         : __GNUC__ && !defined __ibmxl__) \
Packit Service 4684c1
        || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
Packit Service 4684c1
        || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
Packit Service 4684c1
#  define _Alignas(a) __attribute__ ((__aligned__ (a)))
Packit Service 4684c1
# elif 1300 <= _MSC_VER
Packit Service 4684c1
#  define _Alignas(a) __declspec (align (a))
Packit Service 4684c1
# endif
Packit Service 4684c1
#endif
Packit Service 4684c1
#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
Packit Service 4684c1
     || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
Packit Service 4684c1
# define alignas _Alignas
Packit Service 4684c1
#endif
Packit Service 4684c1
#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
Packit Service 4684c1
# define __alignas_is_defined 1
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#endif /* _GL_STDALIGN_H */