]> granicus.if.org Git - strace/commitdiff
Add UnixWare support to configure
authorWichert Akkerman <wichert@deephackmode.org>
Mon, 29 Nov 1999 15:34:02 +0000 (15:34 +0000)
committerWichert Akkerman <wichert@deephackmode.org>
Mon, 29 Nov 1999 15:34:02 +0000 (15:34 +0000)
ChangeLog
README-svr4
acconfig.h
aclocal.m4
configure.in
defs.h
ioctl.c
proc.c
strace.c
system.c
util.c

index 6f745ff0ac69e0f921ca8ac288f2db2e392b75ae..e4621275d2c6cdcb9c04a6a668ad29b6c2409e67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Nov 29 16:33:04 CET 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Merge patches from John Hughes to make configure support UnixWare
+
 Sat Nov 27 21:38:17 CET 1999 Wichert Akkerman <wakkerma@debian.org>
 
   * Enhance sys_query_module
index 8f66a7fdf4348e429e03b83e948d14666c9bb371..aaf5dff86969186977e05528260d6dc488dcf987 100644 (file)
@@ -9,13 +9,6 @@ lot of processes at once.
 
 There is no thread support but it wouldn't be very difficult to add it.
 
-There is currently no configure-support yet for UnixWare system. To compile
-on UnixWare 2.1 you need to add the following to config.h yourself:
-
-    #define SVR4_MP 1
-    #define UNIXWARE 2
-    #define HAVE_POLLABLE_PROCFS 1
-
 On UnixWare using the -f option to follow forked children sometimes shows
 many "unfinished" system calls as strace bounces between each runnable child.
 A crude workaround for this is available by adding
index 8a9a9c3d4ef510576fea9845b1cfdf24dec149d1..3f63ef12238f2f93747be2c143cced95fdde6f86 100644 (file)
@@ -9,6 +9,9 @@
    or a derivative like Solaris 2.x or Irix 5.x.  */
 #undef SVR4
 
+/* Define for UnixWare systems. */
+#undef UNIXWARE
+
 /* Define if this is an i386, i486 or pentium architecture.  */
 #undef I386
 
 /* Define if this is an powerpc architecture.  */
 #undef POWERPC
 
+/* Define if you have a SVR4 MP type procfs.  I.E. /dev/xxx/ctl,
+   /dev/xxx/status.  Also implies that you have the pr_lwp
+   member in prstatus. */
+#undef HAVE_MP_PROCFS
+
 /* Define if you have SVR4 and the poll system call works on /proc files.  */
 #undef HAVE_POLLABLE_PROCFS
 
+/* Define if you have SVR4_MP and you need to use the poll hack
+   to avoid unfinished system calls. */
+#undef POLL_HACK
+
 /* Define if the prstatus structure in sys/procfs.h has a pr_syscall member.  */
 #undef HAVE_PR_SYSCALL
 
index de48e6606dd1cb8914d8a18feb09f5d7f3ee69c9..264d5e3fa20c84d182d03594b2cda4c3347d2ff6 100644 (file)
@@ -68,6 +68,66 @@ then
 fi
 ])
 
+dnl ### A macro to determine if we have a "MP" type procfs
+AC_DEFUN(AC_MP_PROCFS,
+[AC_MSG_CHECKING(for MP procfs)
+AC_CACHE_VAL(ac_cv_mp_procfs,
+[AC_TRY_RUN([
+#include <stdio.h>
+#include <signal.h>
+#include <sys/procfs.h>
+
+main()
+{
+       int pid;
+       char proc[32];
+       FILE *ctl;
+       FILE *status;
+       int cmd;
+       struct pstatus pstatus;
+
+       if ((pid = fork()) == 0) {
+               pause();
+               exit(0);
+       }
+       sprintf(proc, "/proc/%d/ctl", pid);
+       if ((ctl = fopen(proc, "w")) == NULL)
+               goto fail;
+       sprintf(proc, "/proc/%d/status", pid);
+       if ((status = fopen (proc, "r")) == NULL)
+               goto fail;
+       cmd = PCSTOP;
+       if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
+               goto fail;
+       if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
+               goto fail;
+       kill(pid, SIGKILL);
+       exit(0);
+fail:
+       kill(pid, SIGKILL);
+       exit(1);
+}
+],
+ac_cv_mp_procfs=yes,
+ac_cv_mp_procfs=no,
+[
+# Guess or punt.
+case "$host_os" in
+svr4.2*|svr5*)
+       ac_cv_mp_procfs=yes
+       ;;
+*)
+       ac_cv_mp_procfs=no
+       ;;
+esac
+])])
+AC_MSG_RESULT($ac_cv_mp_procfs)
+if test "$ac_cv_mp_procfs" = yes
+then
+       AC_DEFINE(HAVE_MP_PROCFS)
+fi
+])
+
 dnl ### A macro to determine if procfs is pollable.
 AC_DEFUN(AC_POLLABLE_PROCFS,
 [AC_MSG_CHECKING(for pollable procfs)
@@ -79,6 +139,21 @@ AC_CACHE_VAL(ac_cv_pollable_procfs,
 #include <sys/stropts.h>
 #include <poll.h>
 
+#ifdef HAVE_MP_PROCFS
+#define PIOCSTOP       PCSTOP
+#define POLLWANT       POLLWRNORM
+#define PROC           "/proc/%d/ctl"
+#define PROC_MODE      "w"
+int IOCTL (int fd, int cmd, int arg) {
+       return write (fd, &cmd, sizeof cmd);
+}
+#else
+#define POLLWANT       POLLPRI
+#define        PROC            "/proc/%d"
+#define PROC_MODE      "r+"
+#define IOCTL          ioctl
+#endif
+
 main()
 {
        int pid;
@@ -90,16 +165,16 @@ main()
                pause();
                exit(0);
        }
-       sprintf(proc, "/proc/%d", pid);
-       if ((pfp = fopen(proc, "r+")) == NULL)
+       sprintf(proc, PROC, pid);
+       if ((pfp = fopen(proc, PROC_MODE)) == NULL)
                goto fail;
-       if (ioctl(fileno(pfp), PIOCSTOP, NULL) < 0)
+       if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
                goto fail;
        pfd.fd = fileno(pfp);
-       pfd.events = POLLPRI;
+       pfd.events = POLLWANT;
        if (poll(&pfd, 1, 0) < 0)
                goto fail;
-       if (!(pfd.revents & POLLPRI))
+       if (!(pfd.revents & POLLWANT))
                goto fail;
        kill(pid, SIGKILL);
        exit(0);
@@ -113,7 +188,7 @@ ac_cv_pollable_procfs=no,
 [
 # Guess or punt.
 case "$host_os" in
-solaris2*|irix5*)
+solaris2*|irix5*|svr4.2uw*|svr5*)
        ac_cv_pollable_procfs=yes
        ;;
 *)
index b134dff97cfbcb04ae0ac444dc32ffb3c7a976d4..a389676a00f16f95e2d9a036ce199ea459dd40c6 100644 (file)
@@ -16,6 +16,9 @@ solaris2*)
 sysv4*)
        opsys=svr4
        ;;
+sysv5*)
+       opsys=svr4
+       ;;
 irix[56]*)
        opsys=svr4
        ;;
@@ -77,11 +80,20 @@ CFLAGS="-D_GNU_SOURCE $CFLAGS"
 AC_CONFIG_HEADER(config.h)
 AC_SUBST(opsys)
 AC_DEFINE_UNQUOTED($OPSYS)
+case "$host_os" in
+sysv4.2uw*)
+       AC_DEFINE(UNIXWARE, 2)
+       ;;
+sysv5*)
+       AC_DEFINE(UNIXWARE, 7)
+       ;;
+esac
 AC_SUBST(arch)
 AC_DEFINE_UNQUOTED($ARCH)
 AC_SUBST(osarch)
 AC_PROG_CC
 AC_PROG_HOSTCC($host_alias $host)
+AC_MP_PROCFS
 AC_POLLABLE_PROCFS
 AC_STRUCT_PR_SYSCALL
 AC_STRUCT_MSG_CONTROL
diff --git a/defs.h b/defs.h
index 56e14b2ecd735f31a6cae8b98faafb41384edcdb..d65fc152c061f444f97d000b754a134058beca73 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -82,7 +82,7 @@
 
 #ifdef SVR4
 #include <sys/procfs.h>
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
 #include <sys/uio.h>
 #endif
 #else /* !SVR4 */
@@ -148,7 +148,7 @@ extern int ptrace();
 
 
 #ifdef SVR4
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
 extern int mp_ioctl (int f, int c, void *a, int s);
 #define IOCTL(f,c,a)   mp_ioctl (f, c, a, sizeof *a)
 #define IOCTL_STATUS(t) \
@@ -204,7 +204,7 @@ struct tcb {
        long inst[2];           /* Instructions on above */
        int pfd;                /* proc file descriptor */
 #ifdef SVR4
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
        int pfd_stat;
        int pfd_as;
        pstatus_t status;
diff --git a/ioctl.c b/ioctl.c
index 24e84ba868b38009ca421205af42ce9bb3f68932..4e6a416be41e2815bce685bec414f797a0bd8bd7 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -108,7 +108,7 @@ long code, arg;
 #endif /* !LINUX */
                return sock_ioctl(tcp, code, arg);
 #ifdef SVR4
-#ifndef SVR4_MP
+#ifndef HAVE_MP_PROCFS
        case 'q':
                return proc_ioctl(tcp, code, arg);
 #endif
diff --git a/proc.c b/proc.c
index a6008f90a1acb9b59606d687606620541cf57a1b..d4969a6cbff2f8bcb2c3f7498a9dd315487142d0 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -30,7 +30,7 @@
 #include "defs.h"
 
 #ifdef SVR4
-#ifndef SVR4_MP
+#ifndef HAVE_MP_PROCFS
 
 static struct xlat proc_status_flags[] = {
        { PR_STOPPED,   "PR_STOPPED"    },
@@ -183,6 +183,6 @@ int code, arg;
        }
 }
 
-#endif /* SVR4_MP */
+#endif /* HAVE_MP_PROCFS */
 #endif /* SVR4 */
 
index f40f5d6348b0e05fc74a7f9a1f124b67f71b9f0d..8288d2abce77264dffc89f11db9536d1f7623e88 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -45,7 +45,7 @@
 #ifdef SVR4
 #include <sys/stropts.h>
 #include <poll.h>
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
 #include <sys/uio.h>
 #endif
 #endif
@@ -108,7 +108,7 @@ static int proc_poll_pipe[2] = { -1, -1 };
 
 #endif /* !HAVE_POLLABLE_PROCFS */
 
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
 #define POLLWANT       POLLWRNORM
 #else
 #define POLLWANT       POLLPRI
@@ -581,7 +581,7 @@ int attaching;
        static int last_pfd;
 #endif
 
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
        /* Open the process pseudo-files in /proc. */
        sprintf(proc, "/proc/%d/ctl", tcp->pid);
        if ((tcp->pfd = open(proc, O_WRONLY|O_EXCL)) < 0) {
@@ -1736,7 +1736,7 @@ struct tcb *tcp;
        tcp_last = NULL;
 }
 
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
 
 int mp_ioctl (int fd, int cmd, void *arg, int size) {
 
index 14099a9a32aadc02122c3bc0d3fd327d6699429a..1d0c1630486eb6a0afc2d2a6c695344d01e94870 100644 (file)
--- a/system.c
+++ b/system.c
@@ -1356,7 +1356,7 @@ struct tcb *tcp;
        }
        return 0;
 }
-#endif /* !SVR4_MP */
+#endif /* !UNIXWARE */
 
 #endif /* !MIPS */
 
diff --git a/util.c b/util.c
index 8893039d4a8cc01b72f9f9f7a688a7f8d2c60403..32b3fef5c8981cda87f24fea0bdaa95b0bb8e8f7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -624,7 +624,7 @@ char *laddr;
 #endif /* SUNOS4 */
 
 #ifdef SVR4
-#ifdef SVR4_MP
+#ifdef HAVE_MP_PROCFS
        if (pread(tcp->pfd_as, laddr, len, addr) == -1)
                return -1;
 #else
@@ -643,7 +643,7 @@ char *laddr;
        if (read(tcp->pfd, laddr, len) == -1)
                return -1;
 #endif /* !HAVE_PREAD */
-#endif /* SVR4_MP */
+#endif /* HAVE_MP_PROCFS */
 #endif /* SVR4 */
 
        return 0;