blob: 34a513a2727bbe83adff047613a1ad3458684ac2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_LINKAGE_H
2#define _LINUX_LINKAGE_H
3
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +01004#include <linux/compiler.h>
Al Viroe1b5bb62013-01-21 17:16:07 -05005#include <linux/stringify.h>
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -07006#include <linux/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/linkage.h>
8
Chen Gang9df62f02014-01-12 09:59:13 +08009/* Some toolchains use other characters (e.g. '`') to mark new line in macro */
10#ifndef ASM_NL
11#define ASM_NL ;
12#endif
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#ifdef __cplusplus
Andi Kleen128ea042014-02-08 09:01:07 +010015#define CPP_ASMLINKAGE extern "C" __visible
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#else
Andi Kleen128ea042014-02-08 09:01:07 +010017#define CPP_ASMLINKAGE __visible
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#endif
19
20#ifndef asmlinkage
21#define asmlinkage CPP_ASMLINKAGE
22#endif
23
Al Viroe1b5bb62013-01-21 17:16:07 -050024#ifndef cond_syscall
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070025#define cond_syscall(x) asm( \
26 ".weak " VMLINUX_SYMBOL_STR(x) "\n\t" \
27 ".set " VMLINUX_SYMBOL_STR(x) "," \
28 VMLINUX_SYMBOL_STR(sys_ni_syscall))
Al Viroe1b5bb62013-01-21 17:16:07 -050029#endif
30
31#ifndef SYSCALL_ALIAS
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070032#define SYSCALL_ALIAS(alias, name) asm( \
33 ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t" \
34 ".set " VMLINUX_SYMBOL_STR(alias) "," \
35 VMLINUX_SYMBOL_STR(name))
Al Viroe1b5bb62013-01-21 17:16:07 -050036#endif
37
Tim Abbott75b13482010-02-20 01:03:37 +010038#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
Tim Abbott7c74df02010-02-20 01:03:38 +010039#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +010040
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070041/*
Tim Abbottd2af12a2009-06-23 19:59:35 -040042 * For assembly routines.
43 *
44 * Note when using these that you must specify the appropriate
45 * alignment directives yourself
46 */
Tim Abbott75b13482010-02-20 01:03:37 +010047#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
Tim Abbott7c74df02010-02-20 01:03:38 +010048#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
Tim Abbottd2af12a2009-06-23 19:59:35 -040049
50/*
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070051 * This is used by architectures to keep arguments on the stack
52 * untouched by the compiler by keeping them live until the end.
53 * The argument stack may be owned by the assembly-language
54 * caller, not the callee, and gcc doesn't always understand
55 * that.
56 *
57 * We have the return value, and a maximum of six arguments.
58 *
59 * This should always be followed by a "return ret" for the
60 * protection to work (ie no more work that the compiler might
61 * end up needing stack temporaries for).
62 */
Heiko Carstensb0fac022008-04-11 13:46:54 +020063/* Assembly files may be compiled with -traditional .. */
64#ifndef __ASSEMBLY__
Roland McGrath54a01512008-04-10 15:37:38 -070065#ifndef asmlinkage_protect
66# define asmlinkage_protect(n, ret, args...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#endif
Heiko Carstensb0fac022008-04-11 13:46:54 +020068#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#ifndef __ALIGN
71#define __ALIGN .align 4,0x90
72#define __ALIGN_STR ".align 4,0x90"
73#endif
74
75#ifdef __ASSEMBLY__
76
Tim Abbott42f29a22009-09-20 18:14:12 -040077#ifndef LINKER_SCRIPT
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define ALIGN __ALIGN
79#define ALIGN_STR __ALIGN_STR
80
Jan Beulichab7efcc2006-03-24 03:16:17 -080081#ifndef ENTRY
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define ENTRY(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080083 .globl name ASM_NL \
84 ALIGN ASM_NL \
85 name:
Jan Beulichab7efcc2006-03-24 03:16:17 -080086#endif
Tim Abbott42f29a22009-09-20 18:14:12 -040087#endif /* LINKER_SCRIPT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Rusty Russell214541d2007-10-21 16:41:34 -070089#ifndef WEAK
90#define WEAK(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080091 .weak name ASM_NL \
Rusty Russell214541d2007-10-21 16:41:34 -070092 name:
93#endif
94
Jan Beulichab7efcc2006-03-24 03:16:17 -080095#ifndef END
96#define END(name) \
Chen Gang9df62f02014-01-12 09:59:13 +080097 .size name, .-name
Jan Beulichab7efcc2006-03-24 03:16:17 -080098#endif
99
John Reiser6b8be6d2008-01-30 13:33:13 +0100100/* If symbol 'name' is treated as a subroutine (gets called, and returns)
101 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
102 * static analysis tools such as stack depth analyzer.
103 */
Jan Beulichab7efcc2006-03-24 03:16:17 -0800104#ifndef ENDPROC
105#define ENDPROC(name) \
Chen Gang9df62f02014-01-12 09:59:13 +0800106 .type name, @function ASM_NL \
107 END(name)
Jan Beulichab7efcc2006-03-24 03:16:17 -0800108#endif
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110#endif
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif