block: remove QUEUE_FLAG_DISCARD
[linux-block.git] / include / linux / linkage.h
CommitLineData
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
33def849
JP
39#define __page_aligned_data __section(".data..page_aligned") __aligned(PAGE_SIZE)
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
ffedeeb7
JS
78/* SYM_T_FUNC -- type used by assembler to mark functions */
79#ifndef SYM_T_FUNC
80#define SYM_T_FUNC STT_FUNC
81#endif
82
83/* SYM_T_OBJECT -- type used by assembler to mark data */
84#ifndef SYM_T_OBJECT
85#define SYM_T_OBJECT STT_OBJECT
86#endif
87
88/* SYM_T_NONE -- type used by assembler to mark entries of unknown type */
89#ifndef SYM_T_NONE
90#define SYM_T_NONE STT_NOTYPE
91#endif
92
93/* SYM_A_* -- align the symbol? */
94#define SYM_A_ALIGN ALIGN
95#define SYM_A_NONE /* nothing */
96
97/* SYM_L_* -- linkage of symbols */
98#define SYM_L_GLOBAL(name) .globl name
99#define SYM_L_WEAK(name) .weak name
100#define SYM_L_LOCAL(name) /* nothing */
101
42f29a25 102#ifndef LINKER_SCRIPT
1da177e4
LT
103#define ALIGN __ALIGN
104#define ALIGN_STR __ALIGN_STR
105
ffedeeb7
JS
106/* === DEPRECATED annotations === */
107
2ce0d7f9 108#ifndef CONFIG_ARCH_USE_SYM_ANNOTATIONS
ad697a1a 109#ifndef GLOBAL
ffedeeb7 110/* deprecated, use SYM_DATA*, SYM_ENTRY, or similar */
ad697a1a
MR
111#define GLOBAL(name) \
112 .globl name ASM_NL \
113 name:
114#endif
115
ab7efcc9 116#ifndef ENTRY
ffedeeb7 117/* deprecated, use SYM_FUNC_START */
1da177e4 118#define ENTRY(name) \
ffedeeb7 119 SYM_FUNC_START(name)
ab7efcc9 120#endif
2ce0d7f9 121#endif /* CONFIG_ARCH_USE_SYM_ANNOTATIONS */
42f29a25 122#endif /* LINKER_SCRIPT */
1da177e4 123
2ce0d7f9 124#ifndef CONFIG_ARCH_USE_SYM_ANNOTATIONS
214541d1 125#ifndef WEAK
ffedeeb7 126/* deprecated, use SYM_FUNC_START_WEAK* */
214541d1 127#define WEAK(name) \
ffedeeb7 128 SYM_FUNC_START_WEAK(name)
214541d1
RR
129#endif
130
ab7efcc9 131#ifndef END
ffedeeb7 132/* deprecated, use SYM_FUNC_END, SYM_DATA_END, or SYM_END */
ab7efcc9 133#define END(name) \
9df62f05 134 .size name, .-name
ab7efcc9
JB
135#endif
136
6b8be6df
JR
137/* If symbol 'name' is treated as a subroutine (gets called, and returns)
138 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
139 * static analysis tools such as stack depth analyzer.
140 */
ab7efcc9 141#ifndef ENDPROC
ffedeeb7 142/* deprecated, use SYM_FUNC_END */
ab7efcc9 143#define ENDPROC(name) \
ffedeeb7
JS
144 SYM_FUNC_END(name)
145#endif
2ce0d7f9 146#endif /* CONFIG_ARCH_USE_SYM_ANNOTATIONS */
ffedeeb7
JS
147
148/* === generic annotations === */
149
150/* SYM_ENTRY -- use only if you have to for non-paired symbols */
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/* SYM_START -- use only if you have to */
159#ifndef SYM_START
160#define SYM_START(name, linkage, align...) \
161 SYM_ENTRY(name, linkage, align)
162#endif
163
164/* SYM_END -- use only if you have to */
165#ifndef SYM_END
166#define SYM_END(name, sym_type) \
167 .type name sym_type ASM_NL \
e0891269
MR
168 .set .L__sym_size_##name, .-name ASM_NL \
169 .size name, .L__sym_size_##name
170#endif
171
172/* SYM_ALIAS -- use only if you have to */
173#ifndef SYM_ALIAS
174#define SYM_ALIAS(alias, name, sym_type, linkage) \
175 linkage(alias) ASM_NL \
176 .set alias, name ASM_NL \
177 .type alias sym_type ASM_NL \
178 .set .L__sym_size_##alias, .L__sym_size_##name ASM_NL \
179 .size alias, .L__sym_size_##alias
ffedeeb7
JS
180#endif
181
182/* === code annotations === */
183
184/*
185 * FUNC -- C-like functions (proper stack frame etc.)
186 * CODE -- non-C code (e.g. irq handlers with different, special stack etc.)
187 *
188 * Objtool validates stack for FUNC, but not for CODE.
189 * Objtool generates debug info for both FUNC & CODE, but needs special
190 * annotations for each CODE's start (to describe the actual stack frame).
191 *
5e6dca82
ND
192 * Objtool requires that all code must be contained in an ELF symbol. Symbol
193 * names that have a .L prefix do not emit symbol table entries. .L
194 * prefixed symbols can be used within a code region, but should be avoided for
195 * denoting a range of code via ``SYM_*_START/END`` annotations.
196 *
ffedeeb7
JS
197 * ALIAS -- does not generate debug info -- the aliased function will
198 */
199
200/* SYM_INNER_LABEL_ALIGN -- only for labels in the middle of code */
201#ifndef SYM_INNER_LABEL_ALIGN
202#define SYM_INNER_LABEL_ALIGN(name, linkage) \
203 .type name SYM_T_NONE ASM_NL \
204 SYM_ENTRY(name, linkage, SYM_A_ALIGN)
205#endif
206
207/* SYM_INNER_LABEL -- only for labels in the middle of code */
208#ifndef SYM_INNER_LABEL
209#define SYM_INNER_LABEL(name, linkage) \
210 .type name SYM_T_NONE ASM_NL \
211 SYM_ENTRY(name, linkage, SYM_A_NONE)
212#endif
213
ffedeeb7
JS
214/* SYM_FUNC_START -- use for global functions */
215#ifndef SYM_FUNC_START
ffedeeb7
JS
216#define SYM_FUNC_START(name) \
217 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
218#endif
219
220/* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
221#ifndef SYM_FUNC_START_NOALIGN
222#define SYM_FUNC_START_NOALIGN(name) \
223 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
224#endif
225
226/* SYM_FUNC_START_LOCAL -- use for local functions */
227#ifndef SYM_FUNC_START_LOCAL
ffedeeb7
JS
228#define SYM_FUNC_START_LOCAL(name) \
229 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
ab7efcc9 230#endif
d0aaff97 231
ffedeeb7
JS
232/* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
233#ifndef SYM_FUNC_START_LOCAL_NOALIGN
234#define SYM_FUNC_START_LOCAL_NOALIGN(name) \
235 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
1da177e4
LT
236#endif
237
ffedeeb7
JS
238/* SYM_FUNC_START_WEAK -- use for weak functions */
239#ifndef SYM_FUNC_START_WEAK
240#define SYM_FUNC_START_WEAK(name) \
241 SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
1da177e4 242#endif
ffedeeb7
JS
243
244/* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
245#ifndef SYM_FUNC_START_WEAK_NOALIGN
246#define SYM_FUNC_START_WEAK_NOALIGN(name) \
247 SYM_START(name, SYM_L_WEAK, SYM_A_NONE)
248#endif
249
ffedeeb7
JS
250/*
251 * SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
252 * SYM_FUNC_START_WEAK, ...
253 */
254#ifndef SYM_FUNC_END
ffedeeb7
JS
255#define SYM_FUNC_END(name) \
256 SYM_END(name, SYM_T_FUNC)
257#endif
258
e0891269
MR
259/*
260 * SYM_FUNC_ALIAS -- define a global alias for an existing function
261 */
262#ifndef SYM_FUNC_ALIAS
263#define SYM_FUNC_ALIAS(alias, name) \
264 SYM_ALIAS(alias, name, SYM_T_FUNC, SYM_L_GLOBAL)
265#endif
266
267/*
268 * SYM_FUNC_ALIAS_LOCAL -- define a local alias for an existing function
269 */
270#ifndef SYM_FUNC_ALIAS_LOCAL
271#define SYM_FUNC_ALIAS_LOCAL(alias, name) \
272 SYM_ALIAS(alias, name, SYM_T_FUNC, SYM_L_LOCAL)
273#endif
274
275/*
276 * SYM_FUNC_ALIAS_WEAK -- define a weak global alias for an existing function
277 */
278#ifndef SYM_FUNC_ALIAS_WEAK
279#define SYM_FUNC_ALIAS_WEAK(alias, name) \
280 SYM_ALIAS(alias, name, SYM_T_FUNC, SYM_L_WEAK)
281#endif
282
ffedeeb7
JS
283/* SYM_CODE_START -- use for non-C (special) functions */
284#ifndef SYM_CODE_START
285#define SYM_CODE_START(name) \
286 SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
287#endif
288
289/* SYM_CODE_START_NOALIGN -- use for non-C (special) functions, w/o alignment */
290#ifndef SYM_CODE_START_NOALIGN
291#define SYM_CODE_START_NOALIGN(name) \
292 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
293#endif
294
295/* SYM_CODE_START_LOCAL -- use for local non-C (special) functions */
296#ifndef SYM_CODE_START_LOCAL
297#define SYM_CODE_START_LOCAL(name) \
298 SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN)
299#endif
300
301/*
302 * SYM_CODE_START_LOCAL_NOALIGN -- use for local non-C (special) functions,
303 * w/o alignment
304 */
305#ifndef SYM_CODE_START_LOCAL_NOALIGN
306#define SYM_CODE_START_LOCAL_NOALIGN(name) \
307 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
308#endif
309
310/* SYM_CODE_END -- the end of SYM_CODE_START_LOCAL, SYM_CODE_START, ... */
311#ifndef SYM_CODE_END
312#define SYM_CODE_END(name) \
313 SYM_END(name, SYM_T_NONE)
314#endif
315
316/* === data annotations === */
317
318/* SYM_DATA_START -- global data symbol */
319#ifndef SYM_DATA_START
320#define SYM_DATA_START(name) \
321 SYM_START(name, SYM_L_GLOBAL, SYM_A_NONE)
322#endif
323
324/* SYM_DATA_START -- local data symbol */
325#ifndef SYM_DATA_START_LOCAL
326#define SYM_DATA_START_LOCAL(name) \
327 SYM_START(name, SYM_L_LOCAL, SYM_A_NONE)
328#endif
329
330/* SYM_DATA_END -- the end of SYM_DATA_START symbol */
331#ifndef SYM_DATA_END
332#define SYM_DATA_END(name) \
333 SYM_END(name, SYM_T_OBJECT)
334#endif
335
336/* SYM_DATA_END_LABEL -- the labeled end of SYM_DATA_START symbol */
337#ifndef SYM_DATA_END_LABEL
338#define SYM_DATA_END_LABEL(name, linkage, label) \
339 linkage(label) ASM_NL \
340 .type label SYM_T_OBJECT ASM_NL \
341 label: \
342 SYM_END(name, SYM_T_OBJECT)
343#endif
344
345/* SYM_DATA -- start+end wrapper around simple global data */
346#ifndef SYM_DATA
347#define SYM_DATA(name, data...) \
348 SYM_DATA_START(name) ASM_NL \
349 data ASM_NL \
350 SYM_DATA_END(name)
351#endif
352
353/* SYM_DATA_LOCAL -- start+end wrapper around simple local data */
354#ifndef SYM_DATA_LOCAL
355#define SYM_DATA_LOCAL(name, data...) \
356 SYM_DATA_START_LOCAL(name) ASM_NL \
357 data ASM_NL \
358 SYM_DATA_END(name)
359#endif
360
361#endif /* __ASSEMBLY__ */
362
363#endif /* _LINUX_LINKAGE_H */