blob: 807f1e5332267e6bd776f9591f106b723e1c02ab [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <asm/linkage.h>
6
7#ifdef __cplusplus
8#define CPP_ASMLINKAGE extern "C"
9#else
10#define CPP_ASMLINKAGE
11#endif
12
13#ifndef asmlinkage
14#define asmlinkage CPP_ASMLINKAGE
15#endif
16
Tim Abbott75b13482010-02-20 01:03:37 +010017#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
Tim Abbott7c74df02010-02-20 01:03:38 +010018#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
Jeremy Fitzhardingea7bf0bd2008-05-28 15:02:14 +010019
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070020/*
Tim Abbottd2af12a2009-06-23 19:59:35 -040021 * For assembly routines.
22 *
23 * Note when using these that you must specify the appropriate
24 * alignment directives yourself
25 */
Tim Abbott75b13482010-02-20 01:03:37 +010026#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
Tim Abbott7c74df02010-02-20 01:03:38 +010027#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
Tim Abbottd2af12a2009-06-23 19:59:35 -040028
29/*
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070030 * This is used by architectures to keep arguments on the stack
31 * untouched by the compiler by keeping them live until the end.
32 * The argument stack may be owned by the assembly-language
33 * caller, not the callee, and gcc doesn't always understand
34 * that.
35 *
36 * We have the return value, and a maximum of six arguments.
37 *
38 * This should always be followed by a "return ret" for the
39 * protection to work (ie no more work that the compiler might
40 * end up needing stack temporaries for).
41 */
Heiko Carstensb0fac022008-04-11 13:46:54 +020042/* Assembly files may be compiled with -traditional .. */
43#ifndef __ASSEMBLY__
Roland McGrath54a01512008-04-10 15:37:38 -070044#ifndef asmlinkage_protect
45# define asmlinkage_protect(n, ret, args...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#endif
Heiko Carstensb0fac022008-04-11 13:46:54 +020047#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#ifndef __ALIGN
50#define __ALIGN .align 4,0x90
51#define __ALIGN_STR ".align 4,0x90"
52#endif
53
54#ifdef __ASSEMBLY__
55
Tim Abbott42f29a22009-09-20 18:14:12 -040056#ifndef LINKER_SCRIPT
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define ALIGN __ALIGN
58#define ALIGN_STR __ALIGN_STR
59
Jan Beulichab7efcc2006-03-24 03:16:17 -080060#ifndef ENTRY
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#define ENTRY(name) \
62 .globl name; \
63 ALIGN; \
64 name:
Jan Beulichab7efcc2006-03-24 03:16:17 -080065#endif
Tim Abbott42f29a22009-09-20 18:14:12 -040066#endif /* LINKER_SCRIPT */
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Rusty Russell214541d2007-10-21 16:41:34 -070068#ifndef WEAK
69#define WEAK(name) \
70 .weak name; \
71 name:
72#endif
73
Jan Beulichab7efcc2006-03-24 03:16:17 -080074#ifndef END
75#define END(name) \
76 .size name, .-name
77#endif
78
John Reiser6b8be6d2008-01-30 13:33:13 +010079/* If symbol 'name' is treated as a subroutine (gets called, and returns)
80 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
81 * static analysis tools such as stack depth analyzer.
82 */
Jan Beulichab7efcc2006-03-24 03:16:17 -080083#ifndef ENDPROC
84#define ENDPROC(name) \
85 .type name, @function; \
86 END(name)
87#endif
Prasanna S Panchamukhid0aaff92005-09-06 15:19:26 -070088
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#endif
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#endif