Annotation of OpenXM_contrib/gc/include/gc_inl.h, Revision 1.1.1.1
1.1 maekawa 1: /*
2: * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3: * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
4: *
5: * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6: * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7: *
8: * Permission is hereby granted to use or copy this program
9: * for any purpose, provided the above notices are retained on all copies.
10: * Permission to modify the code and to distribute modified code is granted,
11: * provided the above notices are retained, and a notice that the code was
12: * modified is included with the above copyright notice.
13: */
14: /* Boehm, October 3, 1995 2:07 pm PDT */
15:
16: # ifndef GC_PRIVATE_H
17: # include "private/gc_priv.h"
18: # endif
19:
20: /* USE OF THIS FILE IS NOT RECOMMENDED unless the collector has been */
21: /* compiled without -DALL_INTERIOR_POINTERS or with */
22: /* -DDONT_ADD_BYTE_AT_END, or the specified size includes a pointerfree */
23: /* word at the end. In the standard collector configuration, */
24: /* the final word of each object may not be scanned. */
25: /* This is most useful for compilers that generate C. */
26: /* Manual use is hereby discouraged. */
27:
28: /* Allocate n words (NOT BYTES). X is made to point to the result. */
29: /* It is assumed that n < MAXOBJSZ, and */
30: /* that n > 0. On machines requiring double word alignment of some */
31: /* data, we also assume that n is 1 or even. This bypasses the */
32: /* MERGE_SIZES mechanism. In order to minimize the number of distinct */
33: /* free lists that are maintained, the caller should ensure that a */
34: /* small number of distinct values of n are used. (The MERGE_SIZES */
35: /* mechanism normally does this by ensuring that only the leading three */
36: /* bits of n may be nonzero. See misc.c for details.) We really */
37: /* recommend this only in cases in which n is a constant, and no */
38: /* locking is required. */
39: /* In that case it may allow the compiler to perform substantial */
40: /* additional optimizations. */
41: # define GC_MALLOC_WORDS(result,n) \
42: { \
43: register ptr_t op; \
44: register ptr_t *opp; \
45: DCL_LOCK_STATE; \
46: \
47: opp = &(GC_objfreelist[n]); \
48: FASTLOCK(); \
49: if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \
50: FASTUNLOCK(); \
51: (result) = GC_generic_malloc_words_small((n), NORMAL); \
52: } else { \
53: *opp = obj_link(op); \
54: obj_link(op) = 0; \
55: GC_words_allocd += (n); \
56: FASTUNLOCK(); \
57: (result) = (GC_PTR) op; \
58: } \
59: }
60:
61:
62: /* The same for atomic objects: */
63: # define GC_MALLOC_ATOMIC_WORDS(result,n) \
64: { \
65: register ptr_t op; \
66: register ptr_t *opp; \
67: DCL_LOCK_STATE; \
68: \
69: opp = &(GC_aobjfreelist[n]); \
70: FASTLOCK(); \
71: if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \
72: FASTUNLOCK(); \
73: (result) = GC_generic_malloc_words_small((n), PTRFREE); \
74: } else { \
75: *opp = obj_link(op); \
76: obj_link(op) = 0; \
77: GC_words_allocd += (n); \
78: FASTUNLOCK(); \
79: (result) = (GC_PTR) op; \
80: } \
81: }
82:
83: /* And once more for two word initialized objects: */
84: # define GC_CONS(result, first, second) \
85: { \
86: register ptr_t op; \
87: register ptr_t *opp; \
88: DCL_LOCK_STATE; \
89: \
90: opp = &(GC_objfreelist[2]); \
91: FASTLOCK(); \
92: if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { \
93: FASTUNLOCK(); \
94: op = GC_generic_malloc_words_small(2, NORMAL); \
95: } else { \
96: *opp = obj_link(op); \
97: GC_words_allocd += 2; \
98: FASTUNLOCK(); \
99: } \
100: ((word *)op)[0] = (word)(first); \
101: ((word *)op)[1] = (word)(second); \
102: (result) = (GC_PTR) op; \
103: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>