18#ifndef __L4_COMPILER_H__
19#define __L4_COMPILER_H__
21#if !defined(__ASSEMBLY__) && !defined(__ASSEMBLER__)
37# define L4_INLINE_STATIC static __inline__
38# define L4_INLINE_EXTERN extern __inline__
39# ifdef __GNUC_STDC_INLINE__
40# define L4_INLINE L4_INLINE_STATIC
42# define L4_INLINE L4_INLINE_EXTERN
45# define L4_INLINE static
48# define L4_INLINE inline
51# define L4_INLINE inline
59#define L4_ALWAYS_INLINE L4_INLINE __attribute__((__always_inline__))
60#elif defined(__cplusplus)
61#define L4_ALWAYS_INLINE inline __attribute__((__always_inline__))
63#define L4_ALWAYS_INLINE static inline __attribute__((__always_inline__))
67#define L4_DECLARE_CONSTRUCTOR(func, prio) \
68 static inline __attribute__((constructor(prio))) void func ## _ctor_func(void) { func(); }
154# define L4_NOTHROW__A __attribute__((nothrow))
156# ifndef __BEGIN_DECLS
157# define __BEGIN_DECLS
162# define L4_BEGIN_DECLS
164# define L4_DEFAULT_PARAM(x)
166# if __cplusplus >= 201103L
167# define L4_NOTHROW noexcept
169# define L4_NOTHROW throw()
171# define L4_BEGIN_DECLS extern "C" {
172# define L4_END_DECLS }
173# if !defined __BEGIN_DECLS || defined DOXYGEN
174# define __BEGIN_DECLS extern "C" {
176# if !defined __END_DECLS || defined DOXYGEN
177# define __END_DECLS }
179# define L4_DEFAULT_PARAM(x) = x
184#define EXTERN_C DO_NOT_USE_EXTERN_C_ANY_MORE
186#ifndef EXTERN_C_BEGIN
187#define EXTERN_C_BEGIN DO_NOT_USE_EXTERN_C_BEGIN_ANY_MORE__USE_L4_BEGIN_DECLS
190#define EXTERN_C_END DO_NOT_USE_EXTERN_C_END_ANY_MORE__USE_L4_END_DECLS
197#if defined __cplusplus && __cplusplus >= 201402L
198# define L4_CONSTEXPR constexpr
207#define L4_NORETURN __attribute__((noreturn))
209#define L4_PURE __attribute__((pure))
215#define L4_NOINSTRUMENT __attribute__((no_instrument_function))
217# define L4_HIDDEN __attribute__((visibility("hidden")))
219#if !defined L4_EXPORT || defined DOXYGEN
220# define L4_EXPORT __attribute__((visibility("default")))
222#ifndef L4_EXPORT_TYPE
224# define L4_EXPORT_TYPE __attribute__((visibility("default")))
226# define L4_EXPORT_TYPE
229#define L4_STRONG_ALIAS(name, aliasname) L4__STRONG_ALIAS(name, aliasname)
230#define L4_WEAK_ALIAS(name, aliasname) L4__WEAK_ALIAS(name, aliasname)
232#define L4__STRONG_ALIAS(name, aliasname) \
233 extern __typeof (name) aliasname __attribute__ ((alias (#name)));
234#define L4__WEAK_ALIAS(name, aliasname) \
235 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
237#define L4__STRONG_ALIAS(name, aliasname) \
238 extern __typeof (name) aliasname __attribute__ ((alias (#name), copy(name)));
239#define L4__WEAK_ALIAS(name, aliasname) \
240 extern __typeof (name) aliasname __attribute__ ((weak, alias (#name), copy(name)));
250#if defined(__i386__) || defined(__amd64__) || \
251 defined(__arm__) || defined(__aarch64__) || \
252 defined(__mips__) || defined(__riscv) || \
253 defined(__powerpc__) || defined(__sparc__)
254# define L4_STACK_ALIGN __BIGGEST_ALIGNMENT__
256# error Define L4_STACK_ALIGN for this target!
276#if defined(__i386__) || defined(__amd64__)
279 if ((stack & (L4_STACK_ALIGN - 1)) == (L4_STACK_ALIGN -
sizeof(
unsigned long)))
281 return (stack & ~(L4_STACK_ALIGN)) -
sizeof(
unsigned long);
286 return stack & ~(L4_STACK_ALIGN);
292#include <l4/sys/linkage.h>
294#define L4_LIKELY(x) __builtin_expect((x),1)
295#define L4_UNLIKELY(x) __builtin_expect((x),0)
299#define L4_STICKY(x) __attribute__((used)) x
300#define L4_DEPRECATED(s) __attribute__((deprecated(s)))
303# if !defined(__cplusplus)
304# define static_assert _Static_assert
305# elif __cplusplus < 201103L
306# define static_assert(x, y) \
307 extern int l4_static_assert[-(!(x))] __attribute__((unused))
311#define L4_stringify_helper(x) #x
312#define L4_stringify(x) L4_stringify_helper(x)
315#define L4_HAS_BUILTIN(def) __has_builtin(def)
317#define L4_HAS_BUILTIN(def) 0
345 __asm__ __volatile__ (
"" : : :
"memory");
350 __asm__ __volatile__ (
"" : : :
"memory");
355 __asm__ __volatile__ (
"" : : :
"memory");
void l4_wmb(void)
Write memory barrier.
#define L4_INLINE
L4 Inline function attribute.
void l4_barrier(void)
Memory barrier.
void l4_mb(void)
Memory barrier.
unsigned long l4_align_stack_for_direct_fncall(unsigned long stack)
Specify the desired alignment of the stack pointer.
L4_NORETURN void l4_infinite_loop(void)
Infinite loop.
#define L4_NORETURN
Noreturn function attribute.