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
|
$NetBSD: patch-ad,v 1.4 2003/05/02 11:49:48 wiz Exp $
--- pth_syscall.c.orig 2003-01-01 16:45:06.000000000 +0100
+++ pth_syscall.c 2003-04-15 14:31:43.000000000 +0200
@@ -57,6 +57,7 @@
#define sendto __pth_sys_sendto
#define pread __pth_sys_pread
#define pwrite __pth_sys_pwrite
+#define wait4 __pth_sys_wait4
/* include the private header and this way system headers */
#include "pth_p.h"
@@ -108,6 +109,7 @@
#undef sendto
#undef pread
#undef pwrite
+#undef wait4
/* internal data structures */
#if cpp
@@ -157,13 +159,18 @@
#define PTH_SCF_sendto 19
#define PTH_SCF_pread 20
#define PTH_SCF_pwrite 21
+#define PTH_SCF_wait4 22
{ "fork", NULL },
{ "waitpid", NULL },
{ "system", NULL },
{ "nanosleep", NULL },
{ "usleep", NULL },
{ "sleep", NULL },
+#if defined(__NetBSD__)
+ { "__sigprocmask14", NULL },
+#else
{ "sigprocmask", NULL },
+#endif
{ "sigwait", NULL },
{ "select", NULL },
{ "poll", NULL },
@@ -179,6 +186,7 @@
{ "sendto", NULL },
{ "pread", NULL },
{ "pwrite", NULL },
+ { "wait4", NULL },
{ NULL, NULL }
};
#endif
@@ -651,6 +659,48 @@
#endif
}
+ssize_t recv(int, void *, size_t, int);
+ssize_t recv(int fd, void *buf, size_t nbytes, int flags)
+{
+ /* external entry point for application */
+ pth_implicit_init();
+ return pth_recv(fd, buf, nbytes, flags);
+}
+intern ssize_t pth_sc_recv(int fd, void *buf, size_t nbytes, int flags)
+{
+ /* internal exit point for Pth */
+ if (pth_syscall_fct_tab[PTH_SCF_recv].addr != NULL)
+ return ((ssize_t (*)(int, void *, size_t, int))
+ pth_syscall_fct_tab[PTH_SCF_recv].addr)
+ (fd, buf, nbytes, flags);
+#if defined(HAVE_SYSCALL) && defined(SYS_recv)
+ else return (ssize_t)syscall(SYS_recv, fd, buf, nbytes, flags);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "recv");
+#endif
+}
+
+ssize_t send(int, void *, size_t, int);
+ssize_t send(int fd, void *buf, size_t nbytes, int flags)
+{
+ /* external entry point for application */
+ pth_implicit_init();
+ return pth_send(fd, buf, nbytes, flags);
+}
+intern ssize_t pth_sc_send(int fd, void *buf, size_t nbytes, int flags)
+{
+ /* internal exit point for Pth */
+ if (pth_syscall_fct_tab[PTH_SCF_send].addr != NULL)
+ return ((ssize_t (*)(int, void *, size_t, int))
+ pth_syscall_fct_tab[PTH_SCF_send].addr)
+ (fd, buf, nbytes, flags);
+#if defined(HAVE_SYSCALL) && defined(SYS_send)
+ else return (ssize_t)syscall(SYS_send, fd, buf, nbytes, flags);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "send");
+#endif
+}
+
/* ==== Pth hard syscall wrapper for sendto(2) ==== */
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
ssize_t sendto(int fd, const void *buf, size_t nbytes, int flags, const struct sockaddr *to, socklen_t tolen)
@@ -664,7 +714,7 @@
/* internal exit point for Pth */
if (pth_syscall_fct_tab[PTH_SCF_sendto].addr != NULL)
return ((ssize_t (*)(int, const void *, size_t, int, const struct sockaddr *, socklen_t))
- pth_syscall_fct_tab[PTH_SCF_recvfrom].addr)
+ pth_syscall_fct_tab[PTH_SCF_sendto].addr)
(fd, buf, nbytes, flags, to, tolen);
#if defined(HAVE_SYSCALL) && defined(SYS_sendto)
else return (ssize_t)syscall(SYS_sendto, fd, buf, nbytes, flags, to, tolen);
@@ -673,5 +723,27 @@
#endif
}
+/* ==== Pth hard syscall wrapper for wait4(2) ==== */
+pid_t wait4(pid_t, int *, int, struct rusage *);
+pid_t wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
+{
+ /* external entry point for application */
+ pth_implicit_init();
+ return pth_wait4(wpid, status, options, rusage);
+}
+intern pid_t pth_sc_wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
+{
+ /* internal exit point for Pth */
+ if (pth_syscall_fct_tab[PTH_SCF_wait4].addr != NULL)
+ return ((pid_t (*)(pid_t, int *, int, struct rusage *))
+ pth_syscall_fct_tab[PTH_SCF_wait4].addr)
+ (wpid, status, options, rusage);
+#if defined(HAVE_SYSCALL) && defined(SYS_wait4)
+ else return (pid_t)syscall(SYS_wait4, wpid, status, options, rusage);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "wait4");
+#endif
+}
+
#endif /* PTH_SYSCALL_HARD */
|