]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_LINKAGE_H |
3 | #define _LINUX_LINKAGE_H | |
4 | ||
d1515582 | 5 | #include <linux/compiler_types.h> |
e1b5bb6d | 6 | #include <linux/stringify.h> |
f8ce1faf | 7 | #include <linux/export.h> |
1da177e4 LT |
8 | #include <asm/linkage.h> |
9 | ||
9df62f05 CG |
10 | /* Some toolchains use other characters (e.g. '`') to mark new line in macro */ |
11 | #ifndef ASM_NL | |
12 | #define ASM_NL ; | |
13 | #endif | |
14 | ||
1da177e4 | 15 | #ifdef __cplusplus |
3adc1bea | 16 | #define CPP_ASMLINKAGE extern "C" |
1da177e4 | 17 | #else |
3adc1bea | 18 | #define CPP_ASMLINKAGE |
1da177e4 LT |
19 | #endif |
20 | ||
21 | #ifndef asmlinkage | |
22 | #define asmlinkage CPP_ASMLINKAGE | |
23 | #endif | |
24 | ||
e1b5bb6d | 25 | #ifndef cond_syscall |
f8ce1faf | 26 | #define cond_syscall(x) asm( \ |
00979ce4 MY |
27 | ".weak " __stringify(x) "\n\t" \ |
28 | ".set " __stringify(x) "," \ | |
29 | __stringify(sys_ni_syscall)) | |
e1b5bb6d AV |
30 | #endif |
31 | ||
32 | #ifndef SYSCALL_ALIAS | |
f8ce1faf | 33 | #define SYSCALL_ALIAS(alias, name) asm( \ |
00979ce4 MY |
34 | ".globl " __stringify(alias) "\n\t" \ |
35 | ".set " __stringify(alias) "," \ | |
36 | __stringify(name)) | |
e1b5bb6d AV |
37 | #endif |
38 | ||
75b13483 | 39 | #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) |
7c74df07 | 40 | #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE) |
a7bf0bd5 | 41 | |
d2af12ae TA |
42 | /* |
43 | * For assembly routines. | |
44 | * | |
45 | * Note when using these that you must specify the appropriate | |
46 | * alignment directives yourself | |
47 | */ | |
75b13483 | 48 | #define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw" |
7c74df07 | 49 | #define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw" |
d2af12ae | 50 | |
d10d89ec LT |
51 | /* |
52 | * This is used by architectures to keep arguments on the stack | |
53 | * untouched by the compiler by keeping them live until the end. | |
54 | * The argument stack may be owned by the assembly-language | |
55 | * caller, not the callee, and gcc doesn't always understand | |
56 | * that. | |
57 | * | |
58 | * We have the return value, and a maximum of six arguments. | |
59 | * | |
60 | * This should always be followed by a "return ret" for the | |
61 | * protection to work (ie no more work that the compiler might | |
62 | * end up needing stack temporaries for). | |
63 | */ | |
b0fac023 HC |
64 | /* Assembly files may be compiled with -traditional .. */ |
65 | #ifndef __ASSEMBLY__ | |
54a01510 RM |
66 | #ifndef asmlinkage_protect |
67 | # define asmlinkage_protect(n, ret, args...) do { } while (0) | |
1da177e4 | 68 | #endif |
b0fac023 | 69 | #endif |
1da177e4 LT |
70 | |
71 | #ifndef __ALIGN | |
72 | #define __ALIGN .align 4,0x90 | |
73 | #define __ALIGN_STR ".align 4,0x90" | |
74 | #endif | |
75 | ||
76 | #ifdef __ASSEMBLY__ | |
77 | ||
42f29a25 | 78 | #ifndef LINKER_SCRIPT |
1da177e4 LT |
79 | #define ALIGN __ALIGN |
80 | #define ALIGN_STR __ALIGN_STR | |
81 | ||
ab7efcc9 | 82 | #ifndef ENTRY |
1da177e4 | 83 | #define ENTRY(name) \ |
9df62f05 CG |
84 | .globl name ASM_NL \ |
85 | ALIGN ASM_NL \ | |
86 | name: | |
ab7efcc9 | 87 | #endif |
42f29a25 | 88 | #endif /* LINKER_SCRIPT */ |
1da177e4 | 89 | |
214541d1 RR |
90 | #ifndef WEAK |
91 | #define WEAK(name) \ | |
9df62f05 | 92 | .weak name ASM_NL \ |
214541d1 RR |
93 | name: |
94 | #endif | |
95 | ||
ab7efcc9 JB |
96 | #ifndef END |
97 | #define END(name) \ | |
9df62f05 | 98 | .size name, .-name |
ab7efcc9 JB |
99 | #endif |
100 | ||
6b8be6df JR |
101 | /* If symbol 'name' is treated as a subroutine (gets called, and returns) |
102 | * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of | |
103 | * static analysis tools such as stack depth analyzer. | |
104 | */ | |
ab7efcc9 JB |
105 | #ifndef ENDPROC |
106 | #define ENDPROC(name) \ | |
9df62f05 CG |
107 | .type name, @function ASM_NL \ |
108 | END(name) | |
ab7efcc9 | 109 | #endif |
d0aaff97 | 110 | |
1da177e4 LT |
111 | #endif |
112 | ||
1da177e4 | 113 | #endif |