[m-rev.] for review: fix autoconf cross-compilation warning
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Sep 13 03:52:31 AEST 2002
For review by stayl.
Estimated hours taken: 0.75
Branches: main
Eliminate an autoconf warning about checking for file existence
not working with cross compilation.
trace/mercury_trace_internal.c:
Check for the existence of /dev/ptmx at run-time, using access(),
rather than at configure-time.
Also fix a bug where it was calling perror() after the value
of errno had already been clobbered by another system call.
configure.in:
Delete the check for /dev/ptmx.
Add a check for the access() function.
runtime/mercury_conf.h.in:
Delete definition of MR_HAVE_DEV_PTMX.
Add definition of MR_HAVE_ACCESS.
runtime/mercury_conf_bootstrap.h:
Delete references to (MR_)HAVE_DEV_PTMX.
Workspace: /home/ceres/fjh/ws-ceres2/mercury
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.318
diff -u -d -r1.318 configure.in
--- configure.in 12 Sep 2002 17:41:37 -0000 1.318
+++ configure.in 12 Sep 2002 17:42:30 -0000
@@ -470,7 +470,8 @@
snprintf vsnprintf _vsnprintf strerror \
open close dup dup2 fdopen fileno fstat stat isatty \
getpid setpgid fork execlp wait kill \
- grantpt unlockpt ptsname tcgetattr tcsetattr ioctl
+ grantpt unlockpt ptsname tcgetattr tcsetattr ioctl \
+ access
#-----------------------------------------------------------------------------#
# This is also used by MERCURY_CHECK_READLINE in aclocal.m4.
@@ -495,8 +496,6 @@
if test "$MR_HAVE_UCONTEXT_H" != 1; then
mercury_check_for_headers sys/ucontext.h
fi
-#-----------------------------------------------------------------------------#
-AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(MR_HAVE_DEV_PTMX))
#-----------------------------------------------------------------------------#
#
# check the basics of sigaction
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.43
diff -u -d -r1.43 mercury_conf.h.in
--- runtime/mercury_conf.h.in 12 Mar 2002 16:33:31 -0000 1.43
+++ runtime/mercury_conf.h.in 12 Sep 2002 17:36:45 -0000
@@ -145,12 +145,6 @@
#undef MR_HAVE_SYS_STROPTS_H
/*
-** MR_HAVE_DEV_PTMX is defined if /dev/ptmx (used to allocate
-** pseudo-terminals) exists.
-*/
-#undef MR_HAVE_DEV_PTMX
-
-/*
** MR_HAVE_POSIX_TIMES is defined if we have the POSIX
** `struct tms' struct and times() function.
*/
@@ -182,22 +176,22 @@
** MR_HAVE_WAIT we have the wait() function.
** MR_HAVE_KILL we have the kill() function.
** MR_HAVE_GETHOSTNAME we have the gethostname() function.
-** MR_HAVE_SNPRINTF we have the snprintf() function.
-** MR_HAVE_VSNPRINTF we have the vsnprintf() function.
+** MR_HAVE_SNPRINTF we have the snprintf() function.
+** MR_HAVE_VSNPRINTF we have the vsnprintf() function.
** MR_HAVE__VSNPRINTF we have the _vsnprintf() function.
** MR_HAVE_SYSCONF we have the sysconf() system call.
-** MR_HAVE_SIGACTION we have the sigaction() system call.
+** MR_HAVE_SIGACTION we have the sigaction() system call.
** MR_HAVE_GETPAGESIZE we have the getpagesize() system call.
** MR_HAVE_MPROTECT we have the mprotect() system call.
** MR_HAVE_MEMALIGN we have the memalign() function.
** MR_HAVE_STRERROR we have the strerror() function.
** MR_HAVE_SIGINTERRUPT we have the siginterrupt() function.
** MR_HAVE_SETITIMER we have the setitimer() function.
-** MR_HAVE_MEMMOVE we have the memmove() function.
-** MR_HAVE_DLOPEN we have the dlopen() function.
-** MR_HAVE_DLCLOSE we have the dlclose() function.
-** MR_HAVE_DLSYM we have the dlsym() function.
-** MR_HAVE_DLERROR we have the dlerror() function.
+** MR_HAVE_MEMMOVE we have the memmove() function.
+** MR_HAVE_DLOPEN we have the dlopen() function.
+** MR_HAVE_DLCLOSE we have the dlclose() function.
+** MR_HAVE_DLSYM we have the dlsym() function.
+** MR_HAVE_DLERROR we have the dlerror() function.
** MR_HAVE_STAT we have the stat() function.
** MR_HAVE_FSTAT we have the fstat() function.
** MR_HAVE_FDOPEN we have the fdopen() function.
@@ -211,11 +205,12 @@
** #if defined(fileno) || defined(MR_HAVE_FILENO)
** MR_HAVE_ISATTY we have the isatty() function.
** MR_HAVE_GRANTPT we have the grantpt() function.
-** MR_HAVE_UNLOCKPT we have the unlockpt() function.
+** MR_HAVE_UNLOCKPT we have the unlockpt() function.
** MR_HAVE_PTSNAME we have the ptsname() function.
-** MR_HAVE_TCGETATTR we have the tcgetattr() function.
-** MR_HAVE_TCSETATTR we have the tcsetattr() function.
+** MR_HAVE_TCGETATTR we have the tcgetattr() function.
+** MR_HAVE_TCSETATTR we have the tcsetattr() function.
** MR_HAVE_IOCTL we have the ioctl() function.
+** MR_HAVE_ACCESS we have the access() function.
*/
#undef MR_HAVE_GETPID
#undef MR_HAVE_SETPGID
@@ -255,6 +250,7 @@
#undef MR_HAVE_TCGETATTR
#undef MR_HAVE_TCSETATTR
#undef MR_HAVE_IOCTL
+#undef MR_HAVE_ACCESS
/*
** We use mprotect() and signals to catch stack and heap overflows.
Index: runtime/mercury_conf_bootstrap.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_bootstrap.h,v
retrieving revision 1.5
diff -u -d -r1.5 mercury_conf_bootstrap.h
--- runtime/mercury_conf_bootstrap.h 14 Mar 2002 04:31:14 -0000 1.5
+++ runtime/mercury_conf_bootstrap.h 12 Sep 2002 17:37:32 -0000
@@ -287,9 +287,6 @@
#ifdef MR_PC_ACCESS
#define PC_ACCESS MR_PC_ACCESS
#endif
-#ifdef MR_HAVE_DEV_PTMX
- #define HAVE_DEV_PTMX 1
-#endif
#endif /* !MR_NO_CONF_BACKWARDS_COMPAT && !MR_NO_BACKWARDS_COMPAT */
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.137
diff -u -d -r1.137 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 11 Sep 2002 07:20:31 -0000 1.137
+++ trace/mercury_trace_internal.c 12 Sep 2002 17:35:21 -0000
@@ -723,9 +723,9 @@
#if defined(MR_HAVE_OPEN) && defined(O_RDWR) && defined(MR_HAVE_FDOPEN) && \
defined(MR_HAVE_CLOSE) && defined(MR_HAVE_DUP) && \
defined(MR_HAVE_DUP2) && defined(MR_HAVE_FORK) && \
- defined(MR_HAVE_EXECLP) && defined(MR_HAVE_DEV_PTMX) && \
+ defined(MR_HAVE_EXECLP) && \
defined(MR_HAVE_GRANTPT) && defined(MR_HAVE_UNLOCKPT) && \
- defined(MR_HAVE_PTSNAME)
+ defined(MR_HAVE_PTSNAME) && defined(MR_HAVE_ACCESS) && defined(F_OK)
int master_fd = -1;
int slave_fd = -1;
@@ -735,13 +735,26 @@
defined(MR_HAVE_TCSETATTR) && defined(ECHO) && defined(TCSADRAIN)
struct termios termio;
#endif
+
+ /*
+ ** first check whether /dev/ptmx even exists, so that we can give
+ ** a slightly better error message if it doesn't.
+ */
+ if (access("/dev/ptmx", F_OK) != 0) {
+ MR_mdb_perror("can't access /dev/ptmx");
+ MR_mdb_warning(
+ "Sorry, `mdb --window' not supported on this platform.\n");
+ return MR_FALSE;
+ }
+
+ /* OK, /dev/ptmx exists; now go ahead and open it. */
master_fd = open("/dev/ptmx", O_RDWR);
if (master_fd == -1 || grantpt(master_fd) == -1
|| unlockpt(master_fd) == -1)
{
- close(master_fd);
MR_mdb_perror(
"error opening master pseudo-terminal for mdb window");
+ close(master_fd);
return MR_FALSE;
}
if ((slave_name = ptsname(master_fd)) == NULL) {
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list