[m-dev.] for review: enforce namespace restrictions
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Nov 24 03:05:24 AEDT 2000
Estimated hours taken: 4
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.
tools/bootcheck:
Add an option, which is enabled by default, to
build the check_namespace target in the runtime.
runtime/RESERVED_MACRO_NAMES:
New file. Contains a list of the macros names that
don't start with `MR_' or the like.
runtime/Mmakefile:
Change the rule for `check_headers' so that it checks for macros
that don't occur in the RESERVED_MACRO_NAMES files, as well as not
starting with `MR_' prefixes, and reports errors for such macros.
Also add a rule for check_objs that checks whether the object
files define any global symbols that don't have the right prefixes,
and a rule `check_namespace' that does both of the above.
runtime/mercury_bootstrap.h:
#include "mercury_types.h" and "mercury_float.h",
to ensure that this header file is self-contained.
runtime/mercury_context.c:
runtime/mercury_thread.h:
runtime/mercury_thread.c:
Use `bool' rather than `MR_Bool' for the argument to
MR_check_pending_contexts() and the return type of
MR_init_thread(), since these are C bools, not Mercury
bools, and there's no requirement that they have the
same size as MR_Integer.
runtime/mercury_type_info.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
library/std_util.m:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
tests/hard_coded/existential_types_test.m:
Add MR_ prefixes to UNIV_OFFSET_FOR_TYPEINFO and UNIV_OFFSET_FOR_VALUE.
runtime/mercury_overflow.h:
runtime/mercury_debug.h:
Add MR_ prefixes to IF().
runtime/mercury_overflow.h:
runtime/mercury_debug.h:
Add MR_ prefixes to table_copy_words() and table_copy_bytes().
Workspace: /home/pgrad/fjh/ws/hg
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.206
diff -u -d -r1.206 std_util.m
--- library/std_util.m 2000/11/23 02:00:07 1.206
+++ library/std_util.m 2000/11/23 13:15:05
@@ -1074,7 +1074,7 @@
** `univ' is represented as a two word structure.
** One word contains the address of a type_info for the type.
** The other word contains the data.
-** The offsets UNIV_OFFSET_FOR_TYPEINFO and UNIV_OFFSET_FOR_DATA
+** The offsets MR_UNIV_OFFSET_FOR_TYPEINFO and MR_UNIV_OFFSET_FOR_DATA
** are defined in runtime/type_info.h.
*/
@@ -1111,13 +1111,15 @@
MR_Word univ_type_info;
int comp;
- univ_type_info = MR_field(MR_mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO);
+ univ_type_info = MR_field(MR_mktag(0), Univ,
+ MR_UNIV_OFFSET_FOR_TYPEINFO);
MR_save_transient_registers();
comp = MR_compare_type_info((MR_TypeInfo) univ_type_info,
(MR_TypeInfo) TypeInfo_for_T);
MR_restore_transient_registers();
if (comp == MR_COMPARE_EQUAL) {
- Value = MR_field(MR_mktag(0), Univ, UNIV_OFFSET_FOR_DATA);
+ Value = MR_field(MR_mktag(0), Univ,
+ MR_UNIV_OFFSET_FOR_DATA);
SUCCESS_INDICATOR = TRUE;
} else {
SUCCESS_INDICATOR = FALSE;
@@ -1125,7 +1127,7 @@
}").
:- pragma c_code(univ_type(Univ::in) = (TypeInfo::out), will_not_call_mercury, "
- TypeInfo = MR_field(MR_mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO);
+ TypeInfo = MR_field(MR_mktag(0), Univ, MR_UNIV_OFFSET_FOR_TYPEINFO);
").
:- pragma c_code("
@@ -1174,8 +1176,8 @@
univ2 = r2;
/* First check the type_infos compare equal */
- typeinfo1 = MR_field(MR_mktag(0), univ1, UNIV_OFFSET_FOR_TYPEINFO);
- typeinfo2 = MR_field(MR_mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
+ typeinfo1 = MR_field(MR_mktag(0), univ1, MR_UNIV_OFFSET_FOR_TYPEINFO);
+ typeinfo2 = MR_field(MR_mktag(0), univ2, MR_UNIV_OFFSET_FOR_TYPEINFO);
MR_save_transient_registers();
comp = MR_compare_type_info((MR_TypeInfo) typeinfo1,
(MR_TypeInfo) typeinfo2);
@@ -1190,8 +1192,8 @@
** unwrapped args
*/
r1 = typeinfo1;
- r2 = MR_field(MR_mktag(0), univ1, UNIV_OFFSET_FOR_DATA);
- r3 = MR_field(MR_mktag(0), univ2, UNIV_OFFSET_FOR_DATA);
+ r2 = MR_field(MR_mktag(0), univ1, MR_UNIV_OFFSET_FOR_DATA);
+ r3 = MR_field(MR_mktag(0), univ2, MR_UNIV_OFFSET_FOR_DATA);
{
MR_declare_entry(mercury__unify_2_0);
MR_tailcall(MR_ENTRY(mercury__unify_2_0),
@@ -1213,8 +1215,8 @@
univ2 = r2;
/* First compare the type_infos */
- typeinfo1 = MR_field(MR_mktag(0), univ1, UNIV_OFFSET_FOR_TYPEINFO);
- typeinfo2 = MR_field(MR_mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
+ typeinfo1 = MR_field(MR_mktag(0), univ1, MR_UNIV_OFFSET_FOR_TYPEINFO);
+ typeinfo2 = MR_field(MR_mktag(0), univ2, MR_UNIV_OFFSET_FOR_TYPEINFO);
MR_save_transient_registers();
comp = MR_compare_type_info((MR_TypeInfo) typeinfo1,
(MR_TypeInfo) typeinfo2);
@@ -1230,8 +1232,8 @@
*/
r1 = typeinfo1;
- r2 = MR_field(MR_mktag(0), univ1, UNIV_OFFSET_FOR_DATA);
- r3 = MR_field(MR_mktag(0), univ2, UNIV_OFFSET_FOR_DATA);
+ r2 = MR_field(MR_mktag(0), univ1, MR_UNIV_OFFSET_FOR_DATA);
+ r3 = MR_field(MR_mktag(0), univ2, MR_UNIV_OFFSET_FOR_DATA);
{
MR_declare_entry(mercury__compare_3_0);
MR_tailcall(MR_ENTRY(mercury__compare_3_0),
@@ -1935,7 +1937,7 @@
}
new_data = MR_field(MR_mktag(0), MR_list_head(ArgList),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
break;
case MR_TYPECTOR_REP_DU:
@@ -1973,7 +1975,7 @@
for (i = 0; i < arity; i++) {
MR_field(ptag, new_data, i + 1) =
MR_field(MR_mktag(0), MR_list_head(arg_list),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
arg_list = MR_list_tail(arg_list);
}
@@ -1988,7 +1990,7 @@
for (i = 0; i < arity; i++) {
MR_field(ptag, new_data, i) =
MR_field(MR_mktag(0), MR_list_head(arg_list),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
arg_list = MR_list_tail(arg_list);
}
@@ -2018,7 +2020,7 @@
for (i = 0; i < arity; i++) {
MR_field(MR_mktag(0), new_data, i) =
MR_field(MR_mktag(0), MR_list_head(arg_list),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
arg_list = MR_list_tail(arg_list);
}
@@ -2080,7 +2082,7 @@
""<created by std_util:construct_tuple/1>"");
for (i = 0; i < Arity; i++) {
arg_value = MR_field(MR_mktag(0), MR_list_head(Args),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
MR_field(MR_mktag(0), new_data, i) = arg_value;
Args = MR_list_tail(Args);
}
@@ -2274,7 +2276,7 @@
}
list_arg_type_info = (MR_TypeInfo) MR_field(MR_mktag(0),
- MR_list_head(arg_list), UNIV_OFFSET_FOR_TYPEINFO);
+ MR_list_head(arg_list), MR_UNIV_OFFSET_FOR_TYPEINFO);
if (MR_TYPE_CTOR_INFO_IS_TUPLE(
MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info)))
@@ -2315,7 +2317,7 @@
for (i = 0; i < arity; i++) {
MR_field(MR_mktag(0), term_vector, i) =
MR_field(MR_mktag(0), MR_list_head(arg_list),
- UNIV_OFFSET_FOR_DATA);
+ MR_UNIV_OFFSET_FOR_DATA);
arg_list = MR_list_tail(arg_list);
}
}
@@ -2960,8 +2962,8 @@
*/
data_word = *data_word_ptr;
ML_expand((MR_TypeInfo)
- ((MR_Word *) data_word)[UNIV_OFFSET_FOR_TYPEINFO],
- &((MR_Word *) data_word)[UNIV_OFFSET_FOR_DATA], expand_info);
+ ((MR_Word *) data_word)[MR_UNIV_OFFSET_FOR_TYPEINFO],
+ &((MR_Word *) data_word)[MR_UNIV_OFFSET_FOR_DATA], expand_info);
break;
}
Index: runtime/mercury_bootstrap.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_bootstrap.h,v
retrieving revision 1.17
diff -u -d -r1.17 mercury_bootstrap.h
--- runtime/mercury_bootstrap.h 2000/11/23 02:00:22 1.17
+++ runtime/mercury_bootstrap.h 2000/11/23 12:59:32
@@ -255,6 +255,8 @@
** the other changes in this file).
*/
+#include "mercury_types.h"
+#include "mercury_float.h"
typedef MR_Word Word;
typedef MR_Code Code;
typedef MR_Char Char;
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.27
diff -u -d -r1.27 mercury_context.c
--- runtime/mercury_context.c 2000/11/23 02:00:23 1.27
+++ runtime/mercury_context.c 2000/11/23 13:03:32
@@ -207,7 +207,7 @@
** block or not.
*/
static int
-MR_check_pending_contexts(MR_Bool block)
+MR_check_pending_contexts(bool block)
{
#ifdef MR_CAN_DO_PENDING_IO
Index: runtime/mercury_debug.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.h,v
retrieving revision 1.10
diff -u -d -r1.10 mercury_debug.h
--- runtime/mercury_debug.h 2000/11/23 02:00:24 1.10
+++ runtime/mercury_debug.h 2000/11/23 13:26:43
@@ -29,10 +29,12 @@
#define MR_debuggoto(label) \
(MR_assert(label), \
- IF (MR_gotodebug, (MR_save_transient_registers(), MR_goto_msg(label))))
+ MR_IF (MR_gotodebug, \
+ (MR_save_transient_registers(), MR_goto_msg(label))))
#define MR_debugsreg() \
- IF (MR_sregdebug, (MR_save_transient_registers(), MR_reg_msg()))
+ MR_IF (MR_sregdebug, \
+ (MR_save_transient_registers(), MR_reg_msg()))
#endif
@@ -61,67 +63,73 @@
#else
#define MR_debugcr1(val0, hp) \
- IF (MR_heapdebug, (MR_save_transient_registers(), MR_cr1_msg(val0, hp)))
+ MR_IF (MR_heapdebug, \
+ (MR_save_transient_registers(), MR_cr1_msg(val0, hp)))
#define MR_debugcr2(val0, val1, hp) \
- IF (MR_heapdebug, (MR_save_transient_registers(), MR_cr2_msg(val0, val1, hp)))
+ MR_IF (MR_heapdebug, \
+ (MR_save_transient_registers(), MR_cr2_msg(val0, val1, hp)))
#define MR_debugincrhp(val, hp) \
- IF (MR_heapdebug, \
+ MR_IF (MR_heapdebug, \
(MR_save_transient_registers(), MR_incr_hp_debug_msg((val), (hp))))
#define MR_debugincrsp(val, sp) \
- IF (MR_detstackdebug, \
+ MR_IF (MR_detstackdebug, \
(MR_save_transient_registers(), MR_incr_sp_msg((val), (sp))))
#define MR_debugdecrsp(val, sp) \
- IF (MR_detstackdebug, \
+ MR_IF (MR_detstackdebug, \
(MR_save_transient_registers(), MR_decr_sp_msg((val), (sp))))
#define MR_debugregs(msg) \
- IF (MR_progdebug, (MR_save_transient_registers(), MR_printregs(msg)))
+ MR_IF (MR_progdebug, (MR_save_transient_registers(), MR_printregs(msg)))
#define MR_debugmkframe(predname) \
- IF (MR_nondstackdebug, \
+ MR_IF (MR_nondstackdebug, \
(MR_save_transient_registers(), MR_mkframe_msg(predname)))
#define MR_debugframe(msg) \
- IF (MR_progdebug, (MR_save_transient_registers(), MR_printframe(msg)))
+ MR_IF (MR_progdebug, \
+ (MR_save_transient_registers(), MR_printframe(msg)))
#define MR_debugsucceed() \
- IF (MR_nondstackdebug, (MR_save_transient_registers(), MR_succeed_msg()))
+ MR_IF (MR_nondstackdebug, \
+ (MR_save_transient_registers(), MR_succeed_msg()))
#define MR_debugsucceeddiscard() \
- IF (MR_nondstackdebug, \
+ MR_IF (MR_nondstackdebug, \
(MR_save_transient_registers(), MR_succeeddiscard_msg()))
#define MR_debugfail() \
IF (MR_nondstackdebug, (MR_save_transient_registers(), MR_fail_msg()))
#define MR_debugredo() \
- IF (MR_nondstackdebug, (MR_save_transient_registers(), MR_redo_msg()))
+ MR_IF (MR_nondstackdebug, \
+ (MR_save_transient_registers(), MR_redo_msg()))
#define MR_debugcall(proc, succ_cont) \
- IF (MR_calldebug, \
+ MR_IF (MR_calldebug, \
(MR_save_transient_registers(), MR_call_msg(proc, succ_cont)))
#define MR_debugtailcall(proc) \
- IF (MR_calldebug, (MR_save_transient_registers(), MR_tailcall_msg(proc)))
+ MR_IF (MR_calldebug, \
+ (MR_save_transient_registers(), MR_tailcall_msg(proc)))
#define MR_debugproceed() \
- IF (MR_calldebug, (MR_save_transient_registers(), MR_proceed_msg()))
+ MR_IF (MR_calldebug, (MR_save_transient_registers(), MR_proceed_msg()))
#define MR_debugmsg0(msg) \
- IF (MR_progdebug, (printf(msg)))
+ MR_IF (MR_progdebug, (printf(msg)))
#define MR_debugmsg1(msg, arg1) \
- IF (MR_progdebug, (printf(msg, arg1)))
+ MR_IF (MR_progdebug, (printf(msg, arg1)))
#define MR_debugmsg2(msg, arg1, arg2) \
- IF (MR_progdebug, (printf(msg, arg1, arg2)))
+ MR_IF (MR_progdebug, (printf(msg, arg1, arg2)))
#define MR_debugmsg3(msg, arg1, arg2, arg3) \
- IF (MR_progdebug, (printf(msg, arg1, arg2, arg3)))
+ MR_IF (MR_progdebug, (printf(msg, arg1, arg2, arg3)))
#endif /* MR_LOWLEVEL_DEBUG */
Index: runtime/mercury_deep_copy_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy_body.h,v
retrieving revision 1.31
diff -u -d -r1.31 mercury_deep_copy_body.h
--- runtime/mercury_deep_copy_body.h 2000/11/23 02:00:25 1.31
+++ runtime/mercury_deep_copy_body.h 2000/11/23 13:13:30
@@ -513,23 +513,23 @@
** to still contain the type rather than just holding
** a forwarding pointer.
*/
- new_data_ptr[UNIV_OFFSET_FOR_DATA] = copy(
- &data_value[UNIV_OFFSET_FOR_DATA],
+ new_data_ptr[MR_UNIV_OFFSET_FOR_DATA] = copy(
+ &data_value[MR_UNIV_OFFSET_FOR_DATA],
(const MR_TypeInfo)
- data_value[UNIV_OFFSET_FOR_TYPEINFO],
+ data_value[MR_UNIV_OFFSET_FOR_TYPEINFO],
lower_limit, upper_limit);
- new_data_ptr[UNIV_OFFSET_FOR_TYPEINFO] =
- (MR_Word) copy_type_info(
- (MR_TypeInfo *) &data_value[UNIV_OFFSET_FOR_TYPEINFO],
+ new_data_ptr[MR_UNIV_OFFSET_FOR_TYPEINFO] =
+ (MR_Word) copy_type_info((MR_TypeInfo *)
+ &data_value[MR_UNIV_OFFSET_FOR_TYPEINFO],
lower_limit, upper_limit);
leave_forwarding_pointer(data_ptr, new_data);
} else if (in_traverse_range(data_value)) {
- copy(&data_value[UNIV_OFFSET_FOR_DATA],
+ copy(&data_value[MR_UNIV_OFFSET_FOR_DATA],
(const MR_TypeInfo)
- data_value[UNIV_OFFSET_FOR_TYPEINFO],
+ data_value[MR_UNIV_OFFSET_FOR_TYPEINFO],
lower_limit, upper_limit);
- copy_type_info(
- (MR_TypeInfo *) &data_value[UNIV_OFFSET_FOR_TYPEINFO],
+ copy_type_info((MR_TypeInfo *)
+ &data_value[MR_UNIV_OFFSET_FOR_TYPEINFO],
lower_limit, upper_limit);
new_data = data;
} else {
Index: runtime/mercury_overflow.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_overflow.h,v
retrieving revision 1.5
diff -u -d -r1.5 mercury_overflow.h
--- runtime/mercury_overflow.h 2000/11/23 02:00:36 1.5
+++ runtime/mercury_overflow.h 2000/11/23 13:29:38
@@ -9,7 +9,7 @@
#ifndef MERCURY_OVERFLOW_H
#define MERCURY_OVERFLOW_H
-#define IF(cond, val) ((cond) ? ((val), (void)0) : (void)0)
+#define MR_IF(cond, val) ((cond) ? ((val), (void)0) : (void)0)
#ifndef MR_CHECK_FOR_OVERFLOW
@@ -25,53 +25,53 @@
#include "mercury_misc.h" /* for MR_fatal_error() */
#define MR_heap_overflow_check() \
- ( \
- IF (MR_hp >= MR_ENGINE(MR_heap_zone)->top,( \
- MR_fatal_error("heap overflow") \
- )), \
- IF (MR_hp > MR_ENGINE(MR_heap_zone)->max,( \
- MR_ENGINE(heap_zone)->max = MR_hp \
- )), \
- (void)0 \
- )
+ ( \
+ MR_IF (MR_hp >= MR_ENGINE(MR_heap_zone)->top,( \
+ MR_fatal_error("heap overflow") \
+ )), \
+ MR_IF (MR_hp > MR_ENGINE(MR_heap_zone)->max,( \
+ MR_ENGINE(heap_zone)->max = MR_hp \
+ )), \
+ (void)0 \
+ )
#define MR_detstack_overflow_check() \
- ( \
- IF (MR_sp >= MR_CONTEXT(MR_detstack_zone)->top,(\
- MR_fatal_error("stack overflow") \
- )), \
- IF (MR_sp > MR_CONTEXT(MR_detstack_zone)->max,( \
- MR_CONTEXT(detstack_zone)->max = MR_sp \
- )), \
- (void)0 \
- )
+ ( \
+ MR_IF (MR_sp >= MR_CONTEXT(MR_detstack_zone)->top,( \
+ MR_fatal_error("stack overflow") \
+ )), \
+ MR_IF (MR_sp > MR_CONTEXT(MR_detstack_zone)->max,( \
+ MR_CONTEXT(detstack_zone)->max = MR_sp \
+ )), \
+ (void)0 \
+ )
#define MR_detstack_underflow_check() \
- ( \
- IF (MR_sp < MR_CONTEXT(MR_detstack_zone)->min,( \
- MR_fatal_error("stack underflow") \
- )), \
- (void)0 \
- )
+ ( \
+ MR_IF (MR_sp < MR_CONTEXT(MR_detstack_zone)->min,( \
+ MR_fatal_error("stack underflow") \
+ )), \
+ (void)0 \
+ )
#define MR_nondstack_overflow_check() \
- ( \
- IF (MR_maxfr >= MR_CONTEXT(MR_nondetstack_zone)->top,( \
- MR_fatal_error("nondetstack overflow") \
- )), \
- IF (MR_maxfr > MR_CONTEXT(MR_nondetstack_zone)->max,( \
- MR_CONTEXT(nondetstack_zone)->max = MR_maxfr \
- )), \
- (void)0 \
- )
+ ( \
+ MR_IF (MR_maxfr >= MR_CONTEXT(MR_nondetstack_zone)->top,( \
+ MR_fatal_error("nondetstack overflow") \
+ )), \
+ MR_IF (MR_maxfr > MR_CONTEXT(MR_nondetstack_zone)->max,( \
+ MR_CONTEXT(nondetstack_zone)->max = MR_maxfr \
+ )), \
+ (void)0 \
+ )
#define MR_nondstack_underflow_check() \
- ( \
- IF (MR_maxfr < MR_CONTEXT(MR_nondetstack_zone)->min,( \
- MR_fatal_error("nondetstack underflow") \
- )), \
- (void)0 \
- )
+ ( \
+ MR_IF (MR_maxfr < MR_CONTEXT(MR_nondetstack_zone)->min,( \
+ MR_fatal_error("nondetstack underflow") \
+ )), \
+ (void)0 \
+ )
#endif /* MR_CHECK_FOR_OVERFLOW */
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.31
diff -u -d -r1.31 mercury_tabling.c
--- runtime/mercury_tabling.c 2000/11/23 02:00:43 1.31
+++ runtime/mercury_tabling.c 2000/11/23 13:19:21
@@ -845,10 +845,10 @@
data_value = (MR_Word *) data;
MR_DEBUG_TABLE_TYPEINFO(table,
- (MR_TypeInfo) data_value[UNIV_OFFSET_FOR_TYPEINFO]);
+ (MR_TypeInfo) data_value[MR_UNIV_OFFSET_FOR_TYPEINFO]);
MR_DEBUG_TABLE_ANY(table,
- (MR_TypeInfo) data_value[UNIV_OFFSET_FOR_TYPEINFO],
- data_value[UNIV_OFFSET_FOR_DATA]);
+ (MR_TypeInfo) data_value[MR_UNIV_OFFSET_FOR_TYPEINFO],
+ data_value[MR_UNIV_OFFSET_FOR_DATA]);
break;
}
@@ -1007,7 +1007,7 @@
saved_state->non_stack_block_size = MR_maxfr - generator_maxfr;
saved_state->non_stack_block =
table_allocate_words(saved_state->non_stack_block_size);
- table_copy_words(saved_state->non_stack_block,
+ MR_table_copy_words(saved_state->non_stack_block,
saved_state->non_stack_block_start,
saved_state->non_stack_block_size);
} else {
@@ -1020,7 +1020,7 @@
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);
- table_copy_words(saved_state->det_stack_block,
+ MR_table_copy_words(saved_state->det_stack_block,
saved_state->det_stack_block_start,
saved_state->det_stack_block_size);
} else {
@@ -1033,13 +1033,13 @@
saved_state->gen_next = MR_gen_next;
saved_state->generator_stack_block = table_allocate_bytes(
MR_gen_next * sizeof(MR_GeneratorStackFrame));
- table_copy_bytes(saved_state->generator_stack_block,
+ 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(
MR_cut_next * sizeof(MR_CutStackFrame));
- table_copy_bytes(saved_state->cut_stack_block,
+ MR_table_copy_bytes(saved_state->cut_stack_block,
MR_cut_stack, MR_cut_next * sizeof(MR_CutStackFrame));
#ifdef MR_USE_TRAIL
@@ -1144,22 +1144,22 @@
MR_curfr = saved_state->cur_fr;
MR_maxfr = saved_state->max_fr;
- table_copy_words(saved_state->non_stack_block_start,
+ MR_table_copy_words(saved_state->non_stack_block_start,
saved_state->non_stack_block,
saved_state->non_stack_block_size);
- table_copy_words(saved_state->det_stack_block_start,
+ MR_table_copy_words(saved_state->det_stack_block_start,
saved_state->det_stack_block,
saved_state->det_stack_block_size);
#endif
MR_gen_next = saved_state->gen_next;
- table_copy_bytes(MR_gen_stack, saved_state->generator_stack_block,
+ MR_table_copy_bytes(MR_gen_stack, saved_state->generator_stack_block,
saved_state->gen_next * sizeof(MR_GeneratorStackFrame));
MR_cut_next = saved_state->cut_next;
- table_copy_bytes(MR_cut_stack, saved_state->cut_stack_block,
+ MR_table_copy_bytes(MR_cut_stack, saved_state->cut_stack_block,
saved_state->cut_next * sizeof(MR_CutStackFrame));
#ifdef MR_TABLE_DEBUG
@@ -1287,8 +1287,8 @@
arena_block = table_allocate_words(arena_size);
- table_copy_words(arena_block, arena_start, extension_size);
- table_copy_words(arena_block + extension_size,
+ MR_table_copy_words(arena_block, arena_start, extension_size);
+ MR_table_copy_words(arena_block + extension_size,
suspension->saved_state.det_stack_block,
suspension->saved_state.det_stack_block_size);
@@ -1322,8 +1322,8 @@
arena_block = table_allocate_words(arena_size);
- table_copy_words(arena_block, arena_start, extension_size);
- table_copy_words(arena_block + extension_size,
+ MR_table_copy_words(arena_block, arena_start, extension_size);
+ MR_table_copy_words(arena_block + extension_size,
suspension->saved_state.non_stack_block,
suspension->saved_state.non_stack_block_size);
Index: runtime/mercury_thread.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.15
diff -u -d -r1.15 mercury_thread.c
--- runtime/mercury_thread.c 2000/11/23 02:00:45 1.15
+++ runtime/mercury_thread.c 2000/11/23 13:03:44
@@ -67,7 +67,7 @@
#endif /* MR_THREAD_SAFE */
-MR_Bool
+bool
MR_init_thread(MR_when_to_use when_to_use)
{
MercuryEngine *eng;
Index: runtime/mercury_thread.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.h,v
retrieving revision 1.9
diff -u -d -r1.9 mercury_thread.h
--- runtime/mercury_thread.h 2000/11/23 02:00:45 1.9
+++ runtime/mercury_thread.h 2000/11/23 13:04:36
@@ -6,11 +6,12 @@
#ifndef MERCURY_THREAD_H
#define MERCURY_THREAD_H
+#include "mercury_std.h"
+
#ifdef MR_THREAD_SAFE
#include <signal.h> /* for sigset_t on the SPARC */
#include <pthread.h>
- #include "mercury_std.h"
#if defined(MR_DIGITAL_UNIX_PTHREADS)
#define MR_MUTEX_ATTR pthread_mutexattr_default
@@ -141,7 +142,7 @@
** finalize_thread_engine if it is true).
*/
-extern MR_Bool MR_init_thread(MR_when_to_use);
+extern bool MR_init_thread(MR_when_to_use);
/*
** Finalize the thread engine running in the current POSIX thread.
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.59
diff -u -d -r1.59 mercury_type_info.h
--- runtime/mercury_type_info.h 2000/11/23 02:00:48 1.59
+++ runtime/mercury_type_info.h 2000/11/23 13:13:50
@@ -341,22 +341,22 @@
** The second word contains the data.
*/
-#define UNIV_OFFSET_FOR_TYPEINFO 0
-#define UNIV_OFFSET_FOR_DATA 1
+#define MR_UNIV_OFFSET_FOR_TYPEINFO 0
+#define MR_UNIV_OFFSET_FOR_DATA 1
#define MR_unravel_univ(univ, typeinfo, value) \
do { \
typeinfo = (MR_TypeInfo) MR_field(MR_mktag(0), (univ), \
- UNIV_OFFSET_FOR_TYPEINFO); \
+ MR_UNIV_OFFSET_FOR_TYPEINFO); \
value = MR_field(MR_mktag(0), (univ), \
- UNIV_OFFSET_FOR_DATA); \
+ MR_UNIV_OFFSET_FOR_DATA); \
} while (0)
#define MR_define_univ_fields(univ, typeinfo, value) \
do { \
- MR_field(MR_mktag(0), (univ), UNIV_OFFSET_FOR_TYPEINFO) \
+ MR_field(MR_mktag(0), (univ), MR_UNIV_OFFSET_FOR_TYPEINFO) \
= (MR_Word) (typeinfo); \
- MR_field(MR_mktag(0), (univ), UNIV_OFFSET_FOR_DATA) \
+ MR_field(MR_mktag(0), (univ), MR_UNIV_OFFSET_FOR_DATA) \
= (MR_Word) (value); \
} while (0)
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.63
diff -u -d -r1.63 Mmakefile
--- runtime/Mmakefile 2000/10/11 03:00:15 1.63
+++ runtime/Mmakefile 2000/11/23 16:00:54
@@ -175,6 +175,7 @@
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)
#-----------------------------------------------------------------------------#
@@ -272,11 +273,6 @@
# 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_'.
-#
-# XXX the `cmp' command below, which forces `mmake check_headers' to fail
-# if the foo_check.macros file is non-empty, i.e. if the header is not
-# macro-namespace-clean, is commented out because currently the headers
-# are not namespace-clean.
#
AWK = awk
@@ -285,11 +281,46 @@
-nostdinc -dN \
2> /dev/null | $(AWK) '/^#define/ { print $$2; }' | \
grep -v -e '^MR_' -e '^GC_' -e '^MERCURY_' | \
- sort | uniq > $@
- #cmp $@ /dev/null # XXX disabled for now
+ fgrep -v -x -f RESERVED_MACRO_NAMES | \
+ sort -u > $@
+ @if cmp -s /dev/null $@; then \
+ true; \
+ else \
+ echo "** Macro name(s) in user namespace:"; \
+ cat $@; \
+ echo "(You may need to add MR_ prefixes to these names.)"; \
+ exit 1; \
+ fi
.PHONY: check_headers
check_headers: $(HDR_CHECK_OBJS) $(HDR_CHECK_MACROS)
+
+#
+# $(OBJ_CHECKS) is used to check that the objects are properly
+# namespace-clean, with regard to the global symbols that they define.
+# For each object file foo.o, the rule below produces a file
+# foo.o.obj_check that contains a list of all the globals defined
+# by that object that do not start with `MR_', `mercury_', or `entry_'.
+#
+
+%.obj_check: %
+ nm -g $< | awk '$$1 != "U" { print $$3; }' | \
+ grep -v -e '^_entry' -e '^MR_' -e '^mercury_' | \
+ sort -u > $@
+ @if cmp -s /dev/null $@; then \
+ true; \
+ else \
+ echo "** Global symbols in user namespace:"; \
+ cat $@; \
+ echo "(You may need to add MR_ prefixes to these names.)"; \
+ exit 1; \
+ fi
+
+.PHONY: check_objs
+check_objs: $(OBJ_CHECKS)
+
+.PHONY: check_namespace
+check_namespace: check_headers check_objs
#-----------------------------------------------------------------------------#
Index: runtime/RESERVED_MACRO_NAMES
===================================================================
RCS file: RESERVED_MACRO_NAMES
diff -N RESERVED_MACRO_NAMES
--- /dev/null Thu Mar 30 14:06:13 2000
+++ RESERVED_MACRO_NAMES Fri Nov 24 02:30:57 2000
@@ -0,0 +1,120 @@
+#-----------------------------------------------------------------------------#
+# Copyright (C) 2000 The University of Melbourne.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#-----------------------------------------------------------------------------#
+#
+# RESERVED_MACRO_NAMES
+#
+# This file lists the macro names, other than the
+# ones starting with `MR_', `MERCURY_', or `GC_',
+# that are defined by the Mercury header files.
+# The Mmakefile target `check_headers' automatically
+# checks that no other macro names are defined.
+# This is done to keep our headers namespace-clean,
+# i.e. ensure that we don't invade the user's namespace.
+#
+# This file is used as the argument to `fgrep -f'.
+# Lines starting with `#' will not match anything in the input,
+# and can thus be used as comments.
+# Other lines are treated as strings to match against.
+#
+#-----------------------------------------------------------------------------#
+# 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.
+bool
+TRUE
+FALSE
+strdiff
+streq
+strndiff
+strneq
+strntest
+strtest
+ungetchar
+max
+min
+reg
+#-----------------------------------------------------------------------------#
+# 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.
+BOXED_FLOAT
+CONSERVATIVE_GC
+LOW_TAG_BITS
+NATIVE_GC
+NO_TYPE_LAYOUT
+PARALLEL
+PC_ACCESS
+PC_ACCESS_GREG
+PROFILE_CALLS
+PROFILE_TIME
+PROFILE_MEMORY
+PIC
+RETSIGTYPE
+SIGACTION_FIELD
+USE_ASM_LABELS
+USE_DLLS
+USE_GCC_GLOBAL_REGISTERS
+USE_GCC_NONLOCAL_GOTOS
+USE_SINGLE_PREC_FLOAT
+HAVE_ASM_SIGCONTEXT
+HAVE_DLCLOSE
+HAVE_DLERROR
+HAVE_DLFCN_H
+HAVE_DLOPEN
+HAVE_DLSYM
+HAVE_FDOPEN
+HAVE_FILENO
+HAVE_FSTAT
+HAVE_GETPAGESIZE
+HAVE_MEMALIGN
+HAVE_MEMMOVE
+HAVE_MPROTECT
+HAVE_READLINE_HISTORY
+HAVE_READLINE_READLINE
+HAVE_SETITIMER
+HAVE_SIGACTION
+HAVE_SIGCONTEXT_STRUCT
+HAVE_SIGCONTEXT_STRUCT_2ARG
+HAVE_SIGCONTEXT_STRUCT_3ARG
+HAVE_SIGINFO
+HAVE_SIGINFO_T
+HAVE_STRERROR
+HAVE_SYSCONF
+HAVE_SYS_PARAM
+HAVE_SYS_STAT_H
+HAVE_SYS_SIGINFO
+HAVE_SYS_TIME
+HAVE_SYS_TIMES_H
+HAVE_SYS_TYPES_H
+HAVE_SYS_UCONTEXT
+HAVE_SYS_WAIT
+HAVE_UCONTEXT
+HAVE_UNISTD_H
+HAVE_VSNPRINTF
+HAVE__VSNPRINTF
+#-----------------------------------------------------------------------------#
+# These are defined by mercury.h
+# Normally macros should start with capital letters,
+# but in this case we need to use lowercase, otherwise
+# the macros wouldn't achieve their desired effect.
+# The `mercury__' prefix is unique enough.
+mercury__builtin____type_ctor_info_character_0
+mercury__builtin____type_ctor_info_float_0
+mercury__builtin____type_ctor_info_int_0
+mercury__builtin____type_ctor_info_pred_0
+mercury__builtin____type_ctor_info_string_0
+mercury__builtin____type_ctor_info_tuple_0
+#-----------------------------------------------------------------------------#
+# These are defined by boehm_gc/gc.h.
+__GC
+_GC_H
+#-----------------------------------------------------------------------------#
+# This is defined by mercury_getopt.h
+# That header file is NOT #included by any of the other
+# headers, so this doesn't cause any name space polution.
+__GNU_LIBRARY__
+#-----------------------------------------------------------------------------#
Index: tests/hard_coded/existential_types_test.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/existential_types_test.m,v
retrieving revision 1.4
diff -u -d -r1.4 existential_types_test.m
--- tests/hard_coded/existential_types_test.m 2000/03/24 10:28:01 1.4
+++ tests/hard_coded/existential_types_test.m 2000/11/23 13:32:26
@@ -40,8 +40,10 @@
call_my_univ_value(Univ) = my_univ_value(Univ).
:- pragma c_code(my_univ_value(Univ::in) = (Value::out), will_not_call_mercury, "
- TypeInfo_for_T = MR_field(MR_mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO);
- Value = MR_field(MR_mktag(0), Univ, UNIV_OFFSET_FOR_DATA);
+ TypeInfo_for_T = MR_field(MR_mktag(0), Univ,
+ MR_UNIV_OFFSET_FOR_TYPEINFO);
+ Value = MR_field(MR_mktag(0), Univ,
+ MR_UNIV_OFFSET_FOR_DATA);
").
% The predicate has_type/2 is basically an existentially typed
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.105
diff -u -d -r1.105 bootcheck
--- tools/bootcheck 2000/11/21 23:52:54 1.105
+++ tools/bootcheck 2000/11/23 16:01:48
@@ -53,6 +53,8 @@
Do not run the bootstrap check; execute the test suite and/or
the extras only. This option requires a previous bootstrap
check to have left a working stage 2 directory.
+ --no-check-namespace
+ Don't build the check_namespace target in the runtime.
-t, --no-test-suite
By default, bootcheck will also run the test quite.
This option prevents that.
@@ -97,6 +99,7 @@
outfile=""
runtests=true
do_bootcheck=true
+check_namespace=true
grade=
test_grade=
test_params=false
@@ -177,6 +180,9 @@
-n|--no-bootcheck)
do_bootcheck=false ;;
+ --no-check_namespace)
+ check_namespace=false ;;
+
-t|--no-test-suite)
runtests=false ;;
@@ -297,6 +303,8 @@
RMSTAGECMD="/bin/rm -fr"
fi
+#-----------------------------------------------------------------------------#
+
if $do_bootcheck
then
if mmake $mmake_opts MMAKEFLAGS=$jfactor all
@@ -715,7 +723,7 @@
exec >&3 # restore stdout from fd 3
if [ $diff_status -ne 0 ]; then
- echo "error - stage 2 and stage 3 differ!"
+ echo "** error - stage 2 and stage 3 differ!"
else
echo "stage 2 and stage 3 compare ok"
echo "removing stage 3..."
@@ -735,6 +743,8 @@
echo "building of stages 1 and 2 skipped"
fi
+#-----------------------------------------------------------------------------#
+
if test "$runtests" = "true" -o "$extras" = "true"
then
# Use everything from stage 2, unless the options say that the tests
@@ -799,6 +809,22 @@
export PATH
fi
+#-----------------------------------------------------------------------------#
+
+# build the check_namespace target in the runtime directory
+
+check_namespace_status=0
+if $check_namespace
+then
+ cd $root/${stage2_insert}runtime
+ mmake $mmake_opts check_namespace || check_namespace_status=1
+ cd $root
+fi
+
+#-----------------------------------------------------------------------------#
+
+# Run the tests in the tests/* directories
+
test_status=0
if $runtests
then
@@ -865,6 +891,10 @@
fi
fi
+#-----------------------------------------------------------------------------#
+
+# Run the tests in the extras/* directories
+
extras_status=0
if $extras
then
@@ -916,6 +946,8 @@
cd $root
fi
+#-----------------------------------------------------------------------------#
+
if test "$type_stats" != ""
then
mv "$type_stats".save.$$ "$type_stats"
@@ -923,9 +955,12 @@
echo "finishing at `date`"
-if test "$diff_status" = 0 -a "$test_status" = 0 -a "$extras_status" = 0
+if test "$diff_status" = 0 -a "$test_status" = 0 -a "$extras_status" = 0 \
+ -a "$check_namespace_status" = 0
then
exit 0
else
exit 1
fi
+
+#-----------------------------------------------------------------------------#
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.33
diff -u -d -r1.33 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c 2000/11/10 01:01:04 1.33
+++ trace/mercury_trace_declarative.c 2000/11/23 13:20:37
@@ -1098,9 +1098,9 @@
MR_TRACE_USE_HP(
tag_incr_hp(arg, MR_mktag(0), 2);
);
- MR_field(MR_mktag(0), arg, UNIV_OFFSET_FOR_TYPEINFO) =
+ MR_field(MR_mktag(0), arg, MR_UNIV_OFFSET_FOR_TYPEINFO) =
(MR_Word) arg_type;
- MR_field(MR_mktag(0), arg, UNIV_OFFSET_FOR_DATA) =
+ MR_field(MR_mktag(0), arg, MR_UNIV_OFFSET_FOR_DATA) =
arg_value;
MR_TRACE_CALL_MERCURY(
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.46
diff -u -d -r1.46 mercury_trace_external.c
--- trace/mercury_trace_external.c 2000/11/23 02:01:07 1.46
+++ trace/mercury_trace_external.c 2000/11/23 13:20:51
@@ -1115,9 +1115,9 @@
incr_hp(univ, 2);
);
- MR_field(MR_mktag(0), univ, UNIV_OFFSET_FOR_TYPEINFO)
+ MR_field(MR_mktag(0), univ, MR_UNIV_OFFSET_FOR_TYPEINFO)
= (MR_Word) type_info;
- MR_field(MR_mktag(0), univ, UNIV_OFFSET_FOR_DATA) = value;
+ MR_field(MR_mktag(0), univ, MR_UNIV_OFFSET_FOR_DATA) = value;
MR_TRACE_USE_HP(
var_list = MR_list_cons(univ, var_list);
@@ -1232,9 +1232,9 @@
problem = MR_trace_return_var_info(var_number, NULL,
&type_info, &value);
if (problem == NULL) {
- MR_field(MR_mktag(0), univ, UNIV_OFFSET_FOR_TYPEINFO)
+ MR_field(MR_mktag(0), univ, MR_UNIV_OFFSET_FOR_TYPEINFO)
= (MR_Word) type_info;
- MR_field(MR_mktag(0), univ, UNIV_OFFSET_FOR_DATA) = value;
+ MR_field(MR_mktag(0), univ, MR_UNIV_OFFSET_FOR_DATA) = value;
} else {
/*
** Should never occur since we check in the external debugger
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.87
diff -u -d -r1.87 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 2000/11/18 11:28:50 1.87
+++ trace/mercury_trace_internal.c 2000/11/23 13:21:03
@@ -465,8 +465,10 @@
return "missing exception value";
}
- type_info = MR_field(MR_mktag(0), exception, UNIV_OFFSET_FOR_TYPEINFO);
- value = MR_field(MR_mktag(0), exception, UNIV_OFFSET_FOR_DATA);
+ type_info = MR_field(MR_mktag(0), exception,
+ MR_UNIV_OFFSET_FOR_TYPEINFO);
+ value = MR_field(MR_mktag(0), exception,
+ MR_UNIV_OFFSET_FOR_DATA);
(*browser)(type_info, value, caller, format);
--
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