PatchworkOS  c9fea19
A non-POSIX operating system.
Loading...
Searching...
No Matches
defs.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdint.h>
6
7/**
8 * @brief Defines.
9 * @defgroup kernel_defs Kernel Defines
10 * @ingroup kernel
11 *
12 * @{
13 */
14
15/**
16 * @brief GCC aligned attribute.
17 *
18 * Tells the compiler to align a variable or structure field to the specified byte alignment.
19 *
20 * Usefull for caching or hardware requirements.
21 */
22#define ALIGNED(alignment) __attribute__((aligned(alignment)))
23
24/**
25 * @brief GCC packed attribute.
26 *
27 * Tells the compiler to pack a structure, meaning there will be no padding between members.
28 *
29 * Needed for most hardware structures.
30 *
31 */
32#define PACKED __attribute__((packed))
33
34/**
35 * @brief GCC noreturn function attribute.
36 *
37 * Tells the compiler that the fuction with said attribute will never return.
38 */
39#define NORETURN __attribute__((noreturn))
40
41/**
42 * @brief GCC noinline function attribute.
43 *
44 * Tells the compiler to never inline the function with said attribute.
45 *
46 */
47#define NOINLINE __attribute__((noinline))
48
49/**
50 * @brief GCC const function attribute.
51 *
52 * Tells the compiler that the fuction with said attribute only depends on the arguments passed to it, and will never
53 * access global variables.
54 *
55 */
56#define CONST_FUNC __attribute__((const))
57
58/**
59 * @brief GCC
60 *
61 * The `PURE` attribute tells gcc that the function with said attribute only depends on the arguments passed to it
62 * and potentially global variables.
63 *
64 */
65#define PURE __attribute__((pure))
66
67/**
68 * @brief Concatenates two tokens.
69 *
70 * This macro concatenates two tokens `a` and `b` into a single token.
71 *
72 * @param a The first token.
73 * @param b The second token.
74 * @return The concatenated token.
75 */
76#define CONCAT(a, b) CONCAT_INNER(a, b)
77
78/**
79 * @brief Inner helper macro for token concatenation.
80 */
81#define CONCAT_INNER(a, b) a##b
82
83/**
84 * @brief The size of the red zone in bytes.
85 *
86 * The red zone is a region of memory below the stack pointer that is reserved and should not be modified by
87 * interrupt handlers or signal handlers. The compiler uses this area for temporary storage for the purpose of
88 * optimization.
89 */
90#define RED_ZONE_SIZE 128
91
92/** @} */