blob: de09dec25ec3b99372bdc4df356380d7ccc4a939 [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#ifdef CONFIG_SYMBOL_PREFIX
James Hogan126de6b2013-05-01 22:04:17 +010019#define __SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX __stringify(x)
Al Viroe1b5bb62013-01-21 17:16:07 -050020#else
James Hogan126de6b2013-05-01 22:04:17 +010021#define __SYMBOL_NAME(x) __stringify(x)
Al Viroe1b5bb62013-01-21 17:16:07 -050022#endif
Al Viroe1b5bb62013-01-21 17:16:07 -050023
24#ifndef cond_syscall
25#define cond_syscall(x) asm(".weak\t" __SYMBOL_NAME(x) \
26 "\n\t.set\t" __SYMBOL_NAME(x) "," __SYMBOL_NAME(sys_ni_syscall));
27#endif
28
29#ifndef SYSCALL_ALIAS
30#define SYSCALL_ALIAS(alias, name) \
31 asm ("\t.globl " __SYMBOL_NAME(alias) \
32 "\n\t.set\t" __SYMBOL_NAME(alias) "," __SYMBOL_NAME(name))
33#endif
34
Tim Abbott75b13482010-02-20 01:03:37 +010035#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
Tim Abbott7c74df02010-02-20 01:03:38 +010036#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +010037
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070038/*
Tim Abbottd2af12a2009-06-23 19:59:35 -040039 * For assembly routines.
40 *
41 * Note when using these that you must specify the appropriate
42 * alignment directives yourself
43 */
Tim Abbott75b13482010-02-20 01:03:37 +010044#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
Tim Abbott7c74df02010-02-20 01:03:38 +010045#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
Tim Abbottd2af12a2009-06-23 19:59:35 -040046
47/*
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070048 * This is used by architectures to keep arguments on the stack
49 * untouched by the compiler by keeping them live until the end.
50 * The argument stack may be owned by the assembly-language
51 * caller, not the callee, and gcc doesn't always understand
52 * that.
53 *
54 * We have the return value, and a maximum of six arguments.
55 *
56 * This should always be followed by a "return ret" for the
57 * protection to work (ie no more work that the compiler might
58 * end up needing stack temporaries for).
59 */
Heiko Carstensb0fac022008-04-11 13:46:54 +020060/* Assembly files may be compiled with -traditional .. */
61#ifndef __ASSEMBLY__
Roland McGrath54a01512008-04-10 15:37:38 -070062#ifndef asmlinkage_protect
63# define asmlinkage_protect(n, ret, args...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#endif
Heiko Carstensb0fac022008-04-11 13:46:54 +020065#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67#ifndef __ALIGN
68#define __ALIGN .align 4,0x90
69#define __ALIGN_STR ".align 4,0x90"
70#endif
71
72#ifdef __ASSEMBLY__
73
Tim Abbott42f29a22009-09-20 18:14:12 -040074#ifndef LINKER_SCRIPT
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define ALIGN __ALIGN
76#define ALIGN_STR __ALIGN_STR
77
Jan Beulichab7efcc2006-03-24 03:16:17 -080078#ifndef ENTRY
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define ENTRY(name) \
80 .globl name; \
81 ALIGN; \
82 name:
Jan Beulichab7efcc2006-03-24 03:16:17 -080083#endif
Tim Abbott42f29a22009-09-20 18:14:12 -040084#endif /* LINKER_SCRIPT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Rusty Russell214541d2007-10-21 16:41:34 -070086#ifndef WEAK
87#define WEAK(name) \
88 .weak name; \
89 name:
90#endif
91
Jan Beulichab7efcc2006-03-24 03:16:17 -080092#ifndef END
93#define END(name) \
94 .size name, .-name
95#endif
96
John Reiser6b8be6d2008-01-30 13:33:13 +010097/* If symbol 'name' is treated as a subroutine (gets called, and returns)
98 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
99 * static analysis tools such as stack depth analyzer.
100 */
Jan Beulichab7efcc2006-03-24 03:16:17 -0800101#ifndef ENDPROC
102#define ENDPROC(name) \
103 .type name, @function; \
104 END(name)
105#endif
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -0700106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107#endif
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#endif