mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-05-10 09:31:43 -07:00
84 lines
2.9 KiB
C
84 lines
2.9 KiB
C
/* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
/* vim: set filetype=c tabstop=2 shiftwidth=2 expandtab: */
|
|
|
|
#ifndef ECL_NUCLEUS_H
|
|
#define ECL_NUCLEUS_H
|
|
|
|
#include "external.h"
|
|
|
|
struct ecl_core_struct {
|
|
cl_env_ptr first_env;
|
|
#ifdef ECL_THREADS
|
|
cl_object threads;
|
|
ecl_mutex_t processes_lock;
|
|
ecl_mutex_t global_lock;
|
|
ecl_mutex_t error_lock;
|
|
ecl_rwlock_t global_env_lock;
|
|
cl_index last_var_index;
|
|
cl_object reused_indices;
|
|
#endif
|
|
struct ecl_allocator_ops *allocator;
|
|
size_t max_heap_size;
|
|
cl_object bytes_consed;
|
|
cl_object gc_counter;
|
|
bool gc_stats;
|
|
char *safety_region;
|
|
|
|
cl_index default_sigmask_bytes;
|
|
cl_object known_signals;
|
|
|
|
int path_max;
|
|
cl_object pathname_translations;
|
|
|
|
cl_object modules;
|
|
cl_object libraries;
|
|
cl_object library_pathname;
|
|
};
|
|
|
|
/* process.c */
|
|
cl_env_ptr ecl_adopt_cpu();
|
|
cl_env_ptr ecl_spawn_cpu(cl_object process);
|
|
void ecl_disown_cpu();
|
|
|
|
/* control.c */
|
|
void ecl_escape(cl_object continuation) ecl_attr_noreturn;
|
|
cl_object ecl_signal(cl_object condition, cl_object returns, cl_object thread);
|
|
cl_object ecl_call_with_handler(cl_object handler, cl_object continuation);
|
|
|
|
/* Binding a handler conses a new list, but at this stage we don't assume the
|
|
the garbage collector to work! Luckily the extent of the binding is dynamic
|
|
and we can allocate cons on the stack. */
|
|
#define ECL_WITH_HANDLER_BEGIN(the_env, handler) do { \
|
|
const cl_env_ptr __the_env = the_env; \
|
|
cl_object __ecl_sym = ECL_SIGNAL_HANDLERS; \
|
|
cl_object __ecl_hnd = ECL_SYM_VAL(__the_env, __ecl_sym); \
|
|
cl_object __ecl_hnds = ecl_cons_stack(handler, __ecl_hnd); \
|
|
ecl_bds_bind(__the_env, __ecl_sym, __ecl_hnds);
|
|
|
|
#define ECL_WITH_HANDLER_END ecl_bds_unwind1(__the_env); } while(0)
|
|
|
|
/* memory.c */
|
|
void *ecl_alloc_memory(cl_index n);
|
|
cl_object ecl_alloc_object(cl_type t);
|
|
void ecl_free_memory(void *ptr);
|
|
void ecl_free_object(cl_object o);
|
|
|
|
/* escape.c */
|
|
cl_object ecl_raise(ecl_ex_type t, bool ret,
|
|
cl_object a1, cl_object a2, cl_object a3, void *a4);
|
|
|
|
#define ecl_ferror ecl_ferror3
|
|
#define ecl_ferror1(extype) ecl_raise(extype, 0, ECL_NIL, ECL_NIL, ECL_NIL, NULL)
|
|
#define ecl_ferror2(extype,a1) ecl_raise(extype, 0, a1, ECL_NIL, ECL_NIL, NULL)
|
|
#define ecl_ferror3(extype,a1,a2) ecl_raise(extype, 0, a1, a2, ECL_NIL, NULL)
|
|
#define ecl_ferror4(extype,a1,a2,a3) ecl_raise(extype, 0, a1, a2, a3, NULL)
|
|
#define ecl_ferror5(extype,a1,a2,a3,p4) ecl_raise(extype, 0, a1, a2, a3, p4)
|
|
|
|
#define ecl_cerror ecl_cerror3
|
|
#define ecl_cerror1(extype) ecl_raise(extype, 1, ECL_NIL, ECL_NIL, ECL_NIL, NULL)
|
|
#define ecl_cerror2(extype,a1) ecl_raise(extype, 1, a1, ECL_NIL, ECL_NIL, NULL)
|
|
#define ecl_cerror3(extype,a1,a2) ecl_raise(extype, 1, a1, a2, ECL_NIL, NULL)
|
|
#define ecl_cerror4(extype,a1,a2,a3) ecl_raise(extype, 1, a1, a2, a3, NULL)
|
|
#define ecl_cerror5(extype,a1,a2,a3,p4) ecl_raise(extype, 1, a1, a2, a3, p4)
|
|
|
|
#endif /* ECL_NUCLEUS_H */
|