]> granicus.if.org Git - strace/blobdiff - stream.c
Change last parameter of umoven() from char* to void*
[strace] / stream.c
index d2b7454d56c839bbb6c699f4c5fd6e87e90d2fb0..3ebbfb731755bbca79351360ef1a17491fbfdb4e 100644 (file)
--- a/stream.c
+++ b/stream.c
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *     $Id$
  */
 
 #include "defs.h"
-#include <sys/syscall.h>
-
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#endif
-#ifdef HAVE_STROPTS_H
-#include <stropts.h>
+#if defined HAVE_POLL_H
+# include <poll.h>
+#elif defined HAVE_SYS_POLL_H
+# include <sys/poll.h>
 #endif
 #ifdef HAVE_SYS_CONF_H
-#include <sys/conf.h>
-#endif
-#ifdef HAVE_SYS_STREAM_H
-#include <sys/stream.h>
-#endif
-#ifdef HAVE_SYS_TIHDR_H
-#include <sys/tihdr.h>
+# include <sys/conf.h>
 #endif
 
+/* Who has STREAMS syscalls?
+ * Linux hasn't. Solaris has (had?).
+ * Just in case I miss something, retain in for Sparc...
+ */
+#if defined(SPARC) || defined(SPARC64)
 
-#ifndef HAVE_STROPTS_H
-#define RS_HIPRI 1
+# ifdef HAVE_STROPTS_H
+#  include <stropts.h>
+# else
+#  define RS_HIPRI 1
 struct strbuf {
        int     maxlen;                 /* no. of bytes in buffer */
        int     len;                    /* no. of bytes returned */
        const char *buf;                /* pointer to data */
 };
-#define MORECTL 1
-#define MOREDATA 2
-#endif /* !HAVE_STROPTS_H */
-
-#ifdef HAVE_SYS_TIUSER_H
-#include <sys/tiuser.h>
-#include <sys/sockmod.h>
-#include <sys/timod.h>
-#endif /* HAVE_SYS_TIUSER_H */
-
-static const struct xlat msgflags[] = {
-       { RS_HIPRI,     "RS_HIPRI"      },
-       { 0,            NULL            },
-};
+#  define MORECTL 1
+#  define MOREDATA 2
+# endif
 
+#include "xlat/msgflags.h"
 
 static void
 printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
@@ -90,7 +73,7 @@ printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
 }
 
 static void
-printstrbufarg(struct tcb *tcp, int arg, int getting)
+printstrbufarg(struct tcb *tcp, long arg, int getting)
 {
        struct strbuf buf;
 
@@ -120,7 +103,6 @@ sys_putmsg(struct tcb *tcp)
        return 0;
 }
 
-#if defined(SPARC) || defined(SPARC64)
 int
 sys_getmsg(struct tcb *tcp)
 {
@@ -166,24 +148,10 @@ sys_getmsg(struct tcb *tcp)
        }
        return RVAL_HEX | RVAL_STR;
 }
-#endif
 
-#if defined SYS_putpmsg || defined SYS_getpmsg
-static const struct xlat pmsgflags[] = {
-#ifdef MSG_HIPRI
-       { MSG_HIPRI,    "MSG_HIPRI"     },
-#endif
-#ifdef MSG_AND
-       { MSG_ANY,      "MSG_ANY"       },
-#endif
-#ifdef MSG_BAND
-       { MSG_BAND,     "MSG_BAND"      },
-#endif
-       { 0,            NULL            },
-};
-#endif
-
-#ifdef SYS_putpmsg
+# if defined SYS_putpmsg || defined SYS_getpmsg
+#include "xlat/pmsgflags.h"
+#  ifdef SYS_putpmsg
 int
 sys_putpmsg(struct tcb *tcp)
 {
@@ -202,9 +170,8 @@ sys_putpmsg(struct tcb *tcp)
        }
        return 0;
 }
-#endif /* SYS_putpmsg */
-
-#ifdef SYS_getpmsg
+#  endif
+#  ifdef SYS_getpmsg
 int
 sys_getpmsg(struct tcb *tcp)
 {
@@ -223,7 +190,7 @@ sys_getpmsg(struct tcb *tcp)
                for (i = 1; i < 3; i++)
                        printstrbufarg(tcp, tcp->u_arg[i], 1);
                /* pointer to band */
-               printnum(tcp, tcp->u_arg[3], "%d");
+               printnum_int(tcp, tcp->u_arg[3], "%d");
                tprints(", ");
                /* pointer to flags */
                if (tcp->u_arg[4] == 0)
@@ -253,35 +220,15 @@ sys_getpmsg(struct tcb *tcp)
        }
        return RVAL_HEX | RVAL_STR;
 }
-#endif /* SYS_getpmsg */
+#  endif
+# endif /* getpmsg/putpmsg */
 
+#endif /* STREAMS syscalls support */
 
 
 #ifdef HAVE_SYS_POLL_H
 
-static const struct xlat pollflags[] = {
-#ifdef POLLIN
-       { POLLIN,       "POLLIN"        },
-       { POLLPRI,      "POLLPRI"       },
-       { POLLOUT,      "POLLOUT"       },
-#ifdef POLLRDNORM
-       { POLLRDNORM,   "POLLRDNORM"    },
-#endif
-#ifdef POLLWRNORM
-       { POLLWRNORM,   "POLLWRNORM"    },
-#endif
-#ifdef POLLRDBAND
-       { POLLRDBAND,   "POLLRDBAND"    },
-#endif
-#ifdef POLLWRBAND
-       { POLLWRBAND,   "POLLWRBAND"    },
-#endif
-       { POLLERR,      "POLLERR"       },
-       { POLLHUP,      "POLLHUP"       },
-       { POLLNVAL,     "POLLNVAL"      },
-#endif
-       { 0,            NULL            },
-};
+#include "xlat/pollflags.h"
 
 static int
 decode_poll(struct tcb *tcp, long pts)
@@ -316,7 +263,7 @@ decode_poll(struct tcb *tcp, long pts)
                                tprints("...");
                                break;
                        }
-                       if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
+                       if (umoven(tcp, cur, sizeof fds, &fds) < 0) {
                                tprints("?");
                                failed = 1;
                                break;
@@ -366,7 +313,7 @@ decode_poll(struct tcb *tcp, long pts)
                outptr = outstr;
 
                for (cur = start; cur < end; cur += sizeof(fds)) {
-                       if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
+                       if (umoven(tcp, cur, sizeof fds, &fds) < 0) {
                                if (outptr < end_outstr - 2)
                                        *outptr++ = '?';
                                failed = 1;
@@ -421,11 +368,11 @@ sys_poll(struct tcb *tcp)
 {
        int rc = decode_poll(tcp, 0);
        if (entering(tcp)) {
-#ifdef INFTIM
+# ifdef INFTIM
                if (tcp->u_arg[2] == INFTIM)
                        tprints("INFTIM");
                else
-#endif
+# endif
                        tprintf("%ld", tcp->u_arg[2]);
        }
        return rc;
@@ -438,7 +385,8 @@ sys_ppoll(struct tcb *tcp)
        if (entering(tcp)) {
                print_timespec(tcp, tcp->u_arg[2]);
                tprints(", ");
-               print_sigset(tcp, tcp->u_arg[3], 0);
+               /* NB: kernel requires arg[4] == NSIG / 8 */
+               print_sigset_addr_len(tcp, tcp->u_arg[3], tcp->u_arg[4]);
                tprintf(", %lu", tcp->u_arg[4]);
        }
        return rc;