external.h 121 KB
Newer Older
1
2
3
/* -*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*- */
/* vim: set filetype=c tabstop=8 shiftwidth=4 expandtab: */

4
5
6
#ifndef ECL_EXTERNAL_H
#define ECL_EXTERNAL_H

7
8
9
10
#ifdef __cplusplus
extern "C" {
#endif

11
#define _ECL_ARGS(x) x
12

13
14
15
16
/*
 * Per-thread data.
 */

17
typedef struct cl_env_struct *cl_env_ptr;
18
struct cl_env_struct {
Daniel Kochmański's avatar
Daniel Kochmański committed
19
20
        /* Flag for disabling interrupts while we call C library functions. */
        volatile int disable_interrupts;
21

Daniel Kochmański's avatar
Daniel Kochmański committed
22
23
24
        /* Array where values are returned by functions. */
        cl_index nvalues;
        cl_object values[ECL_MULTIPLE_VALUES_LIMIT];
25

26
27
28
        /* Environment for calling closures, CLOS generic functions, etc */
        cl_object function;

29
30
31
        /* Current stack frame */
        cl_object stack_frame;

Daniel Kochmański's avatar
Daniel Kochmański committed
32
33
34
35
36
37
38
39
        /* The four stacks in ECL. */

        /*
         * The lisp stack, which is used mainly for keeping the arguments of a
         * function before it is invoked, and also by the compiler and by the
         * reader when they are building some data structure.
         */
        cl_index stack_size;
40
        cl_index stack_limit_size;
Daniel Kochmański's avatar
Daniel Kochmański committed
41
42
43
44
45
46
47
        cl_object *stack;
        cl_object *stack_top;
        cl_object *stack_limit;

        /*
         * The BinDing Stack stores the bindings of special variables.
         */
48
49
50
#ifdef ECL_THREADS
        cl_index thread_local_bindings_size;
        cl_object *thread_local_bindings;
Daniel Kochmański's avatar
Daniel Kochmański committed
51
        cl_object bindings_array;
52
#endif
Daniel Kochmański's avatar
Daniel Kochmański committed
53
        cl_index bds_size;
54
        cl_index bds_limit_size;
Daniel Kochmański's avatar
Daniel Kochmański committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
        struct ecl_bds_frame *bds_org;
        struct ecl_bds_frame *bds_top;
        struct ecl_bds_frame *bds_limit;

        /*
         * The Invocation History Stack (IHS) keeps a list of the names of the
         * functions that are invoked, together with their lexical
         * environments.
         */
        struct ecl_ihs_frame *ihs_top;

        /*
         * The FRames Stack (FRS) is a list of frames or jump points, and it
         * is used by different high-level constructs (BLOCK, TAGBODY, CATCH...)
         * to set return points.
         */
        cl_index frs_size;
72
        cl_index frs_limit_size;
Daniel Kochmański's avatar
Daniel Kochmański committed
73
74
75
76
        struct ecl_frame *frs_org;
        struct ecl_frame *frs_top;
        struct ecl_frame *frs_limit;
        struct ecl_frame *nlj_fr;
77
        cl_index frame_id;
78

Daniel Kochmański's avatar
Daniel Kochmański committed
79
80
81
82
83
84
        /*
         * The following pointers to the C Stack are used to ensure that a
         * recursive function does not enter an infinite loop and exhausts all
         * memory. They will eventually disappear, because most operating
         * systems already take care of this.
         */
85
86
87
88
89
90
91
92
93
94
95
        cl_index cs_size;       /* current size */
        cl_index cs_limit_size; /* current size minus safety area */
        cl_index cs_max_size;   /* maximum possible size */
        char *cs_org;           /* origin address */
        char *cs_limit;         /* limit address; if the stack pointer
                                   goes beyond this value, a stack
                                   overflow will be signaled ... */
        char *cs_barrier;       /* ... but the area up to cs_barrier
                                   is still available to allow
                                   programs to recover from the
                                   stack overflow */
Daniel Kochmański's avatar
Daniel Kochmański committed
96
97

        /* Private variables used by different parts of ECL: */
98
        /* ... the reader and printer ... */
Daniel Kochmański's avatar
Daniel Kochmański committed
99
100
101
102
103
104
        cl_object string_pool;

        /* ... the compiler ... */
        struct cl_compiler_env *c_env;

        /* ... the formatter ... */
105
#if !defined(ECL_CMU_FORMAT)
Daniel Kochmański's avatar
Daniel Kochmański committed
106
        cl_object fmt_aux_stream;
107
#endif
Daniel Kochmański's avatar
Daniel Kochmański committed
108
109

        /* ... arithmetics ... */
110
        cl_object big_register[ECL_BIGNUM_REGISTER_NUMBER];
Daniel Kochmański's avatar
Daniel Kochmański committed
111
112

        cl_object own_process;
113
114
115
116
        /* The objects in this struct need to be writeable from a
           different thread, if environment is write-protected by
           mprotect. Hence they have to be allocated seperately. */
        struct ecl_interrupt_struct *interrupt_struct;
117
        void *default_sigmask;
118

Daniel Kochmański's avatar
Daniel Kochmański committed
119
120
121
122
123
124
        /* The following is a hash table for caching invocations of
           generic functions. In a multithreaded environment we must
           queue operations in which the hash is cleared from updated
           generic functions. */
        struct ecl_cache *method_cache;
        struct ecl_cache *slot_cache;
125

Daniel Kochmański's avatar
Daniel Kochmański committed
126
        /* foreign function interface */
127
128
#ifdef HAVE_LIBFFI
        cl_index ffi_args_limit;
Daniel Kochmański's avatar
Daniel Kochmański committed
129
        struct _ffi_type **ffi_types;
130
131
132
        union ecl_ffi_values *ffi_values;
        union ecl_ffi_values **ffi_values_ptrs;
#endif
133

134
135
        /* Floating point interrupts which are trapped */
        int trap_fpe_bits;
136

137
138
        /* List of packages interned when loading a FASL but which have
         * to be explicitely created by the compiled code itself. */
Daniel Kochmański's avatar
Daniel Kochmański committed
139
        cl_object packages_to_be_created;
140
        cl_object packages_to_be_created_p;
141

Daniel Kochmański's avatar
Daniel Kochmański committed
142
143
        /* Segmentation fault address */
        void *fault_address;
144
145

#ifdef ECL_THREADS
Daniel Kochmański's avatar
Daniel Kochmański committed
146
        int cleanup;
147
#endif
jjgarcia's avatar
jjgarcia committed
148
149
};

150
151
152
153
154
155
struct ecl_interrupt_struct {
        cl_object pending_interrupt;
        cl_object signal_queue;
        cl_object signal_queue_spinlock;
};

156
157
158
#ifndef __GNUC__
#define __attribute__(x)
#endif
jjgarcia's avatar
jjgarcia committed
159
#if defined(ECL_THREADS)
160
161
# define cl_env (*ecl_process_env())
  extern ECL_API cl_env_ptr ecl_process_env(void) __attribute__((const));
162
  extern ECL_API cl_env_ptr ecl_process_env_unsafe(void);
163
#else
164
# define cl_env (*cl_env_p)
165
# define ecl_process_env() cl_env_p
166
# define ecl_process_env_unsafe() cl_env_p
167
  extern ECL_API cl_env_ptr cl_env_p;
168
169
170
#endif

/*
171
 * Per-process data. Modify main.d accordingly.
172
173
174
 */

struct cl_core_struct {
Daniel Kochmański's avatar
Daniel Kochmański committed
175
176
177
178
179
        cl_object packages;
        cl_object lisp_package;
        cl_object user_package;
        cl_object keyword_package;
        cl_object system_package;
180
        cl_object ext_package;
Daniel Kochmański's avatar
Daniel Kochmański committed
181
        cl_object clos_package;
jgarcia's avatar
jgarcia committed
182
# ifdef ECL_CLOS_STREAMS
Daniel Kochmański's avatar
Daniel Kochmański committed
183
        cl_object gray_package;
jgarcia's avatar
jgarcia committed
184
# endif
Daniel Kochmański's avatar
Daniel Kochmański committed
185
        cl_object mp_package;
186
        cl_object c_package;
Daniel Kochmański's avatar
Daniel Kochmański committed
187
        cl_object ffi_package;
188

Daniel Kochmański's avatar
Daniel Kochmański committed
189
        cl_object pathname_translations;
190
        cl_object library_pathname;
191

Daniel Kochmański's avatar
Daniel Kochmański committed
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
        cl_object terminal_io;
        cl_object null_stream;
        cl_object standard_input;
        cl_object standard_output;
        cl_object error_output;
        cl_object standard_readtable;
        cl_object dispatch_reader;
        cl_object default_dispatch_macro;

        cl_object char_names;
        cl_object null_string;

        cl_object plus_half;
        cl_object minus_half;
        cl_object imag_unit;
        cl_object minus_imag_unit;
        cl_object imag_two;
        cl_object singlefloat_zero;
        cl_object doublefloat_zero;
        cl_object singlefloat_minus_zero;
        cl_object doublefloat_minus_zero;
        cl_object longfloat_zero;
        cl_object longfloat_minus_zero;
215

Daniel Kochmański's avatar
Daniel Kochmański committed
216
217
218
        cl_object gensym_prefix;
        cl_object gentemp_prefix;
        cl_object gentemp_counter;
219

Daniel Kochmański's avatar
Daniel Kochmański committed
220
        cl_object Jan1st1970UT;
221

Daniel Kochmański's avatar
Daniel Kochmański committed
222
223
        cl_object system_properties;
        cl_object setf_definitions;
224
225

#ifdef ECL_THREADS
Daniel Kochmański's avatar
Daniel Kochmański committed
226
227
228
        cl_object processes;
        cl_object processes_spinlock;
        cl_object global_lock;
229
        cl_object error_lock;
230
        cl_object global_env_lock;
231
#endif
Daniel Kochmański's avatar
Daniel Kochmański committed
232
        cl_object libraries;
233

234
        size_t max_heap_size;
Daniel Kochmański's avatar
Daniel Kochmański committed
235
236
237
238
        cl_object bytes_consed;
        cl_object gc_counter;
        bool gc_stats;
        int path_max;
239
240
#ifdef GBC_BOEHM
        char *safety_region;
241
#endif
242
243
        void *default_sigmask;
        cl_index default_sigmask_bytes;
244
245
246
247
248

#ifdef ECL_THREADS
        cl_index last_var_index;
        cl_object reused_indices;
#endif
Daniel Kochmański's avatar
Daniel Kochmański committed
249
        cl_object slash;
250

Daniel Kochmański's avatar
Daniel Kochmański committed
251
        cl_object compiler_dispatch;
252
253
254

        cl_object rehash_size;
        cl_object rehash_threshold;
255

Daniel Kochmański's avatar
Daniel Kochmański committed
256
        cl_object known_signals;
jjgarcia's avatar
jjgarcia committed
257
258
};

259
extern ECL_API struct cl_core_struct cl_core;
260

261
/* alloc.c / alloc_2.c */
jjgarcia's avatar
jjgarcia committed
262

263
264
extern ECL_API cl_object ecl_alloc_object(cl_type t);
extern ECL_API cl_object ecl_alloc_instance(cl_index slots);
265
extern ECL_API cl_object ecl_cons(cl_object a, cl_object d);
266
extern ECL_API cl_object ecl_list1(cl_object a);
267
#ifdef GBC_BOEHM
268
extern ECL_API cl_object si_gc(cl_narg narg, ...);
269
270
extern ECL_API cl_object si_gc_dump(void);
extern ECL_API cl_object si_gc_stats(cl_object enable);
Samium Gromoff's avatar
Samium Gromoff committed
271
272
extern ECL_API void *ecl_alloc_unprotected(cl_index n);
extern ECL_API void *ecl_alloc_atomic_unprotected(cl_index n);
273
274
extern ECL_API void *ecl_alloc(cl_index n);
extern ECL_API void *ecl_alloc_atomic(cl_index n);
275
276
extern ECL_API void *ecl_alloc_uncollectable(size_t size);
extern ECL_API void ecl_free_uncollectable(void *);
277
278
279
extern ECL_API void ecl_dealloc(void *);
#define ecl_alloc_align(s,d) ecl_alloc(s)
#define ecl_alloc_atomic_align(s,d) ecl_alloc_atomic(s)
280
#define ecl_register_static_root(x) ecl_register_root(x)
281
extern ECL_API cl_object ecl_alloc_compact_object(cl_type t, cl_index extra_space);
282
283
284

extern ECL_API cl_object si_make_weak_pointer(cl_object o);
extern ECL_API cl_object si_weak_pointer_value(cl_object o);
285
#else
286
extern ECL_API cl_object si_allocate _ECL_ARGS((cl_narg narg, cl_object type, cl_object qty, ...));
287
288
extern ECL_API cl_object si_maximum_allocatable_pages _ECL_ARGS((cl_narg narg, cl_object type, ...));
extern ECL_API cl_object si_allocated_pages _ECL_ARGS((cl_narg narg, cl_object type, ...));
289
extern ECL_API cl_object si_alloc_contpage _ECL_ARGS((cl_narg narg, cl_object qty, ...));
290
291
extern ECL_API cl_object si_allocated_contiguous_pages _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_maximum_contiguous_pages _ECL_ARGS((cl_narg narg, ...));
292
extern ECL_API cl_object si_allocate_contiguous_pages _ECL_ARGS((cl_narg narg, cl_object qty, ...));
293
294
extern ECL_API cl_object si_get_hole_size _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_set_hole_size _ECL_ARGS((cl_narg narg, cl_object size, ...));
295
extern ECL_API cl_object si_ignore_maximum_pages _ECL_ARGS((cl_narg narg, ...));
296
297
extern ECL_API void *ecl_alloc(cl_index n);
extern ECL_API void *ecl_alloc_align(cl_index size, cl_index align);
298
299
extern ECL_API void *ecl_alloc_uncollectable(size_t size);
extern ECL_API void ecl_free_uncollectable(void *);
300
301
302
extern ECL_API void ecl_dealloc(void *p);
#define ecl_alloc_atomic(x) ecl_alloc(x)
#define ecl_alloc_atomic_align(x,s) ecl_alloc_align(x,s)
303
#define ecl_register_static_root(x) ecl_register_root(x);
jjgarcia's avatar
jjgarcia committed
304
305
306
#endif /* GBC_BOEHM */

/* all_symbols */
307

308
extern ECL_API cl_object si_mangle_name _ECL_ARGS((cl_narg narg, cl_object symbol, ...));
309

310
typedef union {
Daniel Kochmański's avatar
Daniel Kochmański committed
311
312
        struct {
                const char *name;
313
                const char *translation;
Daniel Kochmański's avatar
Daniel Kochmański committed
314
                void *fun;
315
316
                int narg;
                int type;
Daniel Kochmański's avatar
Daniel Kochmański committed
317
318
319
                cl_object value;
        } init;
        struct ecl_symbol data;
320
} cl_symbol_initializer;
321
322
extern ECL_API cl_symbol_initializer cl_symbols[];
extern ECL_API cl_index cl_num_symbols_in_core;
jjgarcia's avatar
jjgarcia committed
323

324
325
#define ECL_SYM(name,code) ((cl_object)(cl_symbols+(code)))

jjgarcia's avatar
jjgarcia committed
326
327
/* apply.c */

328
329
extern ECL_API cl_object APPLY_fixed(cl_narg n, cl_object (*f)(), cl_object *x);
extern ECL_API cl_object APPLY(cl_narg n, cl_objectfn, cl_object *x);
jjgarcia's avatar
jjgarcia committed
330
331
332
333


/* array.c */

334
335
336
extern ECL_API cl_object cl_row_major_aref(cl_object x, cl_object i);
extern ECL_API cl_object si_row_major_aset(cl_object x, cl_object i, cl_object v);
extern ECL_API cl_object si_make_vector(cl_object etype, cl_object dim, cl_object adj, cl_object fillp, cl_object displ, cl_object disploff);
337
338
339
340

/* for open-coding the access while preserving the bounds and type check: */
extern ECL_API void *ecl_row_major_ptr(cl_object arr, cl_index index, cl_index bytes);

341
342
343
344
345
346
extern ECL_API cl_object cl_array_element_type(cl_object a);
extern ECL_API cl_object cl_array_rank(cl_object a);
extern ECL_API cl_object cl_array_dimension(cl_object a, cl_object index);
extern ECL_API cl_object cl_array_total_size(cl_object a);
extern ECL_API cl_object cl_adjustable_array_p(cl_object a);
extern ECL_API cl_object cl_array_displacement(cl_object a);
347
extern ECL_API cl_object si_array_raw_data(cl_object array);
348
extern ECL_API cl_object si_array_element_type_byte_size(cl_object type);
349
350
351
352
353
354
extern ECL_API cl_object cl_svref(cl_object x, cl_object index);
extern ECL_API cl_object si_svset(cl_object x, cl_object index, cl_object v);
extern ECL_API cl_object cl_array_has_fill_pointer_p(cl_object a);
extern ECL_API cl_object cl_fill_pointer(cl_object a);
extern ECL_API cl_object si_fill_pointer_set(cl_object a, cl_object fp);
extern ECL_API cl_object si_replace_array(cl_object old_obj, cl_object new_obj);
355
356
extern ECL_API cl_object cl_aref _ECL_ARGS((cl_narg narg, cl_object x, ...));
extern ECL_API cl_object si_aset _ECL_ARGS((cl_narg narg, cl_object x, ...));
357
extern ECL_API cl_object si_make_pure_array(cl_object etype, cl_object dims, cl_object adj, cl_object fillp, cl_object displ, cl_object disploff);
358
extern ECL_API cl_object si_copy_subarray(cl_object dest, cl_object start0, cl_object orig, cl_object start1, cl_object length);
359
extern ECL_API cl_object si_fill_array_with_elt(cl_object array, cl_object elt, cl_object start, cl_object end);
360

361
extern ECL_API void FEwrong_dimensions(cl_object a, cl_index rank) ecl_attr_noreturn;
362
extern ECL_API cl_index ecl_to_index(cl_object n);
363
extern ECL_API cl_index ecl_array_dimension(cl_object x, cl_index n);
364
extern ECL_API cl_index ecl_array_rank(cl_object x);
365
366
extern ECL_API cl_object ecl_aref_unsafe(cl_object x, cl_index index);
extern ECL_API cl_object ecl_aset_unsafe(cl_object x, cl_index index, cl_object value);
367
368
369
370
371
extern ECL_API cl_object ecl_aref(cl_object x, cl_index index);
extern ECL_API cl_object ecl_aref1(cl_object v, cl_index index);
extern ECL_API cl_object ecl_aset(cl_object x, cl_index index, cl_object value);
extern ECL_API cl_object ecl_aset1(cl_object v, cl_index index, cl_object val);
extern ECL_API void ecl_array_allocself(cl_object x);
372
extern ECL_API cl_object ecl_alloc_simple_vector(cl_index l, cl_elttype aet);
373
374
375
376
377
extern ECL_API cl_elttype ecl_array_elttype(cl_object x);
extern ECL_API cl_elttype ecl_symbol_to_elttype(cl_object x);
extern ECL_API cl_object ecl_elttype_to_symbol(cl_elttype aet);
extern ECL_API void ecl_copy_subarray(cl_object dest, cl_index i0, cl_object orig, cl_index i1, cl_index l);
extern ECL_API void ecl_reverse_subarray(cl_object dest, cl_index i0, cl_index i1);
jjgarcia's avatar
jjgarcia committed
378

379
#ifdef ECL_THREADS
380
extern ECL_API cl_object mp_compare_and_swap_svref(cl_object x, cl_object index, cl_object old_val, cl_object new_val);
381
382
extern ECL_API cl_object mp_atomic_incf_svref(cl_object x, cl_object index, cl_object increment);
#endif
jjgarcia's avatar
jjgarcia committed
383
384
385

/* assignment.c */

386
387
388
extern ECL_API cl_object cl_set(cl_object var, cl_object val);
extern ECL_API cl_object cl_makunbound(cl_object sym);
extern ECL_API cl_object cl_fmakunbound(cl_object sym);
389
extern ECL_API cl_object si_fset _ECL_ARGS((cl_narg narg, cl_object fun, cl_object def, ...));
390
391
392
extern ECL_API cl_object si_get_sysprop(cl_object sym, cl_object prop);
extern ECL_API cl_object si_put_sysprop(cl_object sym, cl_object prop, cl_object value);
extern ECL_API cl_object si_rem_sysprop(cl_object sym, cl_object prop);
393
394
extern ECL_API cl_object ecl_setf_definition(cl_object fname, cl_object createp);
extern ECL_API cl_object si_setf_definition(cl_object fname, cl_object createp);
395

396
extern ECL_API void ecl_clear_compiler_properties(cl_object sym);
jjgarcia's avatar
jjgarcia committed
397

398
#ifdef ECL_THREADS
399
extern ECL_API cl_object mp_compare_and_swap_symbol_value(cl_object x, cl_object old_val, cl_object new_val);
400
401
402
extern ECL_API cl_object mp_atomic_incf_symbol_value(cl_object x, cl_object increment);
#endif

jjgarcia's avatar
jjgarcia committed
403
404
/* big.c */

405
/* Note: Needs to be adapted if ECL_BIGNUM_REGISTER_NUMBER changes */
Daniel Kochmański's avatar
Daniel Kochmański committed
406
407
408
#define _ecl_big_register0()    ecl_process_env()->big_register[0]
#define _ecl_big_register1()    ecl_process_env()->big_register[1]
#define _ecl_big_register2()    ecl_process_env()->big_register[2]
409
extern ECL_API cl_object _ecl_fix_times_fix(cl_fixnum x, cl_fixnum y);
410
411
extern ECL_API cl_object _ecl_big_register_copy(cl_object x);
extern ECL_API cl_object _ecl_big_register_normalize(cl_object x);
412
413
414
415
416
417
extern ECL_API cl_object _ecl_big_times_fix(cl_object x, cl_fixnum y);
extern ECL_API cl_object _ecl_big_times_big(cl_object x, cl_object y);
extern ECL_API cl_object _ecl_big_plus_fix(cl_object x, cl_fixnum y);
extern ECL_API cl_object _ecl_big_plus_big(cl_object x, cl_object y);
extern ECL_API cl_object _ecl_fix_minus_big(cl_fixnum x, cl_object y);
extern ECL_API cl_object _ecl_big_minus_big(cl_object x, cl_object y);
418
419
420
extern ECL_API cl_object _ecl_fix_divided_by_big(cl_fixnum x, cl_object y);
extern ECL_API cl_object _ecl_big_divided_by_fix(cl_object x, cl_fixnum y);
extern ECL_API cl_object _ecl_big_divided_by_big(cl_object x, cl_object y);
421
extern ECL_API cl_object _ecl_big_gcd(cl_object x, cl_object y);
422
423
extern ECL_API cl_object _ecl_big_ceiling(cl_object x, cl_object y, cl_object *r);
extern ECL_API cl_object _ecl_big_floor(cl_object x, cl_object y, cl_object *r);
424
extern ECL_API cl_object _ecl_big_negate(cl_object x);
425
extern ECL_API void _ecl_big_register_free(cl_object x);
jjgarcia's avatar
jjgarcia committed
426
427
428

/* cfun.c */

429
430
431
extern ECL_API cl_object si_compiled_function_name(cl_object fun);
extern ECL_API cl_object si_compiled_function_block(cl_object fun);
extern ECL_API cl_object cl_function_lambda_expression(cl_object fun);
432
extern ECL_API cl_object si_compiled_function_file(cl_object fun);
433

434
extern ECL_API cl_object ecl_make_cfun(cl_objectfn_fixed c_function, cl_object name, cl_object block, int narg);
435
436
extern ECL_API cl_object ecl_make_cfun_va(cl_objectfn c_function, cl_object name, cl_object block, int narg_fixed);
extern ECL_API cl_object ecl_make_cclosure_va(cl_objectfn c_function, cl_object env, cl_object block, int narg_fixed);
437
438
extern ECL_API void ecl_def_c_function(cl_object sym, cl_objectfn_fixed c_function, int narg);
extern ECL_API void ecl_def_c_macro(cl_object sym, cl_objectfn_fixed c_function, int narg);
439
440
extern ECL_API void ecl_def_c_macro_va(cl_object sym, cl_objectfn c_function, int narg_fixed);
extern ECL_API void ecl_def_c_function_va(cl_object sym, cl_objectfn c_function, int narg_fixed);
441
extern ECL_API void ecl_set_function_source_file_info(cl_object fun, cl_object source, cl_object position);
442
443
extern ECL_API void ecl_cmp_defmacro(cl_object data);
extern ECL_API void ecl_cmp_defun(cl_object data);
jjgarcia's avatar
jjgarcia committed
444
445
446
447


/* character.c */

448
449
450
451
452
453
454
455
456
457
458
459
460
461
extern ECL_API cl_object cl_digit_char_p _ECL_ARGS((cl_narg narg, cl_object c, ...));
extern ECL_API cl_object cl_charE _ECL_ARGS((cl_narg narg, cl_object c, ...));
extern ECL_API cl_object cl_charNE _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_charL _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_charG _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_charLE _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_charGE _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_char_equal _ECL_ARGS((cl_narg narg, cl_object c, ...));
extern ECL_API cl_object cl_char_not_equal _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_char_lessp _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_char_greaterp _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_char_not_greaterp _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_char_not_lessp _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_digit_char _ECL_ARGS((cl_narg narg, cl_object w, ...));
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

extern ECL_API cl_object cl_alpha_char_p(cl_object c);
extern ECL_API cl_object cl_alphanumericp(cl_object c);
extern ECL_API cl_object cl_both_case_p(cl_object c);
extern ECL_API cl_object cl_char_code(cl_object c);
extern ECL_API cl_object cl_char_downcase(cl_object c);
extern ECL_API cl_object cl_char_int(cl_object c);
extern ECL_API cl_object cl_char_name(cl_object c);
extern ECL_API cl_object cl_char_upcase(cl_object c);
extern ECL_API cl_object cl_character(cl_object x);
extern ECL_API cl_object cl_code_char(cl_object c);
extern ECL_API cl_object cl_graphic_char_p(cl_object c);
extern ECL_API cl_object cl_lower_case_p(cl_object c);
extern ECL_API cl_object cl_name_char(cl_object s);
extern ECL_API cl_object cl_standard_char_p(cl_object c);
extern ECL_API cl_object cl_upper_case_p(cl_object c);
478
extern ECL_API int ecl_string_case(cl_object s);
479

480
481
482
483
484
485
486
487
488
489
extern ECL_API bool ecl_alpha_char_p(ecl_character c);
extern ECL_API bool ecl_alphanumericp(ecl_character c);
extern ECL_API bool ecl_both_case_p(ecl_character c);
extern ECL_API ecl_character ecl_char_downcase(ecl_character c);
extern ECL_API ecl_character ecl_char_upcase(ecl_character c);
extern ECL_API bool ecl_graphic_char_p(ecl_character c);
extern ECL_API bool ecl_lower_case_p(ecl_character c);
extern ECL_API bool ecl_standard_char_p(ecl_character c);
extern ECL_API bool ecl_base_char_p(ecl_character c);
extern ECL_API bool ecl_upper_case_p(ecl_character c);
490
491

extern ECL_API int ecl_base_string_case(cl_object s);
492
493
494
extern ECL_API ecl_character ecl_char_code(cl_object c);
extern ECL_API ecl_base_char ecl_base_char_code(cl_object c);
extern ECL_API int ecl_digitp(ecl_character i, int r);
495
496
497
498
499
extern ECL_API bool ecl_char_eq(cl_object x, cl_object y);
extern ECL_API int ecl_char_cmp(cl_object x, cl_object y);
extern ECL_API bool ecl_char_equal(cl_object x, cl_object y);
extern ECL_API int ecl_char_compare(cl_object x, cl_object y);
extern ECL_API short ecl_digit_char(cl_fixnum w, cl_fixnum r);
jjgarcia's avatar
jjgarcia committed
500
501
502

/* clos.c */

503
extern ECL_API cl_object cl_find_class _ECL_ARGS((cl_narg narg, cl_object name, ...));
504
extern ECL_API cl_object cl_class_of(cl_object x);
jjgarcia's avatar
jjgarcia committed
505
506
507

/* cmpaux.c */

508
509
510
511
512
513
514
515
516
extern ECL_API cl_object si_specialp(cl_object sym);

extern ECL_API cl_fixnum ecl_ifloor(cl_fixnum x, cl_fixnum y);
extern ECL_API cl_fixnum ecl_imod(cl_fixnum x, cl_fixnum y);
extern ECL_API char ecl_to_char(cl_object x);
extern ECL_API cl_fixnum ecl_to_fixnum(cl_object x);
extern ECL_API cl_index ecl_to_unsigned_integer(cl_object x);
extern ECL_API int ecl_aref_bv(cl_object x, cl_index index);
extern ECL_API int ecl_aset_bv(cl_object x, cl_index index, int value);
517
518
519
extern ECL_API void cl_throw(cl_object tag) /*ecl_attr_noreturn*/;
extern ECL_API void cl_return_from(cl_object block_id, cl_object block_name) /*ecl_attr_noreturn*/;
extern ECL_API void cl_go(cl_object tag_id, cl_object label) /*ecl_attr_noreturn*/;
520
521
extern ECL_API void cl_parse_key(ecl_va_list args, int nkey, cl_object *keys, cl_object *vars, cl_object *rest, bool allow_other_keys);
extern ECL_API cl_object cl_grab_rest_args(ecl_va_list args);
522

jjgarcia's avatar
jjgarcia committed
523
524
/* compiler.c */

525
extern ECL_API cl_object si_macrolet_function(cl_object form, cl_object env);
526
extern ECL_API cl_object si_need_to_make_load_form_p(cl_object object);
527
528
529
530
531
extern ECL_API cl_object si_process_lambda_list(cl_object lambda_list, cl_object context);
extern ECL_API cl_object si_process_lambda(cl_object lambda);
extern ECL_API cl_object si_make_lambda(cl_object name, cl_object body);
extern ECL_API cl_object si_function_block_name(cl_object name);
extern ECL_API cl_object si_valid_function_name_p(cl_object name);
532
extern ECL_API cl_object si_process_declarations _ECL_ARGS((cl_narg narg, cl_object body, ...));
533

534
535
extern ECL_API cl_object si_bc_compile_from_stream (cl_object input);

536
extern ECL_API cl_object si_eval_with_env _ECL_ARGS((cl_narg narg, cl_object form, ...));
jjgarcia's avatar
jjgarcia committed
537
538
539

/* interpreter.c */

540
extern ECL_API cl_object si_interpreter_stack _ECL_ARGS((cl_narg narg, ...));
541
extern ECL_API cl_object ecl_stack_frame_open(cl_env_ptr env, cl_object f, cl_index size);
542
543
544
extern ECL_API void ecl_stack_frame_push(cl_object f, cl_object o);
extern ECL_API void ecl_stack_frame_push_values(cl_object f);
extern ECL_API cl_object ecl_stack_frame_pop_values(cl_object f);
545
extern ECL_API void ecl_stack_frame_close(cl_object f);
jgarcia's avatar
jgarcia committed
546
#define si_apply_from_stack_frame ecl_apply_from_stack_frame
547

548
549
extern ECL_API void FEstack_underflow(void) ecl_attr_noreturn;
extern ECL_API void FEstack_advance(void) ecl_attr_noreturn;
550
551
extern ECL_API cl_object *ecl_stack_grow(cl_env_ptr env);
extern ECL_API cl_object *ecl_stack_set_size(cl_env_ptr env, cl_index new_size);
552
553
extern ECL_API cl_index ecl_stack_push_values(cl_env_ptr env);
extern ECL_API void ecl_stack_pop_values(cl_env_ptr env, cl_index n);
554
extern ECL_API cl_object ecl_interpret(cl_object frame, cl_object env, cl_object bytecodes);
555
556
extern ECL_API cl_object _ecl_bytecodes_dispatch(cl_narg narg, ...);
extern ECL_API cl_object _ecl_bclosure_dispatch(cl_narg narg, ...);
jjgarcia's avatar
jjgarcia committed
557

558
559
/* disassembler.c */

560
561
extern ECL_API cl_object si_bc_disassemble(cl_object v);
extern ECL_API cl_object si_bc_split(cl_object v);
562
extern ECL_API cl_object si_bc_join(cl_object lex, cl_object code, cl_object data, cl_object name);
jjgarcia's avatar
jjgarcia committed
563
564
565

/* error.c */

566
567
extern ECL_API cl_object cl_error _ECL_ARGS((cl_narg narg, cl_object eformat, ...)) ecl_attr_noreturn;
extern ECL_API cl_object cl_cerror _ECL_ARGS((cl_narg narg, cl_object cformat, cl_object eformat, ...));
568

569
extern ECL_API void ecl_internal_error(const char *s) ecl_attr_noreturn;
570
571
572
#ifdef ECL_THREADS
extern ECL_API void ecl_thread_internal_error(const char *s) ecl_attr_noreturn;
#endif
573
extern ECL_API void ecl_unrecoverable_error(cl_env_ptr the_env, const char *message) ecl_attr_noreturn;
574
575
576
577
extern ECL_API void ecl_cs_overflow(void) /*ecl_attr_noreturn*/;
extern ECL_API void FEprogram_error(const char *s, int narg, ...) ecl_attr_noreturn;
extern ECL_API void FEcontrol_error(const char *s, int narg, ...) ecl_attr_noreturn;
extern ECL_API void FEreader_error(const char *s, cl_object stream, int narg, ...) ecl_attr_noreturn;
jjgarcia's avatar
jjgarcia committed
578
#define FEparse_error FEreader_error
579
580
581
582
583
extern ECL_API void FEerror(const char *s, int narg, ...) ecl_attr_noreturn;
extern ECL_API void FEcannot_open(cl_object fn) ecl_attr_noreturn;
extern ECL_API void FEend_of_file(cl_object strm) ecl_attr_noreturn;
extern ECL_API void FEclosed_stream(cl_object strm) ecl_attr_noreturn;
extern ECL_API void FEwrong_type_argument(cl_object type, cl_object value) ecl_attr_noreturn;
584
extern ECL_API void FEwrong_type_only_arg(cl_object function, cl_object type, cl_object value) ecl_attr_noreturn;
585
extern ECL_API void FEwrong_type_nth_arg(cl_object function, cl_narg narg, cl_object value, cl_object type) ecl_attr_noreturn;
586
extern ECL_API void FEwrong_type_key_arg(cl_object function, cl_object keyo, cl_object type, cl_object value) ecl_attr_noreturn;
587
588
extern ECL_API void FEwrong_num_arguments(cl_object fun) ecl_attr_noreturn;
extern ECL_API void FEwrong_num_arguments_anonym(void) ecl_attr_noreturn;
589
extern ECL_API void FEwrong_index(cl_object function, cl_object a, int which, cl_object ndx, cl_index nonincl_limit) ecl_attr_noreturn;
590
591
592
extern ECL_API void FEunbound_variable(cl_object sym) ecl_attr_noreturn;
extern ECL_API void FEinvalid_macro_call(cl_object obj) ecl_attr_noreturn;
extern ECL_API void FEinvalid_variable(const char *s, cl_object obj) ecl_attr_noreturn;
593
extern ECL_API void FEillegal_variable_name(cl_object) ecl_attr_noreturn;
594
extern ECL_API void FEassignment_to_constant(cl_object v) ecl_attr_noreturn;
595
extern ECL_API void FEbinding_a_constant(cl_object v) ecl_attr_noreturn;
596
597
598
extern ECL_API void FEundefined_function(cl_object fname) ecl_attr_noreturn;
extern ECL_API void FEinvalid_function(cl_object obj) ecl_attr_noreturn;
extern ECL_API void FEinvalid_function_name(cl_object obj) ecl_attr_noreturn;
599
extern ECL_API void FEprint_not_readable(cl_object obj) ecl_attr_noreturn;
600
extern ECL_API void FEtimeout() ecl_attr_noreturn;
601
extern ECL_API cl_object CEerror(cl_object c, const char *err_str, int narg, ...);
602
extern ECL_API void FElibc_error(const char *msg, int narg, ...) ecl_attr_noreturn;
603
#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin)
604
extern ECL_API void FEwin32_error(const char *msg, int narg, ...) ecl_attr_noreturn;
605
#endif
606
607
extern ECL_API cl_object si_signal_type_error(cl_object value, cl_object type) ecl_attr_noreturn;

jjgarcia's avatar
jjgarcia committed
608
609
610

/* eval.c */

611
612
613
extern ECL_API cl_object cl_funcall _ECL_ARGS((cl_narg narg, cl_object fun, ...));
extern ECL_API cl_object cl_apply _ECL_ARGS((cl_narg narg, cl_object fun, cl_object arg, ...));
extern ECL_API cl_object si_safe_eval _ECL_ARGS((cl_narg narg, cl_object form, cl_object env, ...));
614
#define cl_safe_eval(form,env,value) si_safe_eval(3,form,env,value)
615
extern ECL_API cl_object *_ecl_va_sp(cl_narg narg);
616
617
extern ECL_API cl_object si_unlink_symbol(cl_object s);
extern ECL_API cl_object cl_eval(cl_object form);
618
extern ECL_API cl_object cl_constantp _ECL_ARGS((cl_narg narg, cl_object arg, ...));
619
620

#define funcall cl_funcall
621
extern ECL_API cl_object cl_apply_from_stack(cl_index narg, cl_object fun);
622
extern ECL_API cl_object ecl_apply_from_stack_frame(cl_object f, cl_object o);
623
extern ECL_API cl_objectfn ecl_function_dispatch(cl_env_ptr env, cl_object f);
624
extern ECL_API cl_object _ecl_link_call(cl_object sym, cl_objectfn *pLK, cl_object cblock, int narg, ecl_va_list args);
jjgarcia's avatar
jjgarcia committed
625

626
627
628
629
/* ffi/cdata.d */
extern ECL_API cl_object si_get_cdata(cl_object filename);
extern ECL_API cl_object si_add_cdata(cl_object filename, cl_object cdata);

630
/* ffi/libraries.d */
631
extern ECL_API cl_object ecl_make_codeblock();
632
633
634
extern ECL_API cl_object ecl_library_open(cl_object filename, bool force_reload);
extern ECL_API void *ecl_library_symbol(cl_object block, const char *symbol, bool lock);
extern ECL_API cl_object ecl_library_error(cl_object block);
635
extern ECL_API bool ecl_library_close(cl_object block);
636
637
extern ECL_API void ecl_library_close_all(void);

638
/* ffi/mmap.d */
639
extern ECL_API cl_object si_mmap _ECL_ARGS((cl_narg narg, cl_object filename, ...));
640
641
642
extern ECL_API cl_object si_munmap(cl_object map);
extern ECL_API cl_object si_mmap_array(cl_object map);

643
644
645
/* ffi/backtrace.d */
extern ECL_API cl_object si_dump_c_backtrace(cl_object size);

jjgarcia's avatar
jjgarcia committed
646
647
/* ffi.c */

648
extern ECL_API cl_object si_allocate_foreign_data(cl_object tag, cl_object size);
649
extern ECL_API cl_object si_foreign_elt_type_p(cl_object f);
650
extern ECL_API cl_object si_foreign_data_p(cl_object f);
651
extern ECL_API cl_object si_foreign_data_address(cl_object f);
652
extern ECL_API cl_object si_foreign_data_equal(cl_object f1, cl_object f2);
653
654
655
656
657
658
659
660
661
662
663
extern ECL_API cl_object si_foreign_data_pointer(cl_object f, cl_object ndx, cl_object size, cl_object tag);
extern ECL_API cl_object si_foreign_data_ref(cl_object f, cl_object ndx, cl_object size, cl_object tag);
extern ECL_API cl_object si_foreign_data_ref_elt(cl_object f, cl_object ndx, cl_object tag);
extern ECL_API cl_object si_foreign_data_set(cl_object f, cl_object ndx, cl_object value);
extern ECL_API cl_object si_foreign_data_set_elt(cl_object f, cl_object ndx, cl_object tag, cl_object value);
extern ECL_API cl_object si_foreign_data_tag(cl_object x);
extern ECL_API cl_object si_foreign_data_recast(cl_object f, cl_object size, cl_object tag);
extern ECL_API cl_object si_free_foreign_data(cl_object x);
extern ECL_API cl_object si_make_foreign_data_from_array(cl_object x);
extern ECL_API cl_object si_null_pointer_p(cl_object f);
extern ECL_API cl_object si_size_of_foreign_elt_type(cl_object tag);
664
extern ECL_API cl_object si_alignment_of_foreign_elt_type(cl_object tag);
665
extern ECL_API cl_object si_load_foreign_module(cl_object module);
666
extern ECL_API cl_object si_unload_foreign_module(cl_object module);
667
668
669
extern ECL_API cl_object si_find_foreign_symbol(cl_object var, cl_object module, cl_object type, cl_object size);
extern ECL_API cl_object si_call_cfun(cl_narg, cl_object fun, cl_object return_type, cl_object arg_types, cl_object args, ...);
extern ECL_API cl_object si_make_dynamic_callback(cl_narg, cl_object fun, cl_object sym, cl_object return_type, cl_object arg_types, ...);
670
extern ECL_API cl_object si_free_ffi_closure(cl_object closure);
671

672
/* Only foreign data types can be coerced to a pointer */
673
#define ecl_make_pointer(x) ecl_make_foreign_data(ECL_NIL,0,(x))
674
#define ecl_to_pointer(x) ecl_foreign_data_pointer_safe(x)
675
676
677
678
679
extern ECL_API cl_object ecl_make_foreign_data(cl_object tag, cl_index size, void *data);
extern ECL_API cl_object ecl_allocate_foreign_data(cl_object tag, cl_index size);
extern ECL_API void *ecl_foreign_data_pointer_safe(cl_object f);
extern ECL_API char *ecl_base_string_pointer_safe(cl_object f);
extern ECL_API cl_object ecl_null_terminated_base_string(cl_object s);
680
681
extern ECL_API cl_object ecl_foreign_data_ref_elt(void *p, enum ecl_ffi_tag type);
extern ECL_API void ecl_foreign_data_set_elt(void *p, enum ecl_ffi_tag type, cl_object value);
jjgarcia's avatar
jjgarcia committed
682

jjgarcia's avatar
jjgarcia committed
683
684
/* file.c */

Daniel Kochmański's avatar
Daniel Kochmański committed
685
686
687
#define ECL_LISTEN_NO_CHAR      0
#define ECL_LISTEN_AVAILABLE    1
#define ECL_LISTEN_EOF          -1
688

689
690
691
692
693
694
695
696
extern ECL_API cl_object cl_make_synonym_stream(cl_object sym);
extern ECL_API cl_object cl_synonym_stream_symbol(cl_object strm);
extern ECL_API cl_object cl_make_two_way_stream(cl_object strm1, cl_object strm2);
extern ECL_API cl_object cl_two_way_stream_input_stream(cl_object strm);
extern ECL_API cl_object cl_two_way_stream_output_stream(cl_object strm);
extern ECL_API cl_object cl_make_echo_stream(cl_object strm1, cl_object strm2);
extern ECL_API cl_object cl_echo_stream_input_stream(cl_object strm);
extern ECL_API cl_object cl_echo_stream_output_stream(cl_object strm);
697
extern ECL_API cl_object cl_make_string_output_stream _ECL_ARGS((cl_narg narg, ...));
698
699
700
701
702
703
704
705
706
extern ECL_API cl_object cl_get_output_stream_string(cl_object strm);
extern ECL_API cl_object cl_streamp(cl_object strm);
extern ECL_API cl_object cl_input_stream_p(cl_object strm);
extern ECL_API cl_object cl_output_stream_p(cl_object strm);
extern ECL_API cl_object cl_stream_element_type(cl_object strm);
extern ECL_API cl_object cl_stream_external_format(cl_object strm);
extern ECL_API cl_object cl_file_length(cl_object strm);
extern ECL_API cl_object si_get_string_input_stream_index(cl_object strm);
extern ECL_API cl_object si_make_string_output_stream_from_string(cl_object strng);
707
extern ECL_API cl_object si_copy_stream(cl_object in, cl_object out, cl_object wait);
708
extern ECL_API cl_object cl_open_stream_p(cl_object strm);
709
extern ECL_API cl_object cl_make_broadcast_stream _ECL_ARGS((cl_narg narg, ...));
710
extern ECL_API cl_object cl_broadcast_stream_streams(cl_object strm);
711
extern ECL_API cl_object cl_make_concatenated_stream _ECL_ARGS((cl_narg narg, ...));
712
extern ECL_API cl_object cl_concatenated_stream_streams(cl_object strm);
713
714
715
716
717
718
extern ECL_API cl_object cl_make_string_input_stream _ECL_ARGS((cl_narg narg, cl_object strng, ...));
extern ECL_API cl_object si_make_sequence_input_stream _ECL_ARGS((cl_narg narg, cl_object vector, ...));
extern ECL_API cl_object si_make_sequence_output_stream _ECL_ARGS((cl_narg narg, cl_object vector, ...));
extern ECL_API cl_object cl_close _ECL_ARGS((cl_narg narg, cl_object strm, ...));
extern ECL_API cl_object cl_open _ECL_ARGS((cl_narg narg, cl_object filename, ...));
extern ECL_API cl_object cl_file_position _ECL_ARGS((cl_narg narg, cl_object file_stream, ...));
719
720
721
722
723
extern ECL_API cl_object cl_file_string_length(cl_object stream, cl_object string);
extern ECL_API cl_object si_do_write_sequence(cl_object string, cl_object stream, cl_object start, cl_object end);
extern ECL_API cl_object si_do_read_sequence(cl_object string, cl_object stream, cl_object start, cl_object end);
extern ECL_API cl_object si_file_column(cl_object strm);
extern ECL_API cl_object cl_interactive_stream_p(cl_object strm);
724
725
726
#if defined(ECL_MS_WINDOWS_HOST)
extern ECL_API cl_object si_windows_codepage_encoding();
#endif
727
extern ECL_API cl_object si_set_buffering_mode(cl_object strm, cl_object mode);
728
extern ECL_API cl_object si_stream_external_format_set(cl_object strm, cl_object format);
729
730
731

extern ECL_API bool ecl_input_stream_p(cl_object strm);
extern ECL_API bool ecl_output_stream_p(cl_object strm);
732
733
extern ECL_API cl_object ecl_stream_element_type(cl_object strm);
extern ECL_API bool ecl_interactive_stream_p(cl_object strm);
734
extern ECL_API cl_object ecl_open_stream(cl_object fn, enum ecl_smmode smm, cl_object if_exists, cl_object if_does_not_exist, cl_fixnum byte_size, int flags, cl_object external_format);
735
extern ECL_API cl_object ecl_make_string_input_stream(cl_object strng, cl_index istart, cl_index iend);
736
extern ECL_API cl_object ecl_make_string_output_stream(cl_index line_length, int extended);
737
738
extern ECL_API cl_object ecl_read_byte(cl_object strm);
extern ECL_API void ecl_write_byte(cl_object byte, cl_object strm);
739
740
741
742
743
extern ECL_API ecl_character ecl_read_char_noeof(cl_object strm);
extern ECL_API ecl_character ecl_read_char(cl_object strm);
extern ECL_API void ecl_unread_char(ecl_character c, cl_object strm);
extern ECL_API ecl_character ecl_peek_char(cl_object strm);
extern ECL_API ecl_character ecl_write_char(ecl_character c, cl_object strm);
744
745
extern ECL_API void writestr_stream(const char *s, cl_object strm);
extern ECL_API void ecl_force_output(cl_object strm);
746
extern ECL_API void ecl_finish_output(cl_object strm);
747
748
749
750
751
extern ECL_API void ecl_clear_input(cl_object strm);
extern ECL_API void ecl_clear_output(cl_object strm);
extern ECL_API bool ecl_listen_stream(cl_object strm);
extern ECL_API cl_object ecl_file_position(cl_object strm);
extern ECL_API cl_object ecl_file_position_set(cl_object strm, cl_object disp);
752
extern ECL_API cl_object ecl_file_length(cl_object strm);
753
extern ECL_API int ecl_file_column(cl_object strm);
754
extern ECL_API cl_fixnum ecl_normalize_stream_element_type(cl_object element);
755
extern ECL_API cl_object ecl_make_stream_from_FILE(cl_object fname, void *fd, enum ecl_smmode smm, cl_fixnum byte_size, int flags, cl_object external_format);
756
extern ECL_API cl_object ecl_make_stream_from_fd(cl_object fname, int fd, enum ecl_smmode smm, cl_fixnum byte_size, int flags, cl_object external_format);
Samium Gromoff's avatar
Samium Gromoff committed
757
extern ECL_API cl_object si_file_stream_fd(cl_object s);
758
extern ECL_API int ecl_stream_to_handle(cl_object s, bool output);
jjgarcia's avatar
jjgarcia committed
759

760
761
/* finalize.c */

762
extern ECL_API void ecl_set_finalizer_unprotected(cl_object o, cl_object finalizer);
763
764
extern ECL_API cl_object si_get_finalizer(cl_object o);
extern ECL_API cl_object si_set_finalizer(cl_object o, cl_object finalizer);
jjgarcia's avatar
jjgarcia committed
765
766
767

/* format.c */

768
extern ECL_API cl_object cl_format _ECL_ARGS((cl_narg narg, cl_object stream, cl_object string, ...));
jjgarcia's avatar
jjgarcia committed
769
770
771
772

/* gbc.c */

#if !defined(GBC_BOEHM)
773
774
775
776
extern ECL_API cl_object si_room_report _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_reset_gc_count _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_gc_time _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_gc(cl_object area, ...);
jjgarcia's avatar
jjgarcia committed
777
778
779
#define GC_enabled() GC_enable
#define GC_enable() GC_enable = TRUE;
#define GC_disable() GC_enable = FALSE;
780
781
782
783
784
extern ECL_API bool GC_enable;
extern ECL_API cl_object (*GC_enter_hook)(void);
extern ECL_API cl_object (*GC_exit_hook)(void);
extern ECL_API void ecl_register_root(cl_object *p);
extern ECL_API void ecl_gc(cl_type t);
jjgarcia's avatar
jjgarcia committed
785
786
787
#endif

#ifdef GBC_BOEHM
788
789
790
#define GC_enabled() !GC_is_disabled()
#define GC_enable() GC_enable()
#define GC_disable() GC_disable()
791
extern ECL_API void ecl_register_root(cl_object *p);
792
#endif /* GBC_BOEHM */
jjgarcia's avatar
jjgarcia committed
793
794
795
796


/* gfun.c */

797
extern ECL_API void _ecl_set_method_hash_size(cl_env_ptr env, cl_index size);
798
799
800
extern ECL_API cl_object si_clear_gfun_hash(cl_object what);
extern ECL_API cl_object clos_set_funcallable_instance_function(cl_object x, cl_object function_or_t);
extern ECL_API cl_object si_generic_function_p(cl_object instance);
801

802
extern ECL_API cl_object _ecl_standard_dispatch(cl_object frame, cl_object fun);
jjgarcia's avatar
jjgarcia committed
803
804
805
806


/* hash.c */

807
extern ECL_API cl_object cl__make_hash_table(cl_object test, cl_object size, cl_object rehash_size, cl_object rehash_threshold);
808
809
810
811
812
813
814
815
816
817
818
819
extern ECL_API cl_object cl_hash_table_p(cl_object ht);
extern ECL_API cl_object si_hash_set(cl_object key, cl_object ht, cl_object val);
extern ECL_API cl_object cl_remhash(cl_object key, cl_object ht);
extern ECL_API cl_object cl_clrhash(cl_object ht);
extern ECL_API cl_object cl_hash_table_count(cl_object ht);
extern ECL_API cl_object cl_sxhash(cl_object key);
extern ECL_API cl_object cl_maphash(cl_object fun, cl_object ht);
extern ECL_API cl_object cl_hash_table_rehash_size(cl_object ht);
extern ECL_API cl_object cl_hash_table_rehash_threshold(cl_object ht);
extern ECL_API cl_object cl_hash_table_size(cl_object ht);
extern ECL_API cl_object cl_hash_table_test(cl_object ht);
extern ECL_API cl_object si_hash_table_iterator(cl_object ht);
820
821
extern ECL_API cl_object cl_make_hash_table _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_gethash _ECL_ARGS((cl_narg narg, cl_object key, cl_object ht, ...));
822
extern ECL_API cl_object si_copy_hash_table(cl_object orig);
823
824
825
extern ECL_API cl_object si_hash_eql _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_hash_equal _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object si_hash_equalp _ECL_ARGS((cl_narg narg, ...));
826
827
extern ECL_API cl_object si_hash_table_content(cl_object ht);
extern ECL_API cl_object si_hash_table_fill(cl_object ht, cl_object values);
Juan Jose Garcia Ripoll's avatar
Juan Jose Garcia Ripoll committed
828
extern ECL_API cl_object si_hash_table_weakness(cl_object ht);
829
extern ECL_API cl_object si_hash_table_synchronized_p(cl_object ht);
830

831
extern ECL_API cl_object ecl_sethash(cl_object key, cl_object hashtable, cl_object value);
832
833
834
extern ECL_API cl_object ecl_gethash(cl_object key, cl_object hash);
extern ECL_API cl_object ecl_gethash_safe(cl_object key, cl_object hash, cl_object def);
extern ECL_API bool ecl_remhash(cl_object key, cl_object hash);
835
extern ECL_API cl_object _ecl_sethash(cl_object key, cl_object hashtable, cl_object value);
836
extern ECL_API cl_index ecl_hash_table_count(cl_object hash);
jjgarcia's avatar
jjgarcia committed
837
838
839

/* instance.c */

840
841
842
843
extern ECL_API cl_object si_allocate_raw_instance(cl_object orig, cl_object clas, cl_object size);
extern ECL_API cl_object si_instance_class(cl_object x);
extern ECL_API cl_object si_instance_class_set(cl_object x, cl_object y);
extern ECL_API cl_object si_instance_ref(cl_object x, cl_object index);
844
extern ECL_API cl_object clos_safe_instance_ref(cl_object x, cl_object index);
845
846
847
848
849
extern ECL_API cl_object si_instance_set(cl_object x, cl_object index, cl_object value);
extern ECL_API cl_object si_instancep(cl_object x);
extern ECL_API cl_object si_unbound(void);
extern ECL_API cl_object si_sl_boundp(cl_object x);
extern ECL_API cl_object si_sl_makunbound(cl_object x, cl_object index);
850
extern ECL_API cl_object si_instance_obsolete_p(cl_object x);
851
852
extern ECL_API cl_object si_instance_new_stamp(cl_object x);
extern ECL_API cl_object si_instance_get_stamp(cl_object x);
853
extern ECL_API cl_object si_instance_slotds(cl_object x);
854
855
856
857
858
859
860
861
862
extern ECL_API cl_object si_instance_sig_set(cl_object x);

extern ECL_API cl_object ecl_allocate_instance(cl_object clas, cl_index size);
extern ECL_API cl_object ecl_instance_ref(cl_object x, cl_fixnum i);
extern ECL_API cl_object ecl_instance_set(cl_object x, cl_fixnum i, cl_object v);
extern ECL_API cl_object si_copy_instance(cl_object x);

extern ECL_API cl_object ecl_slot_value(cl_object x, const char *slot);
extern ECL_API cl_object ecl_slot_value_set(cl_object x, const char *slot, cl_object y);
jjgarcia's avatar
jjgarcia committed
863

864
#ifdef ECL_THREADS
865
866
extern ECL_API cl_object ecl_compare_and_swap_instance(cl_object x, cl_fixnum i, cl_object old_val, cl_object new_val);
extern ECL_API cl_object mp_compare_and_swap_instance(cl_object x, cl_object index, cl_object old_val, cl_object new_val);
867
868
869
extern ECL_API cl_object ecl_atomic_incf_instance(cl_object x, cl_fixnum i, cl_object increment);
extern ECL_API cl_object mp_atomic_incf_instance(cl_object x, cl_object index, cl_object increment);
#endif
jjgarcia's avatar
jjgarcia committed
870
871
872

/* list.c */

jjgarcia's avatar
jjgarcia committed
873
874
875
876
877
#define cl_rest cl_cdr
#define cl_first cl_car
#define cl_second cl_cadr
#define cl_third cl_caddr
#define cl_fourth cl_cadddr
878

879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
extern ECL_API cl_object cl_fifth(cl_object x);
extern ECL_API cl_object cl_sixth(cl_object x);
extern ECL_API cl_object cl_seventh(cl_object x);
extern ECL_API cl_object cl_eighth(cl_object x);
extern ECL_API cl_object cl_ninth(cl_object x);
extern ECL_API cl_object cl_tenth(cl_object x);
extern ECL_API cl_object cl_endp(cl_object x);
extern ECL_API cl_object cl_list_length(cl_object x);
extern ECL_API cl_object cl_nth(cl_object n, cl_object x);
extern ECL_API cl_object cl_nthcdr(cl_object n, cl_object x);
extern ECL_API cl_object cl_copy_list(cl_object x);
extern ECL_API cl_object cl_copy_alist(cl_object x);
extern ECL_API cl_object cl_copy_tree(cl_object x);
extern ECL_API cl_object cl_revappend(cl_object x, cl_object y);
extern ECL_API cl_object cl_ldiff(cl_object x, cl_object y);
extern ECL_API cl_object cl_rplaca(cl_object x, cl_object v);
extern ECL_API cl_object cl_rplacd(cl_object x, cl_object v);
extern ECL_API cl_object cl_tailp(cl_object y, cl_object x);
extern ECL_API cl_object si_memq(cl_object x, cl_object l);
extern ECL_API cl_object cl_nreconc(cl_object x, cl_object y);
extern ECL_API cl_object cl_cons(cl_object x, cl_object y);
extern ECL_API cl_object cl_acons(cl_object x, cl_object y, cl_object z);
901
902
903
904
905
906
907
908
909
910
911
912
913
914
extern ECL_API cl_object cl_list _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_listX _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_append _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_tree_equal _ECL_ARGS((cl_narg narg, cl_object x, cl_object y, ...));
extern ECL_API cl_object cl_last _ECL_ARGS((cl_narg narg, cl_object x, ...));
extern ECL_API cl_object cl_make_list _ECL_ARGS((cl_narg narg, cl_object size, ...));
extern ECL_API cl_object cl_nconc _ECL_ARGS((cl_narg narg, ...));
extern ECL_API cl_object cl_butlast _ECL_ARGS((cl_narg narg, cl_object lis, ...));
extern ECL_API cl_object cl_nbutlast _ECL_ARGS((cl_narg narg, cl_object lis, ...));
extern ECL_API cl_object cl_subst _ECL_ARGS((cl_narg narg, cl_object new_obj, cl_object old_obj, cl_object tree, ...));
extern ECL_API cl_object cl_nsubst _ECL_ARGS((cl_narg narg, cl_object new_obj, cl_object old_obj, cl_object tree, ...));
extern ECL_API cl_object cl_sublis _ECL_ARGS((cl_narg narg, cl_object alist, cl_object tree, ...));
extern ECL_API cl_object cl_nsublis _ECL_ARGS((cl_narg narg, cl_object alist, cl_object tree, ...));
extern ECL_API cl_object cl_member _ECL_ARGS((cl_narg narg, cl_object item, cl_object list, ...));
915
extern ECL_API cl_object si_member1 (cl_object item, cl_object list, cl_object test, cl_object test_not, cl_object key);
916
917
918
919
extern ECL_API cl_object cl_adjoin _ECL_ARGS((cl_narg narg, cl_object item, cl_object list, ...));
extern ECL_API cl_object cl_pairlis _ECL_ARGS((cl_narg narg, cl_object keys, cl_object data, ...));
extern ECL_API cl_object cl_rassoc _ECL_ARGS((cl_narg narg, cl_object item, cl_object alist, ...));
extern ECL_API cl_object cl_assoc _ECL_ARGS((cl_narg narg, cl_object item, cl_object alist, ...));
920
extern ECL_API cl_object si_proper_list_p(cl_object V1);
921

922
923
924
extern ECL_API cl_object ecl_last(cl_object x, cl_index n);
extern ECL_API cl_object ecl_butlast(cl_object x, cl_index n);
extern ECL_API cl_object ecl_nbutlast(cl_object x, cl_index n);
925
926
927
928
929
930
931
932
933
934
935
936
937
extern ECL_API cl_object ecl_append(cl_object x, cl_object y);
extern ECL_API bool ecl_endp(cl_object x);
extern ECL_API cl_object</