File: util.h

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (67 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

/*
** Copyright (C) 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.
**
** $Id: util.h,v 1.11 1997/07/27 14:59:32 fjh Exp $
*/


#ifndef MB_UTIL_H
#define	MB_UTIL_H

#include	<stdio.h>	/* for fprintf */

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)
#define	XXXdebug1(msg) \
	do { \
		fprintf(stderr, "%s\n", msg); \
	} while(0)
#else
#define	XXXdebug(msg, fmt, val)	do {} while(0)
#define	XXXdebug1(msg) 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 */