From: Pavel Pisa Date: Sun, 14 Sep 2014 00:04:32 +0000 (+0200) Subject: Define UL_ALIGNOF macro to allow adjustments for different compilers. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/ulut.git/commitdiff_plain/d3e61309db4cef685f5c5675c26442d3b3ee84a6 Define UL_ALIGNOF macro to allow adjustments for different compilers. Signed-off-by: Pavel Pisa --- diff --git a/ulut/ul_utdefs.h b/ulut/ul_utdefs.h index 7cd38a7..a85614e 100644 --- a/ulut/ul_utdefs.h +++ b/ulut/ul_utdefs.h @@ -66,6 +66,14 @@ extern "C" { #endif /*__GNUC__*/ #endif /*UL_CONTAINEROF*/ +#ifndef UL_ALIGNOF +#ifdef __GNUC__ +#define UL_ALIGNOF(_type) __alignof__(_type) +#else /*__GNUC__*/ +#define UL_ALIGNOF(_type) UL_OFFSETOF(struct {char _fld0; _type _fld1;}, _fld1) +#endif /*__GNUC__*/ +#endif /*UL_ALIGNOF*/ + #ifndef UL_NOPSTATEMENT #define UL_NOPSTATEMENT do { } while(0) #endif