pkgsrc/devel/pth/patches/patch-ad
wiz 07b7bebeec Adapt syscall name patch for NetBSD>=6.0.
From Yasushi Oshima in PR 49759.
2015-03-21 16:18:12 +00:00

113 lines
3.9 KiB
Text

$NetBSD: patch-ad,v 1.7 2015/03/21 16:18:12 wiz Exp $
Fix syscall names on NetBSD.
--- pth_syscall.c.orig 2006-06-08 17:54:03.000000000 +0000
+++ pth_syscall.c
@@ -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 @@ int pth_syscall_hard = PTH_SYSCALL_HARD;
#undef sendto
#undef pread
#undef pwrite
+#undef wait4
/* internal data structures */
#if cpp
@@ -157,15 +159,28 @@ intern pth_syscall_fct_tab_t pth_syscall
#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 },
+#if defined(__NetBSD__) && defined(SYS___nanosleep50)
+ { "__nanosleep50", NULL },
+#else
{ "nanosleep", NULL },
+#endif
{ "usleep", NULL },
{ "sleep", NULL },
+#if defined(__NetBSD__)
+ { "__sigprocmask14", NULL },
+#else
{ "sigprocmask", NULL },
+#endif
{ "sigwait", NULL },
+#if defined(__NetBSD__) && defined(SYS___select50)
+ { "__select50", NULL },
+#else
{ "select", NULL },
+#endif
{ "poll", NULL },
{ "connect", NULL },
{ "accept", NULL },
@@ -179,6 +194,11 @@ intern pth_syscall_fct_tab_t pth_syscall
{ "sendto", NULL },
{ "pread", NULL },
{ "pwrite", NULL },
+#if defined(__NetBSD__) && defined(SYS___wait450)
+ { "__wait450", NULL },
+#else
+ { "wait4", NULL },
+#endif
{ NULL, NULL }
};
#endif
@@ -405,6 +425,10 @@ intern pid_t pth_sc_waitpid(pid_t wpid,
(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);
+#elif defined(HAVE_SYSCALL) && defined(SYS___wait450)
+ else return (pid_t)syscall(SYS___wait450, wpid, status, options, (struct rusage *) NULL);
#else
else PTH_SYSCALL_ERROR(-1, ENOSYS, "waitpid");
#endif
@@ -491,6 +515,8 @@ intern int pth_sc_select(int nfds, fd_se
else return (int)syscall(SYS__newselect, nfds, readfds, writefds, exceptfds, timeout);
#elif defined(HAVE_SYSCALL) && defined(SYS_select)
else return (int)syscall(SYS_select, nfds, readfds, writefds, exceptfds, timeout);
+#elif defined(HAVE_SYSCALL) && defined(SYS___select50)
+ else return (int)syscall(SYS___select50, nfds, readfds, writefds, exceptfds, timeout);
#else
else PTH_SYSCALL_ERROR(-1, ENOSYS, "accept");
#endif
@@ -721,5 +747,29 @@ intern ssize_t pth_sc_sendto(int fd, con
#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);
+#elif defined(HAVE_SYSCALL) && defined(SYS___wait450)
+ else return (pid_t)syscall(SYS___wait450, wpid, status, options, rusage);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "wait4");
+#endif
+}
+
#endif /* PTH_SYSCALL_HARD */