OSSP CVS Repository

ossp - Difference in ossp-pkg/pth/pth_syscall.c versions 1.26 and 1.27
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/pth/pth_syscall.c 1.26 -> 1.27

--- pth_syscall.c        2002/10/25 11:56:16     1.26
+++ pth_syscall.c        2002/11/03 16:53:27     1.27
@@ -27,6 +27,36 @@
                                   forces to help you shoot yourself
                                   in the foot for free.''
                                                  -- Unknown         */
+/*
+ * Prevent system includes from declaring the syscalls in order to avoid
+ * prototype mismatches. In theory those mismatches should not happen
+ * at all, but slight (but still compatible) differences (ssize_t vs.
+ * size_t, etc) can lead to a compile-time failure (although run-time
+ * would be ok). Hence protect ourself from this situation.
+ */
+#define fork          __pth_sys_fork
+#define waitpid       __pth_sys_waitpid
+#define system        __pth_sys_system
+#define sleep         __pth_sys_sleep
+#define sigprocmask   __pth_sys_sigmask
+#define sigwait       __pth_sys_sigwait
+#define select        __pth_sys_select
+#define pselect       __pth_sys_pselect
+#define poll          __pth_sys_poll
+#define connect       __pth_sys_connect
+#define accept        __pth_sys_accept
+#define read          __pth_sys_read
+#define write         __pth_sys_write
+#define readv         __pth_sys_readv
+#define writev        __pth_sys_writev
+#define recv          __pth_sys_recv
+#define send          __pth_sys_send
+#define recvfrom      __pth_sys_recvfrom
+#define sendto        __pth_sys_sendto
+#define pread         __pth_sys_pread
+#define pwrite        __pth_sys_pwrite
+
+/* include the private header and this way system headers */
 #include "pth_p.h"
 
 /* some exported variables for object layer checks */
@@ -49,6 +79,32 @@
 #endif /* PTH_SYSCALL_HARD */
 #endif /* cpp */
 
+/*
+ * Unprotect us from the namespace conflict with the
+ * syscall prototypes in system headers.
+ */
+#undef fork
+#undef waitpid
+#undef system
+#undef sleep
+#undef sigprocmask
+#undef sigwait
+#undef select
+#undef pselect
+#undef poll
+#undef connect
+#undef accept
+#undef read
+#undef write
+#undef readv
+#undef writev
+#undef recv
+#undef send
+#undef recvfrom
+#undef sendto
+#undef pread
+#undef pwrite
+
 /* internal data structures */
 #if cpp
 typedef int (*pth_syscall_fct_t)();
@@ -224,6 +280,7 @@
     } while (0)
 
 /* ==== Pth hard syscall wrapper for fork(2) ==== */
+pid_t fork(void);
 pid_t fork(void)
 {
     /* external entry point for application */
@@ -245,6 +302,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for sleep(3) ==== */
+unsigned int sleep(unsigned int);
 unsigned int sleep(unsigned int sec)
 {
     /* external entry point for application */
@@ -255,6 +313,7 @@
    internal exit point pth_sc_sleep necessary! */
 
 /* ==== Pth hard syscall wrapper for system(3) ==== */
+int system(const char *);
 int system(const char *cmd)
 {
     /* external entry point for application */
@@ -265,6 +324,7 @@
    internal exit point pth_sc_system necessary! */
 
 /* ==== Pth hard syscall wrapper for sigprocmask(2) ==== */
+int sigprocmask(int, const sigset_t *, sigset_t *);
 int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
 {
     /* external entry point for application */
@@ -288,6 +348,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for sigwait(3) ==== */
+int sigwait(const sigset_t *, int *);
 int sigwait(const sigset_t *set, int *sigp)
 {
     /* external entry point for application */
@@ -298,6 +359,7 @@
    internal exit point pth_sc_sigwait necessary! */
 
 /* ==== Pth hard syscall wrapper for waitpid(2) ==== */
+pid_t waitpid(pid_t, int *, int);
 pid_t waitpid(pid_t wpid, int *status, int options)
 {
     /* external entry point for application */
@@ -319,6 +381,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for connect(2) ==== */
+int connect(int, const struct sockaddr *, socklen_t);
 int connect(int s, const struct sockaddr *addr, socklen_t addrlen)
 {
     /* external entry point for application */
@@ -348,6 +411,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for accept(2) ==== */
+int accept(int, struct sockaddr *, socklen_t *);
 int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
 {
     /* external entry point for application */
@@ -377,6 +441,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for select(2) ==== */
+int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 int select(int nfds, fd_set *readfds, fd_set *writefds,
            fd_set *exceptfds, struct timeval *timeout)
 {
@@ -414,6 +479,7 @@
    internal exit point pth_sc_pselect necessary! */
 
 /* ==== Pth hard syscall wrapper for poll(2) ==== */
+int poll(struct pollfd *, nfds_t, int);
 int poll(struct pollfd *pfd, nfds_t nfd, int timeout)
 {
     /* external entry point for application */
@@ -424,6 +490,7 @@
    internal exit point pth_sc_poll necessary! */
 
 /* ==== Pth hard syscall wrapper for read(2) ==== */
+ssize_t read(int, void *, size_t);
 ssize_t read(int fd, void *buf, size_t nbytes)
 {
     /* external entry point for application */
@@ -445,6 +512,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for write(2) ==== */
+ssize_t write(int, const void *, size_t);
 ssize_t write(int fd, const void *buf, size_t nbytes)
 {
     /* external entry point for application */
@@ -466,6 +534,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for readv(2) ==== */
+ssize_t readv(int, const struct iovec *, int);
 ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
 {
     /* external entry point for application */
@@ -487,6 +556,7 @@
 }
 
 /* ==== Pth hard syscall wrapper for writev(2) ==== */
+ssize_t writev(int, const struct iovec *, int);
 ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
 {
     /* external entry point for application */
@@ -530,6 +600,7 @@
    internal exit point pth_sc_pwrite necessary! */
 
 /* ==== 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)
 {
     /* external entry point for application */
@@ -551,6 +622,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)
 {
     /* external entry point for application */

CVSTrac 2.0.1