1
2#ifndef _LINUX_LINKAGE_H
3#define _LINUX_LINKAGE_H
4
5#include <linux/compiler_types.h>
6#include <linux/stringify.h>
7#include <linux/export.h>
8#include <asm/linkage.h>
9
10
11#ifndef ASM_NL
12#define ASM_NL ;
13#endif
14
15#ifdef __cplusplus
16#define CPP_ASMLINKAGE extern "C"
17#else
18#define CPP_ASMLINKAGE
19#endif
20
21#ifndef asmlinkage
22#define asmlinkage CPP_ASMLINKAGE
23#endif
24
25#ifndef cond_syscall
26#define cond_syscall(x) asm( \
27 ".weak " __stringify(x) "\n\t" \
28 ".set " __stringify(x) "," \
29 __stringify(sys_ni_syscall))
30#endif
31
32#ifndef SYSCALL_ALIAS
33#define SYSCALL_ALIAS(alias, name) asm( \
34 ".globl " __stringify(alias) "\n\t" \
35 ".set " __stringify(alias) "," \
36 __stringify(name))
37#endif
38
39#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
40#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
41
42
43
44
45
46
47
48#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
49#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65#ifndef __ASSEMBLY__
66#ifndef asmlinkage_protect
67# define asmlinkage_protect(n, ret, args...) do { } while (0)
68#endif
69#endif
70
71#ifndef __ALIGN
72#define __ALIGN .align 4,0x90
73#define __ALIGN_STR ".align 4,0x90"
74#endif
75
76#ifdef __ASSEMBLY__
77
78
79#ifndef SYM_T_FUNC
80#define SYM_T_FUNC STT_FUNC
81#endif
82
83
84#ifndef SYM_T_OBJECT
85#define SYM_T_OBJECT STT_OBJECT
86#endif
87
88
89#ifndef SYM_T_NONE
90#define SYM_T_NONE STT_NOTYPE
91#endif
92
93
94#define SYM_A_ALIGN ALIGN
95#define SYM_A_NONE
96
97
98#define SYM_L_GLOBAL(name) .globl name
99#define SYM_L_WEAK(name) .weak name
100#define SYM_L_LOCAL(name)
101
102#ifndef LINKER_SCRIPT
103#define ALIGN __ALIGN
104#define ALIGN_STR __ALIGN_STR
105
106
107
108#ifndef CONFIG_X86
109#ifndef GLOBAL
110
111#define GLOBAL(name) \
112 .globl name ASM_NL \
113 name:
114#endif
115
116#ifndef ENTRY
117
118#define ENTRY(name) \
119 SYM_FUNC_START(name)
120#endif
121#endif
122#endif
123
124#ifndef CONFIG_X86
125#ifndef WEAK
126
127#define WEAK(name) \
128 SYM_FUNC_START_WEAK(name)
129#endif
130
131#ifndef END
132
133#define END(name) \
134 .size name, .-name
135#endif
136
137
138
139
140
141#ifndef ENDPROC
142
143#define ENDPROC(name) \
144 SYM_FUNC_END(name)
145#endif
146#endif
147
148
149
150
151#ifndef SYM_ENTRY
152#define SYM_ENTRY(name, linkage, align...) \
153 linkage(name) ASM_NL \
154 align ASM_NL \
155 name:
156#endif
157
158
159#ifndef SYM_START
160#define SYM_START(name, linkage, align...) \
161 SYM_ENTRY(name, linkage, align)
162#endif
163
164
165#ifndef SYM_END
166#define SYM_END(name, sym_type) \
167 .type name sym_type ASM_NL \
168 .size name, .-name
169#endif
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185#ifndef SYM_INNER_LABEL_ALIGN
186#define SYM_INNER_LABEL_ALIGN(name, linkage) \
187 .type name SYM_T_NONE ASM_NL \
188 SYM_ENTRY(name, linkage, SYM_A_ALIGN)
189#endif
190
191
192#ifndef SYM_INNER_LABEL
193#define SYM_INNER_LABEL(name, linkage) \
194 .type name SYM_T_NONE ASM_NL \
195 SYM_ENTRY(name, linkage, SYM_A_NONE)
196#endif
197
198
199
200
201
202#ifndef SYM_FUNC_START_LOCAL_ALIAS
203#define SYM_FUNC_START_LOCAL_ALIAS(name) \
204 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
205#endif
206
207
208
209
210
211#ifndef SYM_FUNC_START_ALIAS
212#define SYM_FUNC_START_ALIAS(name) \
213 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
214#endif
215
216
217#ifndef SYM_FUNC_START
218
219
220
221
222#define SYM_FUNC_START(name) \
223 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
224#endif
225
226
227#ifndef SYM_FUNC_START_NOALIGN
228#define SYM_FUNC_START_NOALIGN(name) \
229 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
230#endif
231
232
233#ifndef SYM_FUNC_START_LOCAL
234
235#define SYM_FUNC_START_LOCAL(name) \
236 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
237#endif
238
239
240#ifndef SYM_FUNC_START_LOCAL_NOALIGN
241#define SYM_FUNC_START_LOCAL_NOALIGN(name) \
242 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
243#endif
244
245
246#ifndef SYM_FUNC_START_WEAK
247#define SYM_FUNC_START_WEAK(name) \
248 SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
249#endif
250
251
252#ifndef SYM_FUNC_START_WEAK_NOALIGN
253#define SYM_FUNC_START_WEAK_NOALIGN(name) \
254 SYM_START(name, SYM_L_WEAK, SYM_A_NONE)
255#endif
256
257
258#ifndef SYM_FUNC_END_ALIAS
259#define SYM_FUNC_END_ALIAS(name) \
260 SYM_END(name, SYM_T_FUNC)
261#endif
262
263
264
265
266
267#ifndef SYM_FUNC_END
268
269#define SYM_FUNC_END(name) \
270 SYM_END(name, SYM_T_FUNC)
271#endif
272
273
274#ifndef SYM_CODE_START
275#define SYM_CODE_START(name) \
276 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
277#endif
278
279
280#ifndef SYM_CODE_START_NOALIGN
281#define SYM_CODE_START_NOALIGN(name) \
282 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
283#endif
284
285
286#ifndef SYM_CODE_START_LOCAL
287#define SYM_CODE_START_LOCAL(name) \
288 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
289#endif
290
291
292
293
294
295#ifndef SYM_CODE_START_LOCAL_NOALIGN
296#define SYM_CODE_START_LOCAL_NOALIGN(name) \
297 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
298#endif
299
300
301#ifndef SYM_CODE_END
302#define SYM_CODE_END(name) \
303 SYM_END(name, SYM_T_NONE)
304#endif
305
306
307
308
309#ifndef SYM_DATA_START
310#define SYM_DATA_START(name) \
311 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
312#endif
313
314
315#ifndef SYM_DATA_START_LOCAL
316#define SYM_DATA_START_LOCAL(name) \
317 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
318#endif
319
320
321#ifndef SYM_DATA_END
322#define SYM_DATA_END(name) \
323 SYM_END(name, SYM_T_OBJECT)
324#endif
325
326
327#ifndef SYM_DATA_END_LABEL
328#define SYM_DATA_END_LABEL(name, linkage, label) \
329 linkage(label) ASM_NL \
330 .type label SYM_T_OBJECT ASM_NL \
331 label: \
332 SYM_END(name, SYM_T_OBJECT)
333#endif
334
335
336#ifndef SYM_DATA
337#define SYM_DATA(name, data...) \
338 SYM_DATA_START(name) ASM_NL \
339 data ASM_NL \
340 SYM_DATA_END(name)
341#endif
342
343
344#ifndef SYM_DATA_LOCAL
345#define SYM_DATA_LOCAL(name, data...) \
346 SYM_DATA_START_LOCAL(name) ASM_NL \
347 data ASM_NL \
348 SYM_DATA_END(name)
349#endif
350
351#endif
352
353#endif
354