From b7e55aa8adfdfbedcd57fcb7b9facbe783129fbf Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Tue, 24 Sep 2002 06:55:36 +0000 Subject: [PATCH] Enforce namespace cleanliness in the library and browser directories Estimated hours taken: 6 Branches: main Enforce namespace cleanliness in the library and browser directories as well as in the runtime and trace directories. Mmake.common.in: Move the rules check_namespace here (they used to be in the Mmakefiles of the runtime and trace directories), together with the variables they need. Generalize them to also handle the needs of the browser, library and bytecode directories. The former two in particular need the ability to check automatically generated .mh files. Make all the rules used by check_namespace conditional on a macro that is defined by the Makefiles in all the directories that are checked for namespace cleanliness. trace/Mmakefile: runtime/Mmakefile: Replace the old rules for check_namespace, which are now in ../Mmake.common.in, with the macros needed to control their behavior. bytecode/Mmakefile: Add the macros needed to control the behavior of the rules for check_namespace. Move the lists of files to the start, before the include of ../Mmake.common. browser/Mmakefile: library/Mmakefile: Add the macros needed to control the behavior of the rules for check_namespace. runtime/RESERVED_MACRO_NAMES: Update comments, and delete obsolete exceptions. browser/RESERVED_MACRO_NAMES: library/RESERVED_MACRO_NAMES: New files to contain the exceptions from the naming scheme. tools/bootcheck: Invoke "mmake check_namespace" in the library and browser directories as well as the runtime and the trace directories. Perform the invocation before we delete the object files we are checking for cleanliness. Clean up object files in all stage2 directories, not just the library, as soon as we can. library/array.m: library/builtin.m: library/io.m: library/time.m: Fix namespace violations. --- Mmake.common.in | 141 +++++++++++++++++-- browser/Mmakefile | 9 ++ browser/RESERVED_MACRO_NAMES | 39 ++++++ bytecode/Mmakefile | 78 ++++++----- library/Mmakefile | 11 +- library/RESERVED_MACRO_NAMES | 39 ++++++ library/array.m | 14 +- library/builtin.m | 16 +-- library/io.m | 257 ++++++++++++++++++----------------- library/time.m | 8 +- runtime/Mmakefile | 95 ++++--------- runtime/RESERVED_MACRO_NAMES | 26 +--- tools/bootcheck | 91 +++++++++---- trace/Mmakefile | 91 +++++-------- 14 files changed, 547 insertions(+), 368 deletions(-) create mode 100644 browser/RESERVED_MACRO_NAMES create mode 100644 library/RESERVED_MACRO_NAMES diff --git a/Mmake.common.in b/Mmake.common.in index 3e4ce0960..0ad010134 100644 --- a/Mmake.common.in +++ b/Mmake.common.in @@ -219,6 +219,74 @@ include $(MERCURY_DIR)/Mercury.options $(MERCURY_DIR)/Mmake.params: ; #-----------------------------------------------------------------------------# +# +# `mmake check_namespace' performs various checks on the header files +# and object files to make sure that they conform with our coding standards. +# + +ifdef CHECK_OBJS + +HDR_CHECK_CS = $(CHECK_HDRS:.h=.check_hdr.c) +HDR_CHECK_OBJS = $(CHECK_HDRS:.h=.check_hdr.$O) +HDR_CHECK_MACROS = $(CHECK_HDRS:.h=.check.macros) +MHDR_CHECK_CS = $(CHECK_MHDRS:.mh=.check_mhdr.c) +MHDR_CHECK_OBJS = $(CHECK_MHDRS:.mh=.check_mhdr.$O) +MHDR_CHECK_MACROS = $(CHECK_MHDRS:.mh=.check.mmacros) +OBJ_CHECKS = $(CHECK_OBJS:%=%.obj_check) + +# Macro names must normally start with one of the prefixes associated +# with the different components of our system: +# `MR_' or `MERCURY_' for stuff in the Mercury runtime implementation +# (the `runtime' and `trace' directories) +# `ML_' for stuff in the Mercury standard library +# (the `library' directory) +# `MDB_' for stuff in the browser +# (the `browser' directory) +# `GC_' for stuff in the Boehm et al conservative garbage collector +# (the `boehm_gc' directory) +# `MPS_' or `mps_' for stuff in the Memory Pool System toolkit +# (the `mps_gc' directory, if present -- note that this +# is in a separate CVS module and is not included in the +# normal Mercury source distributions) +# Exceptions to this policy must be listed in the RESERVED_MACRO_NAMES file +# in the relevant directory. + +GEN_MACRO_PREFIX_EXPRS = \ + -e '^MR_' -e '^MERCURY_' -e '^GC_' -e '^MPS_' -e '^mps_' +GEN_OBJ_PREFIX_EXPRS = \ + -e '^MR_' -e '^_entry' -e '^mercury_' + +ifeq ("$(ALLOW_LIB_PREFIX)","yes") +LIB_MACRO_PREFIX_EXPRS = \ + -e '^ML_' +LIB_OBJ_PREFIX_EXPRS = \ + -e '^ML_' +else +LIB_MACRO_PREFIX_EXPRS = +LIB_OBJ_PREFIX_EXPRS = +endif + +ifeq ("$(ALLOW_BROWSER_PREFIX)","yes") +BROWSER_MACRO_PREFIX_EXPRS = \ + -e '^MDB_' +BROWSER_OBJ_PREFIX_EXPRS = \ + -e '^MDB_' -e '^mdb_' +else +BROWSER_MACRO_PREFIX_EXPRS = +BROWSER_OBJ_PREFIX_EXPRS = +endif + +MACRO_PREFIX_EXPRS = \ + $(GEN_MACRO_PREFIX_EXPRS) \ + $(LIB_MACRO_PREFIX_EXPRS) \ + $(BROWSER_MACRO_PREFIX_EXPRS) +OBJ_PREFIX_EXPRS = \ + $(GEN_OBJ_PREFIX_EXPRS) \ + $(LIB_OBJ_PREFIX_EXPRS) \ + $(BROWSER_OBJ_PREFIX_EXPRS) + +HEADER_CLEAN_FILTER = \ + grep -v $(MACRO_PREFIX_EXPRS) | fgrep -v -x -f RESERVED_MACRO_NAMES # This rule checks that object files are properly namespace-clean, with # regard to the global symbols that they define. @@ -228,39 +296,66 @@ $(MERCURY_DIR)/Mmake.params: ; %.obj_check: % nm -g $< | awk '$$1 != "U" { print $$3; }' | \ - grep -v -e '^_entry' -e '^MR_' -e '^mercury_' | \ - sort -u > $@ + grep -v $(OBJ_PREFIX_EXPRS) | 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.)"; \ + echo "(You may need to add a distinguishing prefix to these names.)"; \ exit 1; \ fi -# This rule helps to check that header files is self-contained, i.e. that each +# These rules help to check that header files is self-contained, i.e. that each # header file foo.h includes any other header files that define types # used by foo.h. It creates a foo.check_hdr.c file that contains only a single # `#include' statement that includes foo.h; compiling foo.check_hdr.c will fail -# if foo.h is not self-contained. +# if foo.h is not self-contained. Similarly for .mh files. %.check_hdr.c : %.h echo "#include \"$*.h\"" > $*.check_hdr.c -# This rule checks whether a header file defines any macros it shouldn't. -# It generates the list of macros defined in the header file, and filters this +%.check_mhdr.c : %.mh + echo "#include \"$*.mh\"" > $*.check_mhdr.c + +# These rules check whether a header file defines any macros it shouldn't. +# They generates the list of macros defined in the header file, and filter this # list through a command that is intended to filter out all references to macro -# names that are all right. Each directory that uses this rule must set -# the HEADER_CLEAN_FILTER make variable to contain this command. +# names that are all right. Each directory that uses this rule must set arrange +# for the precursors of the HEADER_CLEAN_FILTER make variable to contain this +# command. +# +# The two rules should differ only in the filenames they use and in the fact +# that the automatically created header file for module x is allowed to have +# two macros, X_H and X_DECL_GUARD over and above what HEADER_CLEAN_FILTER +# allows. AWK = awk + %.check.macros: %.h %.check_hdr.c -$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) \ -DMERCURY_BOOTSTRAP_H -DMR_NO_CONF_BACKWARDS_COMPAT \ -E $*.check_hdr.c \ -nostdinc -dN \ - 2> /dev/null | $(AWK) '/^#define/ { print $$2; }' | \ + 2> /dev/null | $(AWK) '/[ \t]*#define/ { print $$2; }' | \ + $(HEADER_CLEAN_FILTER) | sort -u > $@ + @if cmp -s /dev/null $@; then \ + true; \ + else \ + echo "** Macro name(s) in user namespace:"; \ + cat $@; \ + echo "(You may need to add a distinguishing prefix to these names.)"; \ + exit 1; \ + fi + +%.check.mmacros: %.mh %.check_mhdr.c + -$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) \ + -DMERCURY_BOOTSTRAP_H -DMR_NO_CONF_BACKWARDS_COMPAT \ + -E $*.check_mhdr.c \ + -nostdinc -dN \ + 2> /dev/null | $(AWK) '/[ \t]*#define/ { print $$2; }' | \ + grep -v -e `echo $(subst .check.mmacros,,$@) | tr '[a-z]' '[A-Z]'`_H | \ + grep -v -e `echo $(subst .check.mmacros,,$@) | tr '[a-z]' '[A-Z]'`_DECL_GUARD | \ $(HEADER_CLEAN_FILTER) | sort -u > $@ @if cmp -s /dev/null $@; then \ true; \ @@ -272,3 +367,29 @@ AWK = awk fi #-----------------------------------------------------------------------------# + +.PHONY: check_headers_self_contained +check_headers_self_contained: $(HDR_CHECK_OBJS) $(MHDR_CHECK_OBJS) + +.PHONY: check_headers_macros +check_headers_macros: $(HDR_CHECK_MACROS) $(MHDR_CHECK_MACROS) + +.PHONY: check_headers +check_headers: check_headers_self_contained check_headers_macros + +.PHONY: check_objs +check_objs: $(OBJ_CHECKS) + +.PHONY: check_namespace +check_namespace: check_headers check_objs + +.PHONY: clean_check +clean_check: + -rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS) + -rm -f $(MHDR_CHECK_OBJS) $(MHDR_CHECK_CS) $(MHDR_CHECK_MACROS) + -rm -f $(OBJ_CHECKS) + +endif +# ifdef CHECK_OBJS + +#-----------------------------------------------------------------------------# diff --git a/browser/Mmakefile b/browser/Mmakefile index c603cc514..c7acb3001 100644 --- a/browser/Mmakefile +++ b/browser/Mmakefile @@ -15,6 +15,15 @@ # in an executable must be of the same grade, we need to be able to # compile the modules in this directory in debug grades as well. +# Specify which files to check for namespace cleanliness, and which name +# prefixes are allowed. + +CHECK_HDRS = +CHECK_MHDRS = $(mer_browser.mhs) +CHECK_OBJS = $(mer_browser.os) +ALLOW_LIB_PREFIX=yes +ALLOW_BROWSER_PREFIX=yes + MERCURY_DIR=.. LINK_STDLIB_ONLY=yes include $(MERCURY_DIR)/Mmake.common diff --git a/browser/RESERVED_MACRO_NAMES b/browser/RESERVED_MACRO_NAMES new file mode 100644 index 000000000..e549bd601 --- /dev/null +++ b/browser/RESERVED_MACRO_NAMES @@ -0,0 +1,39 @@ +#-----------------------------------------------------------------------------# +# Copyright (C) 2000-2002 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 a +# certain set of allowed prefixes 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. +# +#-----------------------------------------------------------------------------# +# This is documented in the Mercury language reference manual +# and defined by mercury_types.h. +SUCCESS_INDICATOR +#-----------------------------------------------------------------------------# +# pid_t is only defined in mercury_conf.h if it is not present +# in the system headers. I don't think there is a nice way to +# prefix this without requiring a later version of autoconf (e.g. 2.52). +pid_t +#-----------------------------------------------------------------------------# +# These are defined by boehm_gc/gc.h. +__GC +_GC_H +#-----------------------------------------------------------------------------# +# This is defined by mps_gc/code/mercury_mps.h, +# which uses this macro for its header guard. +# Normally it would be better to use uppercase for header guard macro names, +# but that would be inconsistent with the coding style used in mps_gc/code. +mercury_mps_h +#-----------------------------------------------------------------------------# diff --git a/bytecode/Mmakefile b/bytecode/Mmakefile index 855fbf878..497a70026 100644 --- a/bytecode/Mmakefile +++ b/bytecode/Mmakefile @@ -1,5 +1,5 @@ #-----------------------------------------------------------------------------# -# Copyright (C) 1998-2001 The University of Melbourne. +# Copyright (C) 1998-2002 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. #-----------------------------------------------------------------------------# @@ -8,40 +8,6 @@ MAIN_TARGET=all -MERCURY_DIR=.. -include $(MERCURY_DIR)/Mmake.common --include ../Mmake.params - -#-----------------------------------------------------------------------------# -# NOTE: any library functions that called from bytecode must be compiled -# with trace information. (So their entry labels can be looked up) -#-----------------------------------------------------------------------------# - -MERCURY_SYSTEM = \ - $(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h \ - $(RUNTIME_DIR)/machdeps/*.c $(RUNTIME_DIR)/machdeps/*.h\ - $(LIBRARY_DIR)/*.m \ - $(TRACE_DIR)/*.h $(TRACE_DIR)/*.c \ - $(BROWSER_DIR)/*.h $(BROWSER_DIR)/*.c \ - $(BOEHM_GC_DIR)/*.h $(BOEHM_GC_DIR)/include/*.h - -MERCURY_INC = \ - -I$(LIBRARY_DIR) \ - -I$(RUNTIME_DIR) \ - -I$(BOEHM_GC_DIR) \ - -I$(BOEHM_GC_DIR)/include \ - -I$(TRACE_DIR) - -#-----------------------------------------------------------------------------# - -CFLAGS = $(MERCURY_INC) -DMR_BYTECODE_CALLABLE -g - -MGNUCFLAGS-mb_disasm = --no-ansi - -MCFLAGS = --trace shallow --generate-bytecode -O 0 - -MLFLAGS = --trace - #-----------------------------------------------------------------------------# # keep these lists in alphabetical order, please @@ -83,6 +49,48 @@ MB_OBJS = $(MB_MFILES:%.m=%.o) $(MB_CFILES:%.c=%.o) $(MB_OBJS): $(MB_HDRS) +# Specify which files to check for namespace cleanliness, and which name +# prefixes are allowed. + +CHECK_HDRS = $(MB_HDRS) +CHECK_MHDRS = +CHECK_OBJS = $(MB_OBJS) +ALLOW_LIB_PREFIX=no +ALLOW_BROWSER_PREFIX=no + +MERCURY_DIR=.. +include $(MERCURY_DIR)/Mmake.common +-include ../Mmake.params + +#-----------------------------------------------------------------------------# +# NOTE: any library functions that called from bytecode must be compiled +# with trace information. (So their entry labels can be looked up) +#-----------------------------------------------------------------------------# + +MERCURY_SYSTEM = \ + $(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h \ + $(RUNTIME_DIR)/machdeps/*.c $(RUNTIME_DIR)/machdeps/*.h\ + $(LIBRARY_DIR)/*.m \ + $(TRACE_DIR)/*.h $(TRACE_DIR)/*.c \ + $(BROWSER_DIR)/*.h $(BROWSER_DIR)/*.c \ + $(BOEHM_GC_DIR)/*.h $(BOEHM_GC_DIR)/include/*.h + +MERCURY_INC = \ + -I$(LIBRARY_DIR) \ + -I$(RUNTIME_DIR) \ + -I$(BOEHM_GC_DIR) \ + -I$(BOEHM_GC_DIR)/include \ + -I$(TRACE_DIR) + +#-----------------------------------------------------------------------------# + +CFLAGS = $(MERCURY_INC) -DMR_BYTECODE_CALLABLE -g + +MGNUCFLAGS-mb_disasm = --no-ansi + +MCFLAGS = --trace shallow --generate-bytecode -O 0 + +MLFLAGS = --trace #-----------------------------------------------------------------------------# # The actual program (as distinct from bytecode interpreter) diff --git a/library/Mmakefile b/library/Mmakefile index 276c963a6..1f26e46be 100644 --- a/library/Mmakefile +++ b/library/Mmakefile @@ -13,7 +13,16 @@ EXTRA_LDFLAGS = EXTRA_LDLIBS = #-----------------------------------------------------------------------------# - + +# Specify which files to check for namespace cleanliness, and which name +# prefixes are allowed. + +CHECK_HDRS = +CHECK_MHDRS = $(mer_std.mhs) +CHECK_OBJS = $(mer_std.os) +ALLOW_LIB_PREFIX=yes +ALLOW_BROWSER_PREFIX=no + MERCURY_DIR=.. LINK_RUNTIME_ONLY=yes include $(MERCURY_DIR)/Mmake.common diff --git a/library/RESERVED_MACRO_NAMES b/library/RESERVED_MACRO_NAMES new file mode 100644 index 000000000..e549bd601 --- /dev/null +++ b/library/RESERVED_MACRO_NAMES @@ -0,0 +1,39 @@ +#-----------------------------------------------------------------------------# +# Copyright (C) 2000-2002 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 a +# certain set of allowed prefixes 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. +# +#-----------------------------------------------------------------------------# +# This is documented in the Mercury language reference manual +# and defined by mercury_types.h. +SUCCESS_INDICATOR +#-----------------------------------------------------------------------------# +# pid_t is only defined in mercury_conf.h if it is not present +# in the system headers. I don't think there is a nice way to +# prefix this without requiring a later version of autoconf (e.g. 2.52). +pid_t +#-----------------------------------------------------------------------------# +# These are defined by boehm_gc/gc.h. +__GC +_GC_H +#-----------------------------------------------------------------------------# +# This is defined by mps_gc/code/mercury_mps.h, +# which uses this macro for its header guard. +# Normally it would be better to use uppercase for header guard macro names, +# but that would be inconsistent with the coding style used in mps_gc/code. +mercury_mps_h +#-----------------------------------------------------------------------------# diff --git a/library/array.m b/library/array.m index 2c08e3689..8b1988d3a 100644 --- a/library/array.m +++ b/library/array.m @@ -555,18 +555,18 @@ MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc array_module_builtins; /* Ensure that the initialization code for the above module gets run. */ /* -INIT sys_init_array_module_builtins +INIT mercury_sys_init_array_module_builtins */ /* suppress gcc -Wmissing-decl warning */ -void sys_init_array_module_builtins_init(void); -void sys_init_array_module_builtins_init_type_tables(void); +void mercury_sys_init_array_module_builtins_init(void); +void mercury_sys_init_array_module_builtins_init_type_tables(void); #ifdef MR_DEEP_PROFILING -void sys_init_array_module_builtins_write_out_proc_statics(FILE *fp); +void mercury_sys_init_array_module_builtins_write_out_proc_statics(FILE *fp); #endif void -sys_init_array_module_builtins_init(void) +mercury_sys_init_array_module_builtins_init(void) { #ifndef MR_HIGHLEVEL_CODE array_module_builtins(); @@ -577,7 +577,7 @@ sys_init_array_module_builtins_init(void) } void -sys_init_array_module_builtins_init_type_tables(void) +mercury_sys_init_array_module_builtins_init_type_tables(void) { #ifndef MR_HIGHLEVEL_CODE MR_register_type_ctor_info( @@ -587,7 +587,7 @@ sys_init_array_module_builtins_init_type_tables(void) #ifdef MR_DEEP_PROFILING void -sys_init_array_module_builtins_write_out_proc_statics(FILE *fp) +mercury_sys_init_array_module_builtins_write_out_proc_statics(FILE *fp) { MR_write_out_proc_static(fp, (MR_ProcStatic *) &MR_proc_static_compiler_name(array, __Unify__, array, 1, 0)); diff --git a/library/builtin.m b/library/builtin.m index 99a83da95..c55f73e49 100644 --- a/library/builtin.m +++ b/library/builtin.m @@ -790,7 +790,7 @@ mercury__builtin__copy_2_p_1(MR_Mercury_Type_Info type_info, } /* forward decl, to suppress gcc -Wmissing-decl warning */ -void sys_init_copy_module(void); +void mercury_sys_init_copy_module(void); #else /* ! MR_HIGHLEVEL_CODE */ @@ -885,20 +885,20 @@ MR_END_MODULE /* Ensure that the initialization code for the above module gets run. */ /* -INIT sys_init_copy_module +INIT mercury_sys_init_copy_module */ /* suppress gcc -Wmissing-decl warnings */ -void sys_init_copy_module_init(void); -void sys_init_copy_module_init_type_tables(void); +void mercury_sys_init_copy_module_init(void); +void mercury_sys_init_copy_module_init_type_tables(void); #ifdef MR_DEEP_PROFILING -void sys_init_copy_module_write_out_proc_statics(FILE *fp); +void mercury_sys_init_copy_module_write_out_proc_statics(FILE *fp); #endif MR_MODULE_STATIC_OR_EXTERN MR_ModuleFunc copy_module; void -sys_init_copy_module_init(void) +mercury_sys_init_copy_module_init(void) { #ifndef MR_HIGHLEVEL_CODE copy_module(); @@ -906,13 +906,13 @@ sys_init_copy_module_init(void) } void -sys_init_copy_module_init_type_tables(void) +mercury_sys_init_copy_module_init_type_tables(void) { } #ifdef MR_DEEP_PROFILING void -sys_init_copy_module_write_out_proc_statics(FILE *fp) +mercury_sys_init_copy_module_write_out_proc_statics(FILE *fp) { MR_write_out_proc_static(fp, (MR_ProcStatic *) &mercury_data__proc_static__mercury__copy_2_0); diff --git a/library/io.m b/library/io.m index e45815e6a..ca3ca8696 100644 --- a/library/io.m +++ b/library/io.m @@ -1604,7 +1604,7 @@ io__read_line_as_string(Stream, Result, IO0, IO) :- if (read_buffer != initial_read_buffer) { MR_free(read_buffer); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__read_line_as_string_2(_, _, _) --> @@ -1774,7 +1774,7 @@ io__input_stream_foldl2_io(Stream, Pred, T0, Res) --> } else { /* Not a file stream so do nothing */ } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", io__clear_err(_Stream::in, IO0::di, IO::uo), @@ -1783,7 +1783,7 @@ io__input_stream_foldl2_io(Stream, Pred, T0, Res) --> // XXX no error flag to reset as in MC++ an error throws directly an // exception (we should create an error indicator in MF_Mercury_file // for compatibility) - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__clear_err(_) --> @@ -1822,7 +1822,7 @@ io__check_err(Stream, Res) --> ML_maybe_make_err_msg(RetVal != 0, ""read failed: "", MR_PROC_LABEL, RetStr); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", ferror(_Stream::in, RetVal::out, _RetStr::out, @@ -1831,7 +1831,7 @@ io__check_err(Stream, Res) --> "{ // XXX see clearerr RetVal = 0; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). ferror(_, _, _) --> @@ -1851,7 +1851,7 @@ ferror(_, _, _) --> [will_not_call_mercury, promise_pure, tabled_for_io], "{ ML_maybe_make_err_msg(MR_TRUE, Msg0, MR_PROC_LABEL, Msg); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -1908,7 +1908,7 @@ make_err_msg(_, _) --> #else Size = -1; #endif - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", io__stream_file_size(Stream::in, Size::out, @@ -1922,7 +1922,7 @@ make_err_msg(_, _) --> } else { Size = -1; } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__stream_file_size(_, _) --> @@ -1964,7 +1964,7 @@ io__file_modification_time(File, Result) --> Msg = MR_make_string_const( ""io__file_modification_time not available on this platform""); #endif - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). @@ -2084,7 +2084,7 @@ io__buffer_to_string(_, _) :- Buffer = (MR_Word) buffer; Pos = Pos0 + items_read; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). @@ -2972,7 +2972,7 @@ io__stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " StreamNames = ML_io_stream_names; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -2980,7 +2980,7 @@ io__stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " ML_io_stream_names = StreamNames; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -2988,7 +2988,7 @@ io__stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " StreamNames = ML_io_stream_names; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -2996,7 +2996,7 @@ io__stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " ML_io_stream_names = StreamNames; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__get_stream_names(_) --> @@ -3038,7 +3038,7 @@ io__insert_stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Globals = ML_io_user_globals; - update_io(IOState0, IOState); + MR_update_io(IOState0, IOState); "). :- pragma foreign_proc("C", @@ -3047,7 +3047,7 @@ io__insert_stream_name(Stream, Name) --> " /* XXX need to globalize the memory */ ML_io_user_globals = Globals; - update_io(IOState0, IOState); + MR_update_io(IOState0, IOState); "). :- pragma foreign_proc("MC++", @@ -3055,7 +3055,7 @@ io__insert_stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Globals = ML_io_user_globals; - update_io(IOState0, IOState); + MR_update_io(IOState0, IOState); "). :- pragma foreign_proc("MC++", @@ -3063,7 +3063,7 @@ io__insert_stream_name(Stream, Name) --> [will_not_call_mercury, promise_pure, tabled_for_io], " ML_io_user_globals = Globals; - update_io(IOState0, IOState); + MR_update_io(IOState0, IOState); "). io__set_globals(_) --> @@ -3229,13 +3229,13 @@ io__finalize_state --> #endif MR_add_root(&ML_io_stream_names, (MR_TypeInfo) StreamNamesType); MR_add_root(&ML_io_user_globals, (MR_TypeInfo) UserGlobalsType); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", io__gc_init(_StreamNamesType::in, _UserGlobalsType::in, IO0::di, IO::uo), [will_not_call_mercury, promise_pure], " - update_io(IO0, IO); + MR_update_io(IO0, IO); ascii_encoder = new System::Text::ASCIIEncoding(); "). @@ -3356,9 +3356,10 @@ extern MercuryFile *mercury_current_text_output; extern MercuryFile *mercury_current_binary_input; extern MercuryFile *mercury_current_binary_output; -#define initial_io_state() 0 /* some random number */ -#define update_io(r_src, r_dest) ((r_dest) = (r_src)) -#define final_io_state(r) ((void)0) +#define MR_initial_io_state() 0 /* some random number */ +#define MR_final_io_state(r) ((void)0) + +#define MR_update_io(r_src, r_dest) ((r_dest) = (r_src)) void mercury_init_io(void); MercuryFile* mercury_open(const char *filename, const char *openmode); @@ -3402,9 +3403,9 @@ typedef __gc struct MR_MercuryFileStruct *MR_MercuryFile; #define ML_DownCast(Cast, Expr) dynamic_cast(Expr) #define ML_UpCast(Cast, Expr) ((Cast) (Expr)) -#define initial_io_state() 0 /* some random number */ -#define update_io(r_src, r_dest) (0) -#define final_io_state(r) +#define MR_initial_io_state() 0 /* some random number */ +#define MR_update_io(r_src, r_dest) (0) +#define MR_final_io_state(r) "). @@ -3933,7 +3934,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) [will_not_call_mercury, promise_pure, tabled_for_io], " CharCode = mercury_getc((MercuryFile *) File); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -3948,7 +3949,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) if (MR_UNGETCH(*mf, Character) == EOF) { mercury_io_error(mf, ""io__putback_char: ungetc failed""); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -3960,7 +3961,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) if (MR_UNGETCH(*mf, Character) == EOF) { mercury_io_error(mf, ""io__putback_byte: ungetc failed""); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -3969,7 +3970,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) MR_MercuryFile mf = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(File)); CharCode = mercury_getc(mf); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -3982,7 +3983,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) mf->line_number--; } mf->stream->Seek(-1, System::IO::SeekOrigin::Current); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -3992,7 +3993,7 @@ ML_fprintf(MercuryFile* mf, const char *format, ...) MR_MercuryFile mf = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(File)); mf->stream->Seek(-1, System::IO::SeekOrigin::Current); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__read_char_code(_, _) --> @@ -4017,7 +4018,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, tabled_for_io, thread_safe], " mercury_print_string(mercury_current_text_output, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4030,7 +4031,7 @@ io__putback_byte(_, _) --> if (Character == '\\n') { MR_line_number(*mercury_current_text_output)++; } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4040,7 +4041,7 @@ io__putback_byte(_, _) --> if (ML_fprintf(mercury_current_text_output, ""%ld"", (long) Val) < 0) { mercury_output_error(mercury_current_text_output); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4050,7 +4051,7 @@ io__putback_byte(_, _) --> if (ML_fprintf(mercury_current_text_output, ""%#.15g"", Val) < 0) { mercury_output_error(mercury_current_text_output); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4063,7 +4064,7 @@ io__putback_byte(_, _) --> { mercury_output_error(mercury_current_text_output); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4071,7 +4072,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, tabled_for_io, thread_safe], "{ mercury_print_binary_string(mercury_current_binary_output, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4081,7 +4082,7 @@ io__putback_byte(_, _) --> if (MR_FLUSH(*mercury_current_text_output) < 0) { mercury_output_error(mercury_current_text_output); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4091,7 +4092,7 @@ io__putback_byte(_, _) --> if (MR_FLUSH(*mercury_current_binary_output) < 0) { mercury_output_error(mercury_current_binary_output); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4099,7 +4100,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], " mercury_print_string(mercury_current_text_output, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4113,7 +4114,7 @@ io__putback_byte(_, _) --> if (Character == '\\n') { mercury_current_text_output->line_number++; } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4121,7 +4122,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], " mercury_print_string(mercury_current_text_output, Val.ToString()); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4129,7 +4130,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], " mercury_print_string(mercury_current_text_output, Val.ToString()); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4149,7 +4150,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], "{ mercury_print_binary_string(mercury_current_binary_output, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4157,7 +4158,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], " mercury_current_text_output->stream->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4165,7 +4166,7 @@ io__putback_byte(_, _) --> [may_call_mercury, promise_pure, thread_safe, tabled_for_io], " mercury_current_binary_output->stream->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__write_string(_) --> @@ -4239,7 +4240,7 @@ io__seek_binary(Stream, Whence, Offset, IO0, IO) :- mercury_io_error(stream, ""io__seek_binary_2: unseekable stream""); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4257,7 +4258,7 @@ io__seek_binary(Stream, Whence, Offset, IO0, IO) :- mercury_io_error(stream, ""io__binary_stream_offset: untellable stream""); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__seek_binary_2(_, _, _) --> @@ -4278,7 +4279,7 @@ io__binary_stream_offset(_, _) --> "{ MercuryFile *stream = (MercuryFile *) Stream; mercury_print_string(stream, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4292,7 +4293,7 @@ io__binary_stream_offset(_, _) --> if (Character == '\\n') { MR_line_number(*stream)++; } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4303,7 +4304,7 @@ io__binary_stream_offset(_, _) --> if (ML_fprintf(stream, ""%ld"", (long) Val) < 0) { mercury_output_error(stream); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4314,7 +4315,7 @@ io__binary_stream_offset(_, _) --> if (ML_fprintf(stream, ""%#.15g"", Val) < 0) { mercury_output_error(stream); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4326,7 +4327,7 @@ io__binary_stream_offset(_, _) --> if (MR_PUTCH(*stream, (int) ((unsigned char) Byte)) < 0) { mercury_output_error(stream); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4335,7 +4336,7 @@ io__binary_stream_offset(_, _) --> "{ MercuryFile *stream = (MercuryFile *) Stream; mercury_print_binary_string(stream, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4346,7 +4347,7 @@ io__binary_stream_offset(_, _) --> if (MR_FLUSH(*stream) < 0) { mercury_output_error(stream); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4357,7 +4358,7 @@ io__binary_stream_offset(_, _) --> if (MR_FLUSH(*stream) < 0) { mercury_output_error(stream); } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4367,7 +4368,7 @@ io__binary_stream_offset(_, _) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); mercury_print_string(stream, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4380,7 +4381,7 @@ io__binary_stream_offset(_, _) --> mercury_current_binary_output->stream); w->Write(Character); w->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4393,7 +4394,7 @@ io__binary_stream_offset(_, _) --> mercury_current_binary_output->stream); w->Write(Val.ToString()); w->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4406,7 +4407,7 @@ io__binary_stream_offset(_, _) --> mercury_current_binary_output->stream); w->Write(Val.ToString()); w->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4421,7 +4422,7 @@ io__binary_stream_offset(_, _) --> mercury_current_binary_output->stream); w->Write(Byte.ToString()); w->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4431,7 +4432,7 @@ io__binary_stream_offset(_, _) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); mercury_print_binary_string(stream, Message); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4441,7 +4442,7 @@ io__binary_stream_offset(_, _) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); stream->stream->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4451,7 +4452,7 @@ io__binary_stream_offset(_, _) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); stream->stream->Flush(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__write_string(_, _) --> @@ -4506,7 +4507,7 @@ io__flush_binary_output(_) --> thread_safe], " Stream = (MR_Word) &mercury_stdin; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4515,7 +4516,7 @@ io__flush_binary_output(_) --> thread_safe], " Stream = (MR_Word) &mercury_stdout; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4524,7 +4525,7 @@ io__flush_binary_output(_) --> thread_safe], " Stream = (MR_Word) &mercury_stderr; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4533,7 +4534,7 @@ io__flush_binary_output(_) --> thread_safe], " Stream = (MR_Word) &mercury_stdin_binary; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4542,7 +4543,7 @@ io__flush_binary_output(_) --> thread_safe], " Stream = (MR_Word) &mercury_stdout_binary; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4550,7 +4551,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Stream = (MR_Word) mercury_current_text_input; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4558,7 +4559,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Stream = (MR_Word) mercury_current_text_output; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4566,7 +4567,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Stream = (MR_Word) mercury_current_binary_input; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4574,7 +4575,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " Stream = (MR_Word) mercury_current_binary_output; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4582,7 +4583,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " LineNum = MR_line_number(*mercury_current_text_input); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4591,7 +4592,7 @@ io__flush_binary_output(_) --> "{ MercuryFile *stream = (MercuryFile *) Stream; LineNum = MR_line_number(*stream); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4599,7 +4600,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_line_number(*mercury_current_text_input) = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4608,7 +4609,7 @@ io__flush_binary_output(_) --> "{ MercuryFile *stream = (MercuryFile *) Stream; MR_line_number(*stream) = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4616,7 +4617,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " LineNum = MR_line_number(*mercury_current_text_output); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4625,7 +4626,7 @@ io__flush_binary_output(_) --> "{ MercuryFile *stream = (MercuryFile *) Stream; LineNum = MR_line_number(*stream); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4633,7 +4634,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_line_number(*mercury_current_text_output) = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4643,7 +4644,7 @@ io__flush_binary_output(_) --> "{ MercuryFile *stream = (MercuryFile *) Stream; MR_line_number(*stream) = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("C", @@ -4651,7 +4652,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " OutStream = (MR_Word) mercury_current_text_input; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4659,7 +4660,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " OutStream = (MR_Word) mercury_current_text_output; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4667,7 +4668,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " OutStream = (MR_Word) mercury_current_binary_input; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4675,7 +4676,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " OutStream = (MR_Word) mercury_current_binary_output; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). % io__set_input_stream(NewStream, OldStream, IO0, IO1) @@ -4688,7 +4689,7 @@ io__flush_binary_output(_) --> " OutStream = (MR_Word) mercury_current_text_input; mercury_current_text_input = (MercuryFile *) NewStream; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4698,7 +4699,7 @@ io__flush_binary_output(_) --> " OutStream = (MR_Word) mercury_current_text_output; mercury_current_text_output = (MercuryFile *) NewStream; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4708,7 +4709,7 @@ io__flush_binary_output(_) --> " OutStream = (MR_Word) mercury_current_binary_input; mercury_current_binary_input = (MercuryFile *) NewStream; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -4718,7 +4719,7 @@ io__flush_binary_output(_) --> " OutStream = (MR_Word) mercury_current_binary_output; mercury_current_binary_output = (MercuryFile *) NewStream; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4727,7 +4728,7 @@ io__flush_binary_output(_) --> tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_stdin); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4736,7 +4737,7 @@ io__flush_binary_output(_) --> tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_stdout); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4745,7 +4746,7 @@ io__flush_binary_output(_) --> tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_stderr); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4754,7 +4755,7 @@ io__flush_binary_output(_) --> tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_stdin_binary); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4763,7 +4764,7 @@ io__flush_binary_output(_) --> tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_stdout_binary); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4771,7 +4772,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_current_text_input); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4779,7 +4780,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_current_text_output); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4787,7 +4788,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_current_binary_input); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4795,7 +4796,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " MR_c_pointer_to_word(Stream, mercury_current_binary_output); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4803,7 +4804,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " LineNum = mercury_current_text_input->line_number; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4813,7 +4814,7 @@ io__flush_binary_output(_) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); LineNum = stream->line_number; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", @@ -4821,7 +4822,7 @@ io__flush_binary_output(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " mercury_current_text_input->line_number = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4831,14 +4832,14 @@ io__flush_binary_output(_) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); stream->line_number = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", io__get_output_line_number(LineNum::out, IO0::di, IO::uo), [will_not_call_mercury, promise_pure, tabled_for_io], " LineNum = mercury_current_text_output->line_number; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4847,14 +4848,14 @@ io__flush_binary_output(_) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); LineNum = stream->line_number; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). :- pragma foreign_proc("MC++", io__set_output_line_number(LineNum::in, IO0::di, IO::uo), [will_not_call_mercury, promise_pure, tabled_for_io], " mercury_current_text_output->line_number = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4863,7 +4864,7 @@ io__flush_binary_output(_) --> MR_MercuryFile stream = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); stream->line_number = LineNum; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). % io__set_input_stream(NewStream, OldStream, IO0, IO1) @@ -4875,7 +4876,7 @@ io__flush_binary_output(_) --> MR_c_pointer_to_word(OutStream, mercury_current_text_input); mercury_current_text_input = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream)); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4884,7 +4885,7 @@ io__flush_binary_output(_) --> MR_c_pointer_to_word(OutStream, mercury_current_text_output); mercury_current_text_output = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream)); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4894,7 +4895,7 @@ io__flush_binary_output(_) --> MR_c_pointer_to_word(OutStream, mercury_current_binary_input); mercury_current_binary_input = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream)); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -4904,7 +4905,7 @@ io__flush_binary_output(_) --> MR_c_pointer_to_word(OutStream, mercury_current_binary_output); mercury_current_binary_output = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream)); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__stdin_stream(_) --> @@ -5045,7 +5046,7 @@ io__set_binary_output_stream(_, _) --> " Stream = (MR_Word) mercury_open(FileName, Mode); ResultCode = (Stream ? 0 : -1); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -5057,7 +5058,7 @@ io__set_binary_output_stream(_, _) --> MR_MercuryFile mf = mercury_open(FileName, Mode); MR_c_pointer_to_word(Stream, mf); ResultCode = (mf ? 0 : -1); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__do_open(_, _, _, _) --> @@ -5086,7 +5087,7 @@ io__close_binary_output(Stream) --> :- pragma foreign_proc("C", io__close_stream(Stream::in, IO0::di, IO::uo), [may_call_mercury, promise_pure, tabled_for_io, thread_safe], " mercury_close((MercuryFile *) Stream); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", io__close_stream(Stream::in, IO0::di, IO::uo), @@ -5094,7 +5095,7 @@ io__close_binary_output(Stream) --> MR_MercuryFile mf = ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(Stream)); mercury_close(mf); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). io__close_stream(_) --> @@ -5124,7 +5125,7 @@ io__close_stream(_) --> } else { PrognameOut = DefaultProgname; } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -5140,7 +5141,7 @@ io__close_stream(_) --> MR_PROC_LABEL); } } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -5148,7 +5149,7 @@ io__close_stream(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " ExitStatus = mercury_exit_status; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -5156,7 +5157,7 @@ io__close_stream(_) --> [will_not_call_mercury, promise_pure, tabled_for_io], " mercury_exit_status = ExitStatus; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("C", @@ -5178,7 +5179,7 @@ io__close_stream(_) --> } else { Msg = MR_make_string_const(""""); } - update_io(IO0, IO); + MR_update_io(IO0, IO); "). @@ -5252,7 +5253,7 @@ io__handle_system_command_exit_code(Status0::in) = (Status::out) :- while (--i > 0) { MR_list_cons(Args, arg_vector[i], Args); } - update_io(IO0, IO); + MR_update_io(IO0, IO); #endif "). @@ -5261,7 +5262,7 @@ io__handle_system_command_exit_code(Status0::in) = (Status::out) :- [will_not_call_mercury, promise_pure, tabled_for_io], " ExitStatus = System::Environment::get_ExitCode(); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). :- pragma foreign_proc("MC++", @@ -5269,7 +5270,7 @@ io__handle_system_command_exit_code(Status0::in) = (Status::out) :- [will_not_call_mercury, promise_pure, tabled_for_io], " System::Environment::set_ExitCode(ExitStatus); - update_io(IO0, IO); + MR_update_io(IO0, IO); "). /* XXX Implementation needs to be finished. @@ -5286,7 +5287,7 @@ io__handle_system_command_exit_code(Status0::in) = (Status::out) :- mercury::runtime::Errors::SORRY(""foreign code for this function""); // Diagnostics::Process::Start(commandstr, argstr); Status = NULL; - update_io(IO0, IO); + MR_update_io(IO0, IO); "). */ @@ -5468,7 +5469,7 @@ io__make_temp(Dir, Prefix, Name) --> MR_PROC_LABEL, ErrorMessage); Error = err; } - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__do_make_temp(_, _, _, _, _) --> @@ -5542,7 +5543,7 @@ io__remove_file(FileName, Result, IO0, IO) :- RetVal = remove(FileName); ML_maybe_make_err_msg(RetVal != 0, ""remove failed: "", MR_PROC_LABEL, RetStr); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). /* XXX Implementation needs to be finished. @@ -5556,7 +5557,7 @@ io__remove_file(FileName, Result, IO0, IO) :- System::IO::File::Delete(FileName); RetVal = 0; RetStr = """"; - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). */ @@ -5585,7 +5586,7 @@ io__rename_file(OldFileName, NewFileName, Result, IO0, IO) :- RetVal = rename(OldFileName, NewFileName); ML_maybe_make_err_msg(RetVal != 0, ""rename failed: "", MR_PROC_LABEL, RetStr); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). io__rename_file_2(_, _, _, _) --> diff --git a/library/time.m b/library/time.m index a58277ede..87464cd23 100644 --- a/library/time.m +++ b/library/time.m @@ -167,7 +167,7 @@ #include #endif - #define update_io(r_src, r_dest) ((r_dest) = (r_src)) + #define MR_update_io(r_src, r_dest) ((r_dest) = (r_src)) #include ""mercury_string.h"" /* for MR_make_aligned_string_copy() */ "). @@ -192,7 +192,7 @@ time__clock(Result, IO0, IO) :- [will_not_call_mercury, promise_pure, tabled_for_io], "{ Ret = (MR_Integer) clock(); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). time__c_clock(_) --> % This version is only used for back-ends for which there is no @@ -253,7 +253,7 @@ time__times(Tms, Result, IO0, IO) :- #else Ret = -1; #endif - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). time__c_times(_, _, _, _, _) --> % This version is only used for back-ends for which there is no @@ -282,7 +282,7 @@ time__time(Result, IO0, IO) :- [will_not_call_mercury, promise_pure, tabled_for_io], "{ Ret = (MR_Integer) time(NULL); - update_io(IO0, IO); + MR_update_io(IO0, IO); }"). time__c_time(_) --> % This version is only used for back-ends for which there is no diff --git a/runtime/Mmakefile b/runtime/Mmakefile index 8ca509890..9b4fe64f8 100644 --- a/runtime/Mmakefile +++ b/runtime/Mmakefile @@ -4,25 +4,6 @@ # Public License - see the file COPYING in the Mercury distribution. #-----------------------------------------------------------------------------# -# Mmake - Mmake file for the Mercury runtime library - -MAIN_TARGET=runtime - -MERCURY_DIR=.. -LINK_BOEHM_GC_ONLY=yes -include $(MERCURY_DIR)/Mmake.common --include Mmake.runtime.params - -# Avoid trying to make this file with `mmc --make' if it doesn't exist. -Mmake.runtime.params: ; - -#-----------------------------------------------------------------------------# - -CFLAGS += -g $(DLL_CFLAGS) -DMERCURY_BOOTSTRAP_H -DMERCURY_CONF_BOOTSTRAP_H -MGNUCFLAGS += --no-ansi - -#-----------------------------------------------------------------------------# - # All the headers in $(HDRS) should be syntactically well-formed # header files, unlike the headers in $(BODY_HDRS). # All the headers in $(HDRS) must also be in C (not C++). @@ -187,6 +168,36 @@ CFILES = \ mercury_type_tables.c \ mercury_wrapper.c +#-----------------------------------------------------------------------------# + +# Mmake - Mmake file for the Mercury runtime library + +MAIN_TARGET=runtime + +# Specify which files to check for namespace cleanliness, and which name +# prefixes are allowed. + +CHECK_HDRS = $(HDRS) +CHECK_MHDRS = +CHECK_OBJS = $(CFILES:.c=.$O) +ALLOW_LIB_PREFIX=no +ALLOW_BROWSER_PREFIX=no + +MERCURY_DIR=.. +LINK_BOEHM_GC_ONLY=yes +include $(MERCURY_DIR)/Mmake.common +-include Mmake.runtime.params + +# Avoid trying to make this file with `mmc --make' if it doesn't exist. +Mmake.runtime.params: ; + +#-----------------------------------------------------------------------------# + +CFLAGS += -g $(DLL_CFLAGS) -DMERCURY_BOOTSTRAP_H -DMERCURY_CONF_BOOTSTRAP_H +MGNUCFLAGS += --no-ansi + +#-----------------------------------------------------------------------------# + OBJS = $(CFILES:.c=.$O) PIC_OBJS = $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS)) @@ -199,11 +210,6 @@ THREADLIBS = \ esac \ ` -HDR_CHECK_CS = $(HDRS:.h=.check_hdr.c) -HDR_CHECK_OBJS = $(HDRS:.h=.check_hdr.$O) -HDR_CHECK_MACROS = $(HDRS:.h=.check.macros) -OBJ_CHECKS = $(OBJS:%=%.obj_check) - $(HDR_CHECK_OBJS): mercury_conf.h #-----------------------------------------------------------------------------# @@ -315,42 +321,6 @@ cs: $(CFILES) tags: $(CFILES) $(HDRS) $(BODY_HDRS) ctags $(CFILES) $(HDRS) $(BODY_HDRS) -#-----------------------------------------------------------------------------# -# -# `mmake check_namespace' performs various checks on the header files -# and object files to make sure that they conform with our coding standards. -# - -# Macro names must normally start with one of the prefixes associated -# with the different components of our system: -# `MR_' or `MERCURY_' for stuff in the Mercury runtime implementation -# (the `runtime' and `trace' directories) -# `GC_' for stuff in the Boehm et al conservative garbage collector -# (the `boehm_gc' directory) -# `MPS_' or `mps_' for stuff in the Memory Pool System toolkit -# (the `mps_gc' directory, if present -- note that this -# is in a separate CVS module and is not included in the -# normal Mercury source distributions) -# Exceptions to this policy must be listed in the RESERVED_MACRO_NAMES file. -HEADER_CLEAN_FILTER = \ - grep -v -e '^MR_' -e '^MERCURY_' -e '^GC_' -e '^MPS_' -e '^mps_' | \ - fgrep -v -x -f RESERVED_MACRO_NAMES - -.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: check_headers_self_contained check_headers_macros - -.PHONY: check_objs -check_objs: $(OBJ_CHECKS) - -.PHONY: check_namespace -check_namespace: check_headers check_objs - #-----------------------------------------------------------------------------# # installation rules @@ -413,11 +383,6 @@ clean_local: clean_o clean_check clean_o: rm -f $(OBJS) $(PIC_OBJS) -.PHONY: clean_check -clean_check: - rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS) - rm -f $(OBJ_CHECKS) - .PHONY: realclean_local realclean_local: rm -f lib$(RT_LIB_NAME).$A lib$(RT_LIB_NAME).so $(RT_LIB_NAME).init diff --git a/runtime/RESERVED_MACRO_NAMES b/runtime/RESERVED_MACRO_NAMES index 58b13ffdf..ca78bc13e 100644 --- a/runtime/RESERVED_MACRO_NAMES +++ b/runtime/RESERVED_MACRO_NAMES @@ -6,12 +6,10 @@ # # 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, +# This file lists the macro names, other than the ones starting with a +# certain set of allowed prefixes 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'. @@ -29,22 +27,6 @@ SUCCESS_INDICATOR # prefix this without requiring a later version of autoconf (e.g. 2.52). pid_t #-----------------------------------------------------------------------------# -# 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_func_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 -mercury__builtin____type_ctor_info_void_0 -mercury__private_builtin__SIZEOF_WORD -mercury__private_builtin__unsafe_type_cast_2_p_0 -#-----------------------------------------------------------------------------# # These are defined by boehm_gc/gc.h. __GC _GC_H diff --git a/tools/bootcheck b/tools/bootcheck index 31dccf6f4..361ed585e 100755 --- a/tools/bootcheck +++ b/tools/bootcheck @@ -54,15 +54,14 @@ Options: that is not compatible with the standard one. -p, --copy-profiler Copy the profiler directory instead of linking it. - This is sometimes necessary for bootstrapping - changes. + This is sometimes necessary for bootstrapping changes. -b-, --no-bootcheck 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 targets in the runtime - and trace directories. + Don't build the check_namespace targets in the runtime, + trace, browser and library directories. -t-, --no-test-suite By default, bootcheck will also run the test quite. This option prevents that. @@ -247,6 +246,7 @@ while [ $# -gt 0 ]; do runtests=false ;; --skip-stage-2) + keep_stage_2=true mmake_stage_2=false ;; -2|--keep-stage-2) @@ -661,20 +661,75 @@ then fi fi + # Build the check_namespace target in the relevant directories. + # We want to do so before we delete any of the stage2 object files. + + check_namespace_status=0 + if $check_namespace + then + cd $root/stage2/runtime + mmake $mmake_opts check_namespace || { + echo '** mmake check_namespace failed in runtime!' + check_namespace_status=1 + } + cd $root/stage2/trace + mmake $mmake_opts check_namespace || { + echo '** mmake check_namespace failed in trace!' + check_namespace_status=1 + } + cd $root/stage2/library + mmake $mmake_opts check_namespace || { + echo '** mmake check_namespace failed in library!' + check_namespace_status=1 + } + cd $root/stage2/browser + mmake $mmake_opts check_namespace || { + echo '** mmake check_namespace failed in browser!' + check_namespace_status=1 + } + cd $root + fi + if $stop_after_stage_2 then echo "stopping after building stage 2" exit 0 fi - # We can remove the library object files now, - # but we will keep the compiler objects for a while longer + # We can now remove the object files from most stage2 directories, + # but we will keep the compiler objects for a while longer. if $keep_objs then true else - find $root/stage2/library -name "*.o" -print | - xargs /bin/rm -f + libdirs="library browser" + if $copy_profiler + then + profdirs="profiler deep_profiler" + else + profdirs= + fi + if $copy_runtime + then + rundirs="runtime trace" + else + rundirs= + fi + + objdirs="$libdirs $profdirs $rundirs" + for rmdir in $objdirs + do + cd $root/stage2/$rmdir + /bin/rm -f *.o *.pic_o + done + + for cleandir in runtime trace library browser + do + cd $root/stage2/$cleandir + mmake clean_check + done + + cd $root fi MERCURY_COMPILER=$root/stage2/compiler/mercury_compile @@ -939,26 +994,6 @@ 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 || { - echo '** mmake check_namespace failed!' - check_namespace_status=1 - } - cd $root/${stage2_insert}trace - mmake $mmake_opts check_namespace || { - echo '** mmake check_namespace failed!' - check_namespace_status=1 - } - cd $root -fi - -#-----------------------------------------------------------------------------# - # Run the tests in the tests/* directories test_status=0 diff --git a/trace/Mmakefile b/trace/Mmakefile index e10dac500..200f1562e 100644 --- a/trace/Mmakefile +++ b/trace/Mmakefile @@ -7,29 +7,6 @@ # Mmakefile for the Mercury trace library, which contains the runtime # system components that are needed only if some procedures are traced. -MAIN_TARGET=trace - -MERCURY_DIR=.. -LINK_STDLIB_ONLY=yes -include $(MERCURY_DIR)/Mmake.common --include Mmake.trace.params - -# Avoid trying to make this file with `mmc --make' if it doesn't exist. -Mmake.trace.params: ; - -#-----------------------------------------------------------------------------# - -CFLAGS += -I$(BROWSER_DIR) -g $(DLL_CFLAGS) \ - -DMR_NO_BACKWARDS_COMPAT -DMERCURY_CONF_BOOTSTRAP_H -MGNUCFLAGS += --no-ansi - -#-----------------------------------------------------------------------------# - -# mercury_readline.c #includes the GNU readline headers, which -# lack prototypes and `const', so we need to disable warnings -# when compiling that file. -MGNUCFLAGS-mercury_trace_readline = --no-check - #-----------------------------------------------------------------------------# # keep this list in alphabetical order, please @@ -77,11 +54,6 @@ RUNTIME_HDRS = \ OBJS = $(CFILES:.c=.$O) PIC_OBJS = $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS)) -HDR_CHECK_CS = $(HDRS:.h=.check_hdr.c) -HDR_CHECK_OBJS = $(HDRS:.h=.check_hdr.$O) -HDR_CHECK_MACROS = $(HDRS:.h=.check.macros) -OBJ_CHECKS = $(OBJS:%=%.obj_check) - LDFLAGS = -L$(BROWSER_DIR) -L$(LIBRARY_DIR) \ -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR) -L/usr/local/lib LDLIBS = -l$(BROWSER_LIB_NAME) $(MLLIBS) $(SOCKET_LIBRARY) \ @@ -91,6 +63,37 @@ THREADLIBS = \ *.par*) echo "-lpthread" ;; \ esac \ ` +MAIN_TARGET=trace + +# Specify which files to check for namespace cleanliness, and which name +# prefixes are allowed. + +CHECK_HDRS = $(HDRS) +CHECK_MHDRS = +CHECK_OBJS = $(OBJS) +ALLOW_LIB_PREFIX=no +ALLOW_BROWSER_PREFIX=no + +MERCURY_DIR=.. +LINK_STDLIB_ONLY=yes +include $(MERCURY_DIR)/Mmake.common +-include Mmake.trace.params + +# Avoid trying to make this file with `mmc --make' if it doesn't exist. +Mmake.trace.params: ; + +#-----------------------------------------------------------------------------# + +CFLAGS += -I$(BROWSER_DIR) -g $(DLL_CFLAGS) \ + -DMR_NO_BACKWARDS_COMPAT -DMERCURY_CONF_BOOTSTRAP_H +MGNUCFLAGS += --no-ansi + +#-----------------------------------------------------------------------------# + +# mercury_readline.c #includes the GNU readline headers, which +# lack prototypes and `const', so we need to disable warnings +# when compiling that file. +MGNUCFLAGS-mercury_trace_readline = --no-check #-----------------------------------------------------------------------------# @@ -147,33 +150,6 @@ cs: $(CFILES) tags: $(CFILES) $(HDRS) ctags $(CFILES) $(HDRS) $(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h -#-----------------------------------------------------------------------------# -# -# `mmake check_namespace' performs various checks on the header files -# and object files to make sure that they conform with our coding standards. -# - -# This should match the definition of HEADER_CLEAN_FILTER in -# runtime/Mmakefile. See the documentation there. -HEADER_CLEAN_FILTER = \ - grep -v -e '^MR_' -e '^MERCURY_' -e '^MPS_' -e '^mps_' -e '^GC_' | \ - fgrep -v -x -f $(RUNTIME_DIR)/RESERVED_MACRO_NAMES - -.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: check_headers_self_contained check_headers_macros - -.PHONY: check_objs -check_objs: $(OBJ_CHECKS) - -.PHONY: check_namespace -check_namespace: check_headers check_objs - #-----------------------------------------------------------------------------# # installation rules @@ -214,11 +190,6 @@ clean_local: clean_o clean_check clean_o: rm -f $(OBJS) $(PIC_OBJS) -.PHONY: clean_check -clean_check: - rm -f $(HDR_CHECK_OBJS) $(HDR_CHECK_CS) $(HDR_CHECK_MACROS) - rm -f $(OBJ_CHECKS) - .PHONY: realclean_local realclean_local: rm -f lib$(TRACE_LIB_NAME).$A lib$(TRACE_LIB_NAME).so