[m-rev.] for review: begin breaking up configure.in

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Oct 25 15:21:31 AEST 2006


Estimated hours taken: 1.5
Branches: main

Move some of the Mercury specific autoconf tests from configure.in into
aclocal.m4.  In addition to simplifying the top-level configuration file
this change is also necessary because we will probably need a different
top-level configuration script for configuring mmc as a cross-compiler and
at some point it would also be good to use autoconf to configure the
extras distribution; both of those tasks require access to at least some
of the macros that are currently defined in configure.in.

configure.in:
aclocal.m4:
 	Move some of the Mercury specific autoconf tests from configure.into
 	aclocal.m4.

Julien.

Index: aclocal.m4
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.25
diff -u -r1.25 aclocal.m4
--- aclocal.m4	1 Feb 2006 12:10:16 -0000	1.25
+++ aclocal.m4	25 Oct 2006 05:12:52 -0000
@@ -8,11 +8,1148 @@
  #
  # This file contains Mercury-specific autoconf tests.
  #
-# We ought to move most of the code in configure.in into this file...
+#-----------------------------------------------------------------------------#
+#
+# Define a macro MERCURY_MSG, similar to AC_MSG_RESULT, for displaying output.
  #
+dnl MERCURY_MSG(MESSAGE)
+define(MERCURY_MSG,
+[echo $1 1>&AC_FD_MSG])
+
  #-----------------------------------------------------------------------------#
-AC_DEFUN(MERCURY_CHECK_FOR_HEADERS,
-[
+
+AC_DEFUN(MERCURY_WORD_TYPE, [
+AC_MSG_CHECKING(for an integer type with the same size as a pointer)
+AC_CACHE_VAL(mercury_cv_word_type,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(int) == sizeof(void *))
+		{
+			fprintf(fp, "int\n");
+			exit(0);
+		}
+
+		if (sizeof(long) == sizeof(void *))
+		{
+			fprintf(fp, "long\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_word_type=`cat conftest.tags`],
+	[mercury_cv_word_type=unknown],
+	[mercury_cv_word_type=unknown])
+)
+if test "$mercury_cv_word_type" = unknown; then
+	AC_TRY_RUN([
+	#include <stdio.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(long long) == sizeof(void *))
+		{
+			fprintf(fp, "long long\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_word_type=`cat conftest.tags`],
+	[mercury_cv_word_type=unknown],
+	[mercury_cv_word_type=unknown])
+fi
+AC_MSG_RESULT($mercury_cv_word_type)
+AC_DEFINE_UNQUOTED(MR_WORD_TYPE, $mercury_cv_word_type)
+MR_WORD_TYPE=$mercury_cv_word_type
+AC_SUBST(MR_WORD_TYPE)
+
+if test "$mercury_cv_word_type" = int; then
+	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "")
+elif test "$mercury_cv_word_type" = long; then
+	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "l")
+elif test "$mercury_cv_word_type" = "long long"; then
+	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "ll")
+else
+	AC_MSG_ERROR(Cannot determine the length modifier for the MR_Integer type.)
+fi
+AC_SUBST(MR_INTEGER_LENGTH_MODIFIER)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_INT_LEAST64_TYPE, [
+AC_MSG_CHECKING(for an integer type of at least 64 bits)
+AC_CACHE_VAL(mercury_cv_int_least64_type,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <limits.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(int) * CHAR_BIT >= 64)
+		{
+			fprintf(fp, "int\n");
+			exit(0);
+		}
+
+		if (sizeof(long) * CHAR_BIT >= 64)
+		{
+			fprintf(fp, "long\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_int_least64_type=`cat conftest.tags`],
+	[mercury_cv_int_least64_type=unknown],
+	[mercury_cv_int_least64_type=unknown])
+)
+if test "$mercury_cv_int_least64_type" = unknown; then
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <limits.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(long long) * CHAR_BIT >= 64)
+		{
+			fprintf(fp, "long long\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_int_least64_type=`cat conftest.tags`],
+	[mercury_cv_int_least64_type=unknown],
+	[mercury_cv_int_least64_type=unknown])
+fi
+# Uncomment the following line to test how the system behaves
+# in the absence of a 64-bit integer type.
+# mercury_cv_int_least64_type=unknown
+AC_MSG_RESULT($mercury_cv_int_least64_type)
+if test "$mercury_cv_int_least64_type" != unknown; then
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST64_TYPE, $mercury_cv_int_least64_type)
+	MR_INT_LEAST64_TYPE=$mercury_cv_int_least64_type
+	AC_SUBST(MR_INT_LEAST64_TYPE)
+fi
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_INT_LEAST32_TYPE, [
+AC_MSG_CHECKING(for an integer type of at least 32 bits)
+AC_CACHE_VAL(mercury_cv_int_least32_type,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <limits.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(int) * CHAR_BIT >= 32)
+		{
+			fprintf(fp, "int\n");
+			exit(0);
+		}
+
+		if (sizeof(long) * CHAR_BIT >= 32)
+		{
+			fprintf(fp, "long\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_int_least32_type=`cat conftest.tags`],
+	[mercury_cv_int_least32_type=unknown],
+	[mercury_cv_int_least32_type=unknown])
+)
+AC_MSG_RESULT($mercury_cv_int_least32_type)
+AC_DEFINE_UNQUOTED(MR_INT_LEAST32_TYPE, $mercury_cv_int_least32_type)
+MR_INT_LEAST32_TYPE=$mercury_cv_int_least32_type
+AC_SUBST(MR_INT_LEAST32_TYPE)
+
+if test "$mercury_cv_int_least32_type" = int; then
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, INT_MAX)
+	AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, UINT_MAX)
+elif test "$mercury_cv_int_least32_type" = long; then
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, LONG_MAX)
+	AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, ULONG_MAX)
+else
+	AC_MSG_ERROR(
+[Cannot find the name of the max values
+	for MR_INT_LEAST32_TYPE.])
+fi
+AC_SUBST(MR_INT_LEAST32_MAX)
+AC_SUBST(MR_UINT_LEAST32_MAX)
+]) 
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_INT_LEAST16_TYPE, [
+AC_MSG_CHECKING(for an integer type of at least 16 bits)
+AC_CACHE_VAL(mercury_cv_int_least16_type,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <limits.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(short) * CHAR_BIT >= 16)
+		{
+			fprintf(fp, "short\n");
+			exit(0);
+		}
+
+		if (sizeof(int) * CHAR_BIT >= 16)
+		{
+			fprintf(fp, "int\n");
+			exit(0);
+		}
+
+		fprintf(fp, "unknown\n");
+		exit(1);
+	}],
+	[mercury_cv_int_least16_type=`cat conftest.tags`],
+	[mercury_cv_int_least16_type=unknown],
+	[mercury_cv_int_least16_type=unknown])
+)
+AC_MSG_RESULT($mercury_cv_int_least16_type)
+AC_DEFINE_UNQUOTED(MR_INT_LEAST16_TYPE, $mercury_cv_int_least16_type)
+MR_INT_LEAST16_TYPE=$mercury_cv_int_least16_type
+AC_SUBST(MR_INT_LEAST16_TYPE)
+
+if test "$mercury_cv_int_least16_type" = short; then
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, SHRT_MAX)
+	AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, USHRT_MAX)
+elif test "$mercury_cv_int_least16_type" = int; then
+	AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, INT_MAX)
+	AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, UINT_MAX)
+else
+	AC_MSG_ERROR(Cannot find the name of the max value for MR_INT_LEAST16_TYPE.)
+fi
+AC_SUBST(MR_INT_LEAST16_MAX)
+AC_SUBST(MR_UINT_LEAST16_MAX)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_LOW_TAG_BITS, [
+AC_MSG_CHECKING(the number of low tag bits available)
+AC_CACHE_VAL(mercury_cv_low_tag_bits,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <stdlib.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.tags", "w");
+		if (fp == NULL)
+			exit(1);
+
+		if (sizeof(void *) == 4)
+		{
+			fprintf(fp, "2\n");
+			exit(0);
+		}
+		if (sizeof(void *) == 8)
+		{
+			fprintf(fp, "3\n");
+			exit(0);
+		}
+		if (sizeof(void *) == 16)
+		{
+			fprintf(fp, "4\n");
+			exit(0);
+		}
+		fprintf(fp, "0\n");
+		exit(1);
+	}],
+	[mercury_cv_low_tag_bits=`cat conftest.tags`],
+	[mercury_cv_low_tag_bits=0],
+	[mercury_cv_low_tag_bits=0])
+)
+AC_MSG_RESULT($mercury_cv_low_tag_bits)
+if test "$mercury_cv_low_tag_bits" -lt 2; then
+	if test "$BOOTSTRAP_MC" = ""; then
+		AC_MSG_ERROR(cannot bootstrap: low tag bits less than 2)
+		exit 1
+	fi
+fi
+if test "$mercury_cv_low_tag_bits" -gt 2; then
+	if test "$BOOTSTRAP_MC" = ""; then
+		AC_MSG_WARN(bootstrapping using only 2 low tag bits)
+		mercury_cv_low_tag_bits=2
+	fi
+fi
+AC_DEFINE_UNQUOTED(MR_LOW_TAG_BITS, $mercury_cv_low_tag_bits)
+LOW_TAG_BITS=$mercury_cv_low_tag_bits
+AC_SUBST(LOW_TAG_BITS)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_BYTES_PER_WORD, [
+AC_MSG_CHECKING(the number of bytes per word)
+AC_CACHE_VAL(mercury_cv_bytes_per_word,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <stdlib.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.wordbytes", "w");
+		if (fp == NULL)
+			exit(1);
+		fprintf(fp, "%d\n", sizeof(void *));
+
+		exit(0);
+	}],
+	[mercury_cv_bytes_per_word=`cat conftest.wordbytes`],
+	[mercury_cv_bytes_per_word=0],
+	[mercury_cv_bytes_per_word=0])
+)
+AC_MSG_RESULT($mercury_cv_bytes_per_word)
+AC_DEFINE_UNQUOTED(MR_BYTES_PER_WORD, $mercury_cv_bytes_per_word)
+BYTES_PER_WORD=$mercury_cv_bytes_per_word
+AC_SUBST(BYTES_PER_WORD)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_SYNC_TERM_SIZE, [
+AC_MSG_CHECKING(the number of words in a synchronization term)
+AC_CACHE_VAL(mercury_cv_sync_term_size,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <stdlib.h>
+	#include <pthread.h>
+	int main() {
+		struct {
+			pthread_mutex_t lock;
+			void		*orig_context;
+			int		count;
+			void		*parent;
+		} x;
+		FILE *fp;
+
+		fp = fopen("conftest.syncsize", "w");
+		if (fp == NULL)
+			exit(1);
+		fprintf(fp, "%d\n", (sizeof(void *) - 1 + sizeof(x))/
+				sizeof(void *));
+
+		exit(0);
+	}],
+	[mercury_cv_sync_term_size=`cat conftest.syncsize`],
+	[mercury_cv_sync_term_size=0],
+	[mercury_cv_sync_term_size=0])
+)
+AC_MSG_RESULT($mercury_cv_sync_term_size)
+AC_DEFINE_UNQUOTED(MR_SYNC_TERM_SIZE, $mercury_cv_sync_term_size)
+SYNC_TERM_SIZE=$mercury_cv_sync_term_size
+AC_SUBST(SYNC_TERM_SIZE)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_BITS_PER_WORD, [
+AC_MSG_CHECKING(the number of bits per word)
+AC_CACHE_VAL(mercury_cv_bits_per_word,
+	AC_TRY_RUN([
+	#include <stdio.h>
+	#include <stdlib.h>
+	#include <limits.h>
+	int main() {
+		FILE *fp;
+
+		fp = fopen("conftest.wordbits", "w");
+		if (fp == NULL)
+			exit(1);
+		fprintf(fp, "%d\n", CHAR_BIT * sizeof(void *));
+
+		exit(0);
+	}],
+	[mercury_cv_bits_per_word=`cat conftest.wordbits`],
+	[mercury_cv_bits_per_word=0],
+	[mercury_cv_bits_per_word=0])
+)
+AC_MSG_RESULT($mercury_cv_bits_per_word)
+AC_DEFINE_UNQUOTED(MR_BITS_PER_WORD, $mercury_cv_bits_per_word)
+BITS_PER_WORD=$mercury_cv_bits_per_word
+AC_SUBST(BITS_PER_WORD)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_UNBOXED_FLOATS, [
+AC_MSG_CHECKING(whether we can use unboxed floats)
+AC_CACHE_VAL(mercury_cv_unboxed_floats,
+	AC_TRY_RUN([
+	int main() {
+		if (sizeof(double) == sizeof(void *))
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_unboxed_floats=yes],
+	[mercury_cv_unboxed_floats=no],
+	[mercury_cv_unboxed_floats=no])
+)
+AC_MSG_RESULT($mercury_cv_unboxed_floats)
+if test "$mercury_cv_unboxed_floats" = yes; then
+	if test "$BOOTSTRAP_MC" = ""; then
+		AC_MSG_WARN(
+[Mercury compiler not yet installed -
+****	cannot use unboxed floats, bootstrapping using boxed floats
+****	after installation is complete you may want to reinstall
+****	from scratch so you can use unboxed floats, which are more
+****	efficient.])
+		mercury_cv_unboxed_floats=no
+	fi
+fi
+if test "$mercury_cv_unboxed_floats" = yes; then
+	HAVE_BOXED_FLOATS="--unboxed-float"
+else
+	AC_DEFINE(MR_BOXED_FLOAT)
+	HAVE_BOXED_FLOATS="--no-unboxed-float"
+fi
+AC_SUBST(HAVE_BOXED_FLOATS)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_FLOAT_IS_64_BIT, [
+AC_MSG_CHECKING(whether float is 64-bit)
+AC_CACHE_VAL(mercury_cv_float_is_64_bit,
+	AC_TRY_RUN([
+	#include <limits.h>
+	int main() {
+		if (sizeof(float) * CHAR_BIT == 64)
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_float_is_64_bit=yes],
+	[mercury_cv_float_is_64_bit=no],
+	[mercury_cv_float_is_64_bit=no])
+)
+AC_MSG_RESULT($mercury_cv_float_is_64_bit)
+if test "$mercury_cv_float_is_64_bit" = yes; then
+	AC_DEFINE(MR_FLOAT_IS_64_BIT)
+fi
+AC_SUBST(MR_FLOAT_IS_64_BIT)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_DOUBLE_IS_64_BIT, [
+AC_MSG_CHECKING(whether double is 64-bit)
+AC_CACHE_VAL(mercury_cv_double_is_64_bit,
+	AC_TRY_RUN([
+	#include <limits.h>
+	int main() {
+		if (sizeof(double) * CHAR_BIT == 64)
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_double_is_64_bit=yes],
+	[mercury_cv_double_is_64_bit=no],
+	[mercury_cv_double_is_64_bit=no])
+)
+AC_MSG_RESULT($mercury_cv_double_is_64_bit)
+if test "$mercury_cv_double_is_64_bit" = yes; then
+	AC_DEFINE(MR_DOUBLE_IS_64_BIT)
+fi
+AC_SUBST(MR_DOUBLE_IS_64_BIT)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_LONG_DOUBLE_IS_64_BIT, [
+AC_MSG_CHECKING(whether long double is 64-bit)
+AC_CACHE_VAL(mercury_cv_long_double_is_64_bit,
+	AC_TRY_RUN([
+	#include <limits.h>
+	int main() {
+		if (sizeof(long double) * CHAR_BIT == 64)
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_long_double_is_64_bit=yes],
+	[mercury_cv_long_double_is_64_bit=no],
+	[mercury_cv_long_double_is_64_bit=no])
+)
+AC_MSG_RESULT($mercury_cv_long_double_is_64_bit)
+if test "$mercury_cv_long_double_is_64_bit" = yes; then
+	AC_DEFINE(MR_LONG_DOUBLE_IS_64_BIT)
+fi
+AC_SUBST(MR_LONG_DOUBLE_IS_64_BIT)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_ARCH_IS_BIG_ENDIAN, [
+AC_MSG_CHECKING(whether architecture is big-endian)
+AC_CACHE_VAL(mercury_cv_is_bigender,
+	AC_TRY_RUN([
+	int main() {
+		int		x = 1;
+		unsigned char	*x_p;
+
+		x_p = (unsigned char*) &x;
+
+		if (*x_p == 0)
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_is_bigender=yes],
+	[mercury_cv_is_bigender=no],
+	[mercury_cv_is_bigender=no])
+)
+AC_MSG_RESULT($mercury_cv_is_bigender)
+if test "$mercury_cv_is_bigender" = yes; then
+	AC_DEFINE(MR_BIG_ENDIAN)
+fi
+AC_SUBST(MR_BIG_ENDIAN)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_ARCH_IS_LITTLE_ENDIAN, [
+AC_MSG_CHECKING(whether architecture is little-endian)
+AC_CACHE_VAL(mercury_cv_is_littleender,
+	AC_TRY_RUN([
+	int main() {
+		int		x = 1;
+		unsigned char	*x_p;
+
+		x_p = (unsigned char*) &x;
+
+		if (*x_p == 1)
+			exit(0);
+		else
+			exit(1);
+	}],
+	[mercury_cv_is_littleender=yes],
+	[mercury_cv_is_littleender=no],
+	[mercury_cv_is_littleender=no])
+)
+AC_MSG_RESULT($mercury_cv_is_littleender)
+if test "$mercury_cv_is_littleender" = yes; then
+	AC_DEFINE(MR_LITTLE_ENDIAN)
+fi
+AC_SUBST(MR_LITTLE_ENDIAN)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_CAN_USE_FILES_AS_LOCKS, [
+AC_MSG_CHECKING(whether we can use files as locks)
+AC_CACHE_VAL(mercury_cv_have_ocreat_oexcl,
+	AC_TRY_COMPILE([
+		#ifdef MR_HAVE_SYS_TYPES_H
+		#include <sys/types.h>
+		#endif
+		#ifdef MR_HAVE_SYS_STAT_H
+		#include <sys/stat.h>
+		#endif
+		#ifdef MR_HAVE_FCNTL_H
+		#include <fcntl.h>
+		#endif
+	],
+	[
+	#if defined(O_CREAT) && defined(O_EXCL)
+
+	#else
+	/* 
+	** As these macros are not defined the compilation must fail.
+	** Unmatched brackets should do that for us.
+	*/
+		}
+	#endif
+	], 
+	[mercury_cv_have_ocreat_oexcl=yes],
+	[mercury_cv_have_ocreat_oexcl=no])
+)
+AC_MSG_RESULT($mercury_cv_have_ocreat_oexcl)
+if test "$mercury_cv_have_ocreat_oexcl" = yes; then
+	AC_DEFINE(MR_HAVE_OCREAT_OEXCL)
+fi
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_NORMAL_SYSTEM_RETVAL, [
+AC_MSG_CHECKING(return values of system)
+AC_CACHE_VAL(mercury_cv_normal_system_retval,
+	AC_TRY_RUN([
+	#include <stdlib.h>
+	#ifdef MR_HAVE_SYS_WAIT_H
+	#include <sys/wait.h>
+	#endif
+	int main() {
+		#if defined (WIFEXITED) && defined (WEXITSTATUS) && \
+			defined (WIFSIGNALED) && defined (WTERMSIG)
+		/* 
+		** All the necessary macros for handling the return values of
+		** system() are defined, so we do not need to test the return
+		** value of system()
+		*/
+		exit(0);
+ 
+		#else
+		/*
+		** Normal return values from system() are considered to be
+		** when high 8 bits of the return value give the exit
+		** status, and the low 8 bits give the signal number which
+		** killed the process.
+		*/
+			if( system("exit 0") == 0 &&
+					system("exit 42") == 42 << 8 ) {
+					/* && system("kill -9 $$") == 9 */
+				exit(0);
+			} else {
+				exit(1);
+			}
+		#endif
+	}],
+	[mercury_cv_normal_system_retval=yes],
+	[mercury_cv_normal_system_retval=no],
+	AC_TRY_COMPILE([#include <sys/wait.h>], [
+	#if defined (WIFEXITED) && defined (WEXITSTATUS) && \
+		defined (WIFSIGNALED) && defined (WTERMSIG)
+
+	#else
+	/* 
+	** As these macros are not defined the compilation must fail.
+	** Unmatched brackets should do that for us.
+	*/
+		}
+	#endif
+	], 
+	[mercury_cv_normal_system_retval=yes],
+	[mercury_cv_normal_system_retval=no]))
+)
+AC_MSG_RESULT($mercury_cv_normal_system_retval)
+if test "$mercury_cv_normal_system_retval" = no; then
+		# Warn since VC++6 compiler fails this test
+	AC_MSG_WARN(Unable to interpret return values from system)
+fi
+])
+
+#-----------------------------------------------------------------------------#
+
+# On sparc, x86, and probably on other architectures,
+# if we're using non-local gotos, then for egcs 1.1, we need
+# `-fno-gcse -fno-function-cse', and for gcc 2.8 we need `-fno-function-cse'.
+# Otherwise gcc generates code which initializes registers in the function
+# prologue and expects them to be valid later on, which doesn't work with
+# non-local gotos, since we jump directly into the middle of a function.
+# (Actually I don't know if `-fno-functions-cse' is really needed.
+# Maybe you can get away without it.  But better to err on the safe side...)
+#
+# For alpha, mips, and ARM, and probably on other architectures, when using
+# non-local gotos we need -fomit-frame-pointer, otherwise when compiling
+# with --no-c-optimize we run into a problem similar to the one above:
+# Gcc generates code which initializes the frame pointer in the
+# function prologue, and then expects it to be valid later on, which
+# doesn't work with non-local gotos, since we jump directly into the
+# middle of a function.
+#
+# For Irix 5, gcc labels don't work with shared libraries,
+# so if we're using gcc labels, we need to use non-shared libraries,
+# which means passing -non_shared and -mno-abicalls and also setting
+# LIBRARY_PATH.
+#
+# For x86, gcc global registers only work with -fno-builtin
+# and -fno-omit-frame-pointer.
+#
+# NB. Any changes here may also require changes to scripts/mgnuc.in.
+
+AC_DEFUN(MERCURY_CFLAGS_FOR_REGS_AND_GOTOS, [
+CFLAGS_FOR_REGS=
+CFLAGS_FOR_GOTOS=
+LIBRARY_PATH_FOR_GOTOS=
+case $ac_cv_prog_gcc in yes)
+    case "`$CC --version < /dev/null`" in
+	2.8*) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse" ;;
+	*)    CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse -fno-gcse" ;;
+    esac
+    case "$host" in
+	mips-sgi-irix5.*)
+		# Non-local gotos don't work with shared libraries on Irix 5,
+		# which causes lots of complications.
+		# Now that we have the hlc back-end, it's not worth
+		# supporting them.
+		MERCURY_MSG("Mercury no longer supports gcc non-local on Irix 5")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -non_shared -mno-abicalls"
+		LIBRARY_PATH_FOR_GOTOS="$NONSHARED_LIB_DIR:/usr/lib/nonshared"
+		;;
+    esac
+    case "$host" in
+	mips-*)
+		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
+		;;
+	i*86-*|x86_64*)
+		CFLAGS_FOR_REGS="-fno-builtin -fno-omit-frame-pointer"
+		;;
+	# We need a special-case hack here, because the auto-config 
+	# gets it wrong on the Alpha: the little example program
+	# works fine in fast.gc mode, but big programs don't,
+	# due to problems with the `gp' register.  Ideally we
+	# ought to write a big enough example program to trigger
+	# the problem, but that would be too much work.
+	alpha*-dec-*)
+		MERCURY_MSG(
+"asm labels work on the Alpha but plain gcc labels do not")
+		mercury_cv_asm_labels=yes
+		mercury_cv_gcc_labels=no
+		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
+		;;
+	# Similarly for rs6000
+	rs6000-*)
+		MERCURY_MSG("gcc labels do not work on the RS/6000")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		;;
+ 	arm*-*)
+ 		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
+ 		;;
+	# On hppa64, ia64 and powerpc64 the test programs appear to work, but
+	# larger programs die with an Illegal Instruction fault.
+	hppa64-*)
+		MERCURY_MSG("gcc labels do not work on HPPA64")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		;;
+	ia64-*)
+		MERCURY_MSG("gcc labels do not work on IA64")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		;;
+	powerpc64-*)
+		MERCURY_MSG("gcc labels do not work on PPC64")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		;;
+	# On s390 the configure test goes into an infinite loop, so we need
+	# to avoid running it.
+	#
+	# s390 systems can report themselves as s390-ibm-linux-gnu
+	# or s390x-ibm-linux-gnu (and possibly others).
+	s390*)
+		MERCURY_MSG("gcc labels do not work on S/390")
+		mercury_cv_asm_labels=no
+		mercury_cv_gcc_labels=no
+		;;
+	sparc*)
+		case "`$CC --version < /dev/null`" in 2.8*)
+			AC_MSG_WARN(
+[Mercury might not work with gcc 2.8 on sparc!
+****	We advise using gcc 2.95.x.])
+			;;
+		esac
+		;;
+    esac
+    ;;
+esac
+AC_SUBST(CFLAGS_FOR_REGS)
+AC_SUBST(CFLAGS_FOR_GOTOS)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_CAN_DO_PENDING_IO, [
+AC_MSG_CHECKING(to see if we can handle contexts blocking on IO)
+AC_CACHE_VAL(mercury_cv_can_do_pending_io,
+	AC_TRY_RUN([
+	#include <sys/types.h>
+	#include <sys/time.h>
+	int main() {
+		fd_set f;
+		struct timeval zero;
+		int err;
+
+		FD_ZERO(&f);
+		zero.tv_sec = 0;
+		zero.tv_usec = 0;
+		err = select(1, &f, &f, &f, &zero);
+		exit(err != 0);
+	}],
+	[mercury_cv_can_do_pending_io=yes],
+	[mercury_cv_can_do_pending_io=no],
+	[mercury_cv_can_do_pending_io=no])
+)
+AC_MSG_RESULT($mercury_cv_can_do_pending_io)
+if test "$mercury_cv_can_do_pending_io" = yes; then
+	AC_DEFINE(MR_CAN_DO_PENDING_IO)
+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_DEFUN(MERCURY_BZERO_NEEDS_STRINGS_H, [
+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)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_GCC_LABELS, [
+AC_MSG_CHECKING(whether we can use gcc labels)
+
+# Set env vars for compiling with gcc non-local gotos
+save_CC="$CC"
+save_LIBRARY_PATH="$LIBRARY_PATH"
+CC="$CC $CFLAGS_FOR_GOTOS"
+if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
+	LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
+	export LIBRARY_PATH
+fi
+
+AC_CACHE_VAL(mercury_cv_gcc_labels,
+	AC_TRY_RUN([
+	extern void exit(int);
+	void *entry_foo_1;
+	void *entry_bar_1;
+	void *succip;
+	int global;
+	void *dummy_identity_function(void *);
+	foo() {
+		entry_foo_1 = && foo_1;
+		goto *dummy_identity_function(&&return_label);
+	return_label:
+		return;
+	foo_1:
+		__asm__ __volatile__("":::"memory");
+		if (global != 42) exit(1);
+		goto *entry_bar_1;
+	}
+	bar() {
+		entry_bar_1 = && bar_1;
+		goto *dummy_identity_function(&&return_label);
+	return_label:
+		return;
+	bar_1:
+		__asm__ __volatile__("":::"memory");
+		if (global != 42) exit(1);
+		goto *succip;
+	}
+	main() {
+		global = 42;
+		foo();
+		bar();
+		succip = &&last;
+		goto *dummy_identity_function(&&return_label);
+	return_label:
+		goto *entry_foo_1;
+		exit(1);
+	last:
+		__asm__ __volatile__("":::"memory");
+		if (global != 42) exit(1);
+		exit(0);
+	}
+	void *dummy_identity_function(void *p) {
+		return p;
+	}
+	], [mercury_cv_gcc_labels=yes], [mercury_cv_gcc_labels=no],
+		[mercury_cv_gcc_labels=no])
+)
+AC_MSG_RESULT($mercury_cv_gcc_labels)
+if test "$mercury_cv_gcc_labels" = yes; then
+	AC_DEFINE(MR_HAVE_GCC_LABELS)
+fi
+
+if test $mercury_cv_gcc_labels = yes; then
+	AC_MSG_CHECKING(whether we can use asm labels)
+
+	AC_CACHE_VAL(mercury_cv_asm_labels,
+	AC_TRY_RUN([
+	void *volatile volatile_global_pointer;
+	extern void mercury__label1 (void) __asm__("entry_" "mercury__label1" );
+	main() {
+		void *addr;
+
+		volatile_global_pointer = &&mercury__label1;
+		addr = &mercury__label1;
+		goto *addr;
+		exit(1);
+
+	mercury__label1:
+		__asm__(".globl entry_" "mercury__label1" "\n" "entry_"
+			"mercury__label1" ":\n"
+			"/* this is a comment */");
+		exit(0);
+	}], [mercury_cv_asm_labels=yes], [mercury_cv_asm_labels=no],
+		[mercury_cv_asm_labels=no])
+	)
+	AC_MSG_RESULT($mercury_cv_asm_labels)
+else
+	mercury_cv_asm_labels=${mercury_cv_asm_labels-no}
+fi
+HAVE_ASM_LABELS=$mercury_cv_asm_labels
+AC_SUBST(HAVE_ASM_LABELS)
+if test $HAVE_ASM_LABELS = 1; then
+	AC_DEFINE(MR_HAVE_ASM_LABELS)
+fi
+
+# Restore env vars modified above
+CC="$save_CC"
+LIBRARY_PATH="$save_LIBRARY_PATH"
+])
+
+#-----------------------------------------------------------------------------#
+
+# We need to ensure that runtime/mercury_conf.h exists, since some of the
+# programs we attempt to compile below indirectly include it.
+
+AC_DEFUN(MERCURY_ENSURE_RUNTIME_CONF_H, [
+test -f runtime/mercury_conf.h || {
+	cat > runtime/mercury_conf.h <<EOF
+#define MR_WORD_TYPE $MR_WORD_TYPE
+EOF
+}
+]) 
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_GCC_LABELS_WITH_GLOBAL_REGS, [
+if test $mercury_cv_gcc_labels = yes || test $mercury_cv_asm_labels = yes; then
+	AC_MSG_CHECKING(whether we can use gcc labels and global registers)
+
+	# Set env vars for compiling with gcc non-local gotos and registers
+	save_CC="$CC"
+	save_LIBRARY_PATH="$LIBRARY_PATH"
+	CC="$CC $CFLAGS_FOR_GOTOS $CFLAGS_FOR_REGS"
+	if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
+		LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
+		export LIBRARY_PATH
+	fi
+
+	AC_CACHE_VAL(mercury_cv_gcc_model_fast,
+	AC_TRY_RUN([
+	#define MR_USE_GCC_NONLOCAL_GOTOS
+	#define MR_USE_GCC_GLOBAL_REGISTERS
+	#include "mercury_engine.h"
+	changequote(<<,>>) 
+	MercuryEngine MR_engine_base;
+	changequote([,]) 
+	main() {
+		MR_mr0 = 20;
+		MR_mr7 = 22;
+		if (MR_mr0 + MR_mr7 != 42)
+			exit(1);
+		exit(0);
+	}], [mercury_cv_gcc_model_fast=yes], [mercury_cv_gcc_model_fast=no],
+		[mercury_cv_gcc_model_fast=no])
+	)
+	AC_MSG_RESULT($mercury_cv_gcc_model_fast)
+
+	# Restore env vars modified above
+	CC="$save_CC"
+	LIBRARY_PATH="$save_LIBRARY_PATH"
+else
+	mercury_cv_gcc_model_fast=no
+fi
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_GLOBAL_REGS_WITHOUT_GCC_LABELS, [
+AC_MSG_CHECKING(whether we can use global registers without gcc labels)
+
+# Set env vars for compiling with gcc registers
+save_CC="$CC"
+CC="$CC $CFLAGS_FOR_REGS"
+
+AC_CACHE_VAL(mercury_cv_gcc_model_reg,
+AC_TRY_RUN([
+#define MR_USE_GCC_GLOBAL_REGISTERS
+#include "mercury_engine.h"
+changequote(<<,>>) 
+MercuryEngine MR_engine_base;
+changequote([,]) 
+main() {
+	MR_mr0 = 20;
+	MR_mr7 = 22;
+	if (MR_mr0 + MR_mr7 != 42)
+		exit(1);
+	exit(0);
+}], [mercury_cv_gcc_model_reg=yes], [mercury_cv_gcc_model_reg=no],
+	[mercury_cv_gcc_model_reg=no])
+)
+AC_MSG_RESULT($mercury_cv_gcc_model_reg)
+
+# Restore env vars modified above
+CC="$save_CC"
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_PROFILING, [
+AC_MSG_CHECKING(whether we can support profiling on this system)
+AC_CACHE_VAL(mercury_cv_profiling,
+AC_TRY_CPP([
+/* The following code comes from runtime/prof.c */
+#include	<unistd.h>
+#include	<errno.h>
+#include	<string.h>
+#include	<signal.h>
+
+#ifdef MR_HAVE_SYS_PARAM_H
+#include	<sys/param.h>
+#endif
+
+#ifdef MR_HAVE_SYS_TIME_H
+#include	<sys/time.h>
+#endif
+
+/* 
+** if HZ is not defined, we may be able to use sysconf(_SC_CLK_TCK) instead
+*/
+#if !defined(HZ) && defined(MR_HAVE_SYSCONF) && defined(_SC_CLK_TCK)
+#define HZ ((int)sysconf(_SC_CLK_TCK))
+#endif
+
+#if !defined(HZ) || !defined(SIGPROF) || !defined(MR_HAVE_SETITIMER)
+#error "Time profiling not supported on this system"
+#endif
+], [mercury_cv_profiling=yes], [mercury_cv_profiling=no]))
+AC_MSG_RESULT($mercury_cv_profiling)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_CC_IS_EGCS, [
+AC_MSG_CHECKING(if C compiler is egcs)
+case "`$CC --version < /dev/null 2>&1`" in
+    egcs-*)
+	mercury_cv_egcs=yes
+	;;
+    *)
+	mercury_cv_egcs=no
+	;;
+esac
+AC_MSG_RESULT($mercury_cv_egcs)
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_GCC_THREAD_LOCAL_STORAGE, [
+AC_MSG_CHECKING(whether we can use thread-local storage class extension)
+AC_CACHE_VAL(mercury_cv_thread_local_storage,
+	AC_TRY_COMPILE([],[
+		static __thread int thread_local_variable;
+	],
+	[mercury_cv_thread_local_storage=yes],
+	[mercury_cv_thread_local_storage=no])
+)
+AC_MSG_RESULT($mercury_cv_thread_local_storage)
+
+# Thread-local storage is disabled on Solaris as there is a linker problem
+# with shared objects and TLS.
+
+if test "$mercury_cv_thread_local_storage" = yes; then
+	case "$host" in 
+		*-solaris2.*)	;;
+		*)		AC_DEFINE(MR_THREAD_LOCAL_STORAGE) ;;
+	esac
+fi
+])
+
+#-----------------------------------------------------------------------------#
+
+AC_DEFUN(MERCURY_CHECK_FOR_HEADERS, [
      for mercury_cv_header in $1; do
  	mercury_cv_header_define="MR_HAVE_`echo $mercury_cv_header | \
  		tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
@@ -23,13 +1160,11 @@
      done
  ])
  #-----------------------------------------------------------------------------#
-AC_DEFUN(MERCURY_CHECK_FOR_IEEEFP_H,
-[
+AC_DEFUN(MERCURY_CHECK_FOR_IEEEFP_H, [
  	MERCURY_CHECK_FOR_HEADERS(ieeefp.h)
  ])

-AC_DEFUN(MERCURY_CHECK_FOR_IEEE_FUNC,
-[
+AC_DEFUN(MERCURY_CHECK_FOR_IEEE_FUNC, [
  AC_REQUIRE([MERCURY_CHECK_FOR_IEEEFP_H])
  AC_MSG_CHECKING(for $1 function)
  mercury_cv_ieee_func_define="MR_HAVE_`echo $1 | \
@@ -61,8 +1196,7 @@
  # when preprocessing the C code generated by the Mercury compiler's LLDS
  # back-end.
  #
-AC_DEFUN(MERCURY_CHECK_CC_NEEDS_TRAD_CPP,
-[
+AC_DEFUN(MERCURY_CHECK_CC_NEEDS_TRAD_CPP, [
  AC_REQUIRE([AC_PROG_CC])
  AC_MSG_CHECKING(whether C compiler needs -no-cpp-precomp)
  AC_CACHE_VAL(mercury_cv_cpp_precomp, [
@@ -143,8 +1277,8 @@
  #
  # Check for readline and related header files and libraries
  #
-AC_DEFUN(MERCURY_CHECK_READLINE,
-[
+
+AC_DEFUN(MERCURY_CHECK_READLINE, [
  AC_ARG_WITH(readline,
  [  --without-readline      Don't use the GPL'd GNU readline library],
  mercury_cv_with_readline="$withval", mercury_cv_with_readline=yes)
Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.476
diff -u -r1.476 configure.in
--- configure.in	2 Oct 2006 06:30:35 -0000	1.476
+++ configure.in	25 Oct 2006 05:13:02 -0000
@@ -10,13 +10,7 @@
  # `configure' script.
  #
  #-----------------------------------------------------------------------------#
-#
-# Define a macro MERCURY_MSG, similar to AC_MSG_RESULT, for displaying output.
-#
-dnl MERCURY_MSG(MESSAGE)
-define(MERCURY_MSG,
-[echo $1 1>&AC_FD_MSG])
-#-----------------------------------------------------------------------------#
+
  AC_INIT(scripts/mmc.in)
  TMPDIR=${TMPDIR=/tmp}

@@ -949,9 +943,10 @@
  if test "$MR_HAVE_UCONTEXT_H" != 1; then
  	MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h)
  fi
+
  #-----------------------------------------------------------------------------#
  #
-# check the basics of sigaction
+# Check the basics of sigaction
  #
  if test "$ac_cv_func_sigaction" = yes; then
  	AC_MSG_CHECKING(for \`sigaction' field name)
@@ -1338,193 +1333,14 @@
  	fi
  fi
  #-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(for an integer type with the same size as a pointer)
-AC_CACHE_VAL(mercury_cv_word_type,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
-
-		if (sizeof(int) == sizeof(void *))
-		{
-			fprintf(fp, "int\n");
-			exit(0);
-		}
-
-		if (sizeof(long) == sizeof(void *))
-		{
-			fprintf(fp, "long\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_word_type=`cat conftest.tags`],
-	[mercury_cv_word_type=unknown],
-	[mercury_cv_word_type=unknown])
-)
-if test "$mercury_cv_word_type" = unknown; then
-	AC_TRY_RUN([
-	#include <stdio.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
-
-		if (sizeof(long long) == sizeof(void *))
-		{
-			fprintf(fp, "long long\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_word_type=`cat conftest.tags`],
-	[mercury_cv_word_type=unknown],
-	[mercury_cv_word_type=unknown])
-fi
-AC_MSG_RESULT($mercury_cv_word_type)
-AC_DEFINE_UNQUOTED(MR_WORD_TYPE, $mercury_cv_word_type)
-MR_WORD_TYPE=$mercury_cv_word_type
-AC_SUBST(MR_WORD_TYPE)
-
-if test "$mercury_cv_word_type" = int; then
-	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "")
-elif test "$mercury_cv_word_type" = long; then
-	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "l")
-elif test "$mercury_cv_word_type" = "long long"; then
-	AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "ll")
-else
-	AC_MSG_ERROR(Cannot determine the length modifier for the MR_Integer type.)
-fi
-AC_SUBST(MR_INTEGER_LENGTH_MODIFIER)
-
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(for an integer type of at least 64 bits)
-AC_CACHE_VAL(mercury_cv_int_least64_type,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <limits.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
-
-		if (sizeof(int) * CHAR_BIT >= 64)
-		{
-			fprintf(fp, "int\n");
-			exit(0);
-		}

-		if (sizeof(long) * CHAR_BIT >= 64)
-		{
-			fprintf(fp, "long\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_int_least64_type=`cat conftest.tags`],
-	[mercury_cv_int_least64_type=unknown],
-	[mercury_cv_int_least64_type=unknown])
-)
-if test "$mercury_cv_int_least64_type" = unknown; then
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <limits.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
+MERCURY_WORD_TYPE
+MERCURY_INT_LEAST64_TYPE
+MERCURY_INT_LEAST32_TYPE

-		if (sizeof(long long) * CHAR_BIT >= 64)
-		{
-			fprintf(fp, "long long\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_int_least64_type=`cat conftest.tags`],
-	[mercury_cv_int_least64_type=unknown],
-	[mercury_cv_int_least64_type=unknown])
-fi
-# Uncomment the following line to test how the system behaves
-# in the absence of a 64-bit integer type.
-# mercury_cv_int_least64_type=unknown
-AC_MSG_RESULT($mercury_cv_int_least64_type)
-if test "$mercury_cv_int_least64_type" != unknown; then
-	AC_DEFINE_UNQUOTED(MR_INT_LEAST64_TYPE, $mercury_cv_int_least64_type)
-	MR_INT_LEAST64_TYPE=$mercury_cv_int_least64_type
-	AC_SUBST(MR_INT_LEAST64_TYPE)
-fi
  #-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(for an integer type of at least 32 bits)
-AC_CACHE_VAL(mercury_cv_int_least32_type,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <limits.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);

-		if (sizeof(int) * CHAR_BIT >= 32)
-		{
-			fprintf(fp, "int\n");
-			exit(0);
-		}
-
-		if (sizeof(long) * CHAR_BIT >= 32)
-		{
-			fprintf(fp, "long\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_int_least32_type=`cat conftest.tags`],
-	[mercury_cv_int_least32_type=unknown],
-	[mercury_cv_int_least32_type=unknown])
-)
-AC_MSG_RESULT($mercury_cv_int_least32_type)
-AC_DEFINE_UNQUOTED(MR_INT_LEAST32_TYPE, $mercury_cv_int_least32_type)
-MR_INT_LEAST32_TYPE=$mercury_cv_int_least32_type
-AC_SUBST(MR_INT_LEAST32_TYPE)
-
-if test "$mercury_cv_int_least32_type" = int; then
-	AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, INT_MAX)
-	AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, UINT_MAX)
-elif test "$mercury_cv_int_least32_type" = long; then
-	AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, LONG_MAX)
-	AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, ULONG_MAX)
-else
-	AC_MSG_ERROR(
-[Cannot find the name of the max values
-	for MR_INT_LEAST32_TYPE.])
-fi
-AC_SUBST(MR_INT_LEAST32_MAX)
-AC_SUBST(MR_UINT_LEAST32_MAX)
-#-----------------------------------------------------------------------------#
  AC_TYPE_PID_T
-
  AC_CHECK_TYPES([dev_t, ino_t])
  case "$ac_cv_type_dev_t" in
  	yes) AC_DEFINE_UNQUOTED(MR_HAVE_DEV_T) ;;
@@ -1534,835 +1350,30 @@
  esac

  #-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(for an integer type of at least 16 bits)
-AC_CACHE_VAL(mercury_cv_int_least16_type,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <limits.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
-
-		if (sizeof(short) * CHAR_BIT >= 16)
-		{
-			fprintf(fp, "short\n");
-			exit(0);
-		}
-
-		if (sizeof(int) * CHAR_BIT >= 16)
-		{
-			fprintf(fp, "int\n");
-			exit(0);
-		}
-
-		fprintf(fp, "unknown\n");
-		exit(1);
-	}],
-	[mercury_cv_int_least16_type=`cat conftest.tags`],
-	[mercury_cv_int_least16_type=unknown],
-	[mercury_cv_int_least16_type=unknown])
-)
-AC_MSG_RESULT($mercury_cv_int_least16_type)
-AC_DEFINE_UNQUOTED(MR_INT_LEAST16_TYPE, $mercury_cv_int_least16_type)
-MR_INT_LEAST16_TYPE=$mercury_cv_int_least16_type
-AC_SUBST(MR_INT_LEAST16_TYPE)
-
-if test "$mercury_cv_int_least16_type" = short; then
-	AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, SHRT_MAX)
-	AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, USHRT_MAX)
-elif test "$mercury_cv_int_least16_type" = int; then
-	AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, INT_MAX)
-	AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, UINT_MAX)
-else
-	AC_MSG_ERROR(Cannot find the name of the max value for MR_INT_LEAST16_TYPE.)
-fi
-AC_SUBST(MR_INT_LEAST16_MAX)
-AC_SUBST(MR_UINT_LEAST16_MAX)
-
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(the number of low tag bits available)
-AC_CACHE_VAL(mercury_cv_low_tag_bits,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <stdlib.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.tags", "w");
-		if (fp == NULL)
-			exit(1);
-
-		if (sizeof(void *) == 4)
-		{
-			fprintf(fp, "2\n");
-			exit(0);
-		}
-		if (sizeof(void *) == 8)
-		{
-			fprintf(fp, "3\n");
-			exit(0);
-		}
-		if (sizeof(void *) == 16)
-		{
-			fprintf(fp, "4\n");
-			exit(0);
-		}
-		fprintf(fp, "0\n");
-		exit(1);
-	}],
-	[mercury_cv_low_tag_bits=`cat conftest.tags`],
-	[mercury_cv_low_tag_bits=0],
-	[mercury_cv_low_tag_bits=0])
-)
-AC_MSG_RESULT($mercury_cv_low_tag_bits)
-if test "$mercury_cv_low_tag_bits" -lt 2; then
-	if test "$BOOTSTRAP_MC" = ""; then
-		AC_MSG_ERROR(cannot bootstrap: low tag bits less than 2)
-		exit 1
-	fi
-fi
-if test "$mercury_cv_low_tag_bits" -gt 2; then
-	if test "$BOOTSTRAP_MC" = ""; then
-		AC_MSG_WARN(bootstrapping using only 2 low tag bits)
-		mercury_cv_low_tag_bits=2
-	fi
-fi
-AC_DEFINE_UNQUOTED(MR_LOW_TAG_BITS, $mercury_cv_low_tag_bits)
-LOW_TAG_BITS=$mercury_cv_low_tag_bits
-AC_SUBST(LOW_TAG_BITS)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(the number of bytes per word)
-AC_CACHE_VAL(mercury_cv_bytes_per_word,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <stdlib.h>
-	int main() {
-		FILE *fp;
-
-		fp = fopen("conftest.wordbytes", "w");
-		if (fp == NULL)
-			exit(1);
-		fprintf(fp, "%d\n", sizeof(void *));
-
-		exit(0);
-	}],
-	[mercury_cv_bytes_per_word=`cat conftest.wordbytes`],
-	[mercury_cv_bytes_per_word=0],
-	[mercury_cv_bytes_per_word=0])
-)
-AC_MSG_RESULT($mercury_cv_bytes_per_word)
-AC_DEFINE_UNQUOTED(MR_BYTES_PER_WORD, $mercury_cv_bytes_per_word)
-BYTES_PER_WORD=$mercury_cv_bytes_per_word
-AC_SUBST(BYTES_PER_WORD)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(the number of words in a synchronization term)
-AC_CACHE_VAL(mercury_cv_sync_term_size,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <stdlib.h>
-	#include <pthread.h>
-	int main() {
-		struct {
-			pthread_mutex_t lock;
-			void		*orig_context;
-			int		count;
-			void		*parent;
-		} x;
-		FILE *fp;
-
-		fp = fopen("conftest.syncsize", "w");
-		if (fp == NULL)
-			exit(1);
-		fprintf(fp, "%d\n", (sizeof(void *) - 1 + sizeof(x))/
-				sizeof(void *));
-
-		exit(0);
-	}],
-	[mercury_cv_sync_term_size=`cat conftest.syncsize`],
-	[mercury_cv_sync_term_size=0],
-	[mercury_cv_sync_term_size=0])
-)
-AC_MSG_RESULT($mercury_cv_sync_term_size)
-AC_DEFINE_UNQUOTED(MR_SYNC_TERM_SIZE, $mercury_cv_sync_term_size)
-SYNC_TERM_SIZE=$mercury_cv_sync_term_size
-AC_SUBST(SYNC_TERM_SIZE)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(the number of bits per word)
-AC_CACHE_VAL(mercury_cv_bits_per_word,
-	AC_TRY_RUN([
-	#include <stdio.h>
-	#include <stdlib.h>
-	#include <limits.h>
-	int main() {
-		FILE *fp;

-		fp = fopen("conftest.wordbits", "w");
-		if (fp == NULL)
-			exit(1);
-		fprintf(fp, "%d\n", CHAR_BIT * sizeof(void *));
+MERCURY_INT_LEAST16_TYPE
+MERCURY_LOW_TAG_BITS
+MERCURY_BYTES_PER_WORD
+MERCURY_SYNC_TERM_SIZE
+MERCURY_BITS_PER_WORD
+MERCURY_UNBOXED_FLOATS
+MERCURY_FLOAT_IS_64_BIT
+MERCURY_DOUBLE_IS_64_BIT
+MERCURY_LONG_DOUBLE_IS_64_BIT
+MERCURY_ARCH_IS_BIG_ENDIAN
+MERCURY_ARCH_IS_LITTLE_ENDIAN
+MERCURY_CAN_USE_FILES_AS_LOCKS
+MERCURY_NORMAL_SYSTEM_RETVAL
+MERCURY_CAN_DO_PENDING_IO
+MERCURY_BZERO_NEEDS_STRINGS_H
+MERCURY_CFLAGS_FOR_REGS_AND_GOTOS
+MERCURY_GCC_LABELS
+MERCURY_ENSURE_RUNTIME_CONF_H
+MERCURY_GCC_LABELS_WITH_GLOBAL_REGS
+MERCURY_GLOBAL_REGS_WITHOUT_GCC_LABELS
+MERCURY_PROFILING
+MERCURY_CC_IS_EGCS

-		exit(0);
-	}],
-	[mercury_cv_bits_per_word=`cat conftest.wordbits`],
-	[mercury_cv_bits_per_word=0],
-	[mercury_cv_bits_per_word=0])
-)
-AC_MSG_RESULT($mercury_cv_bits_per_word)
-AC_DEFINE_UNQUOTED(MR_BITS_PER_WORD, $mercury_cv_bits_per_word)
-BITS_PER_WORD=$mercury_cv_bits_per_word
-AC_SUBST(BITS_PER_WORD)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether we can use unboxed floats)
-AC_CACHE_VAL(mercury_cv_unboxed_floats,
-	AC_TRY_RUN([
-	int main() {
-		if (sizeof(double) == sizeof(void *))
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_unboxed_floats=yes],
-	[mercury_cv_unboxed_floats=no],
-	[mercury_cv_unboxed_floats=no])
-)
-AC_MSG_RESULT($mercury_cv_unboxed_floats)
-if test "$mercury_cv_unboxed_floats" = yes; then
-	if test "$BOOTSTRAP_MC" = ""; then
-		AC_MSG_WARN(
-[Mercury compiler not yet installed -
-****	cannot use unboxed floats, bootstrapping using boxed floats
-****	after installation is complete you may want to reinstall
-****	from scratch so you can use unboxed floats, which are more
-****	efficient.])
-		mercury_cv_unboxed_floats=no
-	fi
-fi
-if test "$mercury_cv_unboxed_floats" = yes; then
-	HAVE_BOXED_FLOATS="--unboxed-float"
-else
-	AC_DEFINE(MR_BOXED_FLOAT)
-	HAVE_BOXED_FLOATS="--no-unboxed-float"
-fi
-AC_SUBST(HAVE_BOXED_FLOATS)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether float is 64-bit)
-AC_CACHE_VAL(mercury_cv_float_is_64_bit,
-	AC_TRY_RUN([
-	#include <limits.h>
-	int main() {
-		if (sizeof(float) * CHAR_BIT == 64)
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_float_is_64_bit=yes],
-	[mercury_cv_float_is_64_bit=no],
-	[mercury_cv_float_is_64_bit=no])
-)
-AC_MSG_RESULT($mercury_cv_float_is_64_bit)
-if test "$mercury_cv_float_is_64_bit" = yes; then
-	AC_DEFINE(MR_FLOAT_IS_64_BIT)
-fi
-AC_SUBST(MR_FLOAT_IS_64_BIT)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether double is 64-bit)
-AC_CACHE_VAL(mercury_cv_double_is_64_bit,
-	AC_TRY_RUN([
-	#include <limits.h>
-	int main() {
-		if (sizeof(double) * CHAR_BIT == 64)
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_double_is_64_bit=yes],
-	[mercury_cv_double_is_64_bit=no],
-	[mercury_cv_double_is_64_bit=no])
-)
-AC_MSG_RESULT($mercury_cv_double_is_64_bit)
-if test "$mercury_cv_double_is_64_bit" = yes; then
-	AC_DEFINE(MR_DOUBLE_IS_64_BIT)
-fi
-AC_SUBST(MR_DOUBLE_IS_64_BIT)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether long double is 64-bit)
-AC_CACHE_VAL(mercury_cv_long_double_is_64_bit,
-	AC_TRY_RUN([
-	#include <limits.h>
-	int main() {
-		if (sizeof(long double) * CHAR_BIT == 64)
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_long_double_is_64_bit=yes],
-	[mercury_cv_long_double_is_64_bit=no],
-	[mercury_cv_long_double_is_64_bit=no])
-)
-AC_MSG_RESULT($mercury_cv_long_double_is_64_bit)
-if test "$mercury_cv_long_double_is_64_bit" = yes; then
-	AC_DEFINE(MR_LONG_DOUBLE_IS_64_BIT)
-fi
-AC_SUBST(MR_LONG_DOUBLE_IS_64_BIT)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether architecture is big-endian)
-AC_CACHE_VAL(mercury_cv_is_bigender,
-	AC_TRY_RUN([
-	int main() {
-		int		x = 1;
-		unsigned char	*x_p;
-
-		x_p = (unsigned char*) &x;
-
-		if (*x_p == 0)
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_is_bigender=yes],
-	[mercury_cv_is_bigender=no],
-	[mercury_cv_is_bigender=no])
-)
-AC_MSG_RESULT($mercury_cv_is_bigender)
-if test "$mercury_cv_is_bigender" = yes; then
-	AC_DEFINE(MR_BIG_ENDIAN)
-fi
-AC_SUBST(MR_BIG_ENDIAN)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether architecture is little-endian)
-AC_CACHE_VAL(mercury_cv_is_littleender,
-	AC_TRY_RUN([
-	int main() {
-		int		x = 1;
-		unsigned char	*x_p;
-
-		x_p = (unsigned char*) &x;
-
-		if (*x_p == 1)
-			exit(0);
-		else
-			exit(1);
-	}],
-	[mercury_cv_is_littleender=yes],
-	[mercury_cv_is_littleender=no],
-	[mercury_cv_is_littleender=no])
-)
-AC_MSG_RESULT($mercury_cv_is_littleender)
-if test "$mercury_cv_is_littleender" = yes; then
-	AC_DEFINE(MR_LITTLE_ENDIAN)
-fi
-AC_SUBST(MR_LITTLE_ENDIAN)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether we can use files as locks)
-AC_CACHE_VAL(mercury_cv_have_ocreat_oexcl,
-	AC_TRY_COMPILE([
-		#ifdef MR_HAVE_SYS_TYPES_H
-		#include <sys/types.h>
-		#endif
-		#ifdef MR_HAVE_SYS_STAT_H
-		#include <sys/stat.h>
-		#endif
-		#ifdef MR_HAVE_FCNTL_H
-		#include <fcntl.h>
-		#endif
-	],
-	[
-	#if defined(O_CREAT) && defined(O_EXCL)
-
-	#else
-	/* 
-	** As these macros are not defined the compilation must fail.
-	** Unmatched brackets should do that for us.
-	*/
-		}
-	#endif
-	], 
-	[mercury_cv_have_ocreat_oexcl=yes],
-	[mercury_cv_have_ocreat_oexcl=no])
-)
-AC_MSG_RESULT($mercury_cv_have_ocreat_oexcl)
-if test "$mercury_cv_have_ocreat_oexcl" = yes; then
-	AC_DEFINE(MR_HAVE_OCREAT_OEXCL)
-fi
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(return values of system)
-AC_CACHE_VAL(mercury_cv_normal_system_retval,
-	AC_TRY_RUN([
-	#include <stdlib.h>
-	#ifdef MR_HAVE_SYS_WAIT_H
-	#include <sys/wait.h>
-	#endif
-	int main() {
-		#if defined (WIFEXITED) && defined (WEXITSTATUS) && \
-			defined (WIFSIGNALED) && defined (WTERMSIG)
-		/* 
-		** All the necessary macros for handling the return values of
-		** system() are defined, so we do not need to test the return
-		** value of system()
-		*/
-		exit(0);
- 
-		#else
-		/*
-		** Normal return values from system() are considered to be
-		** when high 8 bits of the return value give the exit
-		** status, and the low 8 bits give the signal number which
-		** killed the process.
-		*/
-			if( system("exit 0") == 0 &&
-					system("exit 42") == 42 << 8 ) {
-					/* && system("kill -9 $$") == 9 */
-				exit(0);
-			} else {
-				exit(1);
-			}
-		#endif
-	}],
-	[mercury_cv_normal_system_retval=yes],
-	[mercury_cv_normal_system_retval=no],
-	AC_TRY_COMPILE([#include <sys/wait.h>], [
-	#if defined (WIFEXITED) && defined (WEXITSTATUS) && \
-		defined (WIFSIGNALED) && defined (WTERMSIG)
-
-	#else
-	/* 
-	** As these macros are not defined the compilation must fail.
-	** Unmatched brackets should do that for us.
-	*/
-		}
-	#endif
-	], 
-	[mercury_cv_normal_system_retval=yes],
-	[mercury_cv_normal_system_retval=no]))
-)
-AC_MSG_RESULT($mercury_cv_normal_system_retval)
-if test "$mercury_cv_normal_system_retval" = no; then
-		# Warn since VC++6 compiler fails this test
-	AC_MSG_WARN(Unable to interpret return values from system)
-fi
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(to see if we can handle contexts blocking on IO)
-AC_CACHE_VAL(mercury_cv_can_do_pending_io,
-	AC_TRY_RUN([
-	#include <sys/types.h>
-	#include <sys/time.h>
-	int main() {
-		fd_set f;
-		struct timeval zero;
-		int err;
-
-		FD_ZERO(&f);
-		zero.tv_sec = 0;
-		zero.tv_usec = 0;
-		err = select(1, &f, &f, &f, &zero);
-		exit(err != 0);
-	}],
-	[mercury_cv_can_do_pending_io=yes],
-	[mercury_cv_can_do_pending_io=no],
-	[mercury_cv_can_do_pending_io=no])
-)
-AC_MSG_RESULT($mercury_cv_can_do_pending_io)
-if test "$mercury_cv_can_do_pending_io" = yes; then
-	AC_DEFINE(MR_CAN_DO_PENDING_IO)
-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
-# `-fno-gcse -fno-function-cse', and for gcc 2.8 we need `-fno-function-cse'.
-# Otherwise gcc generates code which initializes registers in the function
-# prologue and expects them to be valid later on, which doesn't work with
-# non-local gotos, since we jump directly into the middle of a function.
-# (Actually I don't know if `-fno-functions-cse' is really needed.
-# Maybe you can get away without it.  But better to err on the safe side...)
-#
-# For alpha, mips, and ARM, and probably on other architectures, when using
-# non-local gotos we need -fomit-frame-pointer, otherwise when compiling
-# with --no-c-optimize we run into a problem similar to the one above:
-# Gcc generates code which initializes the frame pointer in the
-# function prologue, and then expects it to be valid later on, which
-# doesn't work with non-local gotos, since we jump directly into the
-# middle of a function.
-#
-# For Irix 5, gcc labels don't work with shared libraries,
-# so if we're using gcc labels, we need to use non-shared libraries,
-# which means passing -non_shared and -mno-abicalls and also setting
-# LIBRARY_PATH.
-#
-# For x86, gcc global registers only work with -fno-builtin
-# and -fno-omit-frame-pointer.
-#
-# NB. Any changes here may also require changes to scripts/mgnuc.in.
-#
-CFLAGS_FOR_REGS=
-CFLAGS_FOR_GOTOS=
-LIBRARY_PATH_FOR_GOTOS=
-case $ac_cv_prog_gcc in yes)
-    case "`$CC --version < /dev/null`" in
-	2.8*) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse" ;;
-	*)    CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse -fno-gcse" ;;
-    esac
-    case "$host" in
-	mips-sgi-irix5.*)
-		# Non-local gotos don't work with shared libraries on Irix 5,
-		# which causes lots of complications.
-		# Now that we have the hlc back-end, it's not worth
-		# supporting them.
-		MERCURY_MSG("Mercury no longer supports gcc non-local on Irix 5")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -non_shared -mno-abicalls"
-		LIBRARY_PATH_FOR_GOTOS="$NONSHARED_LIB_DIR:/usr/lib/nonshared"
-		;;
-    esac
-    case "$host" in
-	mips-*)
-		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
-		;;
-	i*86-*|x86_64*)
-		CFLAGS_FOR_REGS="-fno-builtin -fno-omit-frame-pointer"
-		;;
-	# We need a special-case hack here, because the auto-config 
-	# gets it wrong on the Alpha: the little example program
-	# works fine in fast.gc mode, but big programs don't,
-	# due to problems with the `gp' register.  Ideally we
-	# ought to write a big enough example program to trigger
-	# the problem, but that would be too much work.
-	alpha*-dec-*)
-		MERCURY_MSG(
-"asm labels work on the Alpha but plain gcc labels do not")
-		mercury_cv_asm_labels=yes
-		mercury_cv_gcc_labels=no
-		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
-		;;
-	# Similarly for rs6000
-	rs6000-*)
-		MERCURY_MSG("gcc labels do not work on the RS/6000")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		;;
- 	arm*-*)
- 		CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
- 		;;
-	# On hppa64, ia64 and powerpc64 the test programs appear to work, but
-	# larger programs die with an Illegal Instruction fault.
-	hppa64-*)
-		MERCURY_MSG("gcc labels do not work on HPPA64")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		;;
-	ia64-*)
-		MERCURY_MSG("gcc labels do not work on IA64")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		;;
-	powerpc64-*)
-		MERCURY_MSG("gcc labels do not work on PPC64")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		;;
-	# On s390 the configure test goes into an infinite loop, so we need
-	# to avoid running it.
-	#
-	# s390 systems can report themselves as s390-ibm-linux-gnu
-	# or s390x-ibm-linux-gnu (and possibly others).
-	s390*)
-		MERCURY_MSG("gcc labels do not work on S/390")
-		mercury_cv_asm_labels=no
-		mercury_cv_gcc_labels=no
-		;;
-	sparc*)
-		case "`$CC --version < /dev/null`" in 2.8*)
-			AC_MSG_WARN(
-[Mercury might not work with gcc 2.8 on sparc!
-****	We advise using gcc 2.95.x.])
-			;;
-		esac
-		;;
-    esac
-    ;;
-esac
-AC_SUBST(CFLAGS_FOR_REGS)
-AC_SUBST(CFLAGS_FOR_GOTOS)
-
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether we can use gcc labels)
-
-# Set env vars for compiling with gcc non-local gotos
-save_CC="$CC"
-save_LIBRARY_PATH="$LIBRARY_PATH"
-CC="$CC $CFLAGS_FOR_GOTOS"
-if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
-	LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
-	export LIBRARY_PATH
-fi
-
-AC_CACHE_VAL(mercury_cv_gcc_labels,
-	AC_TRY_RUN([
-	extern void exit(int);
-	void *entry_foo_1;
-	void *entry_bar_1;
-	void *succip;
-	int global;
-	void *dummy_identity_function(void *);
-	foo() {
-		entry_foo_1 = && foo_1;
-		goto *dummy_identity_function(&&return_label);
-	return_label:
-		return;
-	foo_1:
-		__asm__ __volatile__("":::"memory");
-		if (global != 42) exit(1);
-		goto *entry_bar_1;
-	}
-	bar() {
-		entry_bar_1 = && bar_1;
-		goto *dummy_identity_function(&&return_label);
-	return_label:
-		return;
-	bar_1:
-		__asm__ __volatile__("":::"memory");
-		if (global != 42) exit(1);
-		goto *succip;
-	}
-	main() {
-		global = 42;
-		foo();
-		bar();
-		succip = &&last;
-		goto *dummy_identity_function(&&return_label);
-	return_label:
-		goto *entry_foo_1;
-		exit(1);
-	last:
-		__asm__ __volatile__("":::"memory");
-		if (global != 42) exit(1);
-		exit(0);
-	}
-	void *dummy_identity_function(void *p) {
-		return p;
-	}
-	], [mercury_cv_gcc_labels=yes], [mercury_cv_gcc_labels=no],
-		[mercury_cv_gcc_labels=no])
-)
-AC_MSG_RESULT($mercury_cv_gcc_labels)
-if test "$mercury_cv_gcc_labels" = yes; then
-	AC_DEFINE(MR_HAVE_GCC_LABELS)
-fi
-
-if test $mercury_cv_gcc_labels = yes; then
-	AC_MSG_CHECKING(whether we can use asm labels)
-
-	AC_CACHE_VAL(mercury_cv_asm_labels,
-	AC_TRY_RUN([
-	void *volatile volatile_global_pointer;
-	extern void mercury__label1 (void) __asm__("entry_" "mercury__label1" );
-	main() {
-		void *addr;
-
-		volatile_global_pointer = &&mercury__label1;
-		addr = &mercury__label1;
-		goto *addr;
-		exit(1);
-
-	mercury__label1:
-		__asm__(".globl entry_" "mercury__label1" "\n" "entry_"
-			"mercury__label1" ":\n"
-			"/* this is a comment */");
-		exit(0);
-	}], [mercury_cv_asm_labels=yes], [mercury_cv_asm_labels=no],
-		[mercury_cv_asm_labels=no])
-	)
-	AC_MSG_RESULT($mercury_cv_asm_labels)
-else
-	mercury_cv_asm_labels=${mercury_cv_asm_labels-no}
-fi
-HAVE_ASM_LABELS=$mercury_cv_asm_labels
-AC_SUBST(HAVE_ASM_LABELS)
-if test $HAVE_ASM_LABELS = 1; then
-	AC_DEFINE(MR_HAVE_ASM_LABELS)
-fi
-
-# Restore env vars modified above
-CC="$save_CC"
-LIBRARY_PATH="$save_LIBRARY_PATH"
-
-#-----------------------------------------------------------------------------#
-# We need to ensure that runtime/mercury_conf.h exists, since some of the
-# programs we attempt to compile below indirectly include it.
-test -f runtime/mercury_conf.h || {
-	cat > runtime/mercury_conf.h <<EOF
-#define MR_WORD_TYPE $MR_WORD_TYPE
-EOF
-}
-#-----------------------------------------------------------------------------#
-if test $mercury_cv_gcc_labels = yes || test $mercury_cv_asm_labels = yes; then
-	AC_MSG_CHECKING(whether we can use gcc labels and global registers)
-
-	# Set env vars for compiling with gcc non-local gotos and registers
-	save_CC="$CC"
-	save_LIBRARY_PATH="$LIBRARY_PATH"
-	CC="$CC $CFLAGS_FOR_GOTOS $CFLAGS_FOR_REGS"
-	if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then
-		LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH"
-		export LIBRARY_PATH
-	fi
-
-	AC_CACHE_VAL(mercury_cv_gcc_model_fast,
-	AC_TRY_RUN([
-	#define MR_USE_GCC_NONLOCAL_GOTOS
-	#define MR_USE_GCC_GLOBAL_REGISTERS
-	#include "mercury_engine.h"
-	changequote(<<,>>) 
-	MercuryEngine MR_engine_base;
-	changequote([,]) 
-	main() {
-		MR_mr0 = 20;
-		MR_mr7 = 22;
-		if (MR_mr0 + MR_mr7 != 42)
-			exit(1);
-		exit(0);
-	}], [mercury_cv_gcc_model_fast=yes], [mercury_cv_gcc_model_fast=no],
-		[mercury_cv_gcc_model_fast=no])
-	)
-	AC_MSG_RESULT($mercury_cv_gcc_model_fast)
-
-	# Restore env vars modified above
-	CC="$save_CC"
-	LIBRARY_PATH="$save_LIBRARY_PATH"
-else
-	mercury_cv_gcc_model_fast=no
-fi
-#-----------------------------------------------------------------------------#
-
-AC_MSG_CHECKING(whether we can use global registers without gcc labels)
-
-# Set env vars for compiling with gcc registers
-save_CC="$CC"
-CC="$CC $CFLAGS_FOR_REGS"
-
-AC_CACHE_VAL(mercury_cv_gcc_model_reg,
-AC_TRY_RUN([
-#define MR_USE_GCC_GLOBAL_REGISTERS
-#include "mercury_engine.h"
-changequote(<<,>>) 
-MercuryEngine MR_engine_base;
-changequote([,]) 
-main() {
-	MR_mr0 = 20;
-	MR_mr7 = 22;
-	if (MR_mr0 + MR_mr7 != 42)
-		exit(1);
-	exit(0);
-}], [mercury_cv_gcc_model_reg=yes], [mercury_cv_gcc_model_reg=no],
-	[mercury_cv_gcc_model_reg=no])
-)
-AC_MSG_RESULT($mercury_cv_gcc_model_reg)
-
-# Restore env vars modified above
-CC="$save_CC"
-
-#-----------------------------------------------------------------------------#
-
-AC_MSG_CHECKING(whether we can support profiling on this system)
-AC_CACHE_VAL(mercury_cv_profiling,
-AC_TRY_CPP([
-/* The following code comes from runtime/prof.c */
-#include	<unistd.h>
-#include	<errno.h>
-#include	<string.h>
-#include	<signal.h>
-
-#ifdef MR_HAVE_SYS_PARAM_H
-#include	<sys/param.h>
-#endif
-
-#ifdef MR_HAVE_SYS_TIME_H
-#include	<sys/time.h>
-#endif
-
-/* 
-** if HZ is not defined, we may be able to use sysconf(_SC_CLK_TCK) instead
-*/
-#if !defined(HZ) && defined(MR_HAVE_SYSCONF) && defined(_SC_CLK_TCK)
-#define HZ ((int)sysconf(_SC_CLK_TCK))
-#endif
-
-#if !defined(HZ) || !defined(SIGPROF) || !defined(MR_HAVE_SETITIMER)
-#error "Time profiling not supported on this system"
-#endif
-], [mercury_cv_profiling=yes], [mercury_cv_profiling=no]))
-AC_MSG_RESULT($mercury_cv_profiling)
-
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(if C compiler is egcs)
-case "`$CC --version < /dev/null 2>&1`" in
-    egcs-*)
-	mercury_cv_egcs=yes
-	;;
-    *)
-	mercury_cv_egcs=no
-	;;
-esac
-AC_MSG_RESULT($mercury_cv_egcs)
  #-----------------------------------------------------------------------------#
  #
  # Add an option that disables the deep profiler.
@@ -2392,7 +1403,7 @@
      mercury_cv_can_enable_deep_profiler=no
  fi

-# on x86, gcc version egcs-1.1.2 has a bug which causes it to get
+# On x86, gcc version egcs-1.1.2 has a bug which causes it to get
  # an internal compiler error when compiling library/random.c
  # (when that file was build with mmc --intermodule-optimization -O4)
  # So if we're using an egcs version of gcc, disable deep profiling.
@@ -2587,25 +1598,7 @@

  #-----------------------------------------------------------------------------#

-AC_MSG_CHECKING(whether we can use thread-local storage class extension)
-AC_CACHE_VAL(mercury_cv_thread_local_storage,
-	AC_TRY_COMPILE([],[
-		static __thread int thread_local_variable;
-	],
-	[mercury_cv_thread_local_storage=yes],
-	[mercury_cv_thread_local_storage=no])
-)
-AC_MSG_RESULT($mercury_cv_thread_local_storage)
-
-# Thread-local storage is disabled on Solaris as there is a linker problem
-# with shared objects and TLS.
-
-if test "$mercury_cv_thread_local_storage" = yes; then
-	case "$host" in 
-		*-solaris2.*)	;;
-		*)		AC_DEFINE(MR_THREAD_LOCAL_STORAGE) ;;
-	esac
-fi
+MERCURY_GCC_THREAD_LOCAL_STORAGE

  #-----------------------------------------------------------------------------#


--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list