* lib/obstack.c: Include <stdalign.h>.
(struct fooalign): Remove.
(DEFAULT_ALIGNMENT): Use alignof rather than the old offsetof hack.
* modules/obstack (Depends-on): Add stdalign.
+2014-10-29 Paul Eggert <eggert@cs.ucla.edu>
+
+ obstack: prefer alignof to calculating alignments by hand
+ * lib/obstack.c: Include <stdalign.h>.
+ (struct fooalign): Remove.
+ (DEFAULT_ALIGNMENT): Use alignof rather than the old offsetof hack.
+ * modules/obstack (Depends-on): Add stdalign.
+
2014-10-28 Paul Eggert <eggert@cs.ucla.edu>
obstack: use size_t alignments and check for overflow
#endif
#ifndef _OBSTACK_ELIDE_CODE
+# include <stdalign.h>
# include <stdlib.h>
# include <stdint.h>
long double d;
void *p;
};
-struct fooalign
-{
- char c;
- union fooround u;
-};
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
But in fact it might be less smart and round addresses to as much as
DEFAULT_ROUNDING. So we prepare for it to do that. */
enum
{
- DEFAULT_ALIGNMENT = offsetof (struct fooalign, u),
+ DEFAULT_ALIGNMENT = alignof (union fooround),
DEFAULT_ROUNDING = sizeof (union fooround)
};
Depends-on:
gettext-h
exitfail
+stdalign
stdint
stdlib