blob: 0cb167ce33e5282c23d4ef789090fd720d3ab4aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef APOS_COMPILER_ATTRIBUTES_H
#define APOS_COMPILER_ATTRIBUTES_H
/**
* @file attrs.h
* Attribute shorthands.
*/
/**
* Ask the preprocessor if specified attribute is available.
* Currently unused, but I really should use it.
*
* @param x Attribute whose existence should be checked.
* @return Non-zero when available, \c 0 when not available.
* \todo Figure out which attributes are necessary and which are good to have
*/
#if !defined(__has_attribute)
#define __has_attribute(x) 0
#endif
/**
* Place object into section.
*
* @param section Section name to place the object in.
*/
#define __section(section) __attribute__((__section__(section)))
/**
* Inform the compiler that the function uses printf formatting.
*
* @param x Index of the format string.
* @param y Index of variadic arguments.
*/
#define __fmt(x, y) __attribute__((format(__printf__, x, y)))
/** Printf formatting attribute to not confuse doxygen. */
#define __printf __fmt(1, 2)
/**
* Align object.
*
* @param a Value to which object should be aligned.
*/
#define __aligned(a) __attribute__((aligned(a)))
/** Don't inline function. */
#define __noinline __attribute__((noinline))
/** Function should not return. */
#define __noreturn __attribute__((noreturn))
/** Pack structure. */
#define __packed __attribute__((packed))
/** Weak linkage. */
#define __weak __attribute__((weak))
/** Main entry point of kernel proper. */
#define __main __section(".kernel.start") __noinline
/** Entry point of kernel loader. */
#define __init __section(".init.start") __noinline
#endif /* APOS_COMPILER_ATTRIBUTES_H */
|