| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifdef __cplusplus |
| 16 |
extern "C" { |
| 17 |
#endif |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#define TRUE 1 |
| 24 |
#define FALSE 0 |
| 25 |
|
| 26 |
typedef unsigned char byte; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
typedef enum { |
| 33 |
t_start = 0, |
| 34 |
t_list = 1, |
| 35 |
|
| 36 |
|
| 37 |
t_character = 2, |
| 38 |
t_fixnum = 3, |
| 39 |
t_bignum = 4, |
| 40 |
t_ratio, |
| 41 |
|
| 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, |
| 94 |
FREE = 127 |
| 95 |
} cl_type; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 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 |
|
| 109 |
|
| 110 |
|
| 111 |
#define OBJNULL ((cl_object)NULL) |
| 112 |
|
| 113 |
|
| 114 |
|
| 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 |
|
| 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 |
|
| 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; |
| 196 |
}; |
| 197 |
#define ecl_single_float(o) ((o)->SF.SFVAL) |
| 198 |
|
| 199 |
struct ecl_doublefloat { |
| 200 |
_ECL_HDR; |
| 201 |
double DFVAL; |
| 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; |
| 223 |
cl_object num; |
| 224 |
}; |
| 225 |
|
| 226 |
struct ecl_complex { |
| 227 |
_ECL_HDR; |
| 228 |
cl_object real; |
| 229 |
cl_object imag; |
| 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 { |
| 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); |
| 273 |
cl_object value; |
| 274 |
cl_object gfdef; |
| 275 |
cl_objectfn undef_entry; |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
cl_object macfun; |
| 280 |
cl_object sfdef; |
| 281 |
cl_object plist; |
| 282 |
cl_object name; |
| 283 |
cl_object cname; |
| 284 |
|
| 285 |
cl_object hpack; |
| 286 |
|
| 287 |
#ifdef ECL_THREADS |
| 288 |
cl_index binding; |
| 289 |
#endif |
| 290 |
}; |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 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; |
| 314 |
cl_object nicknames; |
| 315 |
cl_object local_nicknames; |
| 316 |
cl_object nicknamedby; |
| 317 |
cl_object shadowings; |
| 318 |
cl_object uses; |
| 319 |
cl_object usedby; |
| 320 |
cl_object internal; |
| 321 |
cl_object external; |
| 322 |
}; |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
enum { |
| 329 |
ECL_INTERNAL = 1, |
| 330 |
ECL_EXTERNAL, |
| 331 |
ECL_INHERITED |
| 332 |
}; |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 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; |
| 368 |
cl_object 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; |
| 384 |
cl_object cdr; |
| 385 |
}; |
| 386 |
#endif |
| 387 |
|
| 388 |
enum ecl_httest { |
| 389 |
ecl_htt_eq, |
| 390 |
ecl_htt_eql, |
| 391 |
ecl_htt_equal, |
| 392 |
ecl_htt_equalp, |
| 393 |
ecl_htt_pack, |
| 394 |
ecl_htt_generic |
| 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 { |
| 406 |
cl_object key; |
| 407 |
cl_object value; |
| 408 |
}; |
| 409 |
|
| 410 |
struct ecl_hashtable { |
| 411 |
_ECL_HDR2(test,weak); |
| 412 |
struct ecl_hashtable_entry *data; |
| 413 |
cl_object sync_lock; |
| 414 |
cl_object generic_test; |
| 415 |
cl_object generic_hash; |
| 416 |
cl_index entries; |
| 417 |
cl_index size; |
| 418 |
cl_index limit; |
| 419 |
cl_object rehash_size; |
| 420 |
cl_object threshold; |
| 421 |
double factor; |
| 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 |
|
| 426 |
|
| 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 { |
| 433 |
ecl_aet_object, |
| 434 |
ecl_aet_sf, |
| 435 |
ecl_aet_df, |
| 436 |
ecl_aet_lf, |
| 437 |
#ifdef ECL_COMPLEX_FLOAT |
| 438 |
ecl_aet_csf, |
| 439 |
ecl_aet_cdf, |
| 440 |
ecl_aet_clf, |
| 441 |
#endif |
| 442 |
ecl_aet_bit, |
| 443 |
ecl_aet_fix, |
| 444 |
ecl_aet_index, |
| 445 |
|
| 446 |
ecl_aet_b8, |
| 447 |
ecl_aet_i8, |
| 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, |
| 462 |
#endif |
| 463 |
ecl_aet_bc, |
| 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 { |
| 506 |
|
| 507 |
|
| 508 |
_ECL_HDR2(elttype,flags); |
| 509 |
cl_object displaced; |
| 510 |
cl_index dim; |
| 511 |
cl_index *dims; |
| 512 |
union ecl_array_data self; |
| 513 |
byte offset; |
| 514 |
byte rank; |
| 515 |
}; |
| 516 |
|
| 517 |
struct ecl_vector { |
| 518 |
|
| 519 |
|
| 520 |
_ECL_HDR2(elttype,flags); |
| 521 |
cl_object displaced; |
| 522 |
cl_index dim; |
| 523 |
cl_index fillp; |
| 524 |
|
| 525 |
union ecl_array_data self; |
| 526 |
byte offset; |
| 527 |
}; |
| 528 |
|
| 529 |
struct ecl_base_string { |
| 530 |
|
| 531 |
|
| 532 |
_ECL_HDR2(elttype,flags); |
| 533 |
cl_object displaced; |
| 534 |
cl_index dim; |
| 535 |
|
| 536 |
cl_index fillp; |
| 537 |
|
| 538 |
|
| 539 |
ecl_base_char *self; |
| 540 |
}; |
| 541 |
|
| 542 |
#ifdef ECL_UNICODE |
| 543 |
struct ecl_string { |
| 544 |
|
| 545 |
|
| 546 |
_ECL_HDR2(elttype,flags); |
| 547 |
cl_object displaced; |
| 548 |
cl_index dim; |
| 549 |
cl_index fillp; |
| 550 |
|
| 551 |
ecl_character *self; |
| 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 { |
| 563 |
ecl_smm_input, |
| 564 |
ecl_smm_input_file, |
| 565 |
ecl_smm_output, |
| 566 |
ecl_smm_output_file, |
| 567 |
ecl_smm_io, |
| 568 |
ecl_smm_io_file, |
| 569 |
ecl_smm_synonym, |
| 570 |
ecl_smm_broadcast, |
| 571 |
ecl_smm_concatenated, |
| 572 |
ecl_smm_two_way, |
| 573 |
ecl_smm_echo, |
| 574 |
ecl_smm_string_input, |
| 575 |
ecl_smm_string_output, |
| 576 |
ecl_smm_probe, |
| 577 |
#if defined(ECL_WSOCK) |
| 578 |
ecl_smm_input_wsock, |
| 579 |
ecl_smm_output_wsock, |
| 580 |
ecl_smm_io_wsock, |
| 581 |
#endif |
| 582 |
#if defined(ECL_MS_WINDOWS_HOST) |
| 583 |
ecl_smm_io_wcon, |
| 584 |
#endif |
| 585 |
ecl_smm_sequence_input, |
| 586 |
ecl_smm_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 |
|
| 649 |
ECL_STREAM_CR = 16, |
| 650 |
ECL_STREAM_LF = 32, |
| 651 |
ECL_STREAM_SIGNED_BYTES = 64, |
| 652 |
ECL_STREAM_LITTLE_ENDIAN = 128, |
| 653 |
|
| 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 |
|
| 659 |
ECL_STREAM_CLOSE_COMPONENTS = 4096, |
| 660 |
ECL_STREAM_USE_VECTOR_FILLP = 8192 |
| 661 |
}; |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
typedef ecl_character (*cl_eformat_decoder)(cl_object stream, unsigned char **buffer, unsigned char *buffer_end); |
| 668 |
|
| 669 |
|
| 670 |
typedef int (*cl_eformat_encoder)(cl_object stream, unsigned char *buffer, ecl_character c); |
| 671 |
|
| 672 |
|
| 673 |
|
| 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); |
| 684 |
|
| 685 |
struct ecl_file_ops *ops; |
| 686 |
union { |
| 687 |
FILE *stream; |
| 688 |
cl_fixnum descriptor; |
| 689 |
} file; |
| 690 |
cl_object object0; |
| 691 |
cl_object object1; |
| 692 |
cl_object last_byte; |
| 693 |
cl_fixnum last_char; |
| 694 |
cl_object byte_stack; |
| 695 |
cl_index column; |
| 696 |
cl_fixnum int0; |
| 697 |
cl_fixnum int1; |
| 698 |
cl_index byte_size; |
| 699 |
cl_fixnum last_op; |
| 700 |
char *buffer; |
| 701 |
unsigned char *byte_buffer; |
| 702 |
cl_object 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; |
| 709 |
ecl_character eof_char; |
| 710 |
}; |
| 711 |
|
| 712 |
struct ecl_random { |
| 713 |
_ECL_HDR; |
| 714 |
cl_object value; |
| 715 |
}; |
| 716 |
|
| 717 |
enum ecl_chattrib { |
| 718 |
cat_whitespace, |
| 719 |
cat_terminating, |
| 720 |
cat_non_terminating, |
| 721 |
cat_single_escape, |
| 722 |
cat_multiple_escape, |
| 723 |
cat_constituent |
| 724 |
}; |
| 725 |
|
| 726 |
struct ecl_readtable_entry { |
| 727 |
enum ecl_chattrib syntax_type; |
| 728 |
cl_object dispatch; |
| 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 { |
| 739 |
_ECL_HDR1(locked); |
| 740 |
enum ecl_readtable_case read_case; |
| 741 |
struct ecl_readtable_entry *table; |
| 742 |
#ifdef ECL_UNICODE |
| 743 |
cl_object hash; |
| 744 |
#endif |
| 745 |
}; |
| 746 |
|
| 747 |
struct ecl_pathname { |
| 748 |
_ECL_HDR1(logical); |
| 749 |
cl_object host; |
| 750 |
cl_object device; |
| 751 |
cl_object directory; |
| 752 |
cl_object name; |
| 753 |
cl_object type; |
| 754 |
cl_object version; |
| 755 |
}; |
| 756 |
|
| 757 |
struct ecl_codeblock { |
| 758 |
_ECL_HDR2(self_destruct,locked); |
| 759 |
|
| 760 |
void *handle; |
| 761 |
void *entry; |
| 762 |
cl_object *data; |
| 763 |
int data_size; |
| 764 |
cl_object *temp_data; |
| 765 |
int temp_data_size; |
| 766 |
const cl_object *data_text; |
| 767 |
cl_object next; |
| 768 |
cl_object name; |
| 769 |
cl_object links; |
| 770 |
cl_index cfuns_size; |
| 771 |
const struct ecl_cfunfixed *cfuns; |
| 772 |
cl_object source; |
| 773 |
cl_object refs; |
| 774 |
cl_object error; |
| 775 |
}; |
| 776 |
|
| 777 |
struct ecl_bytecodes { |
| 778 |
_ECL_HDR; |
| 779 |
cl_object name; |
| 780 |
cl_object definition; |
| 781 |
cl_objectfn entry; |
| 782 |
|
| 783 |
cl_index code_size; |
| 784 |
char *code; |
| 785 |
cl_object data; |
| 786 |
cl_object flex; |
| 787 |
cl_object nlcl; |
| 788 |
cl_object file; |
| 789 |
cl_object file_position; |
| 790 |
}; |
| 791 |
|
| 792 |
struct ecl_bclosure { |
| 793 |
_ECL_HDR; |
| 794 |
cl_object code; |
| 795 |
cl_object lex; |
| 796 |
cl_objectfn entry; |
| 797 |
}; |
| 798 |
|
| 799 |
struct ecl_cfun { |
| 800 |
_ECL_HDR1(narg); |
| 801 |
cl_object name; |
| 802 |
cl_object block; |
| 803 |
cl_objectfn entry; |
| 804 |
#ifdef ECL_C_COMPATIBLE_VARIADIC_DISPATCH |
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
cl_objectfn entry_variadic; |
| 813 |
#endif |
| 814 |
cl_object file; |
| 815 |
cl_object file_position; |
| 816 |
}; |
| 817 |
|
| 818 |
struct ecl_cfunfixed { |
| 819 |
_ECL_HDR1(narg); |
| 820 |
cl_object name; |
| 821 |
cl_object block; |
| 822 |
cl_objectfn entry; |
| 823 |
|
| 824 |
cl_objectfn_fixed entry_fixed; |
| 825 |
cl_object file; |
| 826 |
cl_object file_position; |
| 827 |
}; |
| 828 |
|
| 829 |
struct ecl_cclosure { |
| 830 |
_ECL_HDR1(narg); |
| 831 |
cl_object env; |
| 832 |
cl_object block; |
| 833 |
cl_objectfn entry; |
| 834 |
|
| 835 |
#ifdef ECL_C_COMPATIBLE_VARIADIC_DISPATCH |
| 836 |
cl_objectfn entry_variadic; |
| 837 |
#endif |
| 838 |
cl_object file; |
| 839 |
cl_object file_position; |
| 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 { |
| 935 |
_ECL_HDR; |
| 936 |
cl_object tag; |
| 937 |
cl_index size; |
| 938 |
char *data; |
| 939 |
}; |
| 940 |
|
| 941 |
struct ecl_stack_frame { |
| 942 |
_ECL_HDR1(opened); |
| 943 |
cl_index base; |
| 944 |
cl_index size; |
| 945 |
cl_index sp; |
| 946 |
struct cl_env_struct *env; |
| 947 |
}; |
| 948 |
|
| 949 |
struct ecl_weak_pointer { |
| 950 |
_ECL_HDR; |
| 951 |
cl_object value; |
| 952 |
}; |
| 953 |
#define ecl_weak_pointer(o) ((o)->weak.value) |
| 954 |
|
| 955 |
|
| 956 |
|
| 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 |
|
| 985 |
|
| 986 |
|
| 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; |
| 1011 |
ecl_cond_var_t exit_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; |
| 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 |
| 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 { |
| 1095 |
_ECL_HDR1(isgf); |
| 1096 |
cl_index length; |
| 1097 |
cl_object clas; |
| 1098 |
cl_objectfn entry; |
| 1099 |
cl_object slotds; |
| 1100 |
cl_object *slots; |
| 1101 |
cl_index stamp; |
| 1102 |
cl_index class_stamp; |
| 1103 |
}; |
| 1104 |
|
| 1105 |
#ifdef ECL_SSE2 |
| 1106 |
union ecl_sse_data { |
| 1107 |
|
| 1108 |
|
| 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 |
|
| 1141 |
|
| 1142 |
union cl_lispunion { |
| 1143 |
#ifndef ECL_SMALL_CONS |
| 1144 |
struct ecl_cons cons; |
| 1145 |
#endif |
| 1146 |
struct ecl_bignum big; |
| 1147 |
struct ecl_ratio ratio; |
| 1148 |
struct ecl_singlefloat SF; |
| 1149 |
struct ecl_doublefloat DF; |
| 1150 |
struct ecl_long_float longfloat; |
| 1151 |
struct ecl_complex gencomplex; |
| 1152 |
#ifdef ECL_COMPLEX_FLOAT |
| 1153 |
struct ecl_csfloat csfloat; |
| 1154 |
struct ecl_cdfloat cdfloat; |
| 1155 |
struct ecl_clfloat clfloat; |
| 1156 |
#endif |
| 1157 |
struct ecl_symbol symbol; |
| 1158 |
struct ecl_package pack; |
| 1159 |
struct ecl_hashtable hash; |
| 1160 |
struct ecl_array array; |
| 1161 |
struct ecl_vector vector; |
| 1162 |
struct ecl_base_string base_string; |
| 1163 |
#ifdef ECL_UNICODE |
| 1164 |
struct ecl_string string; |
| 1165 |
#endif |
| 1166 |
struct ecl_stream stream; |
| 1167 |
struct ecl_random random; |
| 1168 |
struct ecl_readtable readtable; |
| 1169 |
struct ecl_pathname pathname; |
| 1170 |
struct ecl_bytecodes bytecodes; |
| 1171 |
struct ecl_bclosure bclosure; |
| 1172 |
struct ecl_cfun cfun; |
| 1173 |
struct ecl_cfunfixed cfunfixed; |
| 1174 |
struct ecl_cclosure cclosure; |
| 1175 |
struct ecl_dummy d; |
| 1176 |
struct ecl_instance instance; |
| 1177 |
#ifdef ECL_THREADS |
| 1178 |
struct ecl_process process; |
| 1179 |
struct ecl_lock lock; |
| 1180 |
struct ecl_rwlock rwlock; |
| 1181 |
struct ecl_condition_variable condition_variable; |
| 1182 |
struct ecl_semaphore semaphore; |
| 1183 |
struct ecl_barrier barrier; |
| 1184 |
struct ecl_mailbox mailbox; |
| 1185 |
#endif |
| 1186 |
struct ecl_codeblock cblock; |
| 1187 |
struct ecl_foreign foreign; |
| 1188 |
struct ecl_stack_frame frame; |
| 1189 |
struct ecl_weak_pointer weak; |
| 1190 |
#ifdef ECL_SSE2 |
| 1191 |
struct ecl_sse_pack sse; |
| 1192 |
#endif |
| 1193 |
}; |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 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 |
|
| 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 |