initial commit
[glibc.git] / sysdeps / unix / bsd / bsd4.4 / kfreebsd / x86_64 / syscalls-internal.h
1 /* generally used "internal syscalls"
2 Copyright (C) 2009 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #ifndef KFREEBSD_INTERNAL_SYSCALLS_H
21 #define KFREEBSD_INTERNAL_SYSCALLS_H
22
23 #include <sys/syscall.h>
24
25 /*
26 for now, we do not care whether syscall succeeded,
27 we do not have defined
28 INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO
29 we do not store errno at all
30 to be sure, we return void
31 */
32
33 #undef INTERNAL_SYSCALL_DECL
34 #undef INTERNAL_SYSCALL_NCS
35 #undef INTERNAL_SYSCALL
36 #undef INTERNAL_SYSCALL_ERROR_P
37 #undef INTERNAL_SYSCALL_ERRNO
38
39 #define INTERNAL_SYSCALL_DECL(err) \
40 do { } while (0)
41
42 #define INTERNAL_SYSCALL(name, err, nr, args...) \
43 INTERNAL_SYSCALL_##name(name, err, nr, ##args)
44
45
46 #define INTERNAL_SYSCALL_clock_gettime(name, err, nr, clkid, ts) \
47 (void)({ \
48 register long int _a1 = (long int) (clkid); \
49 register long int _a2 = (long int) (ts); \
50 register long int result; \
51 asm volatile ( \
52 "syscall" \
53 : "=a" (result) \
54 : "0" ((long int) SYS_##name), \
55 "D" (_a1), \
56 "S" (_a2) \
57 : "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
58 result; \
59 })
60
61 #define INTERNAL_SYSCALL_close(name, err, nr, fd) \
62 (void)({ \
63 register long int _a1 = (long int) (fd); \
64 register long int result; \
65 asm volatile ( \
66 "syscall" \
67 : "=a" (result) \
68 : "0" ((long int) SYS_##name), \
69 "D" (_a1) \
70 : "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
71 result; \
72 })
73
74 #define INTERNAL_SYSCALL_kill(name, err, nr, pid, sig) \
75 (void)({ \
76 register long int _a1 = (long int) (pid); \
77 register long int _a2 = (long int) (sig); \
78 register long int result; \
79 asm volatile ( \
80 "syscall" \
81 : "=a" (result) \
82 : "0" ((long int) SYS_##name), \
83 "D" (_a1), \
84 "S" (_a2) \
85 : "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
86 result; \
87 })
88
89 #define INTERNAL_SYSCALL_write(name, err, nr, fd, buf, cnt) \
90 (void)({ \
91 register long int _a1 = (long int) (fd); \
92 register long int _a2 = (long int) (buf); \
93 register long int _a3 = (long int) (cnt); \
94 register long int result; \
95 register long int _trash; \
96 asm volatile ( \
97 "syscall" \
98 : "=a" (result), \
99 "=d" (_trash) \
100 : "0" ((long int) SYS_##name), \
101 "D" (_a1), \
102 "S" (_a2), \
103 "d" (_a3) \
104 /* beware rdx is not preserved after syscall */ \
105 : "memory", "cc", "cx", "r8", "r9", "r10", "r11"); \
106 result; \
107 })
108
109 #define INTERNAL_SYSCALL_writev(name, err, nr, fd, iov, cnt) \
110 (void)({ \
111 register long int _a1 = (long int) (fd); \
112 register long int _a2 = (long int) (iov); \
113 register long int _a3 = (long int) (cnt); \
114 register long int result; \
115 register long int _trash; \
116 asm volatile ( \
117 "syscall" \
118 : "=a" (result), \
119 "=d" (_trash) \
120 : "0" ((long int) SYS_##name), \
121 "D" (_a1), \
122 "S" (_a2), \
123 "d" (_a3) \
124 /* beware rdx is not preserved after syscall */ \
125 : "memory", "cc", "cx", "r8", "r9", "r10", "r11"); \
126 result; \
127 })
128
129 #endif