Debian Codegraph @

src/h/object.h

raw symbols SCIP
1 /* -*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*- */
2 /* vim: set filetype=c tabstop=8 shiftwidth=4 expandtab: */
3
4 /*
5 * Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya.
6 * Copyright (c) 1990, Giuseppe Attardi.
7 * Copyright (c) 2001, Juan Jose Garcia Ripoll.
8 *
9 * See file 'LICENSE' for the copyright details.
10 *
11 */
12
13 /* object.h -- Data structure definitions. */
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 /*
20 Integer and boolean types (see config.h)
21 */
22
23 #define TRUE 1 /* boolean true value */
24 #define FALSE 0 /* boolean false value */
25
26 typedef unsigned char byte;
27
28 /*
29 Implementation types.
30 Verify that it matches printer/write_ugly.d
31 */
32 typedef enum {
33 t_start = 0,
34 t_list = 1,
35 /* The most specific numeric types come first. Assumed by
36 some routines, like cl_expt. See ANSI 12.1.1.2. */
37 t_character = 2, /* immediate character */
38 t_fixnum = 3, /* immediate fixnum */
39 t_bignum = 4,
40 t_ratio,
41 /* t_shortfloat, */
42 t_singlefloat,
43 t_doublefloat,
44 t_longfloat,
45 t_complex,
46 #ifdef ECL_COMPLEX_FLOAT
47 t_csfloat,
48 t_cdfloat,
49 t_clfloat,
50 t_last_number = t_clfloat,
51 #else
52 t_last_number = t_complex,
53 #endif
54 t_symbol,
55 t_package,
56 t_hashtable,
57 t_array,
58 t_vector,
59 #ifdef ECL_UNICODE
60 t_string,
61 #endif
62 t_base_string,
63 t_bitvector,
64 t_stream,
65 t_random,
66 t_readtable,
67 t_pathname,
68 t_bytecodes,
69 t_bclosure,
70 t_cfun,
71 t_cfunfixed,
72 t_cclosure,
73 t_instance,
74 t_structure = t_instance,
75 #ifdef ECL_THREADS
76 t_process,
77 t_lock,
78 t_rwlock,
79 t_condition_variable,
80 t_semaphore,
81 t_barrier,
82 t_mailbox,
83 #endif
84 t_codeblock,
85 t_foreign,
86 t_frame,
87 t_weak_pointer,
88 #ifdef ECL_SSE2
89 t_sse_pack,
90 #endif
91 t_end,
92 t_other,
93 t_contiguous, /* contiguous block */
94 FREE = 127 /* free object */
95 } cl_type;
96
97
98 /*
99 Definition of the type of LISP objects.
100 */
101 typedef union cl_lispunion *cl_object;
102 typedef cl_object cl_return;
103 typedef cl_fixnum cl_narg;
104 typedef cl_object (*cl_objectfn)(cl_narg narg, ...);
105 typedef cl_object (*cl_objectfn_fixed)();
106
107 /*
108 OBJect NULL value.
109 It should not coincide with any legal object value.
110 */
111 #define OBJNULL ((cl_object)NULL)
112
113 /*
114 Definition of each implementation type.
115 */
116
117 #define ECL_TAG_BITS 2
118 #define ECL_IMMEDIATE(o) ((cl_fixnum)(o) & 3)
119 #define ECL_IMMEDIATE_TAG 3
120
121 #define ecl_to_bool(x) ((x)!=ECL_NIL)
122 #define ecl_make_bool(x) ((x)? ECL_T : ECL_NIL)
123
124 /* Immediate fixnums: */
125 #define ECL_FIXNUM_TAG t_fixnum
126 #define ECL_FIXNUMP(o) (ECL_IMMEDIATE(o) == t_fixnum)
127 #define ecl_make_fixnum(n) ((cl_object)(((cl_fixnum)(n) << 2) | t_fixnum))
128 #define ecl_fixnum_lower(a,b) ((cl_fixnum)(a) < (cl_fixnum)(b))
129 #define ecl_fixnum_greater(a,b) ((cl_fixnum)(a) > (cl_fixnum)(b))
130 #define ecl_fixnum_leq(a,b) ((cl_fixnum)(a) <= (cl_fixnum)(b))
131 #define ecl_fixnum_geq(a,b) ((cl_fixnum)(a) >= (cl_fixnum)(b))
132 #define ecl_fixnum_plusp(a) ((cl_fixnum)(a) > (cl_fixnum)ecl_make_fixnum(0))
133 #define ecl_fixnum_minusp(a) ((cl_fixnum)(a) < (cl_fixnum)(0))
134 #define ecl_fixnum(a) (((cl_fixnum)(a)) >> 2)
135
136 /* Immediate characters: */
137 #define ECL_CHARACTER_TAG t_character
138 #define ECL_CHARACTERP(o) (ECL_IMMEDIATE(o) == t_character)
139 #ifdef ECL_UNICODE
140 #define ECL_BASE_CHAR_P(obje) ((((cl_fixnum)(obje)) & 0xFFFFFC03) == ECL_CHARACTER_TAG)
141 #define ECL_BASE_CHAR_CODE_P(x) ((x & ~((cl_fixnum)0xFF)) == 0)
142 #define ECL_CODE_CHAR(c) ((cl_object)(((cl_fixnum)(c << 2)|ECL_CHARACTER_TAG)))
143 #define ECL_CHAR_CODE(obje) (((cl_fixnum)(obje)) >> 2)
144 #else
145 #define ECL_BASE_CHAR_P(o) ECL_CHARACTERP(o)
146 #define ECL_CODE_CHAR(c) ((cl_object)(((cl_fixnum)((c & 0xff) << 2)|ECL_CHARACTER_TAG)))
147 #define ECL_CHAR_CODE(obje) ((((cl_fixnum)(obje)) >> 2) & 0xff)
148 #endif
149 #define ECL_CHAR_CODE_RETURN 13
150 #define ECL_CHAR_CODE_NEWLINE 10
151 #define ECL_CHAR_CODE_LINEFEED 10
152
153 #define ECL_NUMBER_TYPE_P(t) (t >= t_fixnum && t <= t_last_number)
154 #define ECL_REAL_TYPE_P(t) (t >= t_fixnum && t < t_complex)
155 #define ECL_ARRAYP(x) ((ECL_IMMEDIATE(x) == 0) && (x)->d.t >= t_array && (x)->d.t <= t_bitvector)
156 #define ECL_VECTORP(x) ((ECL_IMMEDIATE(x) == 0) && (x)->d.t >= t_vector && (x)->d.t <= t_bitvector)
157 #define ECL_BIT_VECTOR_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_bitvector))
158 #ifdef ECL_UNICODE
159 #define ECL_STRINGP(x) ((ECL_IMMEDIATE(x) == 0) && \
160 ((x)->d.t == t_base_string || (x)->d.t == t_string))
161 #define ECL_EXTENDED_STRING_P(x) ((ECL_IMMEDIATE(x) == 0) && (x)->d.t == t_string)
162 #else
163 #define ECL_STRINGP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_base_string))
164 #define ECL_EXTENDED_STRING_P(x) 0
165 #endif
166 #define ECL_BASE_STRING_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_base_string))
167 #define ECL_HASH_TABLE_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_hashtable))
168 #define ECL_BIGNUMP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_bignum))
169 #ifdef ECL_COMPLEX_FLOAT
170 #define ECL_COMPLEXP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t >= t_complex) && ((x)->d.t <= t_clfloat))
171 #define ECL_COMPLEX_SINGLE_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_csfloat))
172 #define ECL_COMPLEX_DOUBLE_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_cdfloat))
173 #define ECL_COMPLEX_LONG_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_clfloat))
174 #else
175 #define ECL_COMPLEXP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_complex))
176 #endif
177 #define ECL_RANDOM_STATE_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_random))
178 #define ECL_SINGLE_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_singlefloat))
179 #define ECL_DOUBLE_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_doublefloat))
180 #define ECL_LONG_FLOAT_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_longfloat))
181 #define ECL_PACKAGEP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_package))
182 #define ECL_PATHNAMEP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_pathname))
183 #define ECL_READTABLEP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_readtable))
184 #define ECL_FOREIGN_DATA_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_foreign))
185 #ifdef ECL_SSE2
186 #define ECL_SSE_PACK_P(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_sse_pack))
187 #endif
188
189 #define _ECL_HDR int8_t t, m, padding1, padding2
190 #define _ECL_HDR1(field) int8_t t, m, field, padding
191 #define _ECL_HDR2(field1,field2) int8_t t, m, field1, field2
192
193 struct ecl_singlefloat {
194 _ECL_HDR;
195 float SFVAL; /* singlefloat value */
196 };
197 #define ecl_single_float(o) ((o)->SF.SFVAL)
198
199 struct ecl_doublefloat {
200 _ECL_HDR;
201 double DFVAL; /* doublefloat value */
202 };
203 #define ecl_double_float(o) ((o)->DF.DFVAL)
204
205 struct ecl_long_float {
206 _ECL_HDR;
207 long double value;
208 };
209 #define ecl_long_float(o) ((o)->longfloat.value)
210
211 typedef mpz_t big_num_t;
212 typedef mp_limb_t ecl_limb_t;
213
214 struct ecl_bignum {
215 _ECL_HDR;
216 big_num_t value;
217 };
218 #define ecl_bignum(o) ((o)->big.value)
219
220 struct ecl_ratio {
221 _ECL_HDR;
222 cl_object den; /* denominator, must be an integer */
223 cl_object num; /* numerator, must be an integer */
224 };
225
226 struct ecl_complex {
227 _ECL_HDR;
228 cl_object real; /* real part, must be a number */
229 cl_object imag; /* imaginary part, must be a number */
230 };
231
232 #ifdef ECL_COMPLEX_FLOAT
233 struct ecl_csfloat {
234 _ECL_HDR;
235 float _Complex value;
236 };
237 #define ecl_csfloat(o) ((o)->csfloat.value)
238
239 struct ecl_cdfloat {
240 _ECL_HDR;
241 double _Complex value;
242 };
243 #define ecl_cdfloat(o) ((o)->cdfloat.value)
244
245 struct ecl_clfloat {
246 _ECL_HDR;
247 long double _Complex value;
248 };
249 #define ecl_clfloat(o) ((o)->clfloat.value)
250 #endif
251
252 enum ecl_stype { /* symbol type */
253 ecl_stp_ordinary = 0,
254 ecl_stp_constant = 1,
255 ecl_stp_special = 2,
256 ecl_stp_macro = 4,
257 ecl_stp_special_form = 8
258 };
259
260 #define ECL_NIL ((cl_object)t_list)
261 #define ECL_NIL_SYMBOL ((cl_object)cl_symbols)
262 #define ECL_T ((cl_object)(cl_symbols+1))
263 #define ECL_UNBOUND ((cl_object)(cl_symbols+2))
264 #define ECL_PROTECT_TAG ((cl_object)(cl_symbols+3))
265 #define ECL_DUMMY_TAG ((cl_object)(cl_symbols+4))
266 #define ECL_RESTART_CLUSTERS ((cl_object)(cl_symbols+5))
267 #define ECL_HANDLER_CLUSTERS ((cl_object)(cl_symbols+6))
268 #define ECL_INTERRUPTS_ENABLED ((cl_object)(cl_symbols+7))
269 #define ECL_NO_TL_BINDING ((cl_object)(1 << ECL_TAG_BITS))
270
271 struct ecl_symbol {
272 _ECL_HDR1(stype); /* symbol type */
273 cl_object value; /* global value of the symbol */
274 cl_object gfdef; /* global function definition */
275 cl_objectfn undef_entry; /* entry point for not fboundp
276 * symbols (must match the position
277 * of cfun.entry); see below for
278 * more explanation */
279 cl_object macfun; /* macro expansion function */
280 cl_object sfdef; /* global (setf f) definition */
281 cl_object plist; /* property list */
282 cl_object name; /* print name */
283 cl_object cname; /* associated C name for function
284 * with exported C interface */
285 cl_object hpack; /* home package */
286 /* ECL_NIL for uninterned symbols */
287 #ifdef ECL_THREADS
288 cl_index binding; /* index into the bindings array */
289 #endif
290 };
291 /*
292 * Undefined functions are implemented as follows.
293 *
294 * For a symbols s with a global function binding: s->symbol.gfdef
295 * points to a cfun object, f->symbol.undef_entry is unused.
296 *
297 * For a symbol without a global function binding: s->symbol.gfdef
298 * points back to s itself, s->symbol.undef_entry is set. When an
299 * attempt is made to funcall s, the entry point in
300 * s->symbol.undef_entry is called which signals an undefined-function
301 * condition. Since the_env->function is set to s->symbol.gfdef which
302 * in this case is just s itself, we know which symbol caused the
303 * error and can signal accordingly. This construction enables us to
304 * skip the check for whether a function is bound or not when
305 * funcalling.
306 */
307 #define ECL_SYM_FUN(sym) ((sym)->symbol.gfdef)
308 #define ECL_FBOUNDP(sym) ((sym)->symbol.gfdef != (sym))
309 #define ECL_FMAKUNBOUND(sym) ((sym)->symbol.gfdef = (sym))
310
311 struct ecl_package {
312 _ECL_HDR1(locked);
313 cl_object name; /* package name, a string */
314 cl_object nicknames; /* nicknames, list of strings */
315 cl_object local_nicknames; /* local nicknames, assoc list */
316 cl_object nicknamedby; /* nicknamed-by-list of packages */
317 cl_object shadowings; /* shadowing symbol list */
318 cl_object uses; /* use-list of packages */
319 cl_object usedby; /* used-by-list of packages */
320 cl_object internal; /* hashtable for internal symbols */
321 cl_object external; /* hashtable for external symbols */
322 };
323
324 /*
325 The values returned by intern and find_symbol.
326 File_symbol may return 0.
327 */
328 enum {
329 ECL_INTERNAL = 1,
330 ECL_EXTERNAL,
331 ECL_INHERITED
332 };
333
334 /*
335 * CONSES
336 *
337 * We implement two variants. The "small cons" type carries the type
338 * information in the least significant bits of the pointer. We have
339 * to do some pointer arithmetics to find out the CAR / CDR of the
340 * cons but the overall result is faster and memory efficient, only
341 * using two words per cons.
342 *
343 * The other scheme stores conses as three-words objects, the first
344 * word carrying the type information. This is kept for backward
345 * compatibility and also because the oldest garbage collector does
346 * not yet support the smaller datatype.
347 *
348 * To make code portable and independent of the representation, only
349 * access the objects using the common macros below (that is all
350 * except ECL_CONS_PTR or ECL_PTR_CONS).
351 */
352
353 #ifdef ECL_SMALL_CONS
354 #define ECL_LISTP(x) (ECL_IMMEDIATE(x) == t_list)
355 #define ECL_CONSP(x) (LISTP(x) && !Null(x))
356 #define ECL_ATOM(x) (Null(x) || !LISTP(x))
357 #define ECL_SYMBOLP(x) (Null(x) || ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_symbol)))
358
359 #define ECL_PTR_CONS(x) (cl_object)((char*)(x) + t_list)
360 #define ECL_CONS_PTR(x) ((struct ecl_cons *)((char *)(x) - t_list))
361 #define ECL_CONS_CAR(x) (*(cl_object*)((char *)(x) - t_list))
362 #define ECL_CONS_CDR(x) (*(cl_object*)((char *)(x) + sizeof(cl_object) - t_list))
363 #define ECL_RPLACA(x,v) (ECL_CONS_CAR(x)=(v))
364 #define ECL_RPLACD(x,v) (ECL_CONS_CDR(x)=(v))
365
366 struct ecl_cons {
367 cl_object car; /* car */
368 cl_object cdr; /* cdr */
369 };
370 #else
371 #define ECL_LISTP(x) (ECL_IMMEDIATE(x)? Null(x) : ((x)->d.t == t_list))
372 #define ECL_CONSP(x) ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_list))
373 #define ECL_ATOM(x) (ECL_IMMEDIATE(x) || ((x)->d.t != t_list))
374 #define ECL_SYMBOLP(x) (Null(x) || ((ECL_IMMEDIATE(x) == 0) && ((x)->d.t == t_symbol)))
375
376 #define ECL_CONS_CAR(x) ((x)->cons.car)
377 #define ECL_CONS_CDR(x) ((x)->cons.cdr)
378 #define ECL_RPLACA(x,v) (ECL_CONS_CAR(x)=(v))
379 #define ECL_RPLACD(x,v) (ECL_CONS_CDR(x)=(v))
380
381 struct ecl_cons {
382 _ECL_HDR;
383 cl_object car; /* car */
384 cl_object cdr; /* cdr */
385 };
386 #endif
387
388 enum ecl_httest { /* hash table key test function */
389 ecl_htt_eq, /* eq */
390 ecl_htt_eql, /* eql */
391 ecl_htt_equal, /* equal */
392 ecl_htt_equalp, /* equalp */
393 ecl_htt_pack, /* symbol hash */
394 ecl_htt_generic /* generic user-supplied test */
395 };
396
397 enum ecl_htweak {
398 ecl_htt_not_weak = 0,
399 ecl_htt_weak_key,
400 ecl_htt_weak_value,
401 ecl_htt_weak_key_and_value,
402 ecl_htt_weak_key_or_value
403 };
404
405 struct ecl_hashtable_entry { /* hash table entry */
406 cl_object key; /* key */
407 cl_object value; /* value */
408 };
409
410 struct ecl_hashtable { /* hash table header */
411 _ECL_HDR2(test,weak);
412 struct ecl_hashtable_entry *data; /* pointer to the hash table */
413 cl_object sync_lock; /* synchronization lock */
414 cl_object generic_test; /* generic test function */
415 cl_object generic_hash; /* generic hashing function */
416 cl_index entries; /* number of entries */
417 cl_index size; /* hash table size */
418 cl_index limit; /* hash table threshold (integer value) */
419 cl_object rehash_size; /* rehash size */
420 cl_object threshold; /* rehash threshold */
421 double factor; /* cached value of threshold */
422 cl_object (*get)(cl_object, cl_object, cl_object);
423 cl_object (*set)(cl_object, cl_object, cl_object);
424 bool (*rem)(cl_object, cl_object);
425 /* Unsafe variants are used to store the real accessors when
426 the synchronized variant is bound to get/set/rem. */
427 cl_object (*get_unsafe)(cl_object, cl_object, cl_object);
428 cl_object (*set_unsafe)(cl_object, cl_object, cl_object);
429 bool (*rem_unsafe)(cl_object, cl_object);
430 };
431
432 typedef enum { /* array element type */
433 ecl_aet_object, /* t */
434 ecl_aet_sf, /* single-float */
435 ecl_aet_df, /* double-float */
436 ecl_aet_lf, /* long-float */
437 #ifdef ECL_COMPLEX_FLOAT
438 ecl_aet_csf, /* complex-single-float */
439 ecl_aet_cdf, /* complex-double-float */
440 ecl_aet_clf, /* complex-long-float */
441 #endif
442 ecl_aet_bit, /* bit */
443 ecl_aet_fix, /* cl_fixnum */
444 ecl_aet_index, /* cl_index */
445 /* Below here, list types accepted by streams (i.e. OPEN) */
446 ecl_aet_b8, /* byte8 */
447 ecl_aet_i8, /* integer8 */
448 #ifdef ecl_uint16_t
449 ecl_aet_b16,
450 ecl_aet_i16,
451 #endif
452 #ifdef ecl_uint32_t
453 ecl_aet_b32,
454 ecl_aet_i32,
455 #endif
456 #ifdef ecl_uint64_t
457 ecl_aet_b64,
458 ecl_aet_i64,
459 #endif
460 #ifdef ECL_UNICODE
461 ecl_aet_ch, /* character */
462 #endif
463 ecl_aet_bc, /* base-char */
464 ecl_aet_last_type = ecl_aet_bc
465 } cl_elttype;
466
467 union ecl_array_data {
468 cl_object *t;
469 ecl_base_char *bc;
470 #ifdef ECL_UNICODE
471 ecl_character *c;
472 #endif
473 uint8_t *b8;
474 int8_t *i8;
475 #ifdef ecl_uint16_t
476 ecl_uint16_t *b16;
477 ecl_int16_t *i16;
478 #endif
479 #ifdef ecl_uint32_t
480 ecl_uint32_t *b32;
481 ecl_int32_t *i32;
482 #endif
483 #ifdef ecl_uint64_t
484 ecl_uint64_t *b64;
485 ecl_int64_t *i64;
486 #endif
487 float *sf;
488 double *df;
489 long double *lf;
490 #ifdef ECL_COMPLEX_FLOAT
491 float _Complex *csf;
492 double _Complex *cdf;
493 long double _Complex *clf;
494 #endif
495 cl_fixnum *fix;
496 cl_index *index;
497 byte *bit;
498 };
499
500 #define ECL_FLAG_HAS_FILL_POINTER 1
501 #define ECL_FLAG_ADJUSTABLE 2
502 #define ECL_ADJUSTABLE_ARRAY_P(x) ((x)->array.flags & ECL_FLAG_ADJUSTABLE)
503 #define ECL_ARRAY_HAS_FILL_POINTER_P(x) ((x)->array.flags & ECL_FLAG_HAS_FILL_POINTER)
504
505 struct ecl_array { /* array header */
506 /* adjustable flag */
507 /* has-fill-pointer flag */
508 _ECL_HDR2(elttype,flags); /* array element type, has fill ptr, adjustable-p */
509 cl_object displaced; /* displaced */
510 cl_index dim; /* dimension */
511 cl_index *dims; /* table of dimensions */
512 union ecl_array_data self; /* pointer to the array */
513 byte offset; /* bitvector offset */
514 byte rank; /* rank of array = # of dimensions */
515 };
516
517 struct ecl_vector { /* vector header */
518 /* adjustable flag */
519 /* has-fill-pointer flag */
520 _ECL_HDR2(elttype,flags); /* array element type, has fill ptr, adjustable-p */
521 cl_object displaced; /* displaced */
522 cl_index dim; /* dimension */
523 cl_index fillp; /* fill pointer */
524 /* For simple vectors, fillp is equal to dim. */
525 union ecl_array_data self; /* pointer to the vector */
526 byte offset;
527 };
528
529 struct ecl_base_string { /* string header */
530 /* adjustable flag */
531 /* has-fill-pointer flag */
532 _ECL_HDR2(elttype,flags); /* array element type, has fill ptr, adjustable-p */
533 cl_object displaced; /* displaced */
534 cl_index dim; /* dimension */
535 /* string length */
536 cl_index fillp; /* fill pointer */
537 /* For simple strings, */
538 /* st_fillp is equal to st_dim-1. */
539 ecl_base_char *self; /* pointer to the string */
540 };
541
542 #ifdef ECL_UNICODE
543 struct ecl_string { /* string header */
544 /* adjustable flag */
545 /* has-fill-pointer flag */
546 _ECL_HDR2(elttype,flags); /* array element type, has fill ptr, adjustable-p */
547 cl_object displaced; /* displaced */
548 cl_index dim; /* dimension, string length */
549 cl_index fillp; /* fill pointer */
550 /* For simple strings, fillp is equal to dim-1. */
551 ecl_character *self; /* pointer to the string */
552 };
553 #endif
554
555 #define T_STRUCTURE t_instance
556 #define ECL_STRUCT_TYPE(x) ECL_CLASS_OF(x)
557 #define ECL_STRUCT_SLOTS(x) (x)->instance.slots
558 #define ECL_STRUCT_LENGTH(x) (x)->instance.length
559 #define ECL_STRUCT_SLOT(x,i) (x)->instance.slots[i]
560 #define ECL_STRUCT_NAME(x) ECL_CLASS_NAME(ECL_CLASS_OF(x))
561
562 enum ecl_smmode { /* stream mode */
563 ecl_smm_input, /* input */
564 ecl_smm_input_file, /* input */
565 ecl_smm_output, /* output */
566 ecl_smm_output_file, /* output */
567 ecl_smm_io, /* input-output */
568 ecl_smm_io_file, /* input-output */
569 ecl_smm_synonym, /* synonym */
570 ecl_smm_broadcast, /* broadcast */
571 ecl_smm_concatenated, /* concatenated */
572 ecl_smm_two_way, /* two way */
573 ecl_smm_echo, /* echo */
574 ecl_smm_string_input, /* string input */
575 ecl_smm_string_output, /* string output */
576 ecl_smm_probe, /* probe (only used in open_stream()) */
577 #if defined(ECL_WSOCK)
578 ecl_smm_input_wsock, /* input socket (Win32) */
579 ecl_smm_output_wsock, /* output socket (Win32) */
580 ecl_smm_io_wsock, /* input/output socket (Win32) */
581 #endif
582 #if defined(ECL_MS_WINDOWS_HOST)
583 ecl_smm_io_wcon, /* windows console (Win32) */
584 #endif
585 ecl_smm_sequence_input, /* sequence input */
586 ecl_smm_sequence_output /* sequence output */
587 };
588
589 struct ecl_file_ops {
590 cl_index (*read_byte8)(cl_object strm, unsigned char *c, cl_index n);
591 cl_index (*write_byte8)(cl_object strm, unsigned char *c, cl_index n);
592
593 cl_object (*read_byte)(cl_object strm);
594 void (*write_byte)(cl_object strm, cl_object byte);
595 void (*unread_byte)(cl_object strm, cl_object byte);
596 cl_object (*peek_byte)(cl_object strm);
597
598 ecl_character (*read_char)(cl_object strm);
599 ecl_character (*write_char)(cl_object strm, ecl_character c);
600 void (*unread_char)(cl_object strm, ecl_character c);
601 ecl_character (*peek_char)(cl_object strm);
602
603 cl_index (*read_vector)(cl_object strm, cl_object data, cl_index start, cl_index end);
604 cl_index (*write_vector)(cl_object strm, cl_object data, cl_index start, cl_index end);
605
606 int (*listen)(cl_object strm);
607 void (*clear_input)(cl_object strm);
608 void (*clear_output)(cl_object strm);
609 void (*finish_output)(cl_object strm);
610 void (*force_output)(cl_object strm);
611
612 int (*input_p)(cl_object strm);
613 int (*output_p)(cl_object strm);
614 int (*interactive_p)(cl_object strm);
615 cl_object (*element_type)(cl_object strm);
616
617 cl_object (*length)(cl_object strm);
618 cl_object (*get_position)(cl_object strm);
619 cl_object (*set_position)(cl_object strm, cl_object pos);
620 cl_object (*string_length)(cl_object strm, cl_object string);
621 int (*column)(cl_object strm);
622
623 cl_object (*pathname)(cl_object strm);
624 cl_object (*truename)(cl_object strm);
625
626 cl_object (*close)(cl_object strm);
627 };
628
629 enum {
630 ECL_STREAM_BINARY = 0,
631 ECL_STREAM_FORMAT = 0xF,
632 #ifndef ECL_UNICODE
633 ECL_STREAM_DEFAULT_FORMAT = 1,
634 #else
635 ECL_STREAM_DEFAULT_FORMAT = 2,
636 ECL_STREAM_ISO_8859_1 = 1,
637 ECL_STREAM_LATIN_1 = 1,
638 ECL_STREAM_UTF_8 = 2,
639 ECL_STREAM_UCS_2 = 3,
640 ECL_STREAM_UCS_2LE = 5 + 128,
641 ECL_STREAM_UCS_2BE = 5,
642 ECL_STREAM_UCS_4 = 6,
643 ECL_STREAM_UCS_4LE = 7 + 128,
644 ECL_STREAM_UCS_4BE = 7,
645 ECL_STREAM_USER_FORMAT = 8,
646 ECL_STREAM_US_ASCII = 10,
647 #endif
648 /* External Format */
649 ECL_STREAM_CR = 16,
650 ECL_STREAM_LF = 32,
651 ECL_STREAM_SIGNED_BYTES = 64,
652 ECL_STREAM_LITTLE_ENDIAN = 128,
653 /* OS Streams */
654 ECL_STREAM_C_STREAM = 256,
655 ECL_STREAM_MIGHT_SEEK = 512,
656 ECL_STREAM_CLOSE_ON_EXEC = 1024,
657 ECL_STREAM_NONBLOCK = 2048,
658 /* Lisp Streams */
659 ECL_STREAM_CLOSE_COMPONENTS = 4096,
660 ECL_STREAM_USE_VECTOR_FILLP = 8192
661 };
662
663 /* buffer points to an array of bytes ending at buffer_end. Decode one
664 character from this array and advance buffer by the number of bytes
665 consumed. If not enough bytes are available, return EOF and don't
666 advance buffer. */
667 typedef ecl_character (*cl_eformat_decoder)(cl_object stream, unsigned char **buffer, unsigned char *buffer_end);
668 /* Encode the character c and store the result in buffer. Return the
669 number of bytes used */
670 typedef int (*cl_eformat_encoder)(cl_object stream, unsigned char *buffer, ecl_character c);
671
672 /* Buffer is assumed to be big enough to store whole byte. The byte size is
673 stream->strm.byte_size. Decoder returns an object, encoder fills a buffer. */
674 typedef cl_object (*cl_binary_decoder)(cl_object stream, unsigned char *buf);
675 typedef void (*cl_binary_encoder)(cl_object stream, unsigned char *buf, cl_object byte);
676
677 #define ECL_ANSI_STREAM_P(o) \
678 (ECL_IMMEDIATE(o) == 0 && ((o)->d.t == t_stream))
679 #define ECL_ANSI_STREAM_TYPE_P(o,m) \
680 (ECL_IMMEDIATE(o) == 0 && ((o)->d.t == t_stream) && ((o)->stream.mode == (m)))
681
682 struct ecl_stream {
683 _ECL_HDR2(mode,closed); /* stream mode of enum smmode */
684 /* closed stream? */
685 struct ecl_file_ops *ops; /* dispatch table */
686 union {
687 FILE *stream; /* ANSI C streams */
688 cl_fixnum descriptor; /* POSIX files */
689 } file;
690 cl_object object0; /* some object */
691 cl_object object1; /* some object */
692 cl_object last_byte; /* last byte read */
693 cl_fixnum last_char; /* last character read */
694 cl_object byte_stack; /* buffer for unread bytes */
695 cl_index column; /* file column */
696 cl_fixnum int0; /* some int */
697 cl_fixnum int1; /* some int */
698 cl_index byte_size; /* size of byte in binary streams */
699 cl_fixnum last_op; /* 0: unknown, 1: reading, -1: writing */
700 char *buffer; /* buffer for FILE */
701 unsigned char *byte_buffer; /* buffer for encoding and decoding */
702 cl_object format; /* external format */
703 cl_eformat_encoder encoder;
704 cl_eformat_decoder decoder;
705 cl_binary_encoder byte_encoder;
706 cl_binary_decoder byte_decoder;
707 cl_object format_table;
708 int flags; /* character table, flags, etc */
709 ecl_character eof_char;
710 };
711
712 struct ecl_random {
713 _ECL_HDR;
714 cl_object value; /* random state value */
715 };
716
717 enum ecl_chattrib { /* character attribute */
718 cat_whitespace, /* whitespace */
719 cat_terminating, /* terminating macro */
720 cat_non_terminating, /* non-terminating macro */
721 cat_single_escape, /* single-escape */
722 cat_multiple_escape, /* multiple-escape */
723 cat_constituent /* constituent */
724 };
725
726 struct ecl_readtable_entry { /* read table entry */
727 enum ecl_chattrib syntax_type; /* character attribute */
728 cl_object dispatch; /* a macro, a hash or NIL */
729 };
730
731 enum ecl_readtable_case {
732 ecl_case_upcase,
733 ecl_case_downcase,
734 ecl_case_invert,
735 ecl_case_preserve
736 };
737
738 struct ecl_readtable { /* read table */
739 _ECL_HDR1(locked);
740 enum ecl_readtable_case read_case; /* readtable-case */
741 struct ecl_readtable_entry *table; /* read table itself */
742 #ifdef ECL_UNICODE
743 cl_object hash; /* hash for values outside base-char range */
744 #endif
745 };
746
747 struct ecl_pathname {
748 _ECL_HDR1(logical); /* logical pathname? */
749 cl_object host; /* host */
750 cl_object device; /* device */
751 cl_object directory; /* directory */
752 cl_object name; /* name */
753 cl_object type; /* type */
754 cl_object version; /* version */
755 };
756
757 struct ecl_codeblock {
758 _ECL_HDR2(self_destruct,locked); /* delete DLL after gc */
759 /* do not garbage collect this library */
760 void *handle; /* handle returned by dlopen */
761 void *entry; /* entry point */
762 cl_object *data; /* data vector */
763 int data_size;
764 cl_object *temp_data; /* data vector for toplevel forms */
765 int temp_data_size;
766 const cl_object *data_text; /* strings with objects to be defined */
767 cl_object next; /* next codeblock within same library */
768 cl_object name;
769 cl_object links; /* list of symbols with linking calls */
770 cl_index cfuns_size; /* number of functions defined */
771 const struct ecl_cfunfixed *cfuns;
772 cl_object source; /* common debug information for this block */
773 cl_object refs; /* reference counter for the library */
774 cl_object error; /* error message when loading */
775 };
776
777 struct ecl_bytecodes {
778 _ECL_HDR;
779 cl_object name; /* function name */
780 cl_object definition; /* function definition in list form */
781 cl_objectfn entry; /* entry address (must match the position of
782 * the equivalent field in cfun) */
783 cl_index code_size; /* number of bytecodes */
784 char *code; /* the intermediate language */
785 cl_object data; /* non-inmediate constants used in the code */
786 cl_object flex; /* indexes of captured objects (vector) */
787 cl_object nlcl; /* number of slots for local values */
788 cl_object file; /* file where it was defined... */
789 cl_object file_position;/* and where it was created */
790 };
791
792 struct ecl_bclosure {
793 _ECL_HDR;
794 cl_object code;
795 cl_object lex; /* captured objects (flat vector) */
796 cl_objectfn entry; /* entry address */
797 };
798
799 struct ecl_cfun { /* compiled function header */
800 _ECL_HDR1(narg); /* number of fixed arguments */
801 cl_object name; /* compiled function name */
802 cl_object block; /* descriptor of C code block for GC */
803 cl_objectfn entry; /* entry address */
804 #ifdef ECL_C_COMPATIBLE_VARIADIC_DISPATCH
805 /* Some architectures (i.e. ARM64 on iOS/Mac OS X) use a different
806 * calling convention for the fixed and variadic arguments of
807 * a variadic function. The only portable way to allow for
808 * function redefinitions during runtime in these
809 * architectures is to set entry to a dispatch function
810 * calling entry_variadic with the correct calling conventions
811 * (see cfun.d). -- mg 2019-12-02 */
812 cl_objectfn entry_variadic;
813 #endif
814 cl_object file; /* file where it was defined... */
815 cl_object file_position;/* and where it was created */
816 };
817
818 struct ecl_cfunfixed { /* compiled function header */
819 _ECL_HDR1(narg); /* number of arguments */
820 cl_object name; /* compiled function name */
821 cl_object block; /* descriptor of C code block for GC */
822 cl_objectfn entry; /* entry address (must match the position of
823 * the equivalent field in cfun) */
824 cl_objectfn_fixed entry_fixed; /* entry address */
825 cl_object file; /* file where it was defined... */
826 cl_object file_position;/* and where it was created */
827 };
828
829 struct ecl_cclosure { /* compiled closure header */
830 _ECL_HDR1(narg); /* number of fixed arguments */
831 cl_object env; /* environment */
832 cl_object block; /* descriptor of C code block for GC */
833 cl_objectfn entry; /* entry address (must match the position of
834 * the equivalent field in cfun) */
835 #ifdef ECL_C_COMPATIBLE_VARIADIC_DISPATCH
836 cl_objectfn entry_variadic; /* see struct ecl_cfun above */
837 #endif
838 cl_object file; /* file where it was defined... */
839 cl_object file_position;/* and where it was created */
840 };
841
842 #define ECL_FFICALL_LIMIT 256
843
844 enum ecl_ffi_tag {
845 ECL_FFI_CHAR = 0,
846 ECL_FFI_UNSIGNED_CHAR,
847 ECL_FFI_BYTE,
848 ECL_FFI_UNSIGNED_BYTE,
849 ECL_FFI_SHORT,
850 ECL_FFI_UNSIGNED_SHORT,
851 ECL_FFI_INT,
852 ECL_FFI_UNSIGNED_INT,
853 ECL_FFI_LONG,
854 ECL_FFI_UNSIGNED_LONG,
855 #ifdef ecl_uint8_t
856 ECL_FFI_INT8_T,
857 ECL_FFI_UINT8_T,
858 #endif
859 #ifdef ecl_uint16_t
860 ECL_FFI_INT16_T,
861 ECL_FFI_UINT16_T,
862 #endif
863 #ifdef ecl_uint32_t
864 ECL_FFI_INT32_T,
865 ECL_FFI_UINT32_T,
866 #endif
867 #ifdef ecl_uint64_t
868 ECL_FFI_INT64_T,
869 ECL_FFI_UINT64_T,
870 #endif
871 #ifdef ecl_long_long_t
872 ECL_FFI_LONG_LONG,
873 ECL_FFI_UNSIGNED_LONG_LONG,
874 #endif
875 ECL_FFI_POINTER_VOID,
876 ECL_FFI_CSTRING,
877 ECL_FFI_OBJECT,
878 ECL_FFI_FLOAT,
879 ECL_FFI_DOUBLE,
880 ECL_FFI_LONG_DOUBLE,
881 #ifdef ECL_COMPLEX_FLOAT
882 ECL_FFI_CSFLOAT,
883 ECL_FFI_CDFLOAT,
884 ECL_FFI_CLFLOAT,
885 #endif
886 ECL_FFI_VOID
887 };
888
889 union ecl_ffi_values {
890 char c;
891 unsigned char uc;
892 int8_t b;
893 uint8_t ub;
894 int i;
895 unsigned int ui;
896 short s;
897 unsigned short us;
898 long l;
899 unsigned long ul;
900 #ifdef ecl_uint8_t
901 ecl_int8_t i8;
902 ecl_uint8_t u8;
903 #endif
904 #ifdef ecl_uint16_t
905 ecl_int16_t i16;
906 ecl_uint16_t u16;
907 #endif
908 #ifdef ecl_uint32_t
909 ecl_int32_t i32;
910 ecl_uint32_t u32;
911 #endif
912 #ifdef ecl_uint64_t
913 ecl_int64_t i64;
914 ecl_uint64_t u64;
915 #endif
916 #ifdef ecl_long_long_t
917 ecl_long_long_t ll;
918 ecl_ulong_long_t ull;
919 unsigned long l2[2];
920 #endif
921 void *pv;
922 char *pc;
923 cl_object o;
924 float f;
925 double d;
926 long double lf;
927 #ifdef ECL_COMPLEX_FLOAT
928 float _Complex csf;
929 double _Complex cdf;
930 long double _Complex clf;
931 #endif
932 };
933
934 struct ecl_foreign { /* user defined datatype */
935 _ECL_HDR;
936 cl_object tag; /* a tag identifying the type */
937 cl_index size; /* the amount of memory allocated */
938 char *data; /* the data itself */
939 };
940
941 struct ecl_stack_frame {
942 _ECL_HDR1(opened);
943 cl_index base; /* Start of the stack frame */
944 cl_index size; /* Number of arguments */
945 cl_index sp; /* Stack pointer */
946 struct cl_env_struct *env;
947 };
948
949 struct ecl_weak_pointer { /* weak pointer to value */
950 _ECL_HDR;
951 cl_object value;
952 };
953 #define ecl_weak_pointer(o) ((o)->weak.value)
954
955 /*
956 dummy type
957 */
958 struct ecl_dummy {
959 _ECL_HDR;
960 };
961
962 #ifdef ECL_THREADS
963
964 #ifdef ECL_WINDOWS_THREADS
965 typedef HANDLE ecl_thread_t;
966 typedef HANDLE ecl_mutex_t;
967 typedef struct ecl_cond_var_t {
968 HANDLE broadcast_event;
969 HANDLE signal_event;
970 cl_index state;
971 } ecl_cond_var_t;
972 typedef SRWLOCK ecl_rwlock_t;
973 #else
974 typedef pthread_t ecl_thread_t;
975 typedef pthread_mutex_t ecl_mutex_t;
976 typedef pthread_cond_t ecl_cond_var_t;
977 # ifdef HAVE_POSIX_RWLOCK
978 typedef pthread_rwlock_t ecl_rwlock_t;
979 # else
980 typedef struct ecl_rwlock_t {
981 pthread_mutex_t mutex;
982 pthread_cond_t reader_cv;
983 pthread_cond_t writer_cv;
984 /* reader_count = 0: lock is free
985 * reader_count =-1: writer holds the lock
986 * reader_count > 0: number of readers */
987 cl_fixnum reader_count;
988 } ecl_rwlock_t;
989 # endif
990 #endif
991
992 enum {
993 ECL_PROCESS_INACTIVE = 0,
994 ECL_PROCESS_BOOTING,
995 ECL_PROCESS_ACTIVE,
996 ECL_PROCESS_EXITING
997 };
998
999 struct ecl_process {
1000 _ECL_HDR;
1001 cl_object name;
1002 cl_object function;
1003 cl_object args;
1004 struct cl_env_struct *env;
1005 cl_object interrupt;
1006 cl_object inherit_bindings_p;
1007 cl_object parent;
1008 cl_object exit_values;
1009 cl_object woken_up;
1010 ecl_mutex_t start_stop_lock; /* phase is updated only when we hold this lock */
1011 ecl_cond_var_t exit_barrier; /* process-join waits on this barrier */
1012 cl_index phase;
1013 ecl_thread_t thread;
1014 int trap_fpe_bits;
1015 };
1016
1017 enum {
1018 ECL_WAKEUP_ONE = 0,
1019 ECL_WAKEUP_ALL = 1,
1020 ECL_WAKEUP_RESET_FLAG = 2,
1021 ECL_WAKEUP_KILL = 4,
1022 ECL_WAKEUP_DELETE = 8
1023 };
1024
1025 struct ecl_semaphore {
1026 _ECL_HDR;
1027 cl_object name;
1028 cl_fixnum counter;
1029 cl_fixnum wait_count;
1030 ecl_mutex_t mutex;
1031 ecl_cond_var_t cv;
1032 };
1033
1034 #define ECL_BARRIER_WAKEUP_NORMAL 1
1035 #define ECL_BARRIER_WAKEUP_KILL 2
1036
1037 struct ecl_barrier {
1038 _ECL_HDR2(disabled,wakeup);
1039 cl_object name;
1040 cl_index count;
1041 cl_index arrivers_count;
1042 ecl_mutex_t mutex;
1043 ecl_cond_var_t cv;
1044 };
1045
1046 struct ecl_lock {
1047 _ECL_HDR1(recursive);
1048 ecl_mutex_t mutex;
1049 cl_object owner; /* thread holding the lock or NIL */
1050 cl_object name;
1051 cl_fixnum counter;
1052 };
1053
1054 struct ecl_mailbox {
1055 _ECL_HDR;
1056 cl_object name;
1057 cl_object data;
1058 ecl_mutex_t mutex;
1059 ecl_cond_var_t reader_cv;
1060 ecl_cond_var_t writer_cv;
1061 cl_index message_count;
1062 cl_index read_pointer;
1063 cl_index write_pointer;
1064 };
1065
1066 struct ecl_rwlock {
1067 _ECL_HDR;
1068 cl_object name;
1069 ecl_rwlock_t mutex;
1070 };
1071
1072 struct ecl_condition_variable {
1073 _ECL_HDR;
1074 ecl_cond_var_t cv;
1075 };
1076 #endif /* ECL_THREADS */
1077
1078 #define ECL_CLASS_OF(x) (x)->instance.clas
1079 #define ECL_SPEC_FLAG(x) (x)->instance.slots[0]
1080 #define ECL_SPEC_OBJECT(x) (x)->instance.slots[3]
1081 #define ECL_CLASS_NAME(x) (x)->instance.slots[3+0]
1082 #define ECL_CLASS_SUPERIORS(x) (x)->instance.slots[3+1]
1083 #define ECL_CLASS_INFERIORS(x) (x)->instance.slots[3+2]
1084 #define ECL_CLASS_SLOTS(x) (x)->instance.slots[3+3]
1085 #define ECL_CLASS_CPL(x) (x)->instance.slots[3+4]
1086 #define ECL_INSTANCEP(x) ((ECL_IMMEDIATE(x)==0) && ((x)->d.t==t_instance))
1087 #define ECL_NOT_FUNCALLABLE 0
1088 #define ECL_STANDARD_DISPATCH 1
1089 #define ECL_RESTRICTED_DISPATCH 2
1090 #define ECL_READER_DISPATCH 3
1091 #define ECL_WRITER_DISPATCH 4
1092 #define ECL_USER_DISPATCH 5
1093
1094 struct ecl_instance { /* -- instance header -- */
1095 _ECL_HDR1(isgf); /* gf type */
1096 cl_index length; /* instance length */
1097 cl_object clas; /* instance class */
1098 cl_objectfn entry; /* entry address */
1099 cl_object slotds; /* slot definitions */
1100 cl_object *slots; /* instance slots */
1101 cl_index stamp; /* instance stamp */
1102 cl_index class_stamp; /* class stamp */
1103 };
1104
1105 #ifdef ECL_SSE2
1106 union ecl_sse_data {
1107 /* This member must be first in order for
1108 ecl_def_ct_sse_pack to work properly. */
1109 uint8_t b8[16];
1110 int8_t i8[16];
1111
1112 __m128 vf;
1113 __m128i vi;
1114 __m128d vd;
1115
1116 #ifdef ecl_uint16_t
1117 ecl_uint16_t b16[8];
1118 ecl_int16_t i16[8];
1119 #endif
1120 #ifdef ecl_uint32_t
1121 ecl_uint32_t b32[4];
1122 ecl_int32_t i32[4];
1123 #endif
1124 #ifdef ecl_uint64_t
1125 ecl_uint64_t b64[2];
1126 ecl_int64_t i64[2];
1127 #endif
1128
1129 float sf[4];
1130 double df[2];
1131 };
1132
1133 struct ecl_sse_pack {
1134 _ECL_HDR1(elttype);
1135 union ecl_sse_data data;
1136 };
1137 #endif
1138
1139 /*
1140 Definition of lispunion.
1141 */
1142 union cl_lispunion {
1143 #ifndef ECL_SMALL_CONS
1144 struct ecl_cons cons; /* unoptimized cons */
1145 #endif
1146 struct ecl_bignum big; /* bignum */
1147 struct ecl_ratio ratio; /* ratio */
1148 struct ecl_singlefloat SF; /* single floating-point number */
1149 struct ecl_doublefloat DF; /* double floating-point number */
1150 struct ecl_long_float longfloat; /* long-float */
1151 struct ecl_complex gencomplex; /* generic complex number */
1152 #ifdef ECL_COMPLEX_FLOAT
1153 struct ecl_csfloat csfloat; /* complex single float */
1154 struct ecl_cdfloat cdfloat; /* complex double float */
1155 struct ecl_clfloat clfloat; /* complex long float */
1156 #endif
1157 struct ecl_symbol symbol; /* symbol */
1158 struct ecl_package pack; /* package */
1159 struct ecl_hashtable hash; /* hash table */
1160 struct ecl_array array; /* array */
1161 struct ecl_vector vector; /* vector */
1162 struct ecl_base_string base_string; /* base-string */
1163 #ifdef ECL_UNICODE
1164 struct ecl_string string; /* string */
1165 #endif
1166 struct ecl_stream stream; /* stream */
1167 struct ecl_random random; /* random-states */
1168 struct ecl_readtable readtable; /* read table */
1169 struct ecl_pathname pathname; /* path name */
1170 struct ecl_bytecodes bytecodes; /* bytecompiled function / code */
1171 struct ecl_bclosure bclosure; /* bytecompiled closure */
1172 struct ecl_cfun cfun; /* compiled function */
1173 struct ecl_cfunfixed cfunfixed; /* compiled function */
1174 struct ecl_cclosure cclosure; /* compiled closure */
1175 struct ecl_dummy d; /* dummy */
1176 struct ecl_instance instance; /* clos instance */
1177 #ifdef ECL_THREADS
1178 struct ecl_process process; /* process */
1179 struct ecl_lock lock; /* lock */
1180 struct ecl_rwlock rwlock; /* read/write lock */
1181 struct ecl_condition_variable condition_variable; /* condition-variable */
1182 struct ecl_semaphore semaphore; /* semaphore */
1183 struct ecl_barrier barrier; /* barrier */
1184 struct ecl_mailbox mailbox; /* mailbox */
1185 #endif
1186 struct ecl_codeblock cblock; /* codeblock */
1187 struct ecl_foreign foreign; /* user defined data type */
1188 struct ecl_stack_frame frame; /* stack frame */
1189 struct ecl_weak_pointer weak; /* weak pointers */
1190 #ifdef ECL_SSE2
1191 struct ecl_sse_pack sse;
1192 #endif
1193 };
1194
1195 /*
1196 Type_of.
1197 */
1198 #if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
1199 static inline cl_type ecl_t_of(cl_object o) {
1200 int i = ECL_IMMEDIATE(o);
1201 return (i? (cl_type)i : (cl_type)(o->d.t));
1202 }
1203 #else
1204 #define ecl_t_of(o) \
1205 ((cl_type)(ECL_IMMEDIATE(o) ? ECL_IMMEDIATE(o) : ((o)->d.t)))
1206 #endif
1207
1208 /*
1209 This is used to retrieve optional arguments
1210 */
1211 typedef struct {
1212 va_list args;
1213 cl_object *sp;
1214 int narg;
1215 } ecl_va_list[1];
1216
1217 #ifdef __cplusplus
1218 }
1219 #endif