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