1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy and Damien Doligez, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
/* Miscellaneous macros and variables. */
|
|
|
|
|
|
|
|
#ifndef _misc_
|
|
|
|
#define _misc_
|
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
/* Standard definitions */
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/* Basic types and constants */
|
|
|
|
|
|
|
|
typedef size_t asize_t;
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
|
|
|
|
2002-02-19 06:37:44 -08:00
|
|
|
/* <private> */
|
1995-05-04 03:15:53 -07:00
|
|
|
typedef char * addr;
|
2002-02-19 06:37:44 -08:00
|
|
|
/* </private> */
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
/* Works only in GCC 2.5 and later */
|
|
|
|
#define Noreturn __attribute ((noreturn))
|
|
|
|
#else
|
|
|
|
#define Noreturn
|
|
|
|
#endif
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
/* Export control (to mark primitives and to handle Windows DLL) */
|
|
|
|
|
|
|
|
#if defined(_WIN32) && defined(_DLL)
|
|
|
|
# define CAMLexport __declspec(dllexport)
|
|
|
|
# define CAMLprim __declspec(dllexport)
|
|
|
|
# if defined(IN_OCAMLRUN)
|
|
|
|
# define CAMLextern __declspec(dllexport) extern
|
|
|
|
# else
|
|
|
|
# define CAMLextern __declspec(dllimport) extern
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define CAMLexport
|
|
|
|
# define CAMLprim
|
|
|
|
# define CAMLextern extern
|
|
|
|
#endif
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
/* Assertions */
|
|
|
|
|
2002-02-19 06:37:44 -08:00
|
|
|
/* <private> */
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
#ifdef DEBUG
|
2002-01-20 09:39:10 -08:00
|
|
|
#define CAMLassert(x) ((x) ? 0 : caml_failed_assert ( #x , __FILE__, __LINE__))
|
|
|
|
int caml_failed_assert (char *, char *, int) Noreturn;
|
1995-05-04 03:15:53 -07:00
|
|
|
#else
|
2002-01-20 09:39:10 -08:00
|
|
|
#define CAMLassert(x) 0
|
1995-05-04 03:15:53 -07:00
|
|
|
#endif
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
void fatal_error (char *msg) Noreturn;
|
|
|
|
void fatal_error_arg (char *fmt, char *arg) Noreturn;
|
|
|
|
void fatal_error_arg2 (char *fmt1, char *arg1,
|
|
|
|
char *fmt2, char *arg2) Noreturn;
|
|
|
|
|
|
|
|
/* Data structures */
|
|
|
|
|
|
|
|
struct ext_table {
|
|
|
|
int size;
|
|
|
|
int capacity;
|
|
|
|
void ** contents;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern void ext_table_init(struct ext_table * tbl, int init_capa);
|
|
|
|
extern int ext_table_add(struct ext_table * tbl, void * data);
|
|
|
|
extern void ext_table_free(struct ext_table * tbl, int free_entries);
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
/* GC flags and messages */
|
|
|
|
|
2001-02-19 02:01:41 -08:00
|
|
|
extern unsigned long verb_gc;
|
1998-08-07 11:43:39 -07:00
|
|
|
void gc_message (int, char *, unsigned long);
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
/* Memory routines */
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
char *aligned_malloc (asize_t, int, void **);
|
1997-05-13 07:45:38 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2000-04-03 01:34:22 -07:00
|
|
|
#ifdef ARCH_SIXTYFOUR
|
|
|
|
#define Debug_tag(x) (0xD700D7D7D700D6D7ul \
|
|
|
|
| ((unsigned long) (x) << 16) \
|
|
|
|
| ((unsigned long) (x) << 48))
|
|
|
|
#else
|
|
|
|
#define Debug_tag(x) (0xD700D6D7ul | ((unsigned long) (x) << 16))
|
2001-03-06 08:54:07 -08:00
|
|
|
#endif /* ARCH_SIXTYFOUR */
|
2000-04-03 01:34:22 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
00 -> free words in minor heap
|
|
|
|
01 -> fields of free list blocks in major heap
|
|
|
|
03 -> heap chunks deallocated by heap shrinking
|
|
|
|
04 -> fields deallocated by obj_truncate
|
|
|
|
10 -> uninitialised fields of minor objects
|
|
|
|
11 -> uninitialised fields of major objects
|
|
|
|
15 -> uninitialised words of aligned_malloc blocks
|
|
|
|
85 -> filler bytes of aligned_malloc
|
2001-12-04 02:53:19 -08:00
|
|
|
|
|
|
|
special case (byte by byte):
|
|
|
|
D7 -> uninitialised words of stat_alloc blocks
|
2000-04-03 01:34:22 -07:00
|
|
|
*/
|
|
|
|
#define Debug_free_minor Debug_tag (0x00)
|
|
|
|
#define Debug_free_major Debug_tag (0x01)
|
|
|
|
#define Debug_free_shrink Debug_tag (0x03)
|
|
|
|
#define Debug_free_truncate Debug_tag (0x04)
|
|
|
|
#define Debug_uninit_minor Debug_tag (0x10)
|
|
|
|
#define Debug_uninit_major Debug_tag (0x11)
|
|
|
|
#define Debug_uninit_align Debug_tag (0x15)
|
|
|
|
#define Debug_filler_align Debug_tag (0x85)
|
2001-12-04 02:53:19 -08:00
|
|
|
|
|
|
|
#define Debug_uninit_stat 0xD7
|
2001-03-06 08:54:07 -08:00
|
|
|
#endif /* DEBUG */
|
1997-05-13 07:45:38 -07:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2000-08-23 10:10:03 -07:00
|
|
|
#ifndef CAML_AVOID_CONFLICTS
|
|
|
|
#define Assert CAMLassert
|
|
|
|
#endif
|
|
|
|
|
2002-02-19 06:37:44 -08:00
|
|
|
/* </private> */
|
2000-08-23 10:10:03 -07:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
#endif /* _misc_ */
|