chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
struct/buf.3.in: Correct the type of `buf_put' in the synopsis.
[mLib]
/
utils
/
align.h
diff --git
a/utils/align.h
b/utils/align.h
index 196c8a2a662b9fa90d7840b2c20f9f3730604f9c..9d2e65492f7d59469f270454db4c53f9e5e5d01e 100644
(file)
--- a/
utils/align.h
+++ b/
utils/align.h
@@
-32,22
+32,36
@@
extern "C" {
#endif
extern "C" {
#endif
+/*----- Header files ------------------------------------------------------*/
+
+#include <stddef.h>
+
/*----- Data structures ---------------------------------------------------*/
union align {
int i;
long l;
double d;
/*----- Data structures ---------------------------------------------------*/
union align {
int i;
long l;
double d;
+ long double ld;
void *p;
void (*f)(void *);
struct notexist *s;
void *p;
void (*f)(void *);
struct notexist *s;
+#if __STDC_VERSION__ >= 201112
+ max_align_t m;
+#endif
};
/*----- Macros provided ---------------------------------------------------*/
};
/*----- Macros provided ---------------------------------------------------*/
+#if __STDC_VERSION__ >= 201112
+# define ALIGNOF(ty) _Alignof(ty)
+#else
+# define ALIGNOF(ty) (offsetof(struct { unsigned char _x; ty _y; }, _y))
+#endif
+
#define ALIGN(sz) do { \
#define ALIGN(sz) do { \
-
sz += sizeof(union align) - 1;
\
-
sz -= sz % sizeof(union align);
\
+
(sz) += ALIGNOF(union align) - 1;
\
+
(sz) -= (sz)%ALIGNOF(union align);
\
} while (0)
/*----- That's all, folks -------------------------------------------------*/
} while (0)
/*----- That's all, folks -------------------------------------------------*/