blob: d3e8ad23a8e0238645fe553f8183a2ad74bf5fc3 [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
9#ifdef __cplusplus
10#define CPP_ASMLINKAGE extern "C"
11#else
12#define CPP_ASMLINKAGE
13#endif
14
15#ifndef asmlinkage
16#define asmlinkage CPP_ASMLINKAGE
17#endif
18
Al Viroe1b5bb62013-01-21 17:16:07 -050019#ifndef cond_syscall
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070020#define cond_syscall(x) asm( \
21 ".weak " VMLINUX_SYMBOL_STR(x) "\n\t" \
22 ".set " VMLINUX_SYMBOL_STR(x) "," \
23 VMLINUX_SYMBOL_STR(sys_ni_syscall))
Al Viroe1b5bb62013-01-21 17:16:07 -050024#endif
25
26#ifndef SYSCALL_ALIAS
Linus Torvaldsf8ce1fa2013-05-05 10:58:06 -070027#define SYSCALL_ALIAS(alias, name) asm( \
28 ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t" \
29 ".set " VMLINUX_SYMBOL_STR(alias) "," \
30 VMLINUX_SYMBOL_STR(name))
Al Viroe1b5bb62013-01-21 17:16:07 -050031#endif
32
Tim Abbott75b13482010-02-20 01:03:37 +010033#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
Tim Abbott7c74df02010-02-20 01:03:38 +010034#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +010035
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070036/*
Tim Abbottd2af12a2009-06-23 19:59:35 -040037 * For assembly routines.
38 *
39 * Note when using these that you must specify the appropriate
40 * alignment directives yourself
41 */
Tim Abbott75b13482010-02-20 01:03:37 +010042#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
Tim Abbott7c74df02010-02-20 01:03:38 +010043#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
Tim Abbottd2af12a2009-06-23 19:59:35 -040044
45/*
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070046 * This is used by architectures to keep arguments on the stack
47 * untouched by the compiler by keeping them live until the end.
48 * The argument stack may be owned by the assembly-language
49 * caller, not the callee, and gcc doesn't always understand
50 * that.
51 *
52 * We have the return value, and a maximum of six arguments.
53 *
54 * This should always be followed by a "return ret" for the
55 * protection to work (ie no more work that the compiler might
56 * end up needing stack temporaries for).
57 */
Heiko Carstensb0fac022008-04-11 13:46:54 +020058/* Assembly files may be compiled with -traditional .. */
59#ifndef __ASSEMBLY__
Roland McGrath54a01512008-04-10 15:37:38 -070060#ifndef asmlinkage_protect
61# define asmlinkage_protect(n, ret, args...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#endif
Heiko Carstensb0fac022008-04-11 13:46:54 +020063#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#ifndef __ALIGN
66#define __ALIGN .align 4,0x90
67#define __ALIGN_STR ".align 4,0x90"
68#endif
69
70#ifdef __ASSEMBLY__
71
Tim Abbott42f29a22009-09-20 18:14:12 -040072#ifndef LINKER_SCRIPT
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#define ALIGN __ALIGN
74#define ALIGN_STR __ALIGN_STR
75
Jan Beulichab7efcc2006-03-24 03:16:17 -080076#ifndef ENTRY
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define ENTRY(name) \
78 .globl name; \
79 ALIGN; \
80 name:
Jan Beulichab7efcc2006-03-24 03:16:17 -080081#endif
Tim Abbott42f29a22009-09-20 18:14:12 -040082#endif /* LINKER_SCRIPT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Rusty Russell214541d2007-10-21 16:41:34 -070084#ifndef WEAK
85#define WEAK(name) \
86 .weak name; \
87 name:
88#endif
89
Jan Beulichab7efcc2006-03-24 03:16:17 -080090#ifndef END
91#define END(name) \
92 .size name, .-name
93#endif
94
John Reiser6b8be6d2008-01-30 13:33:13 +010095/* If symbol 'name' is treated as a subroutine (gets called, and returns)
96 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
97 * static analysis tools such as stack depth analyzer.
98 */
Jan Beulichab7efcc2006-03-24 03:16:17 -080099#ifndef ENDPROC
100#define ENDPROC(name) \
101 .type name, @function; \
102 END(name)
103#endif
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#endif
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107#endif