Subject: pkg/24704: devel/pth: add support for waitpid(), send(), and recv()
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itohy@netbsd.org>
List: netbsd-bugs
Date: 03/08/2004 18:11:04
>Number: 24704
>Category: pkg
>Synopsis: devel/pth: add support for waitpid(), send(), and recv()
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Mar 08 09:12:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: ITOH Yasufumi
>Release: NetBSD 1.6L
>Organization:
>Environment:
System: NetBSD pino.my.domain 1.6L NetBSD 1.6L (PINO) #380: Mon Jun 9 20:33:32 JST 2003 itohy@pino.my.domain:/remote/fmv.w/src/sys/arch/i386/compile/PINO i386
Architecture: i386
Machine: i386
>Description:
GNU pth package (devel/pth) doesn't provide
waitpid(), recv(), send() on NetBSD.
>How-To-Repeat:
Install devel/pth package, then,
% ed test.c
test.c: No such file or directory
a
main()
{
int status;
return waitpid(1, &status, 0);
}
.
w
56
q
% cc -I/usr/pkg/include test.c -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lpth
% ./a.out
pth:WARNING: unable to perform syscall `waitpid': no implementation resolvable
%
>Fix:
Here's patch to patches/patch-ad.
Index: patches/patch-ad
===================================================================
RCS file: /cvsroot/pkgsrc/devel/pth/patches/patch-ad,v
retrieving revision 1.4
diff -u -r1.4 patch-ad
--- patches/patch-ad 2 May 2003 11:49:48 -0000 1.4
+++ patches/patch-ad 8 Mar 2004 05:02:56 -0000
@@ -1,7 +1,7 @@
$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
+--- pth_syscall.c.orig Wed Jan 1 15:45:06 2003
++++ pth_syscall.c Mon Mar 8 04:12:44 2004
@@ -57,6 +57,7 @@
#define sendto __pth_sys_sendto
#define pread __pth_sys_pread
@@ -45,7 +45,16 @@
{ NULL, NULL }
};
#endif
-@@ -651,6 +659,48 @@
+@@ -405,6 +413,8 @@
+ (wpid, status, options);
+ #if defined(HAVE_SYSCALL) && defined(SYS_waitpid)
+ else return (pid_t)syscall(SYS_waitpid, wpid, status, options);
++#elif defined(HAVE_SYSCALL) && defined(SYS_wait4)
++ else return (pid_t)syscall(SYS_wait4, wpid, status, options, (struct rusage *) NULL);
+ #else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "waitpid");
+ #endif
+@@ -651,6 +661,52 @@
#endif
}
@@ -65,6 +74,8 @@
+ (fd, buf, nbytes, flags);
+#if defined(HAVE_SYSCALL) && defined(SYS_recv)
+ else return (ssize_t)syscall(SYS_recv, fd, buf, nbytes, flags);
++#elif defined(HAVE_SYSCALL) && defined(SYS_recvfrom)
++ else return (ssize_t)syscall(SYS_recvfrom, fd, buf, nbytes, flags, (struct sockaddr *) NULL, (socklen_t *) NULL);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "recv");
+#endif
@@ -86,6 +97,8 @@
+ (fd, buf, nbytes, flags);
+#if defined(HAVE_SYSCALL) && defined(SYS_send)
+ else return (ssize_t)syscall(SYS_send, fd, buf, nbytes, flags);
++#elif defined(HAVE_SYSCALL) && defined(SYS_sendto)
++ else return (ssize_t)syscall(SYS_sendto, fd, buf, nbytes, flags, (struct sockaddr *) NULL, NULL);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "send");
+#endif
@@ -94,7 +107,7 @@
/* ==== 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 @@
+@@ -664,12 +720,34 @@
/* 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))
@@ -103,10 +116,11 @@
(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
- }
-
+ #else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "sendto");
++#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)
@@ -126,8 +140,6 @@
+ else return (pid_t)syscall(SYS_wait4, wpid, status, options, rusage);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "wait4");
-+#endif
-+}
-+
- #endif /* PTH_SYSCALL_HARD */
+ #endif
+ }
>Release-Note:
>Audit-Trail:
>Unformatted: