[m-dev.] for review: enforce namespace restrictions

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 5 05:20:55 AEDT 2000


On 24-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Add some Mmake rules to the runtime and some code to tools/bootcheck
> so that we automatically check that the namespace remains clean.
> Also add some `MR_' prefixes that Zoltan missed in his earlier change.

More testing revealed that the following additional changes
were required, in addition to the ones I posted earlier.

I'll go ahead and commit this now, together with my earlier change.

----------

Estimated hours taken: 16

Add some more `MR_' prefixes.
 
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_tables.c:
	Add MR_ prefixes to do_init_modules().

runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
runtime/mercury_overflow.h:
runtime/mercury_debug.h:
	Add MR_ prefixes to table_*.
	Add MR_ prefixes to IF().

runtime/mercury_context.h:
	Add MR_ prefixes to IF_MR_THREAD_SAFE().

runtime/mercury_engine.h:
	Add MR_ prefixes to IF_NOT_CONSERVATIVE_GC().

runtime/mercury_engine.h:
runtime/mercury_engine.c:
runtime/*.[ch]:
compiler/llds_out.m:
extras/aditi.m:
	Add MR_ prefixes to do_fail, do_redo, do_not_reached, etc.

compiler/llds_out.m:
	Add MR_ prefixes to r1 and LVALUE_CAST.

compiler/trace.m:
	Add MR_ prefix to Code.

compiler/fact_table.m:
	Add various MR_ prefixes to the generated code.

diff -u runtime/mercury_bootstrap.h runtime/mercury_bootstrap.h
--- runtime/mercury_bootstrap.h
+++ runtime/mercury_bootstrap.h
@@ -15,6 +15,14 @@
 #ifndef	MERCURY_BOOTSTRAP_H
 #define	MERCURY_BOOTSTRAP_H
 
+#define do_redo				MR_do_redo
+#define do_fail				MR_do_fail
+#define do_reset_hp_fail		MR_do_reset_hp_fail
+#define do_reset_framevar0_fail		MR_do_reset_framevar0_fail
+#define do_succeed			MR_do_succeed
+#define do_not_reached			MR_do_not_reached
+#define exception_handler_do_fail	MR_exception_handler_do_fail
+
 #define	r1				MR_r1
 #define	r2				MR_r2
 #define	r3				MR_r3
diff -u runtime/mercury_context.c runtime/mercury_context.c
--- runtime/mercury_context.c
+++ runtime/mercury_context.c
@@ -92,7 +92,7 @@
 #ifdef	MR_THREAD_SAFE
 	c->owner_thread = (MercuryThread) NULL;
 #endif
-	c->context_succip = MR_ENTRY(do_not_reached);
+	c->context_succip = MR_ENTRY(MR_do_not_reached);
 
 	if (c->detstack_zone != NULL) {
 		MR_reset_redzone(c->detstack_zone);
@@ -118,10 +118,10 @@
 	*/
 	c->context_maxfr = c->nondetstack_zone->min + MR_NONDET_FIXED_SIZE - 1;
 	c->context_curfr = c->context_maxfr;
-	MR_redoip_slot(c->context_curfr) = MR_ENTRY(do_not_reached);
+	MR_redoip_slot(c->context_curfr) = MR_ENTRY(MR_do_not_reached);
 	MR_redofr_slot(c->context_curfr) = NULL;
 	MR_prevfr_slot(c->context_curfr) = NULL;
-	MR_succip_slot(c->context_curfr) = MR_ENTRY(do_not_reached);
+	MR_succip_slot(c->context_curfr) = MR_ENTRY(MR_do_not_reached);
 	MR_succfr_slot(c->context_curfr) = NULL;
 
 #ifdef	MR_USE_MINIMAL_MODEL
@@ -300,13 +300,13 @@
 	MR_UNLOCK(MR_runqueue_lock, "schedule");
 }
 
-MR_define_extern_entry(do_runnext);
+MR_define_extern_entry(MR_do_runnext);
 
 MR_BEGIN_MODULE(scheduler_module)
-	MR_init_entry_ai(do_runnext);
+	MR_init_entry_ai(MR_do_runnext);
 MR_BEGIN_CODE
 
-MR_define_entry(do_runnext);
+MR_define_entry(MR_do_runnext);
 #ifdef MR_THREAD_SAFE
 {
 	MR_Context *tmp, *prev;
@@ -316,11 +316,11 @@
 	depth = MR_ENGINE(c_depth);
 	thd = MR_ENGINE(owner_thread);
 
-	MR_LOCK(MR_runqueue_lock, "do_runnext (i)");
+	MR_LOCK(MR_runqueue_lock, "MR_do_runnext (i)");
 
 	while (1) {
 		if (MR_exit_now == TRUE) {
-			MR_UNLOCK(MR_runqueue_lock, "do_runnext (ii)");
+			MR_UNLOCK(MR_runqueue_lock, "MR_do_runnext (ii)");
 			MR_destroy_thread(MR_cur_engine());
 		}
 		tmp = MR_runqueue_head;
@@ -348,7 +348,7 @@
 	if (MR_runqueue_tail == tmp) {
 		MR_runqueue_tail = prev;
 	}
-	MR_UNLOCK(MR_runqueue_lock, "do_runnext (iii)");
+	MR_UNLOCK(MR_runqueue_lock, "MR_do_runnext (iii)");
 	MR_load_context(MR_ENGINE(this_context));
 	MR_GOTO(MR_ENGINE(this_context)->resume);
 }
diff -u runtime/mercury_tabling.c runtime/mercury_tabling.c
--- runtime/mercury_tabling.c
+++ runtime/mercury_tabling.c
@@ -342,7 +342,7 @@
 			}						      \
 		}							      \
 									      \
-		table_free(table->hash_table);				      \
+		MR_table_free(table->hash_table);			      \
 		table->hash_table = new_hash_table;			      \
 		table->size = new_size;					      \
 		table->threshold = new_threshold;			      \
@@ -1006,7 +1006,7 @@
 	if (MR_maxfr > generator_maxfr) {
 		saved_state->non_stack_block_size = MR_maxfr - generator_maxfr;
 		saved_state->non_stack_block =
-			table_allocate_words(saved_state->non_stack_block_size);
+			MR_table_allocate_words(saved_state->non_stack_block_size);
 		MR_table_copy_words(saved_state->non_stack_block,
 			saved_state->non_stack_block_start,
 			saved_state->non_stack_block_size);
@@ -1019,7 +1019,7 @@
 	if (MR_sp > generator_sp) {
 		saved_state->det_stack_block_size = (MR_sp - 1) - generator_sp;
 		saved_state->det_stack_block =
-			table_allocate_words(saved_state->det_stack_block_size);
+			MR_table_allocate_words(saved_state->det_stack_block_size);
 		MR_table_copy_words(saved_state->det_stack_block,
 			saved_state->det_stack_block_start,
 			saved_state->det_stack_block_size);
@@ -1031,13 +1031,13 @@
   #endif /* ! MR_HIGHLEVEL_CODE */
 
 	saved_state->gen_next = MR_gen_next;
-	saved_state->generator_stack_block = table_allocate_bytes(
+	saved_state->generator_stack_block = MR_table_allocate_bytes(
 			MR_gen_next * sizeof(MR_GeneratorStackFrame));
 	MR_table_copy_bytes(saved_state->generator_stack_block,
 		MR_gen_stack, MR_gen_next * sizeof(MR_GeneratorStackFrame));
 
 	saved_state->cut_next = MR_cut_next;
-	saved_state->cut_stack_block = table_allocate_bytes(
+	saved_state->cut_stack_block = MR_table_allocate_bytes(
 			MR_cut_next * sizeof(MR_CutStackFrame));
 	MR_table_copy_bytes(saved_state->cut_stack_block,
 		MR_cut_stack, MR_cut_next * sizeof(MR_CutStackFrame));
@@ -1285,7 +1285,7 @@
 				== suspension->saved_state.s_p - 1);
 	}
 
-	arena_block = table_allocate_words(arena_size);
+	arena_block = MR_table_allocate_words(arena_size);
 
 	MR_table_copy_words(arena_block, arena_start, extension_size);
 	MR_table_copy_words(arena_block + extension_size,
@@ -1320,7 +1320,7 @@
 	assert(leader->generator_maxfr + arena_size
 			== suspension->saved_state.max_fr);
 
-	arena_block = table_allocate_words(arena_size);
+	arena_block = MR_table_allocate_words(arena_size);
 
 	MR_table_copy_words(arena_block, arena_start, extension_size);
 	MR_table_copy_words(arena_block + extension_size,
@@ -1364,7 +1364,8 @@
 		if (saved_fr - frame_size
 			> suspension->saved_state.non_stack_block)
 		{
-			*MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(do_fail);
+			*MR_redoip_addr(saved_fr) =
+				(MR_Word) MR_ENTRY(MR_do_fail);
 
 #ifdef	MR_TABLE_DEBUG
 			if (MR_tabledebug) {
@@ -1492,11 +1493,11 @@
 	** nondet stack fragment. The framevar slot is for use by
 	** table_nondet_resume.
 	*/
-	MR_mkframe("mercury__table_nondet_suspend", 1, MR_ENTRY(do_fail));
+	MR_mkframe("mercury__table_nondet_suspend", 1, MR_ENTRY(MR_do_fail));
 
 	table = (MR_TrieNode) r1;
 	subgoal = table->MR_subgoal;
-	consumer = table_allocate_bytes(sizeof(MR_Consumer));
+	consumer = MR_table_allocate_bytes(sizeof(MR_Consumer));
 	consumer->remaining_answer_list_ptr = &subgoal->answer_list;
 
 	MR_save_transient_registers();
@@ -1558,7 +1559,7 @@
 
 				assert(MR_prevfr_slot(fr) != (stop_addr - 1));
 
-				*clobber_addr = (MR_Word) MR_ENTRY(do_fail);
+				*clobber_addr = (MR_Word) MR_ENTRY(MR_do_fail);
 #ifdef	MR_TABLE_DEBUG
 				if (MR_tablestackdebug) {
 					printf("clobbering redoip "
@@ -1589,7 +1590,7 @@
 
 			cur_cut--;
 		} else {
-			*clobber_addr = (MR_Word) MR_ENTRY(do_fail);
+			*clobber_addr = (MR_Word) MR_ENTRY(MR_do_fail);
 #ifdef	MR_TABLE_DEBUG
 			if (MR_tablestackdebug) {
 				printf("clobbering redoip of frame at ");
@@ -1609,7 +1610,7 @@
 #endif
 
 	assert(*(subgoal->consumer_list_tail) == NULL);
-	listnode = table_allocate_bytes(sizeof(MR_ConsumerListNode));
+	listnode = MR_table_allocate_bytes(sizeof(MR_ConsumerListNode));
 	*(subgoal->consumer_list_tail) = listnode;
 	subgoal->consumer_list_tail = &(listnode->next);
 	listnode->item = consumer;
diff -u runtime/mercury_thread.c runtime/mercury_thread.c
--- runtime/mercury_thread.c
+++ runtime/mercury_thread.c
@@ -8,7 +8,7 @@
 #include "mercury_regs.h"
 #include "mercury_engine.h"
 #include "mercury_memory.h"
-#include "mercury_context.h"	/* for do_runnext */
+#include "mercury_context.h"	/* for MR_do_runnext */
 #include "mercury_thread.h"
 
 #include <stdio.h>
@@ -106,7 +106,7 @@
 
 	switch (when_to_use) {
 		case MR_use_later :
-			(void) MR_call_engine(MR_ENTRY(do_runnext), FALSE);
+			(void) MR_call_engine(MR_ENTRY(MR_do_runnext), FALSE);
 
 			MR_destroy_engine(eng);
 			return FALSE;
diff -u runtime/Mmakefile runtime/Mmakefile
--- runtime/Mmakefile
+++ runtime/Mmakefile
@@ -173,7 +173,6 @@
 
 HDR_CHECK_CS = $(HDRS:.h=_check.c)
 HDR_CHECK_OBJS = $(HDRS:.h=_check.$O)
-HDR_CHECK_NMS = $(HDRS:.h=_check.nms)
 HDR_CHECK_MACROS = $(HDRS:.h=_check.macros)
 OBJ_CHECKS = $(OBJS:%=%.obj_check)
 
@@ -273,11 +272,16 @@
 # foo_check.macros that contains a list of all the macros defined
 # by the header file (or by headers that it includes, excluding
 # standard headers) that do not start with `GC_', `MR_', or `MERCURY_'.
+# We define MERCURY_BOOTSTRAP_H to avoid including the contents of
+# that header; stuff there is for backwards compatibility and is
+# therefore excluded from these checks.
 # 
 
 AWK = awk
 %_check.macros: %.h %_check.c
-	-$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -E $*_check.c \
+	-$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) \
+		-DMERCURY_BOOTSTRAP_H \
+		-E $*_check.c \
 		-nostdinc -dN \
 		2> /dev/null | $(AWK) '/^#define/ { print $$2; }' | \
 		grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
@@ -292,8 +296,14 @@
 		exit 1; \
 	fi
 
+.PHONY: check_headers_self_contained
+check_headers_self_contained: $(HDR_CHECK_OBJS)
+
+.PHONY: check_headers_macros
+check_headers_macros: $(HDR_CHECK_MACROS)
+
 .PHONY: check_headers
-check_headers: $(HDR_CHECK_OBJS) $(HDR_CHECK_MACROS)
+check_headers: check_headers_self_contained check_headers_macros
 
 #
 # $(OBJ_CHECKS) is used to check that the objects are properly
@@ -373,6 +383,7 @@
 .PHONY: clean_check
 clean_check:
 	rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS)
+	rm -f $(OBJ_CHECKS)
 
 realclean_local:
 	rm -f lib$(RT_LIB_NAME).$A lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init
diff -u RESERVED_MACRO_NAMES RESERVED_MACRO_NAMES
--- RESERVED_MACRO_NAMES
+++ RESERVED_MACRO_NAMES
@@ -20,6 +20,10 @@
 # Other lines are treated as strings to match against.
 #
 #-----------------------------------------------------------------------------#
+# This is documented in the Mercury language reference manual
+# and defined by mercury_types.h.
+SUCCESS_INDICATOR
+#-----------------------------------------------------------------------------#
 # These are defined by mercury_std.h
 # XXX we should probably add MR_ prefixes to all of these,
 # especially the str* ones, which violate the ANSI/ISO C standard.
@@ -36,11 +40,16 @@
 max
 min
 reg
+NO_RETURN
 #-----------------------------------------------------------------------------#
 # These are configuration parameters that are defined
 # by mercury_conf.h and/or mercury_conf_param.h and/or
 # on the command-line or by scripts/mgnuc.
 # XXX we ought to add MR_ prefixes to all of these.
+# XXX USE_TYPE_LAYOUT is defined in mercury_type_info.h
+# but it ought to be defined in mercury_conf_param.h,
+# or just deleted, since it is not used at all
+# XXX TAG_BITS is defined in mercury_tags.h
 BOXED_FLOAT
 CONSERVATIVE_GC
 LOW_TAG_BITS
@@ -49,17 +58,19 @@
 PARALLEL
 PC_ACCESS
 PC_ACCESS_GREG
+PIC
 PROFILE_CALLS
-PROFILE_TIME
 PROFILE_MEMORY
-PIC
+PROFILE_TIME
 RETSIGTYPE
 SIGACTION_FIELD
+TAG_BITS
 USE_ASM_LABELS
 USE_DLLS
 USE_GCC_GLOBAL_REGISTERS
 USE_GCC_NONLOCAL_GOTOS
 USE_SINGLE_PREC_FLOAT
+USE_TYPE_LAYOUT
 HAVE_ASM_SIGCONTEXT
 HAVE_DLCLOSE
 HAVE_DLERROR
@@ -108,6 +119,8 @@
 mercury__builtin____type_ctor_info_pred_0
 mercury__builtin____type_ctor_info_string_0
 mercury__builtin____type_ctor_info_tuple_0
+mercury__private_builtin__SIZEOF_WORD
+mercury__private_builtin__unsafe_type_cast_2_p_0
 #-----------------------------------------------------------------------------#
 # These are defined by boehm_gc/gc.h.
 __GC
diff -u tools/bootcheck tools/bootcheck
--- tools/bootcheck
+++ tools/bootcheck
@@ -817,7 +817,15 @@
 if $check_namespace
 then
 	cd $root/${stage2_insert}runtime
-	mmake $mmake_opts check_namespace || check_namespace_status=1
+	mmake $mmake_opts check_namespace || {
+		echo '** mmake check_namespace failed!'
+		# XXX Currently we just report the errors;
+		#     we don't yet actually return a non-zero status.
+		#     That's why the line below is commented out.
+		#     This is a transition measure until we're sure
+		#     that everything really is namespace-clean.
+		# check_namespace_status=1
+	}
 	cd $root
 fi
 
diff -u trace/mercury_trace_external.c trace/mercury_trace_external.c
--- trace/mercury_trace_external.c
+++ trace/mercury_trace_external.c
@@ -644,7 +644,7 @@
 					fprintf(stderr, "\nMercury runtime: "
 						"REQUEST_STACK\n");
 				}
-				do_init_modules();
+				MR_do_init_modules();
 				message = MR_dump_stack_from_layout(
 					stdout, layout,
 					MR_saved_sp(saved_regs),
@@ -665,7 +665,7 @@
 					fprintf(stderr, "\nMercury runtime: "
 						"REQUEST_NONDET_STACK\n");
 				}
-				do_init_modules();
+				MR_do_init_modules();
 				/* 
 			        ** XXX As in stack dump, we could send the
 				** output of this function on the socket. But
diff -u trace/mercury_trace_internal.c trace/mercury_trace_internal.c
--- trace/mercury_trace_internal.c
+++ trace/mercury_trace_internal.c
@@ -1052,7 +1052,7 @@
 			; /* the usage message has already been printed */
 		} else if (word_count == 1) {
 			const char	*msg;
-			do_init_modules();
+			MR_do_init_modules();
 			msg = MR_dump_stack_from_layout(MR_mdb_out, layout,
 					MR_saved_sp(saved_regs),
 					MR_saved_curfr(saved_regs),
@@ -1822,7 +1822,7 @@
 #endif	/* MR_TRACE_HISTOGRAM */
 	} else if (streq(words[0], "nondet_stack")) {
 		if (word_count == 1) {
-			do_init_modules();
+			MR_do_init_modules();
 			MR_dump_nondet_stack_from_layout(MR_mdb_out,
 				MR_saved_maxfr(saved_regs));
 		} else {
@@ -1833,7 +1833,7 @@
 		if (word_count == 1) {
 			bool	saved_tabledebug;
 
-			do_init_modules();
+			MR_do_init_modules();
 			saved_tabledebug = MR_tabledebug;
 			MR_tabledebug = TRUE;
 			MR_print_gen_stack(MR_mdb_out);
only in patch2:
--- trace/mercury_trace_tables.c	2000/08/25 09:53:37	1.11
+++ trace/mercury_trace_tables.c	2000/12/04 06:27:34
@@ -50,7 +50,7 @@
 			fflush(fp);
 		}
 
-		do_init_modules();
+		MR_do_init_modules();
 		done = TRUE;
 		if (verbose) {
 			fprintf(fp, "done.\n");
only in patch2:
--- runtime/machdeps/sparc_regs.h	2000/11/23 02:01:04	1.21
+++ runtime/machdeps/sparc_regs.h	2000/11/23 15:03:07
@@ -4,8 +4,8 @@
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
-#ifndef SPARC_REGS_H
-#define SPARC_REGS_H
+#ifndef MR_MACHDEPS_SPARC_REGS_H
+#define MR_MACHDEPS_SPARC_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the SPARC architecture.
@@ -115,4 +115,4 @@
 
 #endif
 
-#endif /* not SPARC_REGS_H */
+#endif /* not MR_MACHDEPS_SPARC_REGS_H */
only in patch2:
--- runtime/machdeps/rs6000_regs.h	2000/11/23 02:01:03	1.10
+++ runtime/machdeps/rs6000_regs.h	2000/11/23 15:03:01
@@ -4,8 +4,8 @@
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
-#ifndef RS6000_REGS_H
-#define RS6000_REGS_H
+#ifndef MR_MACHDEPS_RS6000_REGS_H
+#define MR_MACHDEPS_RS6000_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the RS/6000 architecture.
@@ -90,4 +90,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not RS6000_REGS_H */
+#endif /* not MR_MACHDEPS_RS6000_REGS_H */
only in patch2:
--- runtime/machdeps/pa_regs.h	2000/11/23 02:01:03	1.7
+++ runtime/machdeps/pa_regs.h	2000/11/23 15:02:46
@@ -4,8 +4,8 @@
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
-#ifndef PA_REGS_H
-#define PA_REGS_H
+#ifndef MR_MACHDEPS_PA_REGS_H
+#define MR_MACHDEPS_PA_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the HP-PA architecture.
@@ -85,4 +85,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not PA_REGS_H */
+#endif /* not MR_MACHDEPS_PA_REGS_H */
only in patch2:
--- runtime/machdeps/no_regs.h	2000/11/23 02:01:03	1.13
+++ runtime/machdeps/no_regs.h	2000/11/23 15:02:34
@@ -3,8 +3,8 @@
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
-#ifndef NO_REGS_H
-#define NO_REGS_H
+#ifndef MR_MACHDEPS_NO_REGS_H
+#define MR_MACHDEPS_NO_REGS_H
 
 /*
 ** Portable version.
@@ -85,4 +85,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not NO_REGS_H */
+#endif /* not MR_MACHDEPS_NO_REGS_H */
only in patch2:
--- runtime/machdeps/mips_regs.h	2000/11/23 02:01:02	1.14
+++ runtime/machdeps/mips_regs.h	2000/11/23 15:02:29
@@ -3,8 +3,8 @@
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
-#ifndef MIPS_REGS_H
-#define MIPS_REGS_H
+#ifndef MR_MACHDEPS_MIPS_REGS_H
+#define MR_MACHDEPS_MIPS_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the MIPS architecture.
@@ -85,4 +85,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not MIPS_REGS_H */
+#endif /* not MR_MACHDEPS_MIPS_REGS_H */
only in patch2:
--- runtime/machdeps/m68k.h	2000/11/23 02:01:02	1.4
+++ runtime/machdeps/m68k.h	2000/11/23 15:02:16
@@ -3,8 +3,8 @@
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
-#ifndef M68K_REGS_H
-#define M68K_REGS_H
+#ifndef MR_MACHDEPS_M68K_REGS_H
+#define MR_MACHDEPS_M68K_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the Motorola 68000 architecture.
@@ -96,4 +96,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not M68K_REGS_H */
+#endif /* not MR_MACHDEPS_M68K_REGS_H */
only in patch2:
--- runtime/machdeps/i386_regs.h	2000/11/23 02:01:02	1.18
+++ runtime/machdeps/i386_regs.h	2000/11/23 15:01:52
@@ -3,8 +3,8 @@
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
-#ifndef I386_REGS_H
-#define I386_REGS_H
+#ifndef MR_MACHDEPS_I386_REGS_H
+#define MR_MACHDEPS_I386_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the Intel 386 architecture.
@@ -144,4 +144,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not I386_REGS_H */
+#endif /* not MR_MACHDEPS_I386_REGS_H */
only in patch2:
--- runtime/machdeps/alpha_regs.h	2000/11/23 02:01:01	1.12
+++ runtime/machdeps/alpha_regs.h	2000/11/23 15:01:45
@@ -4,8 +4,8 @@
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
-#ifndef ALPHA_REGS_H
-#define ALPHA_REGS_H
+#ifndef MR_MACHDEPS_ALPHA_REGS_H
+#define MR_MACHDEPS_ALPHA_REGS_H
 
 /*
 ** Machine registers MR_mr0 - MR_mr36 for the Alpha architecture.
@@ -97,4 +97,4 @@
 #define	MR_mr36	MR_fake_reg[36]
 #define	MR_mr37	MR_fake_reg[37]
 
-#endif /* not ALPHA_REGS_H */
+#endif /* not MR_MACHDEPS_ALPHA_REGS_H */
only in patch2:
--- runtime/mercury_wrapper.h	2000/12/03 02:22:54	1.39
+++ runtime/mercury_wrapper.h	2000/12/03 22:49:02
@@ -12,6 +12,7 @@
 #ifndef	MERCURY_WRAPPER_H
 #define	MERCURY_WRAPPER_H
 
+#include "mercury_regs.h"		/* needs to come first */
 #include <stddef.h>			/* for `size_t' */
 #include "mercury_std.h"		/* for `bool' */
 #include "mercury_stack_layout.h"	/* for `MR_Stack_Layout_Label' etc */
only in patch2:
--- runtime/mercury_wrapper.c	2000/12/03 02:22:53	1.80
+++ runtime/mercury_wrapper.c	2000/12/04 06:24:44
@@ -21,7 +21,7 @@
 **	processes options (which are specified via an environment variable).
 **
 **	It also defines mercury_runtime_main(), which invokes
-**	MR_call_engine(do_interpreter), which invokes main/2.
+**	MR_call_engine(MR_do_interpreter), which invokes main/2.
 **
 **	It also defines mercury_runtime_terminate(), which performs
 **	various cleanups that are needed to terminate cleanly.
@@ -251,9 +251,9 @@
 #endif
 
 #ifdef MR_HIGHLEVEL_CODE
-  static void do_interpreter(void);
+  static void MR_do_interpreter(void);
 #else
-  MR_declare_entry(do_interpreter);
+  MR_declare_entry(MR_do_interpreter);
 #endif
 
 /*---------------------------------------------------------------------------*/
@@ -310,7 +310,7 @@
 	MR_trace_enabled = FALSE;
 
 #ifdef MR_NEED_INITIALIZATION_AT_START
-	do_init_modules();
+	MR_do_init_modules();
 #endif
 
 	(*MR_address_of_mercury_init_io)();
@@ -439,7 +439,7 @@
 		/*
 		** Some system-defined types have the code to register
 		** their type_ctor_infos in the initialization function
-		** invoked by do_init_modules.
+		** invoked by MR_do_init_modules.
 		*/
 
 		MR_do_init_modules();
@@ -984,10 +984,10 @@
 
 	for (repcounter = 0; repcounter < repeats; repcounter++) {
 #ifdef MR_HIGHLEVEL_CODE
-		do_interpreter();
+		MR_do_interpreter();
 #else
 		MR_debugmsg0("About to call engine\n");
-		(void) MR_call_engine(MR_ENTRY(do_interpreter), FALSE);
+		(void) MR_call_engine(MR_ENTRY(MR_do_interpreter), FALSE);
 		MR_debugmsg0("Returning from MR_call_engine()\n");
 #endif
 	}
@@ -1242,19 +1242,19 @@
 
 #else /* ! MR_HIGHLEVEL_CODE */
 
-MR_define_extern_entry(do_interpreter);
+MR_define_extern_entry(MR_do_interpreter);
 MR_declare_label(global_success);
 MR_declare_label(global_fail);
 MR_declare_label(all_done);
 
 MR_BEGIN_MODULE(interpreter_module)
-	MR_init_entry_ai(do_interpreter);
+	MR_init_entry_ai(MR_do_interpreter);
 	MR_init_label_ai(global_success);
 	MR_init_label_ai(global_fail);
 	MR_init_label_ai(all_done);
 MR_BEGIN_CODE
 
-MR_define_entry(do_interpreter);
+MR_define_entry(MR_do_interpreter);
 	MR_incr_sp(4);
 	MR_stackvar(1) = (MR_Word) MR_hp;
 	MR_stackvar(2) = (MR_Word) MR_succip;
only in patch2:
--- runtime/mercury_unify_compare_body.h	2000/11/23 02:00:50	1.6
+++ runtime/mercury_unify_compare_body.h	2000/11/23 13:13:58
@@ -455,9 +455,9 @@
 
                 /* First compare the type_infos */
                 type_info_x = (MR_TypeInfo) MR_field(MR_mktag(0), x,
-                        UNIV_OFFSET_FOR_TYPEINFO);
+                        MR_UNIV_OFFSET_FOR_TYPEINFO);
                 type_info_y = (MR_TypeInfo) MR_field(MR_mktag(0), y,
-                        UNIV_OFFSET_FOR_TYPEINFO);
+                        MR_UNIV_OFFSET_FOR_TYPEINFO);
                 MR_save_transient_registers();
                 result = MR_compare_type_info(type_info_x, type_info_y);
                 MR_restore_transient_registers();
@@ -475,8 +475,8 @@
                 */
 
                 type_info = type_info_x;
-                x = MR_field(MR_mktag(0), x, UNIV_OFFSET_FOR_DATA);
-                y = MR_field(MR_mktag(0), y, UNIV_OFFSET_FOR_DATA);
+                x = MR_field(MR_mktag(0), x, MR_UNIV_OFFSET_FOR_DATA);
+                y = MR_field(MR_mktag(0), y, MR_UNIV_OFFSET_FOR_DATA);
                 goto start_label;
             }
 
only in patch2:
--- runtime/mercury_tabling.h	2000/11/23 02:00:44	1.24
+++ runtime/mercury_tabling.h	2000/12/03 12:23:40
@@ -349,19 +349,19 @@
   #define MR_TABLE_RESIZE_ARRAY(ptr, type, count)			\
 	MR_GC_RESIZE_ARRAY((ptr), type, (count))
 
-  #define table_allocate_bytes(size)					\
+  #define MR_table_allocate_bytes(size)					\
 	MR_GC_malloc((size))
 
-  #define table_reallocate_bytes(pointer, size)				\
+  #define MR_table_reallocate_bytes(pointer, size)			\
 	MR_GC_realloc((pointer), (size))
 
-  #define table_allocate_words(size)					\
+  #define MR_table_allocate_words(size)					\
 	MR_GC_malloc(sizeof(MR_Word) * (size))
 
-  #define table_reallocate_words(pointer, size)				\
+  #define MR_table_reallocate_words(pointer, size)			\
 	MR_GC_realloc((pointer), sizeof(MR_Word) * (size))
 
-  #define table_free(pointer)						\
+  #define MR_table_free(pointer)					\
 	MR_GC_free((pointer))
 
   #define MR_table_list_cons(h, t)					\
@@ -378,19 +378,19 @@
   #define MR_TABLE_RESIZE_ARRAY(pointer, type, count)			\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
 	(void *) NULL)
-  #define table_allocate_bytes(size)					\
+  #define MR_table_allocate_bytes(size)					\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
 	(void *) NULL)
-  #define table_reallocate_bytes(pointer, size)				\
+  #define MR_table_reallocate_bytes(pointer, size)				\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
 	(void *) NULL)
-  #define table_allocate_words(size)					\
+  #define MR_table_allocate_words(size)					\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
 	(void *) NULL)
-  #define table_reallocate_words(pointer, size)				\
+  #define MR_table_reallocate_words(pointer, size)				\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
 	(void *) NULL)
-  #define table_free(pointer)						\
+  #define MR_table_free(pointer)						\
 	MR_fatal_error("Sorry, not implemented: tabling in native gc grades")
   #define MR_table_list_cons(h, t)					\
 	(MR_fatal_error("Sorry, not implemented: tabling in native gc grades"), \
@@ -398,10 +398,10 @@
 
 #endif /* NATIVE_GC */
 
-#define table_copy_bytes(dest, source, size)				\
+#define MR_table_copy_bytes(dest, source, size)				\
 	MR_memcpy((dest), (source), (size))
 
-#define table_copy_words(dest, source, size)				\
+#define MR_table_copy_words(dest, source, size)				\
 	MR_memcpy((char *) (dest), (char *) (source), sizeof(MR_Word) * (size))
 
 /*---------------------------------------------------------------------------*/
only in patch2:
--- runtime/mercury_string.h	2000/11/28 04:31:48	1.20
+++ runtime/mercury_string.h	2000/12/04 06:21:34
@@ -9,11 +9,11 @@
 #ifndef MERCURY_STRING_H
 #define MERCURY_STRING_H
 
+#include "mercury_heap.h"	/* for incr_hp_atomic */
+
 #include <string.h>	/* for strcmp() etc. */
 #include <stdarg.h>
 
-#include "mercury_heap.h"	/* for incr_hp_atomic */
-
 /*
 ** Mercury characters are given type `MR_Char', which is a typedef for `char'.
 ** But BEWARE: when stored in an MR_Integer, the value must be
@@ -120,7 +120,7 @@
 	} while(0)
 
 /*
-** do_hash_string(int & hash, MR_Word string):
+** MR_do_hash_string(int & hash, MR_Word string):
 **	Given a Mercury string `string', set `hash' to the hash value
 **	for that string.  (`hash' must be an lvalue.)
 **
only in patch2:
--- runtime/mercury_stacks.h	2000/11/24 06:03:38	1.24
+++ runtime/mercury_stacks.h	2000/12/04 06:26:05
@@ -257,8 +257,8 @@
 /*
 ** Define a struct for the framevars that we use in an exception handler
 ** nondet stack frame.  This struct gets allocated on the nondet stack
-** using mkpragmaframe(), with a special redoip of
-** `exception_handler_do_fail'.
+** using MR_mkpragmaframe(), with a special redoip of
+** `MR_exception_handler_do_fail'.
 */
 typedef struct MR_Exception_Handler_Frame_struct {
 	/*
@@ -307,14 +307,14 @@
 	do {								      \
 		/*							      \
 		** Create a handler on the stack with the special redoip      \
-		** of `exception_handler_do_fail' (we'll look for this        \
+		** of `MR_exception_handler_do_fail' (we'll look for this     \
 		** redoip when unwinding the nondet stack in		      \
 		** builtin_throw/1), and save the stuff we will		      \
 		** need if an exception is thrown.			      \
 		*/							      \
 		MR_mkpragmaframe((name), 0,				      \
 			MR_Exception_Handler_Frame_struct,		      \
-			MR_ENTRY(exception_handler_do_fail));		      \
+			MR_ENTRY(MR_exception_handler_do_fail));	      \
 		/* record the handler's code model */			      \
 		MR_EXCEPTION_FRAMEVARS->code_model = (handler_code_model);    \
 		/* save the handler's closure */			      \
only in patch2:
--- runtime/mercury_prof.h	2000/11/23 02:00:37	1.11
+++ runtime/mercury_prof.h	2000/12/04 06:21:23
@@ -42,7 +42,7 @@
 
 /*
 ** This variable holds the address of the calling procedure
-** for a call to do_call_closure or do_call_class_method.
+** for a call to MR_do_call_closure or MR_do_call_class_method.
 */
 
 #ifdef PROFILE_CALLS
only in patch2:
--- runtime/mercury_label.c	2000/11/28 04:31:47	1.18
+++ runtime/mercury_label.c	2000/12/04 06:23:38
@@ -18,10 +18,10 @@
 
 #include	"mercury_label.h"
 
-#include	"mercury_hash_table.h"	/* for `MR_Hash_Table' and its ops */
+#include	"mercury_hash_table.h"	/* for MR_Hash_Table and its ops */
 #include	"mercury_prof.h"	/* for prof_output_addr_decl() */
-#include	"mercury_engine.h"	/* for `MR_progdebug' */
-#include	"mercury_wrapper.h"	/* for do_init_modules() */
+#include	"mercury_engine.h"	/* for MR_progdebug */
+#include	"mercury_wrapper.h"	/* for MR_do_init_modules() */
 
 /*
 ** We record information about entry labels in an array that
@@ -165,7 +165,7 @@
 	int	i;
 
 	MR_do_init_label_tables();
-	do_init_modules();
+	MR_do_init_modules();
 
 	if (!entry_array_sorted) {
 		qsort(entry_array, entry_array_next, sizeof(MR_Entry),
only in patch2:
--- runtime/mercury_init.h	2000/11/23 02:00:31	1.27
+++ runtime/mercury_init.h	2000/12/04 06:21:11
@@ -78,8 +78,8 @@
 
 #include "mercury_regs.h"	/* must come before system headers */
 #include "mercury_goto.h"	/* for MR_declare_entry */
-#include "mercury_types.h"	/* for `MR_Word' */
-#include "mercury_wrapper.h"	/* for do_init_modules,
+#include "mercury_types.h"	/* for MR_Word */
+#include "mercury_wrapper.h"	/* for MR_do_init_modules,
 				   mercury_runtime_init(),
 				   mercury_runtime_main(),
 				   mercury_runtime_terminate(),
only in patch2:
--- runtime/mercury_ho_call.c	2000/11/28 04:31:50	1.41
+++ runtime/mercury_ho_call.c	2000/12/04 06:23:18
@@ -128,7 +128,7 @@
 
 	/*
 	** Note that we pass MR_prof_ho_caller_proc rather than
-	** MR_LABEL(do_call_closure), so that the call gets recorded
+	** MR_LABEL(MR_do_call_closure), so that the call gets recorded
 	** as having come from our caller.
 	*/
 	MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
@@ -189,7 +189,7 @@
 
 	/*
 	** Note that we pass MR_prof_ho_caller_proc rather than
-	** MR_LABEL(do_call_class_method), so that the call gets recorded
+	** MR_LABEL(MR_do_call_class_method), so that the call gets recorded
 	** as having come from our caller.
 	*/
 	MR_tailcall(destination, MR_prof_ho_caller_proc);
only in patch2:
--- runtime/mercury_engine.h	2000/11/24 06:03:36	1.20
+++ runtime/mercury_engine.h	2000/12/04 05:56:10
@@ -275,23 +275,23 @@
 #define	MR_CONTEXT(x)		(MR_ENGINE(context).x)
 
 #ifndef CONSERVATIVE_GC
-  #define IF_NOT_CONSERVATIVE_GC(x)	x
+  #define MR_IF_NOT_CONSERVATIVE_GC(x)	x
 #else
-  #define IF_NOT_CONSERVATIVE_GC(x)
+  #define MR_IF_NOT_CONSERVATIVE_GC(x)
 #endif
 
 #define MR_load_engine_regs(eng)					\
   	do {								\
-		IF_NOT_CONSERVATIVE_GC(MR_hp = (eng)->e_hp;)		\
-		IF_NOT_CONSERVATIVE_GC(MR_sol_hp = (eng)->e_sol_hp;)	\
-		IF_NOT_CONSERVATIVE_GC(MR_global_hp = (eng)->e_global_hp;) \
+		MR_IF_NOT_CONSERVATIVE_GC(MR_hp = (eng)->e_hp;)		\
+		MR_IF_NOT_CONSERVATIVE_GC(MR_sol_hp = (eng)->e_sol_hp;)	\
+		MR_IF_NOT_CONSERVATIVE_GC(MR_global_hp = (eng)->e_global_hp;) \
 	} while (0)
 
 #define MR_save_engine_regs(eng)					\
   	do {								\
-		IF_NOT_CONSERVATIVE_GC((eng)->e_hp = MR_hp;)		\
-		IF_NOT_CONSERVATIVE_GC((eng)->e_sol_hp = MR_sol_hp;)	\
-		IF_NOT_CONSERVATIVE_GC((eng)->e_global_hp = MR_global_hp;) \
+		MR_IF_NOT_CONSERVATIVE_GC((eng)->e_hp = MR_hp;)		\
+		MR_IF_NOT_CONSERVATIVE_GC((eng)->e_sol_hp = MR_sol_hp;)	\
+		MR_IF_NOT_CONSERVATIVE_GC((eng)->e_global_hp = MR_global_hp;) \
 	} while (0)
 
 /*
@@ -323,12 +323,12 @@
 ** Builtin labels that point to commonly used code fragments.
 */
 
-MR_declare_entry(do_redo);
-MR_declare_entry(do_fail);
-MR_declare_entry(do_reset_hp_fail);
-MR_declare_entry(do_reset_framevar0_fail);
-MR_declare_entry(do_succeed);
-MR_declare_entry(do_not_reached);
-MR_declare_entry(exception_handler_do_fail);
+MR_declare_entry(MR_do_redo);
+MR_declare_entry(MR_do_fail);
+MR_declare_entry(MR_do_reset_hp_fail);
+MR_declare_entry(MR_do_reset_framevar0_fail);
+MR_declare_entry(MR_do_succeed);
+MR_declare_entry(MR_do_not_reached);
+MR_declare_entry(MR_exception_handler_do_fail);
 
 #endif /* not MERCURY_ENGINE_H */
only in patch2:
--- runtime/mercury_engine.c	2000/11/24 06:03:35	1.30
+++ runtime/mercury_engine.c	2000/12/04 06:22:58
@@ -233,7 +233,7 @@
 	*/
 	if (catch_exceptions) {
 		MR_create_exception_handler("call_engine",
-			MR_C_LONGJMP_HANDLER, 0, MR_ENTRY(do_fail));
+			MR_C_LONGJMP_HANDLER, 0, MR_ENTRY(MR_do_fail));
 	}
 
 	/*
@@ -652,43 +652,43 @@
 
 /*---------------------------------------------------------------------------*/
 
-MR_define_extern_entry(do_redo);
-MR_define_extern_entry(do_fail);
-MR_define_extern_entry(do_succeed);
-MR_define_extern_entry(do_last_succeed);
-MR_define_extern_entry(do_not_reached);
-MR_define_extern_entry(exception_handler_do_fail);
+MR_define_extern_entry(MR_do_redo);
+MR_define_extern_entry(MR_do_fail);
+MR_define_extern_entry(MR_do_succeed);
+MR_define_extern_entry(MR_do_last_succeed);
+MR_define_extern_entry(MR_do_not_reached);
+MR_define_extern_entry(MR_exception_handler_do_fail);
 
 MR_BEGIN_MODULE(special_labels_module)
-	MR_init_entry_ai(do_redo);
-	MR_init_entry_ai(do_fail);
-	MR_init_entry_ai(do_succeed);
-	MR_init_entry_ai(do_last_succeed);
-	MR_init_entry_ai(do_not_reached);
-	MR_init_entry_ai(exception_handler_do_fail);
+	MR_init_entry_ai(MR_do_redo);
+	MR_init_entry_ai(MR_do_fail);
+	MR_init_entry_ai(MR_do_succeed);
+	MR_init_entry_ai(MR_do_last_succeed);
+	MR_init_entry_ai(MR_do_not_reached);
+	MR_init_entry_ai(MR_exception_handler_do_fail);
 MR_BEGIN_CODE
 
-MR_define_entry(do_redo);
+MR_define_entry(MR_do_redo);
 	MR_redo();
 
-MR_define_entry(do_fail);
+MR_define_entry(MR_do_fail);
 	MR_fail();
 
-MR_define_entry(do_succeed);
+MR_define_entry(MR_do_succeed);
 	MR_succeed();
 
-MR_define_entry(do_last_succeed);
+MR_define_entry(MR_do_last_succeed);
 	MR_succeed_discard();
 
-MR_define_entry(do_not_reached);
+MR_define_entry(MR_do_not_reached);
 	MR_fatal_error("reached not_reached\n");
 
-MR_define_entry(exception_handler_do_fail);
+MR_define_entry(MR_exception_handler_do_fail);
 	/*
-	** `exception_handler_do_fail' is the same as `do_fail':
-	** it just invokes fail().  The reason we don't just use
-	** `do_fail' for this is that when unwinding the stack we
-	** check for a redoip of `exception_handler_do_fail' and
+	** `MR_exception_handler_do_fail' is the same as `MR_do_fail':
+	** it just invokes MR_fail().  The reason we don't just use
+	** `MR_do_fail' for this is that when unwinding the stack we
+	** check for a redoip of `MR_exception_handler_do_fail' and
 	** handle it specially.
 	*/
 	MR_fail();
only in patch2:
--- runtime/mercury_context.h	2000/11/23 02:00:24	1.15
+++ runtime/mercury_context.h	2000/12/04 05:56:17
@@ -227,16 +227,16 @@
 
 extern	void		MR_schedule(MR_Context *ctxt);
 
-MR_declare_entry(do_runnext);
+MR_declare_entry(MR_do_runnext);
 #define MR_runnext()						\
 	do {							\
-		MR_GOTO(MR_ENTRY(do_runnext));			\
+		MR_GOTO(MR_ENTRY(MR_do_runnext));		\
 	} while (0)						\
 
 #ifdef	MR_THREAD_SAFE
-  #define IF_MR_THREAD_SAFE(x)	x
+  #define MR_IF_MR_THREAD_SAFE(x)	x
 #else
-  #define IF_MR_THREAD_SAFE(x)
+  #define MR_IF_MR_THREAD_SAFE(x)
 #endif
 
 /*
@@ -250,7 +250,7 @@
 		MR_Context	*f_n_c_context;				\
 		int		fork_new_context_i;			\
 		f_n_c_context = MR_create_context();			\
-		IF_MR_THREAD_SAFE(					\
+		MR_IF_MR_THREAD_SAFE(					\
 			f_n_c_context->owner_thread = NULL;		\
 		)							\
 		for (fork_new_context_i = (numslots) ;			\
only in patch2:
--- runtime/mercury_agc_debug.h	2000/11/23 02:00:22	1.5
+++ runtime/mercury_agc_debug.h	2000/12/03 22:47:29
@@ -12,6 +12,7 @@
 **	Debugging support for accurate garbage collection.
 */
 
+#include "mercury_regs.h"		/* needs to come first */
 #include "mercury_types.h"		/* for MR_Word */
 #include "mercury_label.h"		/* for MR_Internal */
 #include "mercury_memory_zones.h"	/* for MR_MemoryZone */
only in patch2:
--- runtime/mercury.h	2000/12/03 02:22:52	1.26
+++ runtime/mercury.h	2000/12/03 22:36:20
@@ -13,6 +13,9 @@
 #ifndef MERCURY_H
 #define MERCURY_H
 
+/* Everything in this file is specific to the high-level-code back-end */
+#ifdef MR_HIGHLEVEL_CODE
+
 /*---------------------------------------------------------------------------*/
 /*
 ** Header files to include
@@ -446,5 +449,7 @@
 	MR_Mercury_Base_TypeClass_Info x, MR_Mercury_Base_TypeClass_Info y);
 
 /*---------------------------------------------------------------------------*/
+
+#endif /* MR_HIGHLEVEL_CODE */
 
 #endif /* not MERCURY_H */
only in patch2:
--- library/exception.m	2000/12/03 02:22:46	1.36
+++ library/exception.m	2000/12/04 06:26:32
@@ -918,7 +918,7 @@
 		entry_layout = return_label_layout->MR_sll_entry;
 		if (!MR_DETISM_DET_STACK(entry_layout->MR_sle_detism)
 		    && MR_redoip_slot(current_frame) ==
-			MR_ENTRY(exception_handler_do_fail))
+			MR_ENTRY(MR_exception_handler_do_fail))
 		{
 			return NULL;
 		}
@@ -1077,7 +1077,7 @@
 	** (Register r3 holds the Handler closure.)
 	*/
 	MR_create_exception_handler(""builtin_catch/3 [model_det]"",
-		MR_MODEL_DET_HANDLER, r3, MR_ENTRY(do_fail));
+		MR_MODEL_DET_HANDLER, r3, MR_ENTRY(MR_do_fail));
 	
 	/*
 	** Now call `Goal(Result)'.
@@ -1128,7 +1128,7 @@
 	** (Register r3 holds the Handler closure.)
 	*/
 	MR_create_exception_handler(""builtin_catch/3 [model_semi]"",
-		MR_MODEL_SEMI_HANDLER, r3, MR_ENTRY(do_fail));
+		MR_MODEL_SEMI_HANDLER, r3, MR_ENTRY(MR_do_fail));
 	
 	/*
 	** Now call `Goal(Result)'.
@@ -1189,7 +1189,7 @@
 		MR_LABEL(mercury__exception__builtin_catch_3_5_i3));
 #else
 	MR_create_exception_handler(""builtin_catch/3 [model_nondet]"",
-		MR_MODEL_NON_HANDLER, r3, MR_ENTRY(do_fail));
+		MR_MODEL_NON_HANDLER, r3, MR_ENTRY(MR_do_fail));
 #endif
 	
 
@@ -1255,7 +1255,7 @@
 
 	/*
 	** Search the nondet stack for an exception handler,
-	** i.e. a frame whose redoip is `exception_handler_do_fail'
+	** i.e. a frame whose redoip is `MR_exception_handler_do_fail'
 	** (one created by `builtin_catch').
 	** N.B.  We search down the `succfr' chain, not the `prevfr' chain;
 	** this ensures that we only find handlers installed by our callers,
@@ -1265,7 +1265,7 @@
 	*/
 	orig_curfr = MR_curfr;
 	while (MR_redoip_slot(MR_curfr)
-			!= MR_ENTRY(exception_handler_do_fail))
+			!= MR_ENTRY(MR_exception_handler_do_fail))
 	{
 		MR_curfr = MR_succfr_slot(MR_curfr);
 		if (MR_curfr < MR_CONTEXT(nondetstack_zone)->min) {
only in patch2:
--- extras/aditi/aditi.m	2000/10/10 05:36:53	1.13
+++ extras/aditi/aditi.m	2000/12/04 06:43:47
@@ -599,7 +599,7 @@
 {
 	MR_mkframe(""do_semidet_aditi_call"",
 		(MADITI_NUM_FRAME_VARS + MADITI_num_output_args),
-		ENTRY(do_not_reached));
+		ENTRY(MR_do_not_reached));
 
 	save_transient_registers();
 
@@ -629,7 +629,7 @@
 {
 	MR_mkframe(""do_det_aditi_call"",
 		(MADITI_NUM_FRAME_VARS + MADITI_num_output_args),
-		ENTRY(do_not_reached));
+		ENTRY(MR_do_not_reached));
 
 	save_transient_registers();
 
only in patch2:
--- compiler/trace.m	2000/11/23 04:32:49	1.40
+++ compiler/trace.m	2000/12/04 06:12:29
@@ -758,7 +758,7 @@
 	set__list_to_set(VarInfoList, VarInfoSet),
 	LayoutLabelInfo = layout_label_info(VarInfoSet, TvarDataMap),
 	llds_out__get_label(Label, yes, LabelStr),
-	DeclStmt = "\t\tCode *MR_jumpaddr;\n",
+	DeclStmt = "\t\tMR_Code *MR_jumpaddr;\n",
 	SaveStmt = "\t\tMR_save_transient_registers();\n",
 	RestoreStmt = "\t\tMR_restore_transient_registers();\n",
 	GotoStmt = "\t\tif (MR_jumpaddr != NULL) MR_GOTO(MR_jumpaddr);"
only in patch2:
--- compiler/mode_info.m	2000/10/13 13:55:39	1.57
+++ compiler/mode_info.m	2000/12/04 12:10:37
@@ -578,7 +578,7 @@
 
 %-----------------------------------------------------------------------------%
 
-			% We keep track of the live variables and the nondet-live variables
+	% We keep track of the live variables and the nondet-live variables
 	% a bag, represented as a list of sets of vars.
 	% This allows us to easily add and remove sets of variables.
 	% It's probably not maximally efficient.
only in patch2:
--- compiler/llds_out.m	2000/11/28 05:20:46	1.167
+++ compiler/llds_out.m	2000/12/04 05:55:16
@@ -1877,7 +1877,7 @@
 output_pragma_c_component(pragma_c_raw_code(C_Code)) -->
 	io__write_string(C_Code).
 output_pragma_c_component(pragma_c_fail_to(Label)) -->
-	io__write_string("if (!r1) MR_GOTO_LABEL("),
+	io__write_string("if (!MR_r1) MR_GOTO_LABEL("),
 	output_label(Label),
 	io__write_string(");\n").
 output_pragma_c_component(pragma_c_noop) --> [].
@@ -2881,7 +2881,7 @@
 	;
 		{ UseMacro = no },
 		io__write_string("MR_declare_entry("),
-		io__write_string("do_redo"),
+		io__write_string("MR_do_redo"),
 		io__write_string(");\n")
 	).
 output_code_addr_decls(do_fail) -->
@@ -2891,7 +2891,7 @@
 	;
 		{ UseMacro = no },
 		io__write_string("MR_declare_entry("),
-		io__write_string("do_fail"),
+		io__write_string("MR_do_fail"),
 		io__write_string(");\n")
 	).
 output_code_addr_decls(do_trace_redo_fail_shallow) -->
@@ -2902,6 +2902,8 @@
 	io__write_string("MR_declare_entry(mercury__do_call_closure);\n").
 output_code_addr_decls(do_call_class_method) -->
 	io__write_string("MR_declare_entry(mercury__do_call_class_method);\n").
+% XXX The do_*_aditi_call and do_aditi_* entry point names
+% should start with an `MADITI_' prefix.
 output_code_addr_decls(do_det_aditi_call) -->
 	io__write_string("MR_declare_entry(do_det_aditi_call);\n").
 output_code_addr_decls(do_semidet_aditi_call) -->
@@ -2919,7 +2921,7 @@
 output_code_addr_decls(do_aditi_bulk_modify) -->
 	io__write_string("MR_declare_entry(do_aditi_bulk_modify);\n").
 output_code_addr_decls(do_not_reached) -->
-	io__write_string("MR_declare_entry(do_not_reached);\n").
+	io__write_string("MR_declare_entry(MR_do_not_reached);\n").
 
 :- pred output_label_as_code_addr_decls(label, io__state, io__state).
 :- mode output_label_as_code_addr_decls(in, di, uo) is det.
@@ -3134,7 +3136,7 @@
 		io__write_string("MR_redo();\n")
 	;
 		{ UseMacro = no },
-		io__write_string("MR_GOTO(MR_ENTRY(do_redo));\n")
+		io__write_string("MR_GOTO(MR_ENTRY(MR_do_redo));\n")
 	).
 output_goto(do_fail, _) -->
 	globals__io_lookup_bool_option(use_macro_for_redo_fail, UseMacro),
@@ -3143,7 +3145,7 @@
 		io__write_string("MR_fail();\n")
 	;
 		{ UseMacro = no },
-		io__write_string("MR_GOTO(MR_ENTRY(do_fail));\n")
+		io__write_string("MR_GOTO(MR_ENTRY(MR_do_fail));\n")
 	).
 output_goto(do_trace_redo_fail_shallow, _) -->
 	io__write_string("MR_GOTO(MR_ENTRY(MR_do_trace_redo_fail_shallow));\n").
@@ -3163,6 +3165,8 @@
 	io__write_string(");\n\t\t"),
 	io__write_string(
 		"MR_noprof_tailcall(MR_ENTRY(mercury__do_call_class_method));\n").
+% XXX The do_*_aditi_call and do_aditi_* entry point names
+% should start with an `MADITI_' prefix.
 output_goto(do_det_aditi_call, CallerLabel) -->
 	io__write_string("MR_tailcall(MR_ENTRY(do_det_aditi_call),\n\t\t"),
 	output_label_as_code_addr(CallerLabel),
@@ -3196,7 +3200,7 @@
 	output_label_as_code_addr(CallerLabel),
 	io__write_string(");\n").
 output_goto(do_not_reached, CallerLabel) -->
-	io__write_string("MR_tailcall(MR_ENTRY(do_not_reached),\n\t\t"),
+	io__write_string("MR_tailcall(MR_ENTRY(MR_do_not_reached),\n\t\t"),
 	output_label_as_code_addr(CallerLabel),
 	io__write_string(");\n").
 
@@ -3962,6 +3966,8 @@
 	io__write_string(""", "),
 	io__write_int(Length),
 	io__write_string(")").
+% XXX we should consider using MR_TRUE and MR_FALSE
+% rather than TRUE and FALSE
 output_rval_const(true) -->
 	io__write_string("TRUE").
 output_rval_const(false) -->
@@ -4038,6 +4044,8 @@
 	io__write_string(""", "),
 	io__write_int(Length),
 	io__write_string(")").
+% XXX we should consider using MR_TRUE and MR_FALSE
+% rather than TRUE and FALSE
 output_rval_static_const(true) -->
 	io__write_string("TRUE").
 output_rval_static_const(false) -->
@@ -4064,7 +4072,7 @@
 		% sanity check -- if this happens, the llds is ill-typed
 		{ error("output_lval_as_word: got float") }
 	;
-		io__write_string("LVALUE_CAST(MR_Word,"),
+		io__write_string("MR_LVALUE_CAST(MR_Word,"),
 		output_lval(Lval),
 		io__write_string(")")
 	).
only in patch2:
--- compiler/fact_table.m	2000/11/25 10:41:54	1.36
+++ compiler/fact_table.m	2000/12/04 06:11:09
@@ -575,23 +575,23 @@
 #ifndef MERCURY_FACT_TABLE_HASH_TABLES
 #define MERCURY_FACT_TABLE_HASH_TABLES
 
-struct fact_table_hash_table_s {
+struct MR_fact_table_hash_table_s {
 	MR_Integer size;		/* size of the hash table */
 	struct fact_table_hash_entry_s *table;	/* the actual table */
 };
 
-struct fact_table_hash_table_f {
+struct MR_fact_table_hash_table_f {
 	MR_Integer size;		/* size of the hash table */
 	struct fact_table_hash_entry_f *table;	/* the actual table */
 };
 
-struct fact_table_hash_table_i {
+struct MR_fact_table_hash_table_i {
 	MR_Integer size;		/* size of the hash table */
 	struct fact_table_hash_entry_i *table;	/* the actual table */
 };
 
 /* hash table for string keys */
-struct fact_table_hash_entry_s {
+struct MR_fact_table_hash_entry_s {
 	MR_ConstString key;   /* lookup key */
 	const MR_Word *index; /* index into fact table data array	     */
 		          /* or pointer to hash table for next argument      */
@@ -604,7 +604,7 @@
 };
 
 /* hash table for float keys */
-struct fact_table_hash_entry_f {
+struct MR_fact_table_hash_entry_f {
 	MR_Float key;
 	const MR_Word *index;
 #if TAGBITS < 2
@@ -614,7 +614,7 @@
 };
 
 /* hash table for int keys */
-struct fact_table_hash_entry_i {
+struct MR_fact_table_hash_entry_i {
 	MR_Integer key;
 	const MR_Word *index;
 #if TAGBITS < 2
@@ -625,17 +625,24 @@
 
 
 #if TAGBITS >= 2
-	#define FACT_TABLE_MAKE_TAGGED_INDEX(i,t)   MR_mkword(MR_mktag(t), MR_mkbody(i))
-	#define FACT_TABLE_MAKE_TAGGED_POINTER(p,t) MR_mkword(MR_mktag(t), p)
-	#define FACT_TABLE_HASH_ENTRY_TYPE(p)       MR_tag((MR_Word)((p).index))
-	#define FACT_TABLE_HASH_INDEX(w)            MR_unmkbody(w)
-	#define FACT_TABLE_HASH_POINTER(w)          MR_body(w,MR_tag(w))
+	#define MR_FACT_TABLE_MAKE_TAGGED_INDEX(i,t)   \
+		MR_mkword(MR_mktag(t), MR_mkbody(i))
+	#define MR_FACT_TABLE_MAKE_TAGGED_POINTER(p,t) \
+		MR_mkword(MR_mktag(t), p)
+	#define MR_FACT_TABLE_HASH_ENTRY_TYPE(p)       \
+		MR_tag((MR_Word)((p).index))
+	#define MR_FACT_TABLE_HASH_INDEX(w)            \
+		MR_unmkbody(w)
+	#define MR_FACT_TABLE_HASH_POINTER(w)          \
+		MR_body(w,MR_tag(w))
 #else
-	#define FACT_TABLE_MAKE_TAGGED_INDEX(i,t)   ((const MR_Word *) i), (t)
-	#define FACT_TABLE_MAKE_TAGGED_POINTER(p,t) ((const MR_Word *) p), (t)
-	#define FACT_TABLE_HASH_ENTRY_TYPE(p)       ((p).type)
-	#define FACT_TABLE_HASH_INDEX(w)            (w)
-	#define FACT_TABLE_HASH_POINTER(w)          (w)
+	#define MR_FACT_TABLE_MAKE_TAGGED_INDEX(i,t)   \
+		((const MR_Word *) i), (t)
+	#define MR_FACT_TABLE_MAKE_TAGGED_POINTER(p,t) \
+		((const MR_Word *) p), (t)
+	#define MR_FACT_TABLE_HASH_ENTRY_TYPE(p)       ((p).type)
+	#define MR_FACT_TABLE_HASH_INDEX(w)            (w)
+	#define MR_FACT_TABLE_HASH_POINTER(w)          (w)
 #endif
 
 #endif /* not MERCURY_FACT_TABLE_HASH_TABLES */
@@ -678,7 +685,7 @@
 			StructContents1, Result),
 		{
 			IsOutput = yes,
-			string__format("\tInteger V_%d;\n", [i(I)], 
+			string__format("\tMR_Integer V_%d;\n", [i(I)], 
 				StructContents0),
 			string__append(StructContents0, StructContents1, 
 				StructContents)
@@ -1425,7 +1432,7 @@
 			{ string__format("%s_hash_table_%d_", 
 				[s(StructName), i(ProcInt)], HashTableName) },
 			{ string__format(
-				"extern struct fact_table_hash_table_i %s0;\n",
+			  "extern struct MR_fact_table_hash_table_i %s0;\n",
 				[s(HashTableName)], C_HeaderCode0) },
 				% Note: the type declared here is not
 				% necessarily correct.  The type is declared
@@ -1501,7 +1508,8 @@
 		{ proc_id_to_int(ProcID, ProcInt) },
 		{ string__format("%s_hash_table_%d_",
 			[s(StructName), i(ProcInt)], HashTableName) },
-		{ string__format("extern struct fact_table_hash_table_i %s0;\n",
+		{ string__format(
+			"extern struct MR_fact_table_hash_table_i %s0;\n",
 			[s(HashTableName)], C_HeaderCode1) },
 			% Note: the type declared here is not
 			% necessarily correct.  The type is declared
@@ -2244,7 +2252,7 @@
 
 write_hash_table(BaseName, TableNum, HashTable, OutputStream) -->
 	{ get_hash_table_type(HashTable, TableType) },
-	{ string__format("struct fact_table_hash_entry_%c %s%d_data[]",
+	{ string__format("struct MR_fact_table_hash_entry_%c %s%d_data[]",
 		[c(TableType), s(BaseName), i(TableNum)], HashTableDataName) },
 	io__set_output_stream(OutputStream, OldOutputStream),
 	io__write_strings([HashTableDataName, " = {\n"]),
@@ -2254,7 +2262,7 @@
 	io__write_string("};\n\n"),
 	io__format("
 
-struct fact_table_hash_table_%c %s%d = {
+struct MR_fact_table_hash_table_%c %s%d = {
 	%d,
 	%s%d_data
 };
@@ -2297,18 +2305,18 @@
 			(
 				{ Index = fact(I) },
 				io__format(
-				    ", FACT_TABLE_MAKE_TAGGED_INDEX(%d, 1), ",
+				", MR_FACT_TABLE_MAKE_TAGGED_INDEX(%d, 1), ",
 				    [i(I)])
 			;
 				{ Index = hash_table(I, H) },
 				io__format(
-				", FACT_TABLE_MAKE_TAGGED_POINTER(&%s%d, 2), ",
+			", MR_FACT_TABLE_MAKE_TAGGED_POINTER(&%s%d, 2), ",
 				    [s(H), i(I)])
 			),
 			io__write_int(Next)
 		;
 			io__write_string(
-			    "0, FACT_TABLE_MAKE_TAGGED_POINTER(NULL, 0), -1 ")
+			"0, MR_FACT_TABLE_MAKE_TAGGED_POINTER(NULL, 0), -1 ")
 		),
 		io__write_string("},\n"),
 		{ NextIndex is CurrIndex + 1 },
@@ -2564,10 +2572,10 @@
 extern MR_ModuleFunc %s_module;
 
 /*
-INIT sys_init_%s_module
+INIT mercury_sys_init_%s_module
 */
-void sys_init_%s_module(void);
-void sys_init_%s_module(void) {
+void mercury_sys_init_%s_module(void);
+void mercury_sys_init_%s_module(void) {
 	%s_module();
 }
 
@@ -2828,7 +2836,7 @@
 
 		/* calculate hash value for an integer */
 
-		hashsize = ((struct fact_table_hash_table_i *)current_table)
+		hashsize = ((struct MR_fact_table_hash_table_i *)current_table)
 			->size;
 
 		hashval = (%s >= 0 ? %s : -%s) %% hashsize;
@@ -2856,13 +2864,13 @@
 
 		/* calculate hash value for a float */
 
-		hashsize = ((struct fact_table_hash_table_f *)current_table)
+		hashsize = ((struct MR_fact_table_hash_table_f *)current_table)
 			->size;
 
-		hashval = hash_float(%s);
+		hashval = MR_hash_float(%s);
 		hashval = (hashval >= 0 ? hashval : -hashval) %% hashsize;
 
-		current_key = float_to_word(%s);
+		current_key = MR_float_to_word(%s);
 
 		/* lookup the hash table */
 		%s
@@ -2883,7 +2891,7 @@
 		Types, ModuleInfo, ArgNum, FactTableSize, HashLookupCode),
 	C_Code_Template = "
 
-		hashsize = ((struct fact_table_hash_table_s *)current_table)
+		hashsize = ((struct MR_fact_table_hash_table_s *)current_table)
 			->size;
 
 		/* calculate hash value for a string */
@@ -2918,7 +2926,7 @@
 		KeyType, CheckKeys, PredName, PragmaVars, Types,
 		ModuleInfo, ArgNum, FactTableSize, HashLookupCode) :-
 	string__format(
-	   "((struct fact_table_hash_table_%c *)current_table)->table[hashval]",
+	"((struct MR_fact_table_hash_table_%c *)current_table)->table[hashval]",
 		[c(KeyType)], HashTableEntry),
 	string__append(HashTableEntry, ".key", HashTableKey),
 	string__format(CompareTemplate, [s(HashTableKey), s(VarName)],
@@ -2927,7 +2935,7 @@
 	HashLookupCodeTemplate = "
 
 		do {
-			if (FACT_TABLE_HASH_ENTRY_TYPE(%s) != 0 && %s)
+			if (MR_FACT_TABLE_HASH_ENTRY_TYPE(%s) != 0 && %s)
 			{
 				ind = (MR_Word) %s.index;
 				goto found_%s_%d;
@@ -2939,8 +2947,8 @@
 
 	found_%s_%d:
 
-		if (FACT_TABLE_HASH_ENTRY_TYPE(%s) == 1) {
-			ind = FACT_TABLE_HASH_INDEX(ind);
+		if (MR_FACT_TABLE_HASH_ENTRY_TYPE(%s) == 1) {
+			ind = MR_FACT_TABLE_HASH_INDEX(ind);
 
 			/* check that any remaining input arguments match */
 			%s
@@ -2949,7 +2957,7 @@
 			goto success_code_%s;
 		}
 
-		current_table = (void *) FACT_TABLE_HASH_POINTER(ind);
+		current_table = (void *) MR_FACT_TABLE_HASH_POINTER(ind);
 
 	",
 	( CheckKeys = yes ->
@@ -3003,14 +3011,15 @@
 		    % Cast MR_ConstString -> MR_Word -> MR_String to avoid 
 		    % gcc warning "assignment discards `const'".
 		    Template = 
-			"\t\tmake_aligned_string(%s, (MR_String) (MR_Word) %s);\n",
+			"\t\tMR_make_aligned_string(%s, (MR_String) (MR_Word) %s);\n",
 		    string__format(Template, [s(VarName), s(TableEntry)],
 		    	C_Code0)
 		;
 		    % Unique modes need to allow destructive update so we
 		    % need to make a copy of the string on the heap.
 		    Template = 
-"		MR_incr_hp_atomic(tmp, (strlen(%s) + sizeof(MR_Word)) / sizeof(MR_Word));
+"		MR_incr_hp_atomic(tmp,
+			(strlen(%s) + sizeof(MR_Word)) / sizeof(MR_Word));
 		%s = (MR_String) tmp;
 		strcpy(%s, %s);
 ",
@@ -3105,10 +3114,10 @@
 extern MR_ModuleFunc %s_module;
 
 /*
-INIT sys_init_%s_module
+INIT mercury_sys_init_%s_module
 */
-void sys_init_%s_module(void);
-void sys_init_%s_module(void) {
+void mercury_sys_init_%s_module(void);
+void mercury_sys_init_%s_module(void) {
 	%s_module();
 }
 
@@ -3422,10 +3431,10 @@
 extern MR_ModuleFunc %s_module;
 
 /*
-INIT sys_init_%s_module
+INIT mercury_sys_init_%s_module
 */
-void sys_init_%s_module(void);
-void sys_init_%s_module(void) {
+void mercury_sys_init_%s_module(void);
+void mercury_sys_init_%s_module(void) {
 	%s_module();
 }
 
@@ -3446,9 +3455,9 @@
 		StringHashLookupCode),
 	generate_hash_lookup_code("MR_framevar(4)", LabelName2, 1, "%s == %s",	
 		'i', no, "", [], [], ModuleInfo, 0, 0, IntHashLookupCode),
-	generate_hash_lookup_code("word_to_float(MR_framevar(4))", LabelName2,
-		2, "%s == %s", 'f', no, "", [], [], ModuleInfo, 0, 0,
-		FloatHashLookupCode),
+	generate_hash_lookup_code("MR_word_to_float(MR_framevar(4))",
+		LabelName2, 2, "%s == %s", 'f', no, "", [], [], ModuleInfo,
+		0, 0, FloatHashLookupCode),
 	generate_fact_lookup_code(PredName, PragmaVars, ArgTypes, ModuleInfo, 1,
 		FactTableSize, FactLookupCode),
 	list__length(PragmaVars, Arity),
 
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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