Files
mercury/runtime/mercury_float.h
Tyson Dowd 7ce7d489a2 Cleaned up runtime directory.
Estimated hours taken: 2

Cleaned up runtime directory.

runtime/*.c:
	- Renamed all .c files as mercury_*.c
	  Some have been renamed to make their purpose clearer.
	  	call.mod -> mercury_ho_call.c

runtime/*.h:
	- Moved contents of .h files to mercury_*.h
	- *.h now contain #include mercury_*.h. They be removed later.
	- Updated references to conf.h -> mercury_conf.h

runtime/conf.h.in:
	- Renamed conf.h.in as mercury_conf.h.in.
	  Didn't leave a forwarding header for this one, as conf.h was
	  never part of the repository anyway.

runtime/Mmakefile:
	- Convert lists to one-per-line lists.
	- Add mercury_accurate_gc.h to HDRS.
	- Remove all .mod files
	- Make sure runtime.init uses the ORIG_CS not MOD_CS.
	- Fix the rules for "clean_o" and "clean_mod_c", which used
	  wildcards like "*.o" to remove files.  The one that removed
	  all .c files corresponding with *.mod, instead of using MOD_CS
	  was particularly vicious.
	- Cope with the file renamings.

configure.in:
	- Cope with the file renamings.
1997-11-20 02:04:40 +00:00

81 lines
1.9 KiB
C

/*
** Copyright (C) 1995-1997 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_float.h - floating point handling */
#ifndef MERCURY_FLOAT_H
#define MERCURY_FLOAT_H
#include "mercury_conf.h" /* for BOXED_FLOAT */
#include "mercury_types.h" /* for `Word' */
#ifdef USE_SINGLE_PREC_FLOAT
typedef float Float;
#else
typedef double Float;
#endif
#ifdef BOXED_FLOAT
#define word_to_float(w) (*(Float *)(w))
#define FLOAT_WORDS ((sizeof(Float) + sizeof(Word) - 1) / sizeof(Word))
#ifdef CONSERVATIVE_GC
#define float_to_word(f) ( \
hp_alloc(FLOAT_WORDS), \
*(Float *)(void *)(MR_hp - FLOAT_WORDS) = (f), \
/* return */ (Word) (MR_hp - FLOAT_WORDS) \
)
#else
/* we need to ensure that what we allocated on the heap is properly
aligned */
#define float_to_word(f) ( \
( (Word)MR_hp & (sizeof(Float) - 1) ? hp_alloc(1) : (void)0 ), \
hp_alloc(FLOAT_WORDS), \
*(Float *)(void *)(MR_hp - FLOAT_WORDS) = (f), \
/* return */ (Word) (MR_hp - FLOAT_WORDS) \
)
#endif
#ifdef __GNUC__
#define float_const(f) ({ static const Float d = f; (Word)&d; })
#else
#define float_const(f) float_to_word(f) /* inefficient */
#endif
#else /* not BOXED_FLOAT */
/* unboxed float means we can assume sizeof(Float) == sizeof(Word) */
union FloatWord {
Float f;
Word w;
};
#define float_const(f) float_to_word(f)
#ifdef __GNUC__
/* GNU C allows you to cast to a union type */
#define float_to_word(f) (__extension__ ((union FloatWord)(Float)(f)).w)
#define word_to_float(w) (__extension__ ((union FloatWord)(Word)(w)).f)
#else /* not __GNUC__ */
static Word float_to_word(Float f)
{ union FloatWord tmp; tmp.f = f; return tmp.w; }
static Float word_to_float(Word w)
{ union FloatWord tmp; tmp.w = w; return tmp.f; }
#endif /* not __GNUC__ */
#endif /* not BOXED_FLOAT */
Integer hash_float(Float);
#endif /* not MERCURY_FLOAT_H */