blob: f68db9e450eb3f7ed00e30855a3b183c42d41b7f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX_LINKAGE_H
3#define _LINUX_LINKAGE_H
4
Will Deacond1515582017-10-24 11:22:46 +01005#include <linux/compiler_types.h>
Al Viroe1b5bb62013-01-21 17:16:07 -05006#include <linux/stringify.h>
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -07007#include <linux/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/linkage.h>
9
Chen Gang9df62f02014-01-12 09:59:13 +080010/* Some toolchains use other characters (e.g. '`') to mark new line in macro */
11#ifndef ASM_NL
12#define ASM_NL ;
13#endif
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#ifdef __cplusplus
Andi Kleen3adc1be2014-05-02 00:44:36 +020016#define CPP_ASMLINKAGE extern "C"
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#else
Andi Kleen3adc1be2014-05-02 00:44:36 +020018#define CPP_ASMLINKAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#endif
20
21#ifndef asmlinkage
22#define asmlinkage CPP_ASMLINKAGE
23#endif
24
Al Viroe1b5bb62013-01-21 17:16:07 -050025#ifndef cond_syscall
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070026#define cond_syscall(x) asm( \
27 ".weak " VMLINUX_SYMBOL_STR(x) "\n\t" \
28 ".set " VMLINUX_SYMBOL_STR(x) "," \
29 VMLINUX_SYMBOL_STR(sys_ni_syscall))
Al Viroe1b5bb62013-01-21 17:16:07 -050030#endif
31
32#ifndef SYSCALL_ALIAS
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070033#define SYSCALL_ALIAS(alias, name) asm( \
34 ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t" \
35 ".set " VMLINUX_SYMBOL_STR(alias) "," \
36 VMLINUX_SYMBOL_STR(name))
Al Viroe1b5bb62013-01-21 17:16:07 -050037#endif
38
Tim Abbott75b13482010-02-20 01:03:37 +010039#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
Tim Abbott7c74df02010-02-20 01:03:38 +010040#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +010041
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070042/*
Tim Abbottd2af12a2009-06-23 19:59:35 -040043 * For assembly routines.
44 *
45 * Note when using these that you must specify the appropriate
46 * alignment directives yourself
47 */
Tim Abbott75b13482010-02-20 01:03:37 +010048#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
Tim Abbott7c74df02010-02-20 01:03:38 +010049#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
Tim Abbottd2af12a2009-06-23 19:59:35 -040050
51/*
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070052 * 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 */
Heiko Carstensb0fac022008-04-11 13:46:54 +020064/* Assembly files may be compiled with -traditional .. */
65#ifndef __ASSEMBLY__
Roland McGrath54a01512008-04-10 15:37:38 -070066#ifndef asmlinkage_protect
67# define asmlinkage_protect(n, ret, args...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#endif
Heiko Carstensb0fac022008-04-11 13:46:54 +020069#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#ifndef __ALIGN
72#define __ALIGN .align 4,0x90
73#define __ALIGN_STR ".align 4,0x90"
74#endif
75
76#ifdef __ASSEMBLY__
77
Tim Abbott42f29a22009-09-20 18:14:12 -040078#ifndef LINKER_SCRIPT
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define ALIGN __ALIGN
80#define ALIGN_STR __ALIGN_STR
81
Jan Beulichab7efcc2006-03-24 03:16:17 -080082#ifndef ENTRY
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#define ENTRY(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080084 .globl name ASM_NL \
85 ALIGN ASM_NL \
86 name:
Jan Beulichab7efcc2006-03-24 03:16:17 -080087#endif
Tim Abbott42f29a22009-09-20 18:14:12 -040088#endif /* LINKER_SCRIPT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Rusty Russell214541d2007-10-21 16:41:34 -070090#ifndef WEAK
91#define WEAK(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080092 .weak name ASM_NL \
Rusty Russell214541d2007-10-21 16:41:34 -070093 name:
94#endif
95
Jan Beulichab7efcc2006-03-24 03:16:17 -080096#ifndef END
97#define END(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080098 .size name, .-name
Jan Beulichab7efcc2006-03-24 03:16:17 -080099#endif
100
John Reiser6b8be6d2008-01-30 13:33:13 +0100101/* 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 */
Jan Beulichab7efcc2006-03-24 03:16:17 -0800105#ifndef ENDPROC
106#define ENDPROC(name) \
Chen Gang9df62f02014-01-12 09:59:13 +0800107 .type name, @function ASM_NL \
108 END(name)
Jan Beulichab7efcc2006-03-24 03:16:17 -0800109#endif
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#endif
112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#endif