OSSP CVS Repository

ossp - Check-in [4709]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4709
Date: 2004-Sep-12 14:33:03 (local)
2004-Sep-12 12:33:03 (UTC)
User:rse
Branch:
Comment: Added hard syscall wrappers for send(2) and recv(2).

Obtained from: NetBSD pkgsrc patches

Tickets:
Inspections:
Files:
ossp-pkg/pth/ChangeLog      1.623 -> 1.624     3 inserted, 0 deleted
ossp-pkg/pth/pth_syscall.c      1.31 -> 1.32     48 inserted, 0 deleted

ossp-pkg/pth/ChangeLog 1.623 -> 1.624

--- ChangeLog    2004/09/12 12:18:22     1.623
+++ ChangeLog    2004/09/12 12:33:03     1.624
@@ -21,6 +21,9 @@
                   
   Changes between 2.0.1 and 2.0.2 (13-Jul-2003 to 12-Sep-2004)
 
+   *) Added hard syscall wrappers for send(2) and recv(2).
+      [NetBSD pkgsrc patches]
+
    *) Internally handle errors returned from pth_event() in order
       to pass them upstream to the caller in pth_high.c functions.
       [Ralf S. Engelschall, NetBSD pkgsrc patches]


ossp-pkg/pth/pth_syscall.c 1.31 -> 1.32

--- pth_syscall.c        2004/09/12 12:02:50     1.31
+++ pth_syscall.c        2004/09/12 12:33:03     1.32
@@ -629,6 +629,54 @@
 /* NOTICE: internally fully emulated, so still no
    internal exit point pth_sc_pwrite necessary! */
 
+/* ==== Pth hard syscall wrapper for recv(2) ==== */
+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);
+#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
+}
+
+/* ==== Pth hard syscall wrapper for send(2) ==== */
+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);
+#elif defined(HAVE_SYSCALL) && defined(SYS_sendto)
+    else return (ssize_t)syscall(SYS_sendto, fd, buf, nbytes, flags, (struct sockaddr *)NULL, 0);
+#else
+    else PTH_SYSCALL_ERROR(-1, ENOSYS, "send");
+#endif
+}
+
 /* ==== Pth hard syscall wrapper for recvfrom(2) ==== */
 ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
 ssize_t recvfrom(int fd, void *buf, size_t nbytes, int flags, struct sockaddr *from, socklen_t *fromlen)

CVSTrac 2.0.1