summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/h8300/bits/syscalls.h
blob: b43795f2e0009f4c3e9c1c50c0a254a89b22d718 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif

#ifndef __ASSEMBLER__

#include <errno.h>

#define ASMFMT_0
#define ASMFMT_1 , "g"(er1)
#define ASMFMT_2 , "g"(er1), "g"(er2)
#define ASMFMT_3 , "g"(er1), "g"(er2), "g"(er3)
#define ASMFMT_4 , "g"(er1), "g"(er2), "g"(er3), "g"(er4)
#define ASMFMT_5 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "g"(er5)
#define ASMFMT_6 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "m"(er5), "m"(er6)

#define SUBSTITUTE_ARGS_0() do {} while(0);
#define SUBSTITUTE_ARGS_1(arg1)			\
	register long int er1 __asm__("er1") = (long int)arg1;
#define SUBSTITUTE_ARGS_2(arg1, arg2)		\
	register long int er1 __asm__("er1") = (long int)arg1; \
	register long int er2 __asm__("er2") = (long int)arg2;
#define SUBSTITUTE_ARGS_3(arg1, arg2, arg3)	\
	register long int er1 __asm__("er1") = (long int)arg1; \
	register long int er2 __asm__("er2") = (long int)arg2; \
	register long int er3 __asm__("er3") = (long int)arg3;
#define SUBSTITUTE_ARGS_4(arg1, arg2, arg3, arg4)	     \
	register long int er1 __asm__("er1") = (long int)arg1; \
	register long int er2 __asm__("er2") = (long int)arg2; \
	register long int er3 __asm__("er3") = (long int)arg3; \
	register long int er4 __asm__("er4") = (long int)arg4;
#define SUBSTITUTE_ARGS_5(arg1, arg2, arg3, arg4, arg5)   \
	register long int er1 __asm__("er1") = (long int)arg1; \
	register long int er2 __asm__("er2") = (long int)arg2; \
	register long int er3 __asm__("er3") = (long int)arg3; \
	register long int er4 __asm__("er4") = (long int)arg4; \
	register long int er5 __asm__("er5") = (long int)arg5;
#define SUBSTITUTE_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6)	\
	register long int er1 __asm__("er1") = (long int)arg1; \
	register long int er2 __asm__("er2") = (long int)arg2; \
	register long int er3 __asm__("er3") = (long int)arg3; \
	register long int er4 __asm__("er4") = (long int)arg4; \
	long int er5 = (long int)arg5; \
	long int er6 = (long int)arg6;

#define LOAD_ARGS_0
#define LOAD_ARGS_1
#define LOAD_ARGS_2
#define LOAD_ARGS_3
#define LOAD_ARGS_4
#define LOAD_ARGS_5
#define LOAD_ARGS_6	"mov.l er5,@-sp\n\tmov.l %6,er5\n\t" \
			"mov.l er6,@-sp\n\tmov.l %7,er6\n\t"

#define RESTORE_ARGS_0
#define RESTORE_ARGS_1
#define RESTORE_ARGS_2
#define RESTORE_ARGS_3
#define RESTORE_ARGS_4
#define RESTORE_ARGS_5
#define RESTORE_ARGS_6	"mov.l @sp+,er6\n\tmov.l @sp+,er5"

/* The _NCS variant allows non-constant syscall numbers.  */
#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
(__extension__ \
  ({							\
    register long int er0 __asm__ ("er0");		\
    SUBSTITUTE_ARGS_##nr(args)				\
    __asm__ __volatile__ ( 				\
		LOAD_ARGS_##nr				\
		"mov.l %1,er0\n\t"			\
		"trapa #0\n\t"				\
		RESTORE_ARGS_##nr			\
		: "=r" (er0)				\
		: "ir" (name) ASMFMT_##nr		\
		: "memory"				\
    );							\
    (int) er0;						\
   }) \
)

#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */