mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
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.
This commit is contained in:
141
Mmake.common.in
141
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
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
@@ -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
|
||||
|
||||
39
browser/RESERVED_MACRO_NAMES
Normal file
39
browser/RESERVED_MACRO_NAMES
Normal file
@@ -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
|
||||
#-----------------------------------------------------------------------------#
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
39
library/RESERVED_MACRO_NAMES
Normal file
39
library/RESERVED_MACRO_NAMES
Normal file
@@ -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
|
||||
#-----------------------------------------------------------------------------#
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
257
library/io.m
257
library/io.m
File diff suppressed because it is too large
Load Diff
@@ -167,7 +167,7 @@
|
||||
#include <sys/times.h>
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user