[m-dev.] for review: changes to VLA autoconfiguration
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Apr 21 04:19:59 AEST 1999
Comments welcome...
--------------------
Estimated hours taken: 2
Fix some problems caused by the recently added autoconf tests for
determining how to handle variable-sized arrays.
runtime/mercury_conf_param.h:
runtime/mercury_std.h:
Change the definition of MR_VARIABLE_SIZED so that it uses
compile-time #ifdef checks rather than autoconf-based configuration.
Using autoconf-based configuration for compiler-dependent
properties breaks the instructions for using compilers other
than gcc in the Mercury User's Guide; in particular, with the
autoconf approach, if you had installed Mercury using GNU C
(or if you were using a binary distribution that was configured
with GNU C), and then you set the environment variable
MERCURY_C_COMPILER to point to a C compiler that doesn't
support GNU-style variable-length arrays (e.g. lcc), then you
would get compile errors.
Also move the definition of MR_VARIABLE_SIZED from
mercury_conf_param.h to mercury_std.h (it never belonged
in the former location, IMHO, since it was only ever
a definition that _used_ configuration parameters rather
than being a configuration parameter itself).
configure.in:
runtime/mercury_conf.h.in:
Delete the configuration tests and configuration macros for
variable-sized arrays, since the above change means these are
no longer needed.
runtime/mercury_stack_layout.h:
Include mercury_std.h rather than mercury_conf_param.h
for MR_VARIABLE_SIZED.
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.161
diff -u -r1.161 configure.in
--- configure.in 1999/04/16 06:03:59 1.161
+++ configure.in 1999/04/19 07:38:50
@@ -1641,44 +1641,6 @@
AC_DEFINE(MR_CANNOT_USE_STRUCTURE_ASSIGNMENT)
fi
#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether structures can include variable sized arrays)
-AC_CACHE_VAL(mercury_cv_support_variable_sized_array,
- AC_TRY_COMPILE([], [
- changequote(<<,>>)
- typedef struct tagname {
- int num;
- int items[];
- } typename;
- changequote([,])
- ],
- [mercury_cv_support_variable_sized_array=yes],
- [mercury_cv_support_variable_sized_array=no])
-)
-AC_MSG_RESULT($mercury_cv_support_variable_sized_array)
-if test "$mercury_cv_support_variable_sized_array" = yes; then
- AC_DEFINE(MR_SUPPORT_VARIABLE_SIZED_ARRAY)
-fi
-AC_SUBST(MR_SUPPORT_VARIABLE_SIZED_ARRAY)
-#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether variable sized arrays in structures can be faked)
-AC_CACHE_VAL(mercury_cv_faked_variable_sized_array,
- AC_TRY_COMPILE([], [
- changequote(<<,>>)
- typedef struct tagname {
- int num;
- int items[0];
- } typename;
- changequote([,])
- ],
- [mercury_cv_faked_variable_sized_array=yes],
- [mercury_cv_faked_variable_sized_array=no])
-)
-AC_MSG_RESULT($mercury_cv_faked_variable_sized_array)
-if test "$mercury_cv_faked_variable_sized_array" = yes; then
- AC_DEFINE(MR_FAKED_VARIABLE_SIZED_ARRAY)
-fi
-AC_SUBST(MR_FAKED_VARIABLE_SIZED_ARRAY)
-#-----------------------------------------------------------------------------#
AC_MSG_CHECKING(whether Mercury supports shared libraries on this system)
# We ought to use $target here rather than $host - but we don't
# support cross-compilation at the moment anyhow.
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.16
diff -u -r1.16 mercury_conf.h.in
--- mercury_conf.h.in 1999/04/19 10:55:54 1.16
+++ mercury_conf.h.in 1999/04/20 15:14:03
@@ -238,20 +238,6 @@
#undef MR_CANNOT_GROK_ASM_TYPE_DIRECTIVE
/*
-** Does the C compiler support structures including, as their last element,
-** a variable sized array indicated by an empty pair of brackets?
-** (The draft C9X standard allows this syntax.)
-*/
-#undef MR_SUPPORT_VARIABLE_SIZED_ARRAY
-
-/*
-** Does the C compiler support structures including, as their last element,
-** a variable sized array indicated by specifying a size of zero?
-** (GNU C allows this syntax.)
-*/
-#undef MR_FAKED_VARIABLE_SIZED_ARRAY
-
-/*
** On some platforms, structure assignments can cause gcc to abort
** with the message "fixed or forbidden register was spilled." in some grades.
*/
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.19
diff -u -r1.19 mercury_conf_param.h
--- mercury_conf_param.h 1999/04/20 11:48:12 1.19
+++ mercury_conf_param.h 1999/04/20 14:38:16
@@ -285,33 +285,4 @@
/*---------------------------------------------------------------------------*/
-/*
-** MR_VARIABLE_SIZED -- what to put between the []s when declaring
-** a variable sized array at the end of a struct.
-**
-** The preferred values, if the compiler understands them, convey to the
-** implementation that the array has a variable size. The default value
-** is the maximum size of the variable-sized arrays that we construct,
-** since giving too small a value may lead the compiler to use inappropriate
-** optimizations (e.g. using small offsets to index into the array).
-** At the moment, we use variable sized arrays that are indexed by
-** closure argument numbers or by type parameter numbers. We therefore
-** use a default MR_VARIABLE_SIZED value that is at least as big as
-** both MAX_VIRTUAL_REG and TYPE_CTOR_LAYOUT_MAX_VARINT.
-*/
-
-#ifdef MR_VARIABLE_SIZED
- #error "MR_VARIABLE_SIZED should not be defined on the command line"
-#endif
-
-#if defined(MR_SUPPORT_VARIABLE_SIZED_ARRAY)
- #define MR_VARIABLE_SIZED /* nothing */
-#elif defined(MR_FAKED_VARIABLE_SIZED_ARRAY)
- #define MR_VARIABLE_SIZED 0
-#else
- #define MR_VARIABLE_SIZED 1024
-#endif
-
-/*---------------------------------------------------------------------------*/
-
#endif /* MERCURY_CONF_PARAM_H */
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.21
diff -u -r1.21 mercury_stack_layout.h
--- mercury_stack_layout.h 1999/04/19 07:43:46 1.21
+++ mercury_stack_layout.h 1999/04/20 15:12:10
@@ -17,7 +17,7 @@
*/
#include "mercury_types.h"
-#include "mercury_conf_param.h" /* for MR_VARIABLE_SIZED */
+#include "mercury_std.h" /* for MR_VARIABLE_SIZED */
/*-------------------------------------------------------------------------*/
/*
Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.6
diff -u -r1.6 mercury_std.h
--- mercury_std.h 1998/10/16 06:19:03 1.6
+++ mercury_std.h 1999/04/19 08:03:11
@@ -76,6 +76,35 @@
#define MR_assert(ASSERTION) ((void)0)
#endif
+/*---------------------------------------------------------------------------*/
+
+/*
+** MR_VARIABLE_SIZED -- what to put between the []s when declaring
+** a variable length array at the end of a struct.
+**
+** The preferred values, if the compiler understands them, convey to the
+** implementation that the array has a variable length. The default value
+** is the maximum length of the variable-length arrays that we construct,
+** since giving too small a value may lead the compiler to use inappropriate
+** optimizations (e.g. using small offsets to index into the array).
+** At the moment, we use variable length arrays that are indexed by
+** closure argument numbers or by type parameter numbers. We therefore
+** use a default MR_VARIABLE_SIZED value that is at least as big as
+** both MAX_VIRTUAL_REG and TYPE_CTOR_LAYOUT_MAX_VARINT.
+*/
+
+#if __STDC_VERSION__ >= 199901 /* January 1999 */
+ /* Use C9X-style variable-length arrays. */
+ #define MR_VARIABLE_SIZED /* nothing */
+#elif defined(__GNUC__)
+ /* Use GNU-style variable-length arrays */
+ #define MR_VARIABLE_SIZED 0
+#else
+ /* Just fake it by pretending that the array has a fixed size */
+ #define MR_VARIABLE_SIZED 1024
+#endif
+
+/*---------------------------------------------------------------------------*/
/* XXX these should go in mercury_memory.h or mercury_heap.h */
extern void *newmem(size_t);
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list