for review: clean up handling of config macros [2/2]
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Mar 16 00:10:22 AEDT 1998
On 15-Mar-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Tyson, can you please review this one?
...
> Clean up the handling of configuration macros in the runtime.
I guess you'll want to see the diff too, not just the new file ;-)
cvs diff: Diffing .
cvs diff: CFLAGSFILE was removed, no comparison available
Index: mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.4
diff -u -u -r1.4 mercury_conf.h.in
--- mercury_conf.h.in 1998/03/11 05:58:24 1.4
+++ mercury_conf.h.in 1998/03/15 10:19:49
@@ -6,14 +6,23 @@
/*
** mercury_conf.h.in -
-** Various configuration parameters, determined automatically by
-** the auto-configuration script. Implications of configuration
-** parameters, and combinations of paramters.
+** Defines various configuration parameters.
+**
+** Configuration parameters fall into three groups.
+** They can be set automatically by autoconf.
+** They can be passed on the command line (e.g. the mgnuc
+** script sets some options based on the grade).
+** Or their values can be entirely determined by the settings
+** of other parameters.
+**
+** The ones defined in this file are determined by autoconf.
+** The remainder are documented and/or defined in mercury_conf_param.h,
+** which is #included by this file.
*/
/*
** IMPORTANT NOTE:
-** This file must not contain any #include statements,
+** This file must not contain any other #include statements,
** and may not define any global variables,
** for reasons explained in mercury_imp.h.
** This file should contain _only_ configuration macros.
@@ -22,6 +31,11 @@
#ifndef MERCURY_CONF_H
#define MERCURY_CONF_H
+/*---------------------------------------------------------------------------*/
+/*
+** Configuration parameters determined by autoconf.
+*/
+
/*
** WORD_TYPE: the base type for the definition of Word.
** This must be a C integral type (e.g. int, long, or long long)
@@ -199,49 +213,8 @@
*/
#undef MR_CANNOT_GROK_ASM_TYPE_DIRECTIVE
-/*
-** Implications of configuration parameters.
-**
-** Meaning of parameters:
-**
-** MR_USE_STACK_LAYOUTS -- stack layouts are in use, generate stack
-** layout structures.
-** MR_INSERT_LABELS -- labels need to be inserted into the label table.
-** (this also means the initialization code needs
-** to be run).
-** MR_NEED_INITIALIZATION_CODE -- the module specific initialization code
-** is needed (doesn't actually run the code,
-** however).
-*/
-
-#if defined(MR_STACK_TRACE) || defined(NATIVE_GC)
- #define MR_USE_STACK_LAYOUTS
- #define MR_INSERT_LABELS
-#endif
-
-#if !defined(SPEED) || defined(DEBUG_GOTOS)
- #define MR_INSERT_LABELS
-#endif
-
-/*
-** Static code addresses are available unless using gcc non-local gotos,
-** without assembler labels.
-*/
-#if (defined(USE_GCC_NONLOCAL_GOTOS) && !defined(USE_ASM_LABELS))
- #undef MR_STATIC_CODE_ADDRESSES
-#else
- #define MR_STATIC_CODE_ADDRESSES
-#endif
-
-/*
-** You need to run initialization code for grades without static
-** code addresses, for profiling, and any time you need to insert
-** labels into the label table.
-*/
-#if !defined(MR_STATIC_CODE_ADDRESSES) || defined(PROFILE_CALLS) \
- || defined(DEBUG_LABELS) || defined(MR_INSERT_LABELS)
- #define MR_NEED_INITIALIZATION_CODE
-#endif
+/*---------------------------------------------------------------------------*/
+#include "mercury_conf_param.h"
#endif /* MERCURY_CONF_H */
cvs diff: mercury_conf_param.h is a new entry, no comparison available
Index: mercury_debug.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.h,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_debug.h
--- mercury_debug.h 1998/01/23 15:26:32 1.3
+++ mercury_debug.h 1998/03/15 09:16:02
@@ -15,9 +15,7 @@
#define DEBUG(X)
#endif
-#endif
-
-#if defined(SPEED) && !defined(DEBUG_GOTOS)
+#if !defined(MR_DEBUG_GOTOS)
#define debuggoto(label) ((void)0)
#define debugsreg() ((void)0)
@@ -33,7 +31,7 @@
#endif
-#ifdef SPEED
+#ifndef MR_LOWLEVEL_DEBUG
#define dump_push_msg(msg) ((void)0)
#define dump_pop_msg() ((void)0)
@@ -133,6 +131,8 @@
#define debugmsg3(msg, arg1, arg2, arg3) \
IF (progdebug, (printf(msg, arg1, arg2, arg3)))
+
+#endif /* MR_LOWLEVEL_DEBUG */
#endif /* not MERCURY_DEBUG_H */
Index: mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.4
diff -u -u -r1.4 mercury_engine.c
--- mercury_engine.c 1997/12/05 17:53:51 1.4
+++ mercury_engine.c 1998/03/15 09:16:38
@@ -170,7 +170,7 @@
unsigned char locals[LOCALS_SIZE];
{
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
{
/* ensure that we only make the label once */
static bool initialized = FALSE;
@@ -197,7 +197,7 @@
global_pointer = locals;
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
memset((void *)locals, MAGIC_MARKER, LOCALS_SIZE);
#endif
debugmsg1("in `call_engine', locals at %p\n", (void *)locals);
@@ -226,7 +226,7 @@
debugmsg1("in label `engine_done', locals at %p\n", locals);
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
/*
** Check how much of the space we reserved for local variables
** was actually used.
@@ -248,7 +248,7 @@
min(high, LOCALS_SIZE - low));
printf("(low mark = %d, high mark = %d)\n", low, high);
}
-#endif /* not SPEED */
+#endif /* MR_LOWLEVEL_DEBUG */
/*
** Despite the above precautions with allocating a large chunk
@@ -322,7 +322,7 @@
{
int i, pos;
-#if defined(SPEED) && !defined(DEBUG_GOTOS)
+#if !defined(MR_DEBUG_GOTOS)
if (tracedebug)
#endif
{
@@ -348,7 +348,7 @@
fp = (*fp)();
fp = entry_point;
-#if defined(SPEED) && !defined(DEBUG_GOTOS)
+#if !defined(MR_DEBUG_GOTOS)
if (!tracedebug) {
for (;;)
{
Index: mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_goto.h
--- mercury_goto.h 1998/03/11 05:58:27 1.6
+++ mercury_goto.h 1998/03/15 12:42:20
@@ -47,7 +47,7 @@
#endif
#if defined(MR_INSERT_LABELS) || defined(PROFILE_CALLS) \
- || defined(DEBUG_LABELS)
+ || defined(MR_CHOOSE_ENTRY_POINT)
#define make_entry(n, a, l) insert_entry(n, a, MR_STACK_LAYOUT(l))
#else
#define make_entry(n, a, l) /* nothing */
Index: mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_grade.h
--- mercury_grade.h 1998/03/11 05:58:29 1.6
+++ mercury_grade.h 1998/03/15 09:11:40
@@ -139,10 +139,10 @@
#define MR_GRADE_PART_8 _sa
#endif
-#ifdef SPEED
+#ifndef MR_DEBUG_NONDET_STACK
#define MR_GRADE_PART_9
#else
- #define MR_GRADE_PART_9 _debug
+ #define MR_GRADE_PART_9 _debugNDS
#endif
#if defined(PIC_REG) && defined(USE_GCC_GLOBAL_REGISTERS) && defined(__i386__)
Index: mercury_label.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_label.c,v
retrieving revision 1.5
diff -u -u -r1.5 mercury_label.c
--- mercury_label.c 1998/01/06 07:06:00 1.5
+++ mercury_label.c 1998/03/15 08:57:25
@@ -66,7 +66,7 @@
if (MR_profiling) MR_prof_output_addr_decl(name, addr);
#endif
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (progdebug) {
printf("inserting label %s at %p\n", name, addr);
}
@@ -89,7 +89,7 @@
{
do_init_entries();
do_init_modules();
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (progdebug) {
printf("looking for label at %p\n", addr);
}
@@ -103,7 +103,7 @@
{
do_init_entries();
do_init_modules();
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (progdebug) {
printf("looking for label %s\n", name);
}
Index: mercury_memory.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.c,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_memory.c
--- mercury_memory.c 1997/11/23 09:31:49 1.3
+++ mercury_memory.c 1998/03/15 09:02:17
@@ -180,7 +180,7 @@
MemoryZone *heap_zone;
MemoryZone *solutions_heap_zone;
#endif
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
MemoryZone *dumpstack_zone;
int dumpindex;
#endif
@@ -371,7 +371,7 @@
zone_table[i].bottom = NULL;
zone_table[i].top = NULL;
zone_table[i].min = NULL;
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
zone_table[i].max = NULL;
#endif
#ifdef HAVE_MPROTECT
@@ -422,7 +422,7 @@
#endif
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
/*
** Create the dumpstack, used for debugging stack traces.
** Note that we can just make the dumpstack the same size as
@@ -576,7 +576,7 @@
zone->top = (Word *) ((char *)base+total_size);
zone->min = (Word *) ((char *)base+offset);
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
zone->max = zone->min;
#endif
@@ -629,16 +629,17 @@
#define STDERR 2
-#ifdef SPEED
+#ifndef MR_LOWLEVEL_DEBUG
static void
print_dump_stack(void)
{
- const char *msg = "You can get a stack dump by using grade debug\n";
+ const char *msg =
+ "You can get a stack dump by using `--low-level-debug'\n";
write(STDERR, msg, strlen(msg));
}
-#else /* not SPEED */
+#else /* MR_LOWLEVEL_DEBUG */
static void
print_dump_stack(void)
@@ -681,7 +682,7 @@
} /* end print_dump_stack() */
-#endif /* not SPEED */
+#endif /* MR_LOWLEVEL_DEBUG */
#if defined(HAVE_MPROTECT) && defined(HAVE_SIGINFO)
/* try_munprotect is only useful if we have SIGINFO */
Index: mercury_memory.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.h,v
retrieving revision 1.2
diff -u -u -r1.2 mercury_memory.h
--- mercury_memory.h 1997/11/23 07:21:28 1.2
+++ mercury_memory.h 1998/03/15 08:58:56
@@ -103,9 +103,9 @@
Word *bottom; /* beginning of the allocated area */
Word *top; /* end of the allocated area */
Word *min; /* lowest word of the area to be used */
-#ifndef SPEED
- Word *max; /* highest word of the area to be used */
-#endif
+ Word *max; /* highest word of the area to be used;
+ computed only if MR_LOWLEVEL_DEBUG is
+ enabled */
#ifdef HAVE_MPROTECT
Word *redzone_base; /* beginning of the original redzone */
Word *redzone; /* beginning of the current redzone */
@@ -133,7 +133,7 @@
extern MemoryZone *solutions_heap_zone;
#endif
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
extern MemoryZone *dumpstack_zone;
extern int dumpindex;
#endif
Index: mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_misc.c
--- mercury_misc.c 1998/01/23 15:26:33 1.3
+++ mercury_misc.c 1998/03/15 09:18:07
@@ -17,7 +17,7 @@
/* debugging messages */
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
void
mkframe_msg(void)
@@ -211,9 +211,9 @@
return;
}
-#endif /* !defined(SPEED) */
+#endif /* defined(MR_LOWLEVEL_DEBUG) */
-#if !defined(SPEED) || defined(DEBUG_GOTOS)
+#if defined(MR_DEBUG_GOTOS)
void
goto_msg(/* const */ Code *addr)
@@ -249,11 +249,11 @@
return;
}
-#endif /* !defined(SPEED) || defined(DEBUG_GOTOS) */
+#endif /* defined(MR_DEBUG_GOTOS) */
/*--------------------------------------------------------------------*/
-#if !defined(SPEED) || defined(DEBUG_GOTOS)
+#if defined(MR_DEBUG_GOTOS)
/* debugging printing tools */
@@ -297,7 +297,7 @@
void
printnondstack(const Word *s)
{
-#ifdef SPEED
+#ifndef MR_DEBUG_NONDET_STACK
printf("ptr 0x%p, offset %3ld words\n",
(const void *) s, (long) (Integer) (s - nondetstack_zone->min));
#else
@@ -327,7 +327,7 @@
printf("frame at ptr 0x%p, offset %3ld words\n",
(const void *) fr,
(long) (Integer) (fr - nondetstack_zone->min));
-#ifndef SPEED
+#ifdef MR_DEBUG_NONDET_STACK
printf("\t predname %s\n", bt_prednm(fr));
#endif
printf("\t succip "); printlabel(bt_succip(fr));
@@ -404,7 +404,7 @@
}
}
-#endif /* !defined(SPEED) || defined(DEBUG_GOTOS) */
+#endif /* defined(MR_DEBUG_GOTOS) */
void
printlabel(/* const */ Code *w)
Index: mercury_misc.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.h,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_misc.h
--- mercury_misc.h 1998/01/23 15:26:35 1.3
+++ mercury_misc.h 1998/03/15 09:16:17
@@ -11,7 +11,7 @@
#include "mercury_types.h" /* for `Code *' */
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
extern void mkframe_msg(void);
extern void modframe_msg(void);
@@ -31,14 +31,14 @@
extern void pop_msg(Word val, const Word *addr);
#endif
-#if !defined(SPEED) || defined(DEBUG_GOTOS)
+#if defined(MR_DEBUG_GOTOS)
extern void goto_msg(/* const */ Code *addr);
extern void reg_msg(void);
#endif
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
extern void printint(Word n);
extern void printstring(const char *s);
Index: mercury_overflow.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_overflow.h,v
retrieving revision 1.2
diff -u -u -r1.2 mercury_overflow.h
--- mercury_overflow.h 1997/11/23 07:21:30 1.2
+++ mercury_overflow.h 1998/03/15 08:49:37
@@ -11,7 +11,7 @@
#define IF(cond, val) ((cond) ? ((val), (void)0) : (void)0)
-#ifdef SPEED
+#ifndef MR_CHECK_FOR_OVERFLOW
#define heap_overflow_check() ((void)0)
#define detstack_overflow_check() ((void)0)
@@ -19,7 +19,7 @@
#define nondstack_overflow_check() ((void)0)
#define nondstack_underflow_check() ((void)0)
-#else /* not SPEED */
+#else /* MR_CHECK_FOR_OVERFLOW */
#include "mercury_regs.h"
#include "mercury_misc.h" /* for fatal_error() */
@@ -73,6 +73,6 @@
(void)0 \
)
-#endif /* not SPEED */
+#endif /* MR_CHECK_FOR_OVERFLOW */
#endif /* not MERCURY_OVERFLOW_H */
Index: mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.1
diff -u -u -r1.1 mercury_stack_trace.c
--- mercury_stack_trace.c 1998/03/11 05:58:40 1.1
+++ mercury_stack_trace.c 1998/03/15 10:55:58
@@ -28,7 +28,7 @@
#ifndef MR_STACK_TRACE
fprintf(stderr, "Stack dump not available in this grade.\n");
#else
- fprintf(stderr, "Stack dump follows (determinisitic stack only):\n");
+ fprintf(stderr, "Stack dump follows (deterministic stack only):\n");
do {
label = lookup_label_addr(success_pointer);
Index: mercury_stacks.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stacks.h,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_stacks.h
--- mercury_stacks.h 1998/01/13 09:52:25 1.3
+++ mercury_stacks.h 1998/03/15 09:08:55
@@ -73,13 +73,13 @@
#define SUCCIP (-2) /* in caller proc, set up at call */
#define SUCCFR (-3) /* frame of caller proc, set up at call */
-#ifdef SPEED
-#define bt_prednm(fr) "unknown"
-#define NONDET_FIXED_SIZE_0 4 /* units: words */
+#ifdef MR_DEBUG_NONDET_STACK
+ #define PREDNM (-4) /* for debugging, set up at call */
+ #define bt_prednm(fr) LVALUE_CAST(const char *, ((Word *) fr)[PREDNM])
+ #define NONDET_FIXED_SIZE_0 5 /* units: words */
#else
-#define PREDNM (-4) /* for debugging, set up at call */
-#define bt_prednm(fr) LVALUE_CAST(const char *, ((Word *) fr)[PREDNM])
-#define NONDET_FIXED_SIZE_0 5 /* units: words */
+ #define bt_prednm(fr) "unknown"
+ #define NONDET_FIXED_SIZE_0 4 /* units: words */
#endif
#define NONDET_FIXED_SIZE NONDET_FIXED_SIZE_0
@@ -102,7 +102,7 @@
/* DEFINITIONS FOR MANIPULATING THE NONDET STACK */
-#ifndef SPEED
+#ifdef MR_DEBUG_NONDET_STACK
#define mkframe_save_prednm(prednm) (curprednm = prednm)
#else
#define mkframe_save_prednm(prednm) /* nothing */
Index: mercury_std.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.2
diff -u -u -r1.2 mercury_std.h
--- mercury_std.h 1997/11/23 07:21:36 1.2
+++ mercury_std.h 1998/03/15 08:54:47
@@ -51,12 +51,13 @@
#endif
/*
-** turn assertions off for speed
+** For speed, turn assertions off,
+** unless low-level debugging is enabled.
*/
-#ifdef SPEED
-#define MR_assert(ASSERTION) ((void)0)
+#ifdef MR_LOWLEVEL_DEBUG
+ #define MR_assert(ASSERTION) assert(ASSERTION)
#else
-#define MR_assert(ASSERTION) assert(ASSERTION)
+ #define MR_assert(ASSERTION) ((void)0)
#endif
Index: mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.7
diff -u -u -r1.7 mercury_wrapper.c
--- mercury_wrapper.c 1998/03/11 22:07:34 1.7
+++ mercury_wrapper.c 1998/03/15 09:06:22
@@ -174,7 +174,7 @@
*/
save_regs_to_mem(c_regs);
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
/*
** Ensure stdio & stderr are unbuffered even if redirected.
** Using setvbuf() is more complicated than using setlinebuf(),
@@ -734,7 +734,7 @@
Word c_regs[NUM_REAL_REGS];
#endif
-#if !defined(SPEED) && defined(USE_GCC_NONLOCAL_GOTOS)
+#if defined(MR_LOWLEVEL_DEBUG) && defined(USE_GCC_NONLOCAL_GOTOS)
unsigned char safety_buffer[SAFETY_BUFFER_SIZE];
#endif
@@ -747,7 +747,7 @@
save_regs_to_mem(c_regs);
restore_registers();
-#if !defined(SPEED) && defined(USE_GCC_NONLOCAL_GOTOS)
+#if defined(MR_LOWLEVEL_DEBUG) && defined(USE_GCC_NONLOCAL_GOTOS)
/*
** double-check to make sure that we're not corrupting
** the C stack with these non-local gotos, by filling
@@ -759,10 +759,10 @@
memset(safety_buffer, MAGIC_MARKER_2, SAFETY_BUFFER_SIZE);
#endif
-#ifndef SPEED
-#ifndef CONSERVATIVE_GC
+#ifdef MR_LOWLEVEL_DEBUG
+ #ifndef CONSERVATIVE_GC
heap_zone->max = heap_zone->min;
-#endif
+ #endif
detstack_zone->max = detstack_zone->min;
nondetstack_zone->max = nondetstack_zone->min;
#endif
@@ -780,7 +780,7 @@
time_at_finish = MR_get_user_cpu_miliseconds();
}
-#if defined(USE_GCC_NONLOCAL_GOTOS) && !defined(SPEED)
+#if defined(USE_GCC_NONLOCAL_GOTOS) && defined(MR_LOWLEVEL_DEBUG)
{
int i;
@@ -793,13 +793,13 @@
debugregs("after final call");
}
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (memdebug) {
printf("\n");
-#ifndef CONSERVATIVE_GC
+ #ifndef CONSERVATIVE_GC
printf("max heap used: %6ld words\n",
(long) (heap_zone->max - heap_zone->min));
-#endif
+ #endif
printf("max detstack used: %6ld words\n",
(long)(detstack_zone->max - detstack_zone->min));
printf("max nondstack used: %6ld words\n",
@@ -906,7 +906,7 @@
noprof_call(program_entry_point, LABEL(global_success));
Define_label(global_success);
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (finaldebug) {
save_transient_registers();
printregs("global succeeded");
@@ -921,7 +921,7 @@
GOTO_LABEL(all_done);
Define_label(global_fail);
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (finaldebug) {
save_transient_registers();
printregs("global failed");
@@ -941,7 +941,7 @@
MR_succip = (Code *) pop();
MR_hp = (Word *) pop();
-#ifndef SPEED
+#ifdef MR_LOWLEVEL_DEBUG
if (finaldebug && detaildebug) {
save_transient_registers();
printregs("after popping...");
cvs diff: Diffing machdeps
--
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.
More information about the developers
mailing list