mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
Estimated hours taken: 16 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. Also make sure that all the old names are disabled if you compile with `-DMR_NO_BACKWARDS_COMPAT'. 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. 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_*. runtime/mercury_overflow.h: runtime/mercury_debug.h: 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: extras/aditi/aditi.m: Add MR_ prefixs to do_fail, do_redo, do_not_reached, etc. compiler/trace.m: compiler/fact_table.m: compiler/llds_out.m: Add MR_ prefixes to the generated code.
79 lines
2.1 KiB
C
79 lines
2.1 KiB
C
/*
|
|
** Copyright (C) 1995-1998,2000 The University of Melbourne.
|
|
** 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.
|
|
*/
|
|
|
|
/* mercury_overflow.h - definitions for overflow checks */
|
|
|
|
#ifndef MERCURY_OVERFLOW_H
|
|
#define MERCURY_OVERFLOW_H
|
|
|
|
#define MR_IF(cond, val) ((cond) ? ((val), (void)0) : (void)0)
|
|
|
|
#ifndef MR_CHECK_FOR_OVERFLOW
|
|
|
|
#define MR_heap_overflow_check() ((void)0)
|
|
#define MR_detstack_overflow_check() ((void)0)
|
|
#define MR_detstack_underflow_check() ((void)0)
|
|
#define MR_nondstack_overflow_check() ((void)0)
|
|
#define MR_nondstack_underflow_check() ((void)0)
|
|
|
|
#else /* MR_CHECK_FOR_OVERFLOW */
|
|
|
|
#include "mercury_regs.h"
|
|
#include "mercury_misc.h" /* for MR_fatal_error() */
|
|
|
|
#define MR_heap_overflow_check() \
|
|
( \
|
|
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() \
|
|
( \
|
|
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() \
|
|
( \
|
|
MR_IF (MR_sp < MR_CONTEXT(MR_detstack_zone)->min,( \
|
|
MR_fatal_error("stack underflow") \
|
|
)), \
|
|
(void)0 \
|
|
)
|
|
|
|
#define MR_nondstack_overflow_check() \
|
|
( \
|
|
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() \
|
|
( \
|
|
MR_IF (MR_maxfr < MR_CONTEXT(MR_nondetstack_zone)->min,( \
|
|
MR_fatal_error("nondetstack underflow") \
|
|
)), \
|
|
(void)0 \
|
|
)
|
|
|
|
#endif /* MR_CHECK_FOR_OVERFLOW */
|
|
|
|
#endif /* not MERCURY_OVERFLOW_H */
|