summaryrefslogtreecommitdiff
path: root/byterun/misc.h
blob: a8960081e3af37e77e3053f0ebc075e7aa2440f8 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***********************************************************************/
/*                                                                     */
/*                           Objective Caml                            */
/*                                                                     */
/*         Xavier Leroy and Damien Doligez, INRIA Rocquencourt         */
/*                                                                     */
/*  Copyright 1996 Institut National de Recherche en Informatique et   */
/*  Automatique.  Distributed only by permission.                      */
/*                                                                     */
/***********************************************************************/

/* $Id$ */

/* Miscellaneous macros and variables. */

#ifndef _misc_
#define _misc_


#include "config.h"

/* Standard definitions */

#ifdef __STDC__
#include <stddef.h>
#include <stdlib.h>
#endif

/* Function prototypes */

#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif

/* Basic types and constants */

#ifdef __STDC__
typedef size_t asize_t;
#else
typedef int asize_t;
#endif

#ifndef NULL
#define NULL 0
#endif

typedef char * addr;

/* Volatile stuff */

#ifdef __STDC__
#define Volatile volatile
#else
#define Volatile
#endif

#ifdef __GNUC__
/* Works only in GCC 2.5 and later */
#define Noreturn __attribute ((noreturn))
#else
#define Noreturn
#endif

/* Assertions */

#ifdef DEBUG
#ifdef __STDC__
#define Assert(x) if (!(x)) failed_assert ( #x , __FILE__, __LINE__)
#else
#ifndef __LINE__
#define __LINE__ 0
#endif
#ifndef __FILE__
#define __FILE__ "(?)"
#endif
#define Assert(x) if (!(x)) failed_assert ("(?)" , __FILE__, __LINE__)
#endif
#else
#define Assert(x)
#endif

void failed_assert P((char *, char *, int)) Noreturn;
void fatal_error P((char *)) Noreturn;
void fatal_error_arg P((char *, char *)) Noreturn;

/* GC flags and messages */

extern int verb_gc;
void gc_message P((char *, unsigned long));

/* Memory routines */

void memmov P((char *, char *, unsigned long));
char * aligned_malloc P((asize_t, int));
unsigned long not_random P((void));

#endif /* _misc_ */