6 * This software is part of the SBCL system. See the README file for
9 * This software is derived from the CMU CL system, which was
10 * written at Carnegie Mellon University and released into the
11 * public domain. The software is in the public domain and is
12 * provided with absolutely no warranty. See the COPYING and CREDITS
13 * files for more information.
23 #define GET_FREE_POINTER() dynamic_space_free_pointer
24 #define SET_FREE_POINTER(new_value) \
25 (dynamic_space_free_pointer = (new_value))
26 #define GET_GC_TRIGGER() current_auto_gc_trigger
27 #define SET_GC_TRIGGER(new_value) \
28 clear_auto_gc_trigger(); set_auto_gc_trigger(new_value);
30 #define ALIGNED_SIZE(n) (n+LOWTAG_MASK) & ~LOWTAG_MASK
33 extern lispobj
*alloc(int bytes
);
40 /* Round to dual word boundary. */
41 bytes
= (bytes
+ LOWTAG_MASK
) & ~LOWTAG_MASK
;
43 result
= GET_FREE_POINTER();
45 SET_FREE_POINTER(result
+ (bytes
/ sizeof(lispobj
)));
47 if (GET_GC_TRIGGER() && GET_FREE_POINTER() > GET_GC_TRIGGER()) {
48 SET_GC_TRIGGER((char *)GET_FREE_POINTER()
49 - (char *)current_dynamic_space
);
56 alloc_unboxed(int type
, int words
)
60 result
= alloc(ALIGNED_SIZE((1 + words
) * sizeof(lispobj
)));
61 *result
= (lispobj
) (words
<< N_WIDETAG_BITS
) | type
;
66 alloc_vector(int type
, int length
, int size
)
68 struct vector
*result
;
70 result
= (struct vector
*)
71 alloc(ALIGNED_SIZE((2 + (length
*size
+ 31) / 32) * sizeof(lispobj
)));
73 result
->header
= type
;
74 result
->length
= make_fixnum(length
);
76 return ((lispobj
)result
)|OTHER_POINTER_LOWTAG
;
80 alloc_cons(lispobj car
, lispobj cdr
)
82 struct cons
*ptr
= (struct cons
*)alloc(ALIGNED_SIZE(sizeof(struct cons
)));
87 return (lispobj
)ptr
| LIST_POINTER_LOWTAG
;
95 if (-0x20000000 < n
&& n
< 0x20000000)
96 return make_fixnum(n
);
98 ptr
= (struct bignum
*)alloc_unboxed(BIGNUM_WIDETAG
, 1);
102 return (lispobj
) ptr
| OTHER_POINTER_LOWTAG
;
107 alloc_string(char *str
)
109 int len
= strlen(str
);
110 lispobj result
= alloc_vector(SIMPLE_STRING_WIDETAG
, len
+1, 8);
111 struct vector
*vec
= (struct vector
*)native_pointer(result
);
113 vec
->length
= make_fixnum(len
);
114 strcpy((char *)vec
->data
, str
);
122 int n_words_to_alloc
=
123 (sizeof(struct sap
) - sizeof(lispobj
)) / sizeof(u32
);
125 (struct sap
*)alloc_unboxed((int)SAP_WIDETAG
, n_words_to_alloc
);
127 return (lispobj
) sap
| OTHER_POINTER_LOWTAG
;