]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/contrib/byterun/gc.h
Inital import
[l4.git] / l4 / pkg / ocaml / contrib / byterun / gc.h
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*             Damien Doligez, projet Para, INRIA Rocquencourt         */
6 /*                                                                     */
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.     */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: gc.h 6557 2004-07-19 13:20:06Z xleroy $ */
15
16 #ifndef CAML_GC_H
17 #define CAML_GC_H
18
19
20 #include "mlvalues.h"
21
22 #define Caml_white (0 << 8)
23 #define Caml_gray  (1 << 8)
24 #define Caml_blue  (2 << 8)
25 #define Caml_black (3 << 8)
26
27 #define Color_hd(hd) ((color_t) ((hd) & Caml_black))
28 #define Color_hp(hp) (Color_hd (Hd_hp (hp)))
29 #define Color_val(val) (Color_hd (Hd_val (val)))
30
31 #define Is_white_hd(hd) (Color_hd (hd) == Caml_white)
32 #define Is_gray_hd(hd) (Color_hd (hd) == Caml_gray)
33 #define Is_blue_hd(hd) (Color_hd (hd) == Caml_blue)
34 #define Is_black_hd(hd) (Color_hd (hd) == Caml_black)
35
36 #define Whitehd_hd(hd) (((hd)  & ~Caml_black)/*| Caml_white*/)
37 #define Grayhd_hd(hd)  (((hd)  & ~Caml_black)  | Caml_gray)
38 #define Blackhd_hd(hd) (((hd)/*& ~Caml_black*/)| Caml_black)
39 #define Bluehd_hd(hd)  (((hd)  & ~Caml_black)  | Caml_blue)
40
41 /* This depends on the layout of the header.  See [mlvalues.h]. */
42 #define Make_header(wosize, tag, color)                                       \
43       (/*Assert ((wosize) <= Max_wosize),*/                                   \
44        ((header_t) (((header_t) (wosize) << 10)                               \
45                     + (color)                                                 \
46                     + (tag_t) (tag)))                                         \
47       )
48
49 #define Is_white_val(val) (Color_val(val) == Caml_white)
50 #define Is_gray_val(val) (Color_val(val) == Caml_gray)
51 #define Is_blue_val(val) (Color_val(val) == Caml_blue)
52 #define Is_black_val(val) (Color_val(val) == Caml_black)
53
54 /* For extern.c */
55 #define Colornum_hd(hd) ((color_t) (((hd) >> 8) & 3))
56 #define Coloredhd_hd(hd,colnum) (((hd) & ~Caml_black) | ((colnum) << 8))
57
58 #endif /* CAML_GC_H */