Blame lib/flexmember.h

Packit Service fdd496
/* Sizes of structs with flexible array members.
Packit Service fdd496
Packit Service fdd496
   Copyright 2016-2017 Free Software Foundation, Inc.
Packit Service fdd496
Packit Service fdd496
   This program is free software: you can redistribute it and/or modify
Packit Service fdd496
   it under the terms of the GNU General Public License as published by
Packit Service fdd496
   the Free Software Foundation; either version 3 of the License, or
Packit Service fdd496
   (at your option) any later version.
Packit Service fdd496
Packit Service fdd496
   This program is distributed in the hope that it will be useful,
Packit Service fdd496
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fdd496
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service fdd496
   GNU General Public License for more details.
Packit Service fdd496
Packit Service fdd496
   You should have received a copy of the GNU General Public License
Packit Service fdd496
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service fdd496
Packit Service fdd496
   Written by Paul Eggert.  */
Packit Service fdd496
Packit Service fdd496
#include <stddef.h>
Packit Service fdd496
Packit Service fdd496
/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
Packit Service fdd496
   On older platforms without _Alignof, use a pessimistic bound that is
Packit Service fdd496
   safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
Packit Service fdd496
   On newer platforms, use _Alignof to get a tighter bound.  */
Packit Service fdd496
Packit Service fdd496
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
Packit Service fdd496
# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
Packit Service fdd496
#else
Packit Service fdd496
# define FLEXALIGNOF(type) _Alignof (type)
Packit Service fdd496
#endif
Packit Service fdd496
Packit Service fdd496
/* Upper bound on the size of a struct of type TYPE with a flexible
Packit Service fdd496
   array member named MEMBER that is followed by N bytes of other data.
Packit Service fdd496
   This is not simply sizeof (TYPE) + N, since it may require
Packit Service fdd496
   alignment on unusually picky C11 platforms, and
Packit Service fdd496
   FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms.
Packit Service fdd496
   Yield a value less than N if and only if arithmetic overflow occurs.  */
Packit Service fdd496
Packit Service fdd496
#define FLEXSIZEOF(type, member, n) \
Packit Service fdd496
   ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
Packit Service fdd496
    & ~ (FLEXALIGNOF (type) - 1))