blob: 829d66c67fc20580a82b5ce7a1be3bf9083c2944 [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 Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/linkage.h>
7
8#ifdef __cplusplus
9#define CPP_ASMLINKAGE extern "C"
10#else
11#define CPP_ASMLINKAGE
12#endif
13
14#ifndef asmlinkage
15#define asmlinkage CPP_ASMLINKAGE
16#endif
17
Al Viroe1b5bb62013-01-21 17:16:07 -050018#ifndef SYMBOL_NAME
19#ifdef CONFIG_SYMBOL_PREFIX
20#define SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX ## x
21#else
22#define SYMBOL_NAME(x) x
23#endif
24#endif
25#define __SYMBOL_NAME(x) __stringify(SYMBOL_NAME(x))
26
27#ifndef cond_syscall
28#define cond_syscall(x) asm(".weak\t" __SYMBOL_NAME(x) \
29 "\n\t.set\t" __SYMBOL_NAME(x) "," __SYMBOL_NAME(sys_ni_syscall));
30#endif
31
32#ifndef SYSCALL_ALIAS
33#define SYSCALL_ALIAS(alias, name) \
34 asm ("\t.globl " __SYMBOL_NAME(alias) \
35 "\n\t.set\t" __SYMBOL_NAME(alias) "," __SYMBOL_NAME(name))
36#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) \
83 .globl name; \
84 ALIGN; \
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) \
91 .weak name; \
92 name:
93#endif
94
Jan Beulichab7efcc2006-03-24 03:16:17 -080095#ifndef END
96#define END(name) \
97 .size name, .-name
98#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) \
106 .type name, @function; \
107 END(name)
108#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