Document the failure of `gc.test' wrt. unused modules.
[bpt/guile.git] / libguile / private-gc.h
CommitLineData
c7743d02 1/*
cb90e2cb
HWN
2 * private-gc.h - private declarations for garbage collection.
3 *
4 * Copyright (C) 2002, 03, 04, 05, 06, 07 Free Software Foundation, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
c7743d02
HWN
20
21#ifndef PRIVATE_GC
22#define PRIVATE_GC
23
24#include "_scm.h"
25
26/* {heap tuning parameters}
27 *
28 * These are parameters for controlling memory allocation. The heap
29 * is the area out of which scm_cons, and object headers are allocated.
30 *
31 * Each heap cell is 8 bytes on a 32 bit machine and 16 bytes on a
32 * 64 bit machine. The units of the _SIZE parameters are bytes.
33 * Cons pairs and object headers occupy one heap cell.
34 *
35 * SCM_INIT_HEAP_SIZE is the initial size of heap. If this much heap is
36 * allocated initially the heap will grow by half its current size
37 * each subsequent time more heap is needed.
38 *
39 * If SCM_INIT_HEAP_SIZE heap cannot be allocated initially, SCM_HEAP_SEG_SIZE
40 * will be used, and the heap will grow by SCM_HEAP_SEG_SIZE when more
41 * heap is needed. SCM_HEAP_SEG_SIZE must fit into type size_t. This code
42 * is in scm_init_storage() and alloc_some_heap() in sys.c
43 *
44 * If SCM_INIT_HEAP_SIZE can be allocated initially, the heap will grow by
45 * SCM_EXPHEAP(scm_heap_size) when more heap is needed.
46 *
47 * SCM_MIN_HEAP_SEG_SIZE is minimum size of heap to accept when more heap
48 * is needed.
49 */
50
51
52/*
53 * Heap size 45000 and 40% min yield gives quick startup and no extra
54 * heap allocation. Having higher values on min yield may lead to
55 * large heaps, especially if code behaviour is varying its
56 * maximum consumption between different freelists.
57 */
58
59/*
60 These values used to be global C variables. However, they're also
61 available through the environment, and having a double interface is
62 confusing. Now they're #defines --hwn.
63 */
64
65#define SCM_DEFAULT_INIT_HEAP_SIZE_1 256*1024
66#define SCM_DEFAULT_MIN_YIELD_1 40
67#define SCM_DEFAULT_INIT_HEAP_SIZE_2 32*1024
68
69/* The following value may seem large, but note that if we get to GC at
70 * all, this means that we have a numerically intensive application
71 */
72#define SCM_DEFAULT_MIN_YIELD_2 40
322a2bf7
MV
73
74#define SCM_DEFAULT_MAX_SEGMENT_SIZE (20*1024*1024L)
c7743d02
HWN
75
76
77
78#define SCM_MIN_HEAP_SEG_SIZE (8 * SCM_GC_SIZEOF_CARD)
79#define SCM_HEAP_SEG_SIZE (16384L * sizeof (scm_t_cell))
80
81
1383773b 82#define SCM_DOUBLECELL_ALIGNED_P(x) (((2 * sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)
c7743d02
HWN
83
84
1383773b
HWN
85#define SCM_GC_CARD_BVEC_SIZE_IN_LONGS \
86 ((SCM_GC_CARD_N_CELLS + SCM_C_BVEC_LONG_BITS - 1) / SCM_C_BVEC_LONG_BITS)
87#define SCM_GC_IN_CARD_HEADERP(x) \
88 (scm_t_cell *) (x) < SCM_GC_CELL_CARD (x) + SCM_GC_CARD_N_HEADER_CELLS
c7743d02
HWN
89
90
91int scm_getenv_int (const char *var, int def);
92
93
94typedef enum { return_on_error, abort_on_error } policy_on_error;
95
c7743d02
HWN
96
97#define SCM_MAX(A, B) ((A) > (B) ? (A) : (B))
98#define SCM_MIN(A, B) ((A) < (B) ? (A) : (B))
99
d3774e2c
MV
100/* CELL_P checks a random word whether it has the right form for a
101 pointer to a cell. Use scm_i_find_heap_segment_containing_object
102 to find out whether it actually points to a real cell.
103
104 The right form for a cell pointer is this: the low three bits must
105 be scm_tc3_cons, and when the scm_tc3_cons tag is stripped, the
106 resulting pointer must be correctly aligned.
107 scm_i_initialize_heap_segment_data guarantees that the test below
108 works.
109*/
110#define CELL_P(x) ((SCM_UNPACK(x) & (sizeof(scm_t_cell)-1)) == scm_tc3_cons)
c7743d02
HWN
111
112/*
113 gc-mark
114 */
115
116
117void scm_mark_all (void);
118
119
1367aa5e
HWN
120char const *scm_i_tag_name (scm_t_bits tag); /* MOVEME */
121
c7743d02
HWN
122
123extern long int scm_i_deprecated_memory_return;
124
125
126/*
127 global init funcs.
128 */
129void scm_gc_init_malloc (void);
130void scm_gc_init_freelist (void);
131void scm_gc_init_segments (void);
132void scm_gc_init_mark (void);
eab1b259
HWN
133
134
c7743d02 135#endif