File: syscalls-internal.h

package info (click to toggle)
glibc 2.31-13%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 278,368 kB
  • sloc: ansic: 1,025,361; asm: 256,790; makefile: 12,097; sh: 10,548; python: 9,618; cpp: 5,233; awk: 1,956; perl: 514; yacc: 290; pascal: 182; sed: 73
file content (157 lines) | stat: -rw-r--r-- 6,256 bytes parent folder | download | duplicates (31)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* generally used "internal syscalls"
   Copyright (C) 2009 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#ifndef KFREEBSD_INTERNAL_SYSCALLS_H
#define KFREEBSD_INTERNAL_SYSCALLS_H

#include <sys/syscall.h>

/* 
   for now, we do not care whether syscall succeeded,
   we do not have defined 
   INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO
   we do not store errno at all
   to be sure, we return void
*/

#undef INTERNAL_SYSCALL_DECL
#undef INTERNAL_SYSCALL_NCS
#undef INTERNAL_SYSCALL
#undef INTERNAL_SYSCALL_ERROR_P
#undef INTERNAL_SYSCALL_ERRNO

#define INTERNAL_SYSCALL_DECL(err)		\
  do { } while (0)

#define INTERNAL_SYSCALL(name, err, nr, args...) \
  INTERNAL_SYSCALL_##name(name, err, nr, ##args)


#define INTERNAL_SYSCALL_clock_gettime(name, err, nr, clkid, ts) \
(void)({                                        \
  register long int _a1 = (long int) (clkid);	\
  register long int _a2 = (long int) (ts);	\
  register long int result;			\
  register long int _trash;			\
  asm volatile (                                \
                "pushl %4\n\t"                  \
                "pushl %3\n\t"                  \
                "pushl %2\n\t"                  \
                "int $0x80\n\t"                 \
                "addl $12,%%esp\n\t"		\
                : "=a" (result),		\
                  "=d" (_trash)                 \
                : "0" ((long int) SYS_##name),	\
                  "ri" (_a1),			\
                  "ri" (_a2)			\
                : "memory", "cc" );             \
  result;                                       \
})

#define INTERNAL_SYSCALL_close(name, err, nr, fd) \
(void)({                                        \
  register long int _a1 = (long int) (fd);	\
  register long int result;			\
  asm volatile (                                \
                "pushl %2\n\t"                  \
                "pushl %1\n\t"                  \
                "int $0x80\n\t"                 \
                "popl %2\n\t"                   \
                "popl %2\n\t"                   \
                : "=a" (result)                 \
                : "0" ((long int) SYS_##name),	\
                  "d" (_a1)                   	\
                : "memory", "cc" );             \
  result;                                       \
})

#define INTERNAL_SYSCALL_kill(name, err, nr, pid, sig) \
(void)({                                        \
  register long int _a1 = (long int) (pid);	\
  register long int _a2 = (long int) (sig);	\
  register long int result;			\
  register long int _trash;			\
  asm volatile (                                \
                "pushl %4\n\t"                  \
                "pushl %3\n\t"                  \
                "pushl %2\n\t"                  \
                "int $0x80\n\t"                 \
                "addl $12,%%esp\n\t"		\
                : "=a" (result),		\
                  "=d" (_trash)                 \
                : "0" ((long int) SYS_##name),	\
                  "ri" (_a1),			\
                  "ri" (_a2)			\
                : "memory", "cc" );             \
  result;                                       \
})

#define INTERNAL_SYSCALL_write(name, err, nr, fd, buf, cnt) \
(void)({                                        \
  register long int _a1 = (long int) (fd);	\
  register long int _a2 = (long int) (buf);	\
  register long int _a3 = (long int) (cnt);	\
  register long int result;			\
  register long int _trash;			\
  asm volatile (                                \
                "pushl %5\n\t"                  \
                "pushl %4\n\t"                  \
                "pushl %3\n\t"                  \
                "pushl %2\n\t"                  \
                "int $0x80\n\t"                 \
                "addl $16,%%esp\n\t"		\
                : "=a" (result),		\
                  "=d" (_trash)                 \
                : "0" ((long int) SYS_##name),	\
                  "ri" (_a1),			\
                  "ri" (_a2),			\
                  "ri" (_a3)			\
              /*   may be even "g" constraint could be used */ \
              /*   but we have to worry about esp register and esp based address */ \
                : "memory", "cc" );             \
  result;                                       \
})

#define INTERNAL_SYSCALL_writev(name, err, nr, fd, iov, cnt) \
(void)({                                        \
  register long int _a1 = (long int) (fd);	\
  register long int _a2 = (long int) (iov);	\
  register long int _a3 = (long int) (cnt);	\
  register long int result;			\
  register long int _trash;			\
  asm volatile (                                \
                "pushl %5\n\t"                  \
                "pushl %4\n\t"                  \
                "pushl %3\n\t"                  \
                "pushl %2\n\t"                  \
                "int $0x80\n\t"                 \
                "addl $16,%%esp\n\t"		\
                : "=a" (result),		\
                  "=d" (_trash)                 \
                : "0" ((long int) SYS_##name),	\
                  "ri" (_a1),			\
                  "ri" (_a2),			\
                  "ri" (_a3)			\
              /*   may be even "g" constraint could be used */ \
              /*   but we have to worry about esp register and esp based address */ \
                : "memory", "cc" );             \
  result;                                       \
})

#endif