mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 15:54:18 +00:00
Estimated hours taken: 10 Make everything in the runtime use MR_ prefixes, and make the compiler bootstrap with -DMR_NO_BACKWARDS_COMPAT. runtime/mercury_*.[ch] Add MR_ prefixes to all functions, global variables and almost all macros that could pollute the namespace. The (intentional) exceptions are 1. some function, variable, type and label names that already start with MR_, mercury_, Mercury or _entry; 2. some standard C macros in mercury_std.h; 3. the macros used in autoconfiguration (since they are used in scripts as well as the runtime, the MR_ prefix may not be appropriate for those). In some cases, I deleted things instead of adding prefixes if the "things" were obsolete and not user visible. runtime/mercury_bootstrap.h: Provide MR_-less forms of the macros for bootstrapping and for backward compatibility for user code. runtime/mercury_debug.[ch]: Add a FILE * parameter to a function that needs it. compiler/code_info.m: compiler/export.m: compiler/fact_table.m: compiler/llds.m: compiler/llds_out.m: compiler/pragma_c_gen.m: compiler/trace.m: Add MR_ prefixes to the C code generated by the compiler. library/*.m: Add MR_ prefixes to handwritten code. trace/mercury_trace_*.c: util/mkinit.c: Add MR_ prefixes as necessary. extras/concurrency/semaphore.m: Add MR_ prefixes as necessary.
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 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() \
|
|
( \
|
|
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 \
|
|
)
|
|
|
|
#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 \
|
|
)
|
|
|
|
#define MR_detstack_underflow_check() \
|
|
( \
|
|
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 \
|
|
)
|
|
|
|
#define MR_nondstack_underflow_check() \
|
|
( \
|
|
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 */
|