Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _LINUX_LINKAGE_H |
| 3 | #define _LINUX_LINKAGE_H |
| 4 | |
Will Deacon | d151558 | 2017-10-24 11:22:46 +0100 | [diff] [blame] | 5 | #include <linux/compiler_types.h> |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 6 | #include <linux/stringify.h> |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 7 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <asm/linkage.h> |
| 9 | |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 10 | /* Some toolchains use other characters (e.g. '`') to mark new line in macro */ |
| 11 | #ifndef ASM_NL |
| 12 | #define ASM_NL ; |
| 13 | #endif |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #ifdef __cplusplus |
Andi Kleen | 3adc1be | 2014-05-02 00:44:36 +0200 | [diff] [blame] | 16 | #define CPP_ASMLINKAGE extern "C" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #else |
Andi Kleen | 3adc1be | 2014-05-02 00:44:36 +0200 | [diff] [blame] | 18 | #define CPP_ASMLINKAGE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #endif |
| 20 | |
| 21 | #ifndef asmlinkage |
| 22 | #define asmlinkage CPP_ASMLINKAGE |
| 23 | #endif |
| 24 | |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 25 | #ifndef cond_syscall |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 26 | #define cond_syscall(x) asm( \ |
| 27 | ".weak " VMLINUX_SYMBOL_STR(x) "\n\t" \ |
| 28 | ".set " VMLINUX_SYMBOL_STR(x) "," \ |
| 29 | VMLINUX_SYMBOL_STR(sys_ni_syscall)) |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #ifndef SYSCALL_ALIAS |
Linus Torvalds | f8ce1fa | 2013-05-05 10:58:06 -0700 | [diff] [blame] | 33 | #define SYSCALL_ALIAS(alias, name) asm( \ |
| 34 | ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t" \ |
| 35 | ".set " VMLINUX_SYMBOL_STR(alias) "," \ |
| 36 | VMLINUX_SYMBOL_STR(name)) |
Al Viro | e1b5bb6 | 2013-01-21 17:16:07 -0500 | [diff] [blame] | 37 | #endif |
| 38 | |
Tim Abbott | 75b1348 | 2010-02-20 01:03:37 +0100 | [diff] [blame] | 39 | #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) |
Tim Abbott | 7c74df0 | 2010-02-20 01:03:38 +0100 | [diff] [blame] | 40 | #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE) |
Jeremy Fitzhardinge | a7bf0bd | 2008-05-28 15:02:14 +0100 | [diff] [blame] | 41 | |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 42 | /* |
Tim Abbott | d2af12a | 2009-06-23 19:59:35 -0400 | [diff] [blame] | 43 | * For assembly routines. |
| 44 | * |
| 45 | * Note when using these that you must specify the appropriate |
| 46 | * alignment directives yourself |
| 47 | */ |
Tim Abbott | 75b1348 | 2010-02-20 01:03:37 +0100 | [diff] [blame] | 48 | #define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw" |
Tim Abbott | 7c74df0 | 2010-02-20 01:03:38 +0100 | [diff] [blame] | 49 | #define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw" |
Tim Abbott | d2af12a | 2009-06-23 19:59:35 -0400 | [diff] [blame] | 50 | |
| 51 | /* |
Linus Torvalds | d10d89e | 2008-04-10 17:35:23 -0700 | [diff] [blame] | 52 | * This is used by architectures to keep arguments on the stack |
| 53 | * untouched by the compiler by keeping them live until the end. |
| 54 | * The argument stack may be owned by the assembly-language |
| 55 | * caller, not the callee, and gcc doesn't always understand |
| 56 | * that. |
| 57 | * |
| 58 | * We have the return value, and a maximum of six arguments. |
| 59 | * |
| 60 | * This should always be followed by a "return ret" for the |
| 61 | * protection to work (ie no more work that the compiler might |
| 62 | * end up needing stack temporaries for). |
| 63 | */ |
Heiko Carstens | b0fac02 | 2008-04-11 13:46:54 +0200 | [diff] [blame] | 64 | /* Assembly files may be compiled with -traditional .. */ |
| 65 | #ifndef __ASSEMBLY__ |
Roland McGrath | 54a0151 | 2008-04-10 15:37:38 -0700 | [diff] [blame] | 66 | #ifndef asmlinkage_protect |
| 67 | # define asmlinkage_protect(n, ret, args...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #endif |
Heiko Carstens | b0fac02 | 2008-04-11 13:46:54 +0200 | [diff] [blame] | 69 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | #ifndef __ALIGN |
| 72 | #define __ALIGN .align 4,0x90 |
| 73 | #define __ALIGN_STR ".align 4,0x90" |
| 74 | #endif |
| 75 | |
| 76 | #ifdef __ASSEMBLY__ |
| 77 | |
Tim Abbott | 42f29a2 | 2009-09-20 18:14:12 -0400 | [diff] [blame] | 78 | #ifndef LINKER_SCRIPT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #define ALIGN __ALIGN |
| 80 | #define ALIGN_STR __ALIGN_STR |
| 81 | |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 82 | #ifndef ENTRY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define ENTRY(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 84 | .globl name ASM_NL \ |
| 85 | ALIGN ASM_NL \ |
| 86 | name: |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 87 | #endif |
Tim Abbott | 42f29a2 | 2009-09-20 18:14:12 -0400 | [diff] [blame] | 88 | #endif /* LINKER_SCRIPT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Rusty Russell | 214541d | 2007-10-21 16:41:34 -0700 | [diff] [blame] | 90 | #ifndef WEAK |
| 91 | #define WEAK(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 92 | .weak name ASM_NL \ |
Rusty Russell | 214541d | 2007-10-21 16:41:34 -0700 | [diff] [blame] | 93 | name: |
| 94 | #endif |
| 95 | |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 96 | #ifndef END |
| 97 | #define END(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 98 | .size name, .-name |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 99 | #endif |
| 100 | |
John Reiser | 6b8be6d | 2008-01-30 13:33:13 +0100 | [diff] [blame] | 101 | /* If symbol 'name' is treated as a subroutine (gets called, and returns) |
| 102 | * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of |
| 103 | * static analysis tools such as stack depth analyzer. |
| 104 | */ |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 105 | #ifndef ENDPROC |
| 106 | #define ENDPROC(name) \ |
Chen Gang | 9df62f0 | 2014-01-12 09:59:13 +0800 | [diff] [blame] | 107 | .type name, @function ASM_NL \ |
| 108 | END(name) |
Jan Beulich | ab7efcc | 2006-03-24 03:16:17 -0800 | [diff] [blame] | 109 | #endif |
Prasanna S Panchamukhi | d0aaff9 | 2005-09-06 15:19:26 -0700 | [diff] [blame] | 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | #endif |
| 112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | #endif |