File: finalise.h

package info (click to toggle)
ocaml 5.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 43,124 kB
  • sloc: ml: 355,439; ansic: 51,636; sh: 25,098; asm: 5,413; makefile: 3,673; python: 919; javascript: 273; awk: 253; perl: 59; fortran: 21; cs: 9
file content (87 lines) | stat: -rw-r--r-- 3,067 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**************************************************************************/
/*                                                                        */
/*                                 OCaml                                  */
/*                                                                        */
/*           Damien Doligez, projet Moscova, INRIA Rocquencourt           */
/*                                                                        */
/*   Copyright 2000 Institut National de Recherche en Informatique et     */
/*     en Automatique.                                                    */
/*                                                                        */
/*   All rights reserved.  This file is distributed under the terms of    */
/*   the GNU Lesser General Public License version 2.1, with the          */
/*   special exception on linking described in the file LICENSE.          */
/*                                                                        */
/**************************************************************************/

#ifndef CAML_FINALISE_H
#define CAML_FINALISE_H

#ifdef CAML_INTERNALS

#include "roots.h"
#include "domain.h"

struct final {
  value fun;
  value val;
  int offset;
};

struct finalisable {
  struct final *table;
  uintnat old;
  uintnat young;
  uintnat size;
};
/* [0..old) : finalisable set, the values are in the major heap
   [old..young) : recent set, the values could be in the minor heap
   [young..size) : free space

   The element of the finalisable set are moved to the finalising set
   below when the value are unreachable (for the first or last time).

*/

struct final_todo {
  struct final_todo *next;
  int size;
  struct final item[1];  /* variable size */
};

/*
  todo_head: head of the list of finalisation functions that can be run.
  todo_tail: tail of the list of finalisation functions that can be run.

  It is the finalising set.
*/

struct caml_final_info {
  struct finalisable first;
  uintnat updated_first;
  struct finalisable last;
  uintnat updated_last;
  struct final_todo *todo_head;
  struct final_todo *todo_tail;
  uintnat running_finalisation_function;
  struct caml_final_info* next; /* used for orphaned finalisers.
                                   See major_gc.c */
};

void caml_final_merge_finalisable (struct finalisable *source,
                                   struct finalisable *target);
int caml_final_update_first (caml_domain_state* d);
int caml_final_update_last (caml_domain_state* d);
caml_result caml_final_do_calls_res (void);
void caml_final_do_roots (
  scanning_action f, scanning_action_flags fflags, void* fdata,
  caml_domain_state* domain, int do_val);
void caml_final_do_young_roots (
  scanning_action f, scanning_action_flags fflags, void* fdata,
  caml_domain_state* d, int do_last_val);
void caml_final_empty_young (caml_domain_state* d);
void caml_final_update_last_minor (caml_domain_state* d);
struct caml_final_info* caml_alloc_final_info(void);

#endif /* CAML_INTERNALS */

#endif /* CAML_FINALISE_H */