[m-rev.] diff: fix warnings from runtime on MacOS 10.3
Julien Fischer
juliensf at cs.mu.OZ.AU
Thu Jun 30 11:26:19 AEST 2005
On Wed, 29 Jun 2005, Peter Ross wrote:
> On Wed, Jun 29, 2005 at 04:01:07PM +1000, Julien Fischer wrote:
> > Index: mercury_reg_workarounds.c
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.c,v
> > retrieving revision 1.7
> > diff -u -r1.7 mercury_reg_workarounds.c
> > --- mercury_reg_workarounds.c 15 Dec 2004 06:57:50 -0000 1.7
> > +++ mercury_reg_workarounds.c 29 Jun 2005 05:52:40 -0000
> > @@ -16,6 +16,15 @@
> >
> > #ifdef MR_CAN_DO_PENDING_IO
> >
> > +/*
> > +** Work around for a problem on MacOS 10.3 and earlier.
> > +** The function prototype for bzero() is not visible otherwise.
> > +** This seems to have been fixed in MacOS 10.4.
> > +*/
> > +#if defined(__APPLE__) && (__MACH__)
> > + #include <strings.h>
> > +#endif
> > +
> > #include <sys/types.h> /* for fd_set and FD_ZERO() */
> > #include <sys/time.h> /* for FD_ZERO() */
> >
> It would be much better to add a configure test for the missing bzero,
> and then test to see if including strings.h fixes it.
Done.
Estimated hour taken: 1.5
Branches: main, release
configure.in:
runtime/mercury_conf.h.in:
Add a configuration macro to check for the situation where FD_ZERO
is defined using bzero() but the function prototype for bzero is
not automatically visible, i.e including the header file(s) for FD_ZERO
does not include the one for bzero(). This is a problem on some BSD
based systems, notably some versions of MacOS X.
runtime/mercury_reg_workarounds.c:
Back out my change for the above problem and use the new configuration
macro instead.
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.418
diff -u -r1.418 configure.in
--- configure.in 19 Jun 2005 02:14:16 -0000 1.418
+++ configure.in 30 Jun 2005 01:16:49 -0000
@@ -1868,6 +1868,60 @@
fi
AC_SUBST(MR_CAN_DO_PENDING_IO)
#-----------------------------------------------------------------------------#
+# There is a problem on some BSD based systems that FD_ZERO is defined
+# defined in terms of bzero() but the appropriate header file for bzero()
+# is not automatically included. The following deals with this situation
+# on MacOS 10.3. (It appears to be fixed in MacOS 10.4.)
+
+AC_MSG_CHECKING(to see if strings.h is needed for bzero)
+AC_CACHE_VAL(mercury_cv_bzero_needs_strings_header, [
+
+ save_CC="$CC"
+
+ case $CC in
+ *gcc*) CC="$CC -Wall -Werror" ;;
+ esac
+
+ cat > conftest.c << EOF
+ #ifdef MR_BZERO_NEEDS_STRINGS_HEADER
+ #include <strings.h>
+ #endif
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <unistd.h>
+
+ void MR_fd_zero(fd_set *fdset);
+
+ void
+ MR_fd_zero(fd_set *fdset)
+ {
+ FD_ZERO(fdset);
+ }
+EOF
+
+ if $CC -c conftest.c < /dev/null >&AC_FD_CC 2>&1
+ then
+ mercury_cv_bzero_needs_strings_header=no
+ else
+ if $CC -DMR_BZERO_NEEDS_STRINGS_HEADER -c conftest.c \
+ < /dev/null >&AC_FD_CC 2>&1
+ then
+ mercury_cv_bzero_needs_strings_header=yes
+ else
+ mercury_cv_bzero_needs_strings_header=no
+ fi
+ fi
+
+ rm -f conftest*
+ CC="$save_CC"
+])
+
+AC_MSG_RESULT($mercury_cv_bzero_needs_strings_header)
+if test "$mercury_cv_bzero_needs_strings_header" = yes; then
+ AC_DEFINE(MR_BZERO_NEEDS_STRINGS_HEADER)
+fi
+AC_SUBST(MR_BZERO_NEEDS_STRINGS_HEADER)
+#-----------------------------------------------------------------------------#
#
# On sparc, x86, and probably on other architectures,
# if we're using non-local gotos, then for egcs 1.1, we need
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.50
diff -u -r1.50 mercury_conf.h.in
--- runtime/mercury_conf.h.in 26 Jul 2003 15:22:32 -0000 1.50
+++ runtime/mercury_conf.h.in 30 Jun 2005 01:16:52 -0000
@@ -421,6 +421,13 @@
#undef MR_CAN_DO_PENDING_IO
/*
+** To see if the problem where the function prototype for bzero() is
+** not visible on some BSD based systems can be fixed by #including
+** strings.h.
+*/
+#undef MR_BZERO_NEEDS_STRINGS_HEADER
+
+/*
** MR_USE_EXTERNAL_DEBUGGER:
** Allow MR_trace() to use an external process debugger
** (with communication done via a socket interface)
Index: runtime/mercury_reg_workarounds.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_reg_workarounds.c,v
retrieving revision 1.8
diff -u -r1.8 mercury_reg_workarounds.c
--- runtime/mercury_reg_workarounds.c 29 Jun 2005 06:22:46 -0000 1.8
+++ runtime/mercury_reg_workarounds.c 30 Jun 2005 01:16:52 -0000
@@ -16,14 +16,9 @@
#ifdef MR_CAN_DO_PENDING_IO
-/*
-** Work around for a problem on MacOS 10.3 and earlier.
-** The function prototype for bzero() is not visible otherwise.
-** This seems to have been fixed in MacOS 10.4.
-*/
-#if defined(__APPLE__) && (__MACH__)
- #include <strings.h>
-#endif
+ #ifdef MR_BZERO_NEEDS_STRINGS_HEADER
+ #include <strings.h>
+ #endif
#include <sys/types.h> /* for fd_set and FD_ZERO() */
#include <sys/time.h> /* for FD_ZERO() */
--------------------------------------------------------------------------
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