Loading...
Note: File does not exist in v4.6.
1/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2/*
3 * NOLIBC compiler support header
4 * Copyright (C) 2023 Thomas Weißschuh <linux@weissschuh.net>
5 */
6#ifndef _NOLIBC_COMPILER_H
7#define _NOLIBC_COMPILER_H
8
9#if defined(__has_attribute)
10# define __nolibc_has_attribute(attr) __has_attribute(attr)
11#else
12# define __nolibc_has_attribute(attr) 0
13#endif
14
15#if __nolibc_has_attribute(naked)
16# define __nolibc_entrypoint __attribute__((naked))
17# define __nolibc_entrypoint_epilogue()
18#else
19# define __nolibc_entrypoint __attribute__((optimize("Os", "omit-frame-pointer")))
20# define __nolibc_entrypoint_epilogue() __builtin_unreachable()
21#endif /* __nolibc_has_attribute(naked) */
22
23#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)
24
25#define _NOLIBC_STACKPROTECTOR
26
27#endif /* defined(__SSP__) ... */
28
29#if __nolibc_has_attribute(no_stack_protector)
30# define __no_stack_protector __attribute__((no_stack_protector))
31#else
32# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
33#endif /* __nolibc_has_attribute(no_stack_protector) */
34
35#if __nolibc_has_attribute(fallthrough)
36# define __nolibc_fallthrough do { } while (0); __attribute__((fallthrough))
37#else
38# define __nolibc_fallthrough do { } while (0)
39#endif /* __nolibc_has_attribute(fallthrough) */
40
41#endif /* _NOLIBC_COMPILER_H */