1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 3 #ifndef LIBPLDM_COMPILER_H 4 #define LIBPLDM_COMPILER_H 5 6 #define LIBPLDM_SIZEAT(type, member) \ 7 (offsetof(type, member) + sizeof(((type *)NULL)->member)) 8 9 #if defined __has_attribute 10 11 #if __has_attribute(always_inline) 12 #define LIBPLDM_CC_ALWAYS_INLINE __attribute__((always_inline)) static inline 13 #endif 14 15 #if __has_attribute(counted_by) 16 #define LIBPLDM_CC_COUNTED_BY(x) __attribute__((counted_by(x))) 17 #endif 18 19 #if __has_attribute(nonnull) 20 #define LIBPLDM_CC_NONNULL __attribute__((nonnull)) 21 #endif 22 23 #endif 24 25 #ifndef LIBPLDM_CC_ALWAYS_INLINE 26 #define LIBPLDM_CC_ALWAYS_INLINE static inline 27 #endif 28 29 #ifndef LIBPLDM_CC_COUNTED_BY 30 #define LIBPLDM_CC_COUNTED_BY(x) 31 #endif 32 33 #ifndef LIBPLDM_CC_NONNULL 34 #define LIBPLDM_CC_NONNULL 35 #endif 36 37 #endif 38