summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/powerpc/bits/syscalls.h
blob: 6168f39066eb841bf07defdaff72a8acd2567de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H

#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif

/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
 * header files.  It also defines the traditional `SYS_<name>' macros for older
 * programs.  */
#include <bits/sysnum.h>


#define __STRINGIFY(s) __STRINGIFY2 (s)
#define __STRINGIFY2(s) #s

#undef JUMPTARGET
#ifdef __PIC__
#define __MAKE_SYSCALL	__STRINGIFY(__uClibc_syscall@plt)
#else
#define __MAKE_SYSCALL	__STRINGIFY(__uClibc_syscall)
#endif

#define unified_syscall_body(name)			\
	__asm__ (					\
	".section \".text\"\n\t"			\
	".align 2\n\t"					\
	".globl " __STRINGIFY(name) "\n\t"		\
	".type " __STRINGIFY(name) ",@function\n\t"	\
	#name":\tli 0," __STRINGIFY(__NR_##name) "\n\t"	\
	"b " __MAKE_SYSCALL "\n\t"		\
	".size\t" __STRINGIFY(name) ",.""-" __STRINGIFY(name) "\n"	\
	)

#undef _syscall0
#define _syscall0(type,name)				\
type name(void);					\
unified_syscall_body(name)

#undef _syscall1
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1);  \
unified_syscall_body(name)

#undef _syscall2
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1, type2 arg2);      \
unified_syscall_body(name)

#undef _syscall3
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1, type2 arg2, type3 arg3);  \
unified_syscall_body(name)

#undef _syscall4
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4);      \
unified_syscall_body(name)

#undef _syscall5
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5);  \
unified_syscall_body(name)

#undef _syscall6
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6);      \
unified_syscall_body(name)

#endif /* _BITS_SYSCALLS_H */