alignof.h 440 B

12345678910111213141516171819
  1. #ifndef CCAN_ALIGNOF_H
  2. #define CCAN_ALIGNOF_H
  3. #include "config.h"
  4. /**
  5. * ALIGNOF - get the alignment of a type
  6. * @t: the type to test
  7. *
  8. * This returns a safe alignment for the given type.
  9. */
  10. #if HAVE_ALIGNOF
  11. /* A GCC extension. */
  12. #define ALIGNOF(t) __alignof__(t)
  13. #else
  14. /* Alignment by measuring structure padding. */
  15. #define ALIGNOF(t) ((char *)(&((struct { char c; t _h; } *)0)->_h) - (char *)0)
  16. #endif
  17. #endif /* CCAN_ALIGNOF_H */