blob: 12d55e773eb605ff85c67c8cbf8d453697e01871 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_LINKAGE_H
2#define _ASM_X86_LINKAGE_H
Harvey Harrison82f74e72008-01-30 13:31:07 +01003
Cyrill Gorcunovbb7f5f62009-03-09 20:19:51 +03004#include <linux/stringify.h>
5
Ingo Molnar78a99092008-04-17 17:40:51 +02006#undef notrace
7#define notrace __attribute__((no_instrument_function))
8
Harvey Harrison82f74e72008-01-30 13:31:07 +01009#ifdef CONFIG_X86_32
10#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
Ingo Molnard50efc62008-01-30 13:33:00 +010011/*
12 * For 32-bit UML - mark functions implemented in assembly that use
13 * regparm input parameters:
14 */
15#define asmregparm __attribute__((regparm(3)))
Roland McGrath54a01512008-04-10 15:37:38 -070016
Linus Torvaldsd10d89e2008-04-10 17:35:23 -070017/*
18 * Make sure the compiler doesn't do anything stupid with the
19 * arguments on the stack - they are owned by the *caller*, not
20 * the callee. This just fools gcc into not spilling into them,
21 * and keeps it from doing tailcall recursion and/or using the
22 * stack slots for temporaries, since they are live and "used"
23 * all the way to the end of the function.
24 *
25 * NOTE! On x86-64, all the arguments are in registers, so this
26 * only matters on a 32-bit kernel.
27 */
Roland McGrath54a01512008-04-10 15:37:38 -070028#define asmlinkage_protect(n, ret, args...) \
29 __asmlinkage_protect##n(ret, ##args)
30#define __asmlinkage_protect_n(ret, args...) \
31 __asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args)
32#define __asmlinkage_protect0(ret) \
33 __asmlinkage_protect_n(ret)
34#define __asmlinkage_protect1(ret, arg1) \
35 __asmlinkage_protect_n(ret, "g" (arg1))
36#define __asmlinkage_protect2(ret, arg1, arg2) \
37 __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2))
38#define __asmlinkage_protect3(ret, arg1, arg2, arg3) \
39 __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3))
40#define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \
41 __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
42 "g" (arg4))
43#define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \
44 __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
45 "g" (arg4), "g" (arg5))
46#define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \
47 __asmlinkage_protect_n(ret, "g" (arg1), "g" (arg2), "g" (arg3), \
48 "g" (arg4), "g" (arg5), "g" (arg6))
49
Cyrill Gorcunov7ab15242009-03-06 19:08:34 +030050#endif /* CONFIG_X86_32 */
51
52#ifdef __ASSEMBLY__
Harvey Harrison82f74e72008-01-30 13:31:07 +010053
Cyrill Gorcunov95695542009-02-14 00:50:18 +030054#define GLOBAL(name) \
55 .globl name; \
56 name:
57
Cyrill Gorcunovbb7f5f62009-03-09 20:19:51 +030058#if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16)
59#define __ALIGN .p2align 4, 0x90
60#define __ALIGN_STR __stringify(__ALIGN)
Harvey Harrison82f74e72008-01-30 13:31:07 +010061#endif
62
Cyrill Gorcunov7ab15242009-03-06 19:08:34 +030063#endif /* __ASSEMBLY__ */
64
H. Peter Anvin1965aae2008-10-22 22:26:29 -070065#endif /* _ASM_X86_LINKAGE_H */
Harvey Harrison82f74e72008-01-30 13:31:07 +010066