Files
mercury/runtime/mercury_reg_workarounds.h
Zoltan Somogyi 95b64f73a1 Move changes in the library on the mode-constraints branch onto the trunk.
Estimated hours taken: unknown (but probably several weeks by dmo)
Branches: main

Move changes in the library on the mode-constraints branch onto the trunk.

library/eqvclass.m:
	Add some utility functions and predicates.

library/map.m:
	Add some utility functions and predicates, and some type
	specialization directives.

library/tree234.m:
	Add some utility functions and predicates.

library/robdd.m:
	Add this module, which provides a Mercury interface to the C code in
	robdd/bryant.c. In some places, robustness has been sacrificed for
	speed, and the module is not (yet) as well documented as it could be;
	therefore it is not (yet) included in the documentation.

library/pprint.m:
	Print robdds nicely, since this is essential to debugging code handling
	robdds. (This is why adding robdd.m in some other directory, e.g. the
	compiler, wouldn't really work.)

library/term.m:
	Add a function that returns the highest numbered vars created from
	a var_supply.

library/varset.m:
	Add a function that returns the highest numbered vars created from
	a varset.

library/unsafe.m:
	Add this module here, since it may be needed to debug code in the
	library (e.g. in robdd.m.).

library/library.m:
	Add a reference to the robdd module, and a commented out reference
	to the unsafe module. If a developer needs to use unsafe.m anywhere
	in the Mercury implementation, they can uncomment this reference
	in the relevant workspace.

	Make the list of modules easier to maintain (especially in the case
	of CVS conflicts) by listing one module per line.

	Fix formatting of some foreign_procs.

NEWS:
	Mention the new predicates and functions.

Mmake.workspace:
	Add a new make variable that specifies the location of the robdd
	subdirectory.

Mmakefile:
	Add rules for handling the robdd subdirectory.

configure.in:
	Check whether the compiler can handle local foreign_decls, since
	robdd.m now needs this.

tools/bootcheck:
	Add the robdd subdirectory to the stage 2 & 3 directories.

deep_profiler/unsafe.m:
	Remove this module from this directory.

doc/Mmakefile:
	Do not include the robdd and unsafe modules in the documentation.
	The robdd module because (in its present state) it is not stable
	enough, the unsafe module because it is not enabled in installed
	versions of the library.

robdd/Makefile:
	Update the set of default compilation flags. The main code in this
	directory, bryant.c, is #included in library/robdd.m, and the only
	other programs in this directory are test programs.

robdd/Mmakefile:
	New file. Includes a mechanism to compile bryant.c in the robdd
	subdirectory, since this can give cleaner error messages than
	compiling library/robdd.m.

robdd/bryant.[ch]:
	Huge cleanup of these files. Add MR_ROBDD_ prefixes to global symbols,
	make the formatting conform to our standards, and fix irregularities
	in the uses of the macros that control the use of optional facilities.

robdd/bryantPrint.[ch]:
robdd/table.[ch]:
robdd/test_abexit.c:
robdd/test_abunify.c:
robdd/test_abglb.c:
robdd/test_iff.c:
robdd/test_rename.c:
robdd/test_restrict.c:
robdd/test_rglb.c:
robdd/test_upclose.c:
robdd/test_var.c:
robdd/test_vars.c:
robdd/timing.[ch]:
robdd/var.h:
	Conform to the changes in bryant.h. Note that since the code in these
	files won't end up in Mercury program code, they don't need to be
	namespace clean.

runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
	#define GC_I_HIDE_POINTERS before each #include of gc.h (bryant.c
	hides pointers). This impact of this #define is so small that it is
	not measurable.

runtime/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
	Add HIDE_POINTER and REVEAL_POINTER, since defining GC_I_HIDE_POINTERS
	makes these macros from gc.h visible.

runtime/mercury_reg_workarounds.[ch]:
	Add the MR_memset function.

tests/debugger/declarative/if_then_else.{inp,exp}:
tests/debugger/declarative/ite_2.{inp,exp,exp2}:
	Avoid a name conflict with the predicate ite in robdd.m.
2004-12-15 06:58:00 +00:00

66 lines
2.1 KiB
C

/*
** Copyright (C) 1998-2004 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
*/
/*
** mercury_reg_workarounds.h - MR_assign_structure(), MR_memcpy(), MR_fd_zero()
*/
#ifndef MERCURY_REG_WORKAROUNDS_H
#define MERCURY_REG_WORKAROUNDS_H
#include "mercury_conf.h"
#ifdef MR_CAN_DO_PENDING_IO
#include <sys/types.h> /* for fd_set */
#include <sys/time.h> /* for FD_ZERO() */
#endif
#include <stdlib.h> /* for size_t */
/*
** This macro defines a safe way to perform assignment between
** structures. The obvious way can cause some versions of
** gcc to abort on x86 processors with the message
** "fixed or forbidden register was spilled."
*/
#if defined(MR_CANNOT_USE_STRUCTURE_ASSIGNMENT) && \
defined(MR_USE_GCC_GLOBAL_REGISTERS)
#define MR_assign_structure(dest, src) \
MR_memcpy(&(dest), &(src), sizeof((dest)))
/*
** We use our own version of memcpy because gcc recognises calls to the
** standard memcpy (even in things that do not mention memcpy by name, e.g.
** structure assignments) and generates inline code for them. Unfortunately
** this causes gcc to abort because it tries to use a register that we have
** already reserved.
** XXX We should fix this eventually by using -fno-builtin since pragma
** c_code may call the builtin functions.
*/
extern void MR_memcpy(void *dest, const void *src, size_t nbytes);
extern void MR_memset(void *dest, char c, size_t nbytes);
#else /* !MR_CANNOT_USE_STRUCTURE_ASSIGNMENT || !MR_USE_GCC_GLOBAL_REGISTERS */
#define MR_assign_structure(dest, src) ((dest) = (src))
#define MR_memcpy(dest, src, nbytes) memcpy((dest), (src), (nbytes))
#define MR_memset(dest, c, nbytes) memset((dest), (c), (nbytes))
#endif /* !MR_CANNOT_USE_STRUCTURE_ASSIGNMENT || !MR_USE_GCC_GLOBAL_REGISTERS */
/*
** We use a forwarding function to FD_ZERO because the Linux headers
** use an asm fragment which conflicts with our use of global registers.
*/
#ifdef MR_CAN_DO_PENDING_IO
void MR_fd_zero(fd_set *fdset);
#endif
#endif /* not MERCURY_REG_WORKAROUNDS_H */