File: syscalls-internal.h

package info (click to toggle)
glibc 2.28-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 271,524 kB
  • sloc: ansic: 1,008,513; asm: 259,608; makefile: 11,266; sh: 10,477; python: 6,910; cpp: 4,992; perl: 2,258; awk: 2,005; yacc: 290; pascal: 182; sed: 73
file content (129 lines) | stat: -rw-r--r-- 4,273 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
/* 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;			\
  asm volatile (				\
	"syscall"				\
        : "=a" (result)				\
        : "0" ((long int) SYS_##name),		\
	  "D" (_a1),				\
	  "S" (_a2)				\
	: "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
  result;                                       \
})

#define INTERNAL_SYSCALL_close(name, err, nr, fd) \
(void)({                                        \
  register long int _a1 = (long int) (fd);	\
  register long int result;			\
  asm volatile (				\
	"syscall"				\
        : "=a" (result)				\
        : "0" ((long int) SYS_##name),		\
	  "D" (_a1)				\
	: "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
  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;			\
  asm volatile (				\
	"syscall"				\
        : "=a" (result)				\
        : "0" ((long int) SYS_##name),		\
	  "D" (_a1),				\
	  "S" (_a2)				\
	: "memory", "cc", "cx", "dx", "r8", "r9", "r10", "r11"); \
  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 (				\
	"syscall"				\
        : "=a" (result),			\
          "=d" (_trash)				\
        : "0" ((long int) SYS_##name),		\
	  "D" (_a1),				\
	  "S" (_a2),				\
	  "d" (_a3)				\
          /*  beware rdx is not preserved after syscall */ \
	: "memory", "cc", "cx", "r8", "r9", "r10", "r11"); \
  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 (				\
	"syscall"				\
        : "=a" (result),			\
          "=d" (_trash)				\
        : "0" ((long int) SYS_##name),		\
	  "D" (_a1),				\
	  "S" (_a2),				\
	  "d" (_a3)				\
          /*  beware rdx is not preserved after syscall */ \
	: "memory", "cc", "cx", "r8", "r9", "r10", "r11"); \
  result;                                       \
})

#endif