PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches

Defines. More...

Collaboration diagram for Defines:

Detailed Description

Defines.

Macros

#define ALIGNED(alignment)   __attribute__((aligned(alignment)))
 GCC aligned attribute.
 
#define PACKED   __attribute__((packed))
 GCC packed attribute.
 
#define NORETURN   __attribute__((noreturn))
 GCC noreturn function attribute.
 
#define NOINLINE   __attribute__((noinline))
 GCC noinline function attribute.
 
#define CONST_FUNC   __attribute__((const))
 GCC const function attribute.
 
#define PURE   __attribute__((pure))
 GCC.
 
#define CONCAT(a, b)   CONCAT_INNER(a, b)
 Concatenates two tokens.
 
#define CONCAT_INNER(a, b)   a##b
 
#define RED_ZONE_SIZE   128
 The size of the red zone in bytes.
 
#define UNUSED(x)   (void)(x)
 Mark a variable as unused.
 
#define UNUSED_FUNC   __attribute__((unused))
 GCC unused function attribute.
 
#define ARRAY_SIZE(x)   ((size_t)(sizeof(x) / sizeof((x)[0])))
 Get the number of elements in a static array.
 
#define LIKELY(x)   __builtin_expect(!!(x), 1)
 Mark a condition as likely.
 
#define UNLIKELY(x)   __builtin_expect(!!(x), 0)
 Mark a condition as unlikely.
 
#define CONSTRUCTOR(priority)   __attribute__((used, constructor(priority)))
 GCC constructor function attribute.
 
#define DESTRUCTOR(priority)   __attribute__((used, destructor(priority)))
 GCC destructor function attribute.
 
#define ASM(...)   __asm__ volatile(__VA_ARGS__)
 Inline assembly macro.
 

Macro Definition Documentation

◆ ALIGNED

#define ALIGNED (   alignment)    __attribute__((aligned(alignment)))

GCC aligned attribute.

Tells the compiler to align a variable or structure field to the specified byte alignment.

Usefull for caching or hardware requirements.

Definition at line 23 of file defs.h.

◆ PACKED

#define PACKED   __attribute__((packed))

GCC packed attribute.

Tells the compiler to pack a structure, meaning there will be no padding between members.

Needed for most hardware structures.

Definition at line 33 of file defs.h.

◆ NORETURN

#define NORETURN   __attribute__((noreturn))

GCC noreturn function attribute.

Tells the compiler that the fuction with said attribute will never return.

Definition at line 40 of file defs.h.

◆ NOINLINE

#define NOINLINE   __attribute__((noinline))

GCC noinline function attribute.

Tells the compiler to never inline the function with said attribute.

Definition at line 48 of file defs.h.

◆ CONST_FUNC

#define CONST_FUNC   __attribute__((const))

GCC const function attribute.

Tells the compiler that the fuction with said attribute only depends on the arguments passed to it, and will never access global variables.

Definition at line 57 of file defs.h.

◆ PURE

#define PURE   __attribute__((pure))

GCC.

The PURE attribute tells gcc that the function with said attribute only depends on the arguments passed to it and potentially global variables.

Definition at line 66 of file defs.h.

◆ CONCAT

#define CONCAT (   a,
 
)    CONCAT_INNER(a, b)

Concatenates two tokens.

This macro concatenates two tokens a and b into a single token.

Parameters
aThe first token.
bThe second token.
Returns
The concatenated token.

Definition at line 77 of file defs.h.

◆ CONCAT_INNER

#define CONCAT_INNER (   a,
 
)    a##b

Definition at line 78 of file defs.h.

◆ RED_ZONE_SIZE

#define RED_ZONE_SIZE   128

The size of the red zone in bytes.

The red zone is a region of memory below the stack pointer that is reserved and should not be modified by interrupt handlers or signal handlers. The compiler uses this area for temporary storage for the purpose of optimization.

Definition at line 87 of file defs.h.

◆ UNUSED

#define UNUSED (   x)    (void)(x)

Mark a variable as unused.

This macro marks a variable as unused to prevent compiler warnings about unused variables.

Parameters
xThe variable to mark as unused.

Definition at line 96 of file defs.h.

◆ UNUSED_FUNC

#define UNUSED_FUNC   __attribute__((unused))

GCC unused function attribute.

Tells the compiler that the function with said attribute might be unused, preventing warnings.

Definition at line 103 of file defs.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   x)    ((size_t)(sizeof(x) / sizeof((x)[0])))

Get the number of elements in a static array.

Parameters
xThe array.
Returns
The number of elements in the array.

Definition at line 111 of file defs.h.

◆ LIKELY

#define LIKELY (   x)    __builtin_expect(!!(x), 1)

Mark a condition as likely.

This macro marks a condition as likely to help the compiler optimize branch prediction.

Parameters
xThe condition.

Definition at line 120 of file defs.h.

◆ UNLIKELY

#define UNLIKELY (   x)    __builtin_expect(!!(x), 0)

Mark a condition as unlikely.

This macro marks a condition as unlikely to help the compiler optimize branch prediction.

Parameters
xThe condition.

Definition at line 129 of file defs.h.

◆ CONSTRUCTOR

#define CONSTRUCTOR (   priority)    __attribute__((used, constructor(priority)))

GCC constructor function attribute.

Will add the function to the .init_array section with the given priority, the function can then be called using INIT_CALL().

Functions with a higher priority number are called last.

Parameters
priorityThe priority of the constructor function.

Definition at line 141 of file defs.h.

◆ DESTRUCTOR

#define DESTRUCTOR (   priority)    __attribute__((used, destructor(priority)))

GCC destructor function attribute.

Will add the function to the .finit_array section with the given priority, the function can then be called using FINIT_CALL().

Functions with a higher priority number are called last.

Parameters
priorityThe priority of the destructor function.

Definition at line 153 of file defs.h.

◆ ASM

#define ASM (   ...)    __asm__ volatile(__VA_ARGS__)

Inline assembly macro.

Parameters
...The assembly code to embed.

Definition at line 160 of file defs.h.