Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_LINKAGE_H |
| 2 | #define _LINUX_LINKAGE_H |
| 3 | |
Jeremy Fitzhardinge | a7bf0bd | 2008-05-28 15:02:14 +0100 | [diff] [blame] | 4 | #include <linux/compiler.h> |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 5 | #include <linux/stringify.h> |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 6 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <asm/linkage.h> |
| 8 | |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 9 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #ifdef __cplusplus |
Andi Kleen | 128ea04 | 2014-02-08 09:01:07 +0100 | [diff] [blame] | 15 | #define CPP_ASMLINKAGE extern "C" __visible |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #else |
Andi Kleen | 128ea04 | 2014-02-08 09:01:07 +0100 | [diff] [blame] | 17 | #define CPP_ASMLINKAGE __visible |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #endif |
| 19 | |
| 20 | #ifndef asmlinkage |
| 21 | #define asmlinkage CPP_ASMLINKAGE |
| 22 | #endif |
| 23 | |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 24 | #ifndef cond_syscall |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 25 | #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 Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 29 | #endif |
| 30 | |
| 31 | #ifndef SYSCALL_ALIAS |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 32 | #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 Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 36 | #endif |
| 37 | |
Tim Abbott | 75b1348 | 2010-02-20 01:03:37 +0100 | [diff] [blame] | 38 | #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) |
Tim Abbott | 7c74df0 | 2010-02-20 01:03:38 +0100 | [diff] [blame] | 39 | #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE) |
Jeremy Fitzhardinge | a7bf0bd | 2008-05-28 15:02:14 +0100 | [diff] [blame] | 40 | |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 41 | /* |
Tim Abbott | d2af12a | 2009-06-23 19:59:35 -0400 | [diff] [blame] | 42 | * For assembly routines. |
| 43 | * |
| 44 | * Note when using these that you must specify the appropriate |
| 45 | * alignment directives yourself |
| 46 | */ |
Tim Abbott | 75b1348 | 2010-02-20 01:03:37 +0100 | [diff] [blame] | 47 | #define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw" |
Tim Abbott | 7c74df0 | 2010-02-20 01:03:38 +0100 | [diff] [blame] | 48 | #define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw" |
Tim Abbott | d2af12a | 2009-06-23 19:59:35 -0400 | [diff] [blame] | 49 | |
| 50 | /* |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 51 | * 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 Carstens | b0fac02 | 2008-04-11 13:46:54 +0200 | [diff] [blame] | 63 | /* Assembly files may be compiled with -traditional .. */ |
| 64 | #ifndef __ASSEMBLY__ |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 65 | #ifndef asmlinkage_protect |
| 66 | # define asmlinkage_protect(n, ret, args...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #endif |
Heiko Carstens | b0fac02 | 2008-04-11 13:46:54 +0200 | [diff] [blame] | 68 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | #ifndef __ALIGN |
| 71 | #define __ALIGN .align 4,0x90 |
| 72 | #define __ALIGN_STR ".align 4,0x90" |
| 73 | #endif |
| 74 | |
| 75 | #ifdef __ASSEMBLY__ |
| 76 | |
Tim Abbott | 42f29a2 | 2009-09-20 18:14:12 -0400 | [diff] [blame] | 77 | #ifndef LINKER_SCRIPT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #define ALIGN __ALIGN |
| 79 | #define ALIGN_STR __ALIGN_STR |
| 80 | |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 81 | #ifndef ENTRY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #define ENTRY(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 83 | .globl name ASM_NL \ |
| 84 | ALIGN ASM_NL \ |
| 85 | name: |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 86 | #endif |
Tim Abbott | 42f29a2 | 2009-09-20 18:14:12 -0400 | [diff] [blame] | 87 | #endif /* LINKER_SCRIPT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Rusty Russell | 214541d | 2007-10-21 16:41:34 -0700 | [diff] [blame] | 89 | #ifndef WEAK |
| 90 | #define WEAK(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 91 | .weak name ASM_NL \ |
Rusty Russell | 214541d | 2007-10-21 16:41:34 -0700 | [diff] [blame] | 92 | name: |
| 93 | #endif |
| 94 | |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 95 | #ifndef END |
| 96 | #define END(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 97 | .size name, .-name |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 98 | #endif |
| 99 | |
John Reiser | 6b8be6d | 2008-01-30 13:33:13 +0100 | [diff] [blame] | 100 | /* 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 Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 104 | #ifndef ENDPROC |
| 105 | #define ENDPROC(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 106 | .type name, @function ASM_NL \ |
| 107 | END(name) |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 108 | #endif |
Prasanna S Panchamukhi | d0aaff9 | 2005-09-06 15:19:26 -0700 | [diff] [blame] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #endif |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #endif |