Lazuli
Loading...
Searching...
No Matches
compiler.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-only
3 * This file is part of Lazuli.
4 */
5
17#ifndef LAZULI_SYS_COMPILER_H
18#define LAZULI_SYS_COMPILER_H
19
20#ifdef __GNUC__
21
22/*
23 * The following macro functions definitions are an ugly hack to solve an ugly
24 * compiler error: "section type conflict".
25 *
26 * TODO: Try a better way to solve this problem.
27 */
33#define COMPILER_H_STRINGIFY(X) #X
34
40#define COMPILER_H_TOSTRING(X) COMPILER_H_STRINGIFY(X)
41
46#define COMPILER_H_GENERATE_PROGMEM_SECTION_NAME() .progmem.__LINE__
47
51#define NORETURN __attribute__((noreturn))
52
53/*
54 * We force the declaration of different ".progmem" sections by using all these
55 * macro functions to eliminate the "section type conflict" error generated by
56 * the compiler.
57 * When linking, all these sections will be grouped into a unique ".progmem"
58 * section.
59 */
67#define PROGMEM \
68 __attribute__ \
69 ((section(COMPILER_H_TOSTRING(COMPILER_H_GENERATE_PROGMEM_SECTION_NAME()))))
70
84#define NOINIT __attribute__((section(".noinit")))
85
86#else /* __GNUC__ */
87
88#define NORETURN
89#define PROGMEM
90#define NOINIT
91
92#endif/* __GNUC__ */
93
94#endif /* LAZULI_SYS_COMPILER_H */