| 1 | #ifndef UST_CORE_H |
| 2 | #define UST_CORE_H |
| 3 | |
| 4 | #if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) |
| 5 | |
| 6 | /* |
| 7 | * Calculate the offset needed to align the type. |
| 8 | * size_of_type must be non-zero. |
| 9 | */ |
| 10 | static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type) |
| 11 | { |
| 12 | size_t alignment = min(sizeof(void *), size_of_type); |
| 13 | return (alignment - align_drift) & (alignment - 1); |
| 14 | } |
| 15 | /* Default arch alignment */ |
| 16 | #define LTT_ALIGN |
| 17 | |
| 18 | static inline int ltt_get_alignment(void) |
| 19 | { |
| 20 | return sizeof(void *); |
| 21 | } |
| 22 | |
| 23 | #else |
| 24 | |
| 25 | static inline unsigned int ltt_align(size_t align_drift, |
| 26 | size_t size_of_type) |
| 27 | { |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | #define LTT_ALIGN __attribute__((packed)) |
| 32 | |
| 33 | static inline int ltt_get_alignment(void) |
| 34 | { |
| 35 | return 0; |
| 36 | } |
| 37 | #endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */ |
| 38 | |
| 39 | #endif /* UST_CORE_H */ |