From ea78f0f77185f7d6d0b2055805139d96e1be816c Mon Sep 17 00:00:00 2001 From: Wichert Akkerman Date: Mon, 29 Nov 1999 15:34:02 +0000 Subject: [PATCH] Add UnixWare support to configure --- ChangeLog | 4 +++ README-svr4 | 7 ----- acconfig.h | 12 ++++++++ aclocal.m4 | 87 ++++++++++++++++++++++++++++++++++++++++++++++++---- configure.in | 12 ++++++++ defs.h | 6 ++-- ioctl.c | 2 +- proc.c | 4 +-- strace.c | 8 ++--- system.c | 2 +- util.c | 4 +-- 11 files changed, 122 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f745ff0..e4621275 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 29 16:33:04 CET 1999 Wichert Akkerman + + * Merge patches from John Hughes to make configure support UnixWare + Sat Nov 27 21:38:17 CET 1999 Wichert Akkerman * Enhance sys_query_module diff --git a/README-svr4 b/README-svr4 index 8f66a7fd..aaf5dff8 100644 --- a/README-svr4 +++ b/README-svr4 @@ -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 diff --git a/acconfig.h b/acconfig.h index 8a9a9c3d..3f63ef12 100644 --- a/acconfig.h +++ b/acconfig.h @@ -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 @@ -30,9 +33,18 @@ /* 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 diff --git a/aclocal.m4 b/aclocal.m4 index de48e660..264d5e3f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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 +#include +#include + +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 #include +#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 ;; *) diff --git a/configure.in b/configure.in index b134dff9..a389676a 100644 --- a/configure.in +++ b/configure.in @@ -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 56e14b2e..d65fc152 100644 --- a/defs.h +++ b/defs.h @@ -82,7 +82,7 @@ #ifdef SVR4 #include -#ifdef SVR4_MP +#ifdef HAVE_MP_PROCFS #include #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 24e84ba8..4e6a416b 100644 --- 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 a6008f90..d4969a6c 100644 --- 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 */ diff --git a/strace.c b/strace.c index f40f5d63..8288d2ab 100644 --- a/strace.c +++ b/strace.c @@ -45,7 +45,7 @@ #ifdef SVR4 #include #include -#ifdef SVR4_MP +#ifdef HAVE_MP_PROCFS #include #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) { diff --git a/system.c b/system.c index 14099a9a..1d0c1630 100644 --- 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 8893039d..32b3fef5 100644 --- 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; -- 2.40.0