[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] flexmember: new macro FLEXALIGNOF
From: |
Paul Eggert |
Subject: |
[PATCH] flexmember: new macro FLEXALIGNOF |
Date: |
Wed, 7 Sep 2016 16:44:47 -0700 |
* lib/flexmember.h: Include <stddef.h>, for offsetof.
(FLEXALIGNOF): Rename from _GL_XALLOC_ALIGNOF, as Emacs can use
this macro. Update comments.
---
ChangeLog | 7 +++++++
lib/flexmember.h | 15 +++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1786c81..3c65fde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-09-07 Paul Eggert <address@hidden>
+
+ flexmember: new macro FLEXALIGNOF
+ * lib/flexmember.h: Include <stddef.h>, for offsetof.
+ (FLEXALIGNOF): Rename from _GL_XALLOC_ALIGNOF, as Emacs can use
+ this macro. Update comments.
+
2016-09-07 Jim Meyering <address@hidden>
getprogname: port to systems with __argv (mingw, msvc)
diff --git a/lib/flexmember.h b/lib/flexmember.h
index 00b084c..62c556b 100644
--- a/lib/flexmember.h
+++ b/lib/flexmember.h
@@ -17,23 +17,26 @@
Written by Paul Eggert. */
+#include <stddef.h>
+
/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
On older platforms without _Alignof, use a pessimistic bound that is
safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
On newer platforms, use _Alignof to get a tighter bound. */
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
-# define _GL_XALLOC_ALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
+# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
#else
-# define _GL_XALLOC_ALIGNOF(type) _Alignof (type)
+# define FLEXALIGNOF(type) _Alignof (type)
#endif
/* Upper bound on the size of a struct of type TYPE with a flexible
array member named MEMBER that is followed by N bytes of other data.
This is not simply sizeof (TYPE) + N, since it may require
- alignment and FLEXIBLE_ARRAY_MEMBER may be 1. Yield a value less
- than N if and only if arithmetic overflow occurs. */
+ alignment on unusually picky C11 platforms, and
+ FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms.
+ Yield a value less than N if and only if arithmetic overflow occurs. */
#define FLEXSIZEOF(type, member, n) \
- ((offsetof (type, member) + _GL_XALLOC_ALIGNOF (type) - 1 + (n)) \
- & ~ (_GL_XALLOC_ALIGNOF (type) - 1))
+ ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
+ & ~ (FLEXALIGNOF (type) - 1))
--
2.7.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] flexmember: new macro FLEXALIGNOF,
Paul Eggert <=