linkage.h 2.6 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3
#ifndef _LINUX_LINKAGE_H
#define _LINUX_LINKAGE_H

4
#include <linux/compiler.h>
5
#include <linux/stringify.h>
6
#include <linux/export.h>
Linus Torvalds's avatar
Linus Torvalds committed
7 8
#include <asm/linkage.h>

9 10 11 12 13
/* Some toolchains use other characters (e.g. '`') to mark new line in macro */
#ifndef ASM_NL
#define ASM_NL		 ;
#endif

Linus Torvalds's avatar
Linus Torvalds committed
14
#ifdef __cplusplus
15
#define CPP_ASMLINKAGE extern "C"
Linus Torvalds's avatar
Linus Torvalds committed
16
#else
17
#define CPP_ASMLINKAGE
Linus Torvalds's avatar
Linus Torvalds committed
18 19 20 21 22 23
#endif

#ifndef asmlinkage
#define asmlinkage CPP_ASMLINKAGE
#endif

24
#ifndef cond_syscall
25 26 27 28
#define cond_syscall(x)	asm(				\
	".weak " VMLINUX_SYMBOL_STR(x) "\n\t"		\
	".set  " VMLINUX_SYMBOL_STR(x) ","		\
		 VMLINUX_SYMBOL_STR(sys_ni_syscall))
29 30 31
#endif

#ifndef SYSCALL_ALIAS
32 33 34 35
#define SYSCALL_ALIAS(alias, name) asm(			\
	".globl " VMLINUX_SYMBOL_STR(alias) "\n\t"	\
	".set   " VMLINUX_SYMBOL_STR(alias) ","		\
		  VMLINUX_SYMBOL_STR(name))
36 37
#endif

38
#define __page_aligned_data	__section(.data..page_aligned) __aligned(PAGE_SIZE)
39
#define __page_aligned_bss	__section(.bss..page_aligned) __aligned(PAGE_SIZE)
40

41 42 43 44 45 46
/*
 * For assembly routines.
 *
 * Note when using these that you must specify the appropriate
 * alignment directives yourself
 */
47
#define __PAGE_ALIGNED_DATA	.section ".data..page_aligned", "aw"
48
#define __PAGE_ALIGNED_BSS	.section ".bss..page_aligned", "aw"
49

50 51 52 53 54 55 56 57 58 59 60 61 62
/*
 * This is used by architectures to keep arguments on the stack
 * untouched by the compiler by keeping them live until the end.
 * The argument stack may be owned by the assembly-language
 * caller, not the callee, and gcc doesn't always understand
 * that.
 *
 * We have the return value, and a maximum of six arguments.
 *
 * This should always be followed by a "return ret" for the
 * protection to work (ie no more work that the compiler might
 * end up needing stack temporaries for).
 */
63 64
/* Assembly files may be compiled with -traditional .. */
#ifndef __ASSEMBLY__
65 66
#ifndef asmlinkage_protect
# define asmlinkage_protect(n, ret, args...)	do { } while (0)
Linus Torvalds's avatar
Linus Torvalds committed
67
#endif
68
#endif
Linus Torvalds's avatar
Linus Torvalds committed
69 70 71 72 73 74 75 76

#ifndef __ALIGN
#define __ALIGN		.align 4,0x90
#define __ALIGN_STR	".align 4,0x90"
#endif

#ifdef __ASSEMBLY__

77
#ifndef LINKER_SCRIPT
Linus Torvalds's avatar
Linus Torvalds committed
78 79 80
#define ALIGN __ALIGN
#define ALIGN_STR __ALIGN_STR

81
#ifndef ENTRY
Linus Torvalds's avatar
Linus Torvalds committed
82
#define ENTRY(name) \
83 84 85
	.globl name ASM_NL \
	ALIGN ASM_NL \
	name:
86
#endif
87
#endif /* LINKER_SCRIPT */
Linus Torvalds's avatar
Linus Torvalds committed
88

89 90
#ifndef WEAK
#define WEAK(name)	   \
91
	.weak name ASM_NL   \
92 93 94
	name:
#endif

95 96
#ifndef END
#define END(name) \
97
	.size name, .-name
98 99
#endif

John Reiser's avatar
John Reiser committed
100 101 102 103
/* If symbol 'name' is treated as a subroutine (gets called, and returns)
 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
 * static analysis tools such as stack depth analyzer.
 */
104 105
#ifndef ENDPROC
#define ENDPROC(name) \
106 107
	.type name, @function ASM_NL \
	END(name)
108
#endif
109

Linus Torvalds's avatar
Linus Torvalds committed
110 111 112
#endif

#endif