1 /***********************************************************************/
5 /* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../LICENSE. */
12 /***********************************************************************/
16 /* Miscellaneous macros and variables. */
21 #ifndef CAML_NAME_SPACE
22 #include "compatibility.h"
26 /* Standard definitions */
31 /* Basic types and constants */
33 typedef size_t asize_t
;
44 /* Works only in GCC 2.5 and later */
45 #define Noreturn __attribute__ ((noreturn))
50 /* Export control (to mark primitives and to handle Windows DLL) */
52 #if defined(_WIN32) && defined(CAML_DLL)
53 # define CAMLexport __declspec(dllexport)
54 # define CAMLprim __declspec(dllexport)
55 # if defined(IN_OCAMLRUN)
56 # define CAMLextern __declspec(dllexport) extern
58 # define CAMLextern __declspec(dllimport) extern
63 # define CAMLextern extern
71 #define CAMLassert(x) ((x) ? 0 : caml_failed_assert ( #x , __FILE__, __LINE__))
72 CAMLextern
int caml_failed_assert (char *, char *, int);
74 #define CAMLassert(x) ((void) 0)
77 CAMLextern
void caml_fatal_error (char *msg
) Noreturn
;
78 CAMLextern
void caml_fatal_error_arg (char *fmt
, char *arg
) Noreturn
;
79 CAMLextern
void caml_fatal_error_arg2 (char *fmt1
, char *arg1
,
80 char *fmt2
, char *arg2
) Noreturn
;
90 extern void caml_ext_table_init(struct ext_table
* tbl
, int init_capa
);
91 extern int caml_ext_table_add(struct ext_table
* tbl
, void * data
);
92 extern void caml_ext_table_free(struct ext_table
* tbl
, int free_entries
);
94 /* GC flags and messages */
96 extern uintnat caml_verb_gc
;
97 void caml_gc_message (int, char *, uintnat
);
101 char *caml_aligned_malloc (asize_t
, int, void **);
104 #ifdef ARCH_SIXTYFOUR
105 #define Debug_tag(x) (0xD700D7D7D700D6D7ul \
106 | ((uintnat) (x) << 16) \
107 | ((uintnat) (x) << 48))
109 #define Debug_tag(x) (0xD700D6D7ul | ((uintnat) (x) << 16))
110 #endif /* ARCH_SIXTYFOUR */
113 00 -> free words in minor heap
114 01 -> fields of free list blocks in major heap
115 03 -> heap chunks deallocated by heap shrinking
116 04 -> fields deallocated by [caml_obj_truncate]
117 10 -> uninitialised fields of minor objects
118 11 -> uninitialised fields of major objects
119 15 -> uninitialised words of [caml_aligned_malloc] blocks
120 85 -> filler bytes of [caml_aligned_malloc]
122 special case (byte by byte):
123 D7 -> uninitialised words of [caml_stat_alloc] blocks
125 #define Debug_free_minor Debug_tag (0x00)
126 #define Debug_free_major Debug_tag (0x01)
127 #define Debug_free_shrink Debug_tag (0x03)
128 #define Debug_free_truncate Debug_tag (0x04)
129 #define Debug_uninit_minor Debug_tag (0x10)
130 #define Debug_uninit_major Debug_tag (0x11)
131 #define Debug_uninit_align Debug_tag (0x15)
132 #define Debug_filler_align Debug_tag (0x85)
134 #define Debug_uninit_stat 0xD7
136 extern void caml_set_fields (char *, unsigned long, unsigned long);
140 #ifndef CAML_AVOID_CONFLICTS
141 #define Assert CAMLassert
146 #endif /* CAML_MISC_H */