1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#ifndef __LIBSEL4_MACROS_H 14#define __LIBSEL4_MACROS_H 15 16#include <autoconf.h> 17 18/* 19 * Some compilers attempt to pack enums into the smallest possible type. 20 * For ABI compatibility with the kernel, we need to ensure they remain 21 * the same size as a 'long'. 22 */ 23#define SEL4_FORCE_LONG_ENUM(type) \ 24 _enum_pad_ ## type = (1ULL << ((sizeof(long)*8) - 1)) - 1 25 26#ifndef CONST 27#define CONST __attribute__((__const__)) 28#endif 29 30#ifndef PURE 31#define PURE __attribute__((__pure__)) 32#endif 33 34#define SEL4_OFFSETOF(type, member) __builtin_offsetof(type, member) 35 36#define SEL4_PACKED __attribute__((packed)) 37 38#ifdef CONFIG_LIB_SEL4_INLINE_INVOCATIONS 39#define LIBSEL4_INLINE static inline 40#define LIBSEL4_INLINE_FUNC static inline 41 42#elif defined(CONFIG_LIB_SEL4_PUBLIC_SYMBOLS) 43#define LIBSEL4_INLINE __attribute__((unused)) __attribute__((weak)) 44#define LIBSEL4_INLINE_FUNC __attribute__((unused)) __attribute__((weak)) 45 46#else 47#define LIBSEL4_INLINE __attribute__((noinline)) __attribute__((unused)) __attribute__((weak)) 48#define LIBSEL4_INLINE_FUNC static inline 49#endif 50 51#define SEL4_DEPRECATED(x) __attribute__((deprecated(x))) 52#define SEL4_DEPRECATE_MACRO(x) _Pragma("deprecated") x 53 54#define SEL4_COMPILE_ASSERT(name, expr) typedef int __assert_failed_##name[(expr) ? 1 : -1]; 55#define SEL4_SIZE_SANITY(index, entry, size) SEL4_COMPILE_ASSERT(index##entry##size, index + entry == size) 56#endif 57