Files
mercury/bytecode/util.h
Fergus Henderson a3644ae6cf More cleanup of the bytecode stuff; in particular, add a `MB_' prefix
Estimated hours taken: 2

More cleanup of the bytecode stuff; in particular, add a `MB_' prefix
to most names.

bytecode/*:
	- Prefix all names defined in header files with `MB_'
	  (except for `TRUE', `FALSE', `DEBUGGING', and `XXXdebug').
	- Add macros `MB_new', `MB_new_array', and `MB_resize_array',
	  and use those instead of using `MB_malloc' and `MB_resize'
	  (formerly `mem_malloc' and `mem_resize') or malloc() and realloc()
	  directly.  Uncomment the definition of MB_strdup() now that it
	  calls MB_malloc().
	- Delete the definitions of `uchar', `uint', `ushort', `ulong'
	  (just spell them out, its clearer and more portable that way).
	- Fix the indentation in a few places I missed on my previous pass.
	- Add a `README' file.
1997-04-26 05:57:14 +00:00

61 lines
1.4 KiB
C

/*
** Copyright (C) 1997 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.
**
** $Id: util.h,v 1.9 1997-04-26 05:57:14 fjh Exp $
*/
#ifndef MB_UTIL_H
#define MB_UTIL_H
typedef int
MB_Bool;
/*
** Since TRUE and FALSE are not prefixed with `MB_',
** we need to only define them if they are not defined elsewhere.
** Even this might cause trouble, if some other header file included
** after this one defines them as `enum { FALSE, TRUE };'.
** It might be better to just prefix them with `MB_' like everything
** else, even if it does look ugly...
*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define MB_INT_SIZE (sizeof(int))
#define MB_FLOAT_SIZE (sizeof(float))
#define MB_DOUBLE_SIZE (sizeof(double))
/*
* For debugging. E.g. XXXdebug("Bad integer value", d, some_var).
* XXX: We should implement some smarter tracing stuff that allows
* us to select a specific module or procedure to trace, or even
* a specific trace statement.
*/
#if defined(DEBUGGING)
#define XXXdebug(msg, fmt, val) \
do { \
fprintf(stderr, "%s: %s = %" #fmt "\n", msg, #val, val); \
} while(0)
#else
#define XXXdebug(msg, fmt, val) do {} while(0)
#endif /* DEBUGGING */
void
MB_util_error(const char *fmt, ...);
void
MB_fatal(const char* message);
char*
MB_strdup(const char *str);
#endif /* MB_UTIL_H */