* Imported original elk 3.0 tree.
git-svn-id: svn://svn.zoy.org/elk/trunk@1 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
SHELL=/bin/sh
|
||||
MAKE=make
|
||||
|
||||
all: default
|
||||
|
||||
Makefile.local: ../config/system ../config/site
|
||||
$(SHELL) ./build
|
||||
|
||||
default: Makefile.local
|
||||
$(MAKE) -f Makefile.local
|
||||
|
||||
install: Makefile.local
|
||||
$(MAKE) -f Makefile.local install
|
||||
|
||||
localize: Makefile.local
|
||||
$(MAKE) -f Makefile.local localize
|
||||
|
||||
lint:
|
||||
|
||||
clean:
|
||||
|
||||
distclean: Makefile.local
|
||||
$(MAKE) -f Makefile.local distclean
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
. ../config/system
|
||||
. ../config/site
|
||||
|
||||
echo Building Makefile.local...
|
||||
cat <<EOT >Makefile.local
|
||||
# This Makefile was produced by running ./build in this directory.
|
||||
|
||||
SHELL=/bin/sh
|
||||
|
||||
FILES= compat.h\\
|
||||
config.h\\
|
||||
cstring.h\\
|
||||
exception.h\\
|
||||
extern.h\\
|
||||
funcproto.h\\
|
||||
gc.h\\
|
||||
misc.h\\
|
||||
object.h\\
|
||||
param.h\\
|
||||
scheme.h\\
|
||||
stkmem.h\\
|
||||
type.h
|
||||
|
||||
config.h: ../config/system ../config/site
|
||||
\$(SHELL) ./build-config
|
||||
|
||||
install: \$(FILES)
|
||||
-@if [ ! -d $install_dir/include ]; then \\
|
||||
echo mkdir $install_dir/include; \\
|
||||
mkdir $install_dir/include; \\
|
||||
fi
|
||||
@for i in \$(FILES) ;\\
|
||||
do \\
|
||||
echo cp \$\$i $install_dir/include; \\
|
||||
cp \$\$i $install_dir/include; \\
|
||||
done
|
||||
|
||||
localize: config.h
|
||||
|
||||
distclean:
|
||||
rm -f Makefile.local config.h
|
||||
EOT
|
||||
Executable
+344
@@ -0,0 +1,344 @@
|
||||
. ../config/system
|
||||
. ../config/site
|
||||
|
||||
case "$system" in
|
||||
*-*-*) ;;
|
||||
*) echo Error in config file:
|
||||
echo Badly formed system identification: "$system"; exit 1;;
|
||||
esac
|
||||
|
||||
def_vfork=undef
|
||||
def_vprintf=undef
|
||||
def_dirent=undef
|
||||
def_atexit=undef
|
||||
def_syms_underl=undef
|
||||
def_random=undef
|
||||
def_include_unistd_h=undef
|
||||
def_sysconf_open_max=undef
|
||||
def_getdtablesize=undef
|
||||
def_pathconf_path_max=undef
|
||||
def_getpagesize=undef
|
||||
def_sysconf_pagesize=undef
|
||||
def_bsd_signals=undef
|
||||
def_posix_signals=undef
|
||||
def_align_8byte=undef
|
||||
def_can_dump=undef
|
||||
def_fchmod_broken=undef
|
||||
def_termio=undef
|
||||
def_flush_bsd=undef
|
||||
def_flush_fpurge=undef
|
||||
def_flush_tiocflush=undef
|
||||
def_flush_tcflsh=undef
|
||||
def_use_alloca=undef
|
||||
def_include_alloca_h=undef
|
||||
def_pragma_alloca=undef
|
||||
def_coff=undef
|
||||
def_ecoff=undef
|
||||
def_xcoff=undef
|
||||
def_elf=undef
|
||||
def_macho=undef
|
||||
def_convex=undef
|
||||
def_hp9k=undef
|
||||
def_hp_shared_libs=undef
|
||||
def_debug_dump=undef
|
||||
def_use_ld=undef
|
||||
def_use_rld=undef
|
||||
def_use_shl=undef
|
||||
def_use_dlopen=undef
|
||||
def_max_stack_size=undef
|
||||
def_mprotect=undef
|
||||
def_mprotect_mmap=undef
|
||||
def_want_proto=undef
|
||||
def_no_proto=undef
|
||||
def_generational_gc=undef
|
||||
def_cachectl_h=undef
|
||||
def_syms_begin_with=undef
|
||||
def_ansi_cpp=undef
|
||||
def_can_load_obj=undef
|
||||
def_sigsegv_siginfo=undef
|
||||
def_sigsegv_sigcontext=undef
|
||||
def_sigsegv_arg4=undef
|
||||
def_sigsegv_aix=undef
|
||||
def_sigsegv_hpux=undef
|
||||
def_gettimeofday=undef
|
||||
def_ftime=undef
|
||||
def_gethostname=undef
|
||||
def_uname=undef
|
||||
def_mktemp=undef
|
||||
def_tmpnam=undef
|
||||
def_tempnam=undef
|
||||
def_getcwd=undef
|
||||
def_getwd=undef
|
||||
def_rename=undef
|
||||
def_waitpid=undef
|
||||
def_wait3=undef
|
||||
def_wait4=undef
|
||||
def_fionread_h=undef
|
||||
def_utime_h=undef
|
||||
def_regcomp=undef
|
||||
|
||||
if [ _$regcomp = _yes ]; then def_regcomp=define; fi
|
||||
if [ _$utime_h = _yes ]; then def_utime_h=define; fi
|
||||
if [ _$fionread_include != _ ]; then def_fionread_h=define; fi
|
||||
if [ _$wait4 = _yes ]; then def_wait4=define; fi
|
||||
if [ _$wait3 = _yes ]; then def_wait3=define; fi
|
||||
if [ _$waitpid = _yes ]; then def_waitpid=define; fi
|
||||
if [ _$rename = _yes ]; then def_rename=define; fi
|
||||
if [ _$getwd = _yes ]; then def_getwd=define; fi
|
||||
if [ _$getcwd = _yes ]; then def_getcwd=define; fi
|
||||
if [ _$tempnam = _yes ]; then def_tempnam=define; fi
|
||||
if [ _$tmpnam = _yes ]; then def_tmpnam=define; fi
|
||||
if [ _$mktemp = _yes ]; then def_mktemp=define; fi
|
||||
if [ _$uname = _yes ]; then def_uname=define; fi
|
||||
if [ _$gethostname = _yes ]; then def_gethostname=define; fi
|
||||
if [ _$gettimeofday = _yes ]; then def_gettimeofday=define; fi
|
||||
if [ _$ftime = _yes ]; then def_ftime=define; fi
|
||||
if [ _$vfork = _yes ]; then def_vfork=define; fi
|
||||
if [ _$vprintf = _yes ]; then def_vprintf=define; fi
|
||||
if [ _$dirent = _yes ]; then def_dirent=define; fi
|
||||
if [ _$atexit = _yes ]; then def_atexit=define; fi
|
||||
if [ _$syms_with_underline = _yes ];
|
||||
then def_syms_underl=define; fi
|
||||
if [ _$random = _yes ]; then def_random=define; fi
|
||||
if [ _$include_unistd_h = _yes ]; then def_include_unistd_h=define; fi
|
||||
if [ _$sysconf_open_max = _yes ]; then def_sysconf=define; fi
|
||||
if [ _$getdtablesize = _yes ]; then def_getdtablesize=define; fi
|
||||
if [ _$pathconf_path_max = _yes ];then def_pathconf_path_max=define;fi
|
||||
if [ _$getpagesize = _yes ]; then def_getpagesize=define; fi
|
||||
if [ _$sysconf_pagesize = _yes ]; then def_sysconf_pagesize=define; fi
|
||||
if [ _$align_8byte = _yes ]; then def_align_8byte=define; fi
|
||||
if [ _$can_dump = _yes ]; then def_can_dump=define; fi
|
||||
if [ _$fchmod_broken = _yes ]; then def_fchmod_broken=define; fi
|
||||
if [ _$termio = _yes ]; then def_termio=define; fi
|
||||
if [ _$use_alloca = _yes ]; then def_use_alloca=define; fi
|
||||
if [ _$include_alloca_h = _yes ]; then def_include_alloca_h=define; fi
|
||||
if [ _$pragma_alloca = _yes ]; then def_pragma_alloca=define; fi
|
||||
if [ _$max_stack_size != _ ]; then def_max_stack_size=define; fi
|
||||
if [ _$generational_gc = _yes ]; then def_generational_gc=define; fi
|
||||
if [ _$cachectl_h != _ ]; then def_cachectl_h=define; fi
|
||||
if [ _$ansi_cpp = _yes ]; then def_ansi_cpp=define; fi
|
||||
if [ _$hp_shared_libraries = _yes ];
|
||||
then def_hp_shared_libs=define; fi
|
||||
if [ _$debug_dump = _yes ]; then def_debug_dump=define; fi
|
||||
if [ _$syms_begin_with != _ ]; then
|
||||
def_syms_begin_with=define
|
||||
syms_begin_char=\'$syms_begin_with\'
|
||||
fi
|
||||
if [ _$mprotect = _yes ]; then def_mprotect=define; fi
|
||||
if [ _$mprotect = _mmap ]; then
|
||||
def_mprotect=define;
|
||||
def_mprotect_mmap=define;
|
||||
fi
|
||||
if [ $def_getpagesize = undef -a $def_sysconf_pagesize = undef ]; then
|
||||
if [ $def_mprotect = define ]; then
|
||||
echo Error in config file:
|
||||
echo mprotect requires getpagesize or sysconf_pagesize; exit 1
|
||||
fi
|
||||
fi
|
||||
if [ _$index != _yes ]; then
|
||||
def_index="#define index strchr"
|
||||
fi
|
||||
if [ _$bstring != _yes ]; then
|
||||
def_bcopy="#define bcopy(from,to,len) memcpy(to,from,len)"
|
||||
def_bzero="#define bzero(p,len) memset(p,0,len)"
|
||||
def_bcmp="#define bcmp memcmp"
|
||||
fi
|
||||
|
||||
case _$reliable_signals in
|
||||
_bsd) def_bsd_signals=define;;
|
||||
_posix) def_posix_signals=define;;
|
||||
esac
|
||||
|
||||
case _$prototypes in
|
||||
_yes) def_want_proto=define;;
|
||||
_no) def_no_proto=define;;
|
||||
esac
|
||||
|
||||
case _$aout_format in
|
||||
_coff) def_coff=define;;
|
||||
_ecoff) def_ecoff=define;;
|
||||
_xcoff) def_xcoff=define;;
|
||||
_elf) def_elf=define;;
|
||||
_macho) def_macho=define;;
|
||||
_hp9k) def_hp9k=define;;
|
||||
_convex) def_convex=define;;
|
||||
esac
|
||||
|
||||
case _$load_obj in
|
||||
_ld) def_use_ld=define; def_can_load_obj=define;;
|
||||
_rld) def_use_rld=define; def_can_load_obj=define;;
|
||||
_shl) def_use_shl=define; def_can_load_obj=define;;
|
||||
_dl) def_use_dlopen=define; def_can_load_obj=define;;
|
||||
_) ;;
|
||||
*) echo Error in config file:
|
||||
echo Invalid value for symbol load_obj: $load_obj; exit 1;;
|
||||
esac
|
||||
|
||||
case _$flush_stdio in
|
||||
_bsd) def_flush_bsd=define;;
|
||||
_fpurge) def_flush_fpurge=define;;
|
||||
_) ;;
|
||||
*) echo Error in config file:
|
||||
echo Invalid value for symbol flush_stdio: $flush_stdio; exit 1;;
|
||||
esac
|
||||
|
||||
case _$flush_tty in
|
||||
_tiocflush) def_flush_tiocflush=define;;
|
||||
_tcflsh) def_flush_tcflsh=define;;
|
||||
_) ;;
|
||||
*) echo Error in config file:
|
||||
echo Invalid value for symbol flush_tty: $flush_tty; exit 1;;
|
||||
esac
|
||||
|
||||
case _$sigsegv_addr in
|
||||
_siginfo) def_sigsegv_siginfo=define;;
|
||||
_sigcontext) def_sigsegv_sigcontext=define;;
|
||||
_arg4) def_sigsegv_arg4=define;;
|
||||
_aix) def_sigsegv_aix=define;;
|
||||
_hpux) def_sigsegv_hpux=define;;
|
||||
_) if [ $def_mprotect = define ]; then
|
||||
echo Error in config file:
|
||||
echo Must specify value for sigsegv_addr if mprotect=yes
|
||||
exit 1
|
||||
fi;;
|
||||
*) echo Error in config file:
|
||||
echo Invalid value for symbol sigsegv_addr: $sigsegv_addr
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
if [ _$load_obj = _ld -a "_$load_libraries" = _ ]; then
|
||||
load_libraries=-lc
|
||||
fi
|
||||
|
||||
if [ _$getgroups_type = _ ]; then
|
||||
echo Error in config file:
|
||||
echo Must specify a value for symbol getgroups_type
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f $install_dir/include/build ]; then
|
||||
echo Error in config file:
|
||||
echo You cannot install Elk into the top of the source tree.
|
||||
echo 'Choose a different directory for $install_dir in config/site'
|
||||
echo '(e.g. a subdirectory or a directory outside the source tree).'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ _$init_prefix != _elk_init_ -o _$finit_prefix != _elk_finit_ ]; then
|
||||
echo "****" Warning:
|
||||
echo "****" Changing init_prefix or finit_prefix in your configuration
|
||||
echo "****" requires you to modify all standard extensions accordingly
|
||||
echo "****" and restricts portability of newly written extension.
|
||||
fi
|
||||
|
||||
rel=`../util/getversion ../README`
|
||||
IFS=.
|
||||
set $rel
|
||||
major=$1
|
||||
minor=$2
|
||||
IFS=
|
||||
|
||||
|
||||
echo Building config.h...
|
||||
cat <<EOT >config.h
|
||||
/* This file was produced by the Makefile in this directory.
|
||||
* If you want to change the value of a constant, edit ../config/system
|
||||
* or ../config/site and run make again.
|
||||
*/
|
||||
|
||||
#$def_regcomp REGCOMP
|
||||
#$def_waitpid WAITPID
|
||||
#$def_wait3 WAIT3
|
||||
#$def_wait4 WAIT4
|
||||
#$def_mktemp MKTEMP
|
||||
#$def_tmpnam TMPNAM
|
||||
#$def_tempnam TEMPNAM
|
||||
#$def_getcwd GETCWD
|
||||
#$def_getwd GETWD
|
||||
#$def_rename RENAME
|
||||
#$def_uname UNAME
|
||||
#$def_gethostname GETHOSTNAME
|
||||
#$def_gettimeofday GETTIMEOFDAY
|
||||
#$def_ftime FTIME
|
||||
#$def_vfork VFORK
|
||||
#$def_vprintf VPRINTF
|
||||
#$def_dirent DIRENT
|
||||
#$def_random RANDOM
|
||||
#$def_include_unistd_h INCLUDE_UNISTD_H
|
||||
#$def_sysconf_open_max SYSCONF_OPEN_MAX
|
||||
#$def_getdtablesize GETDTABLESIZE
|
||||
#$def_pathconf_path_max PATHCONF_PATH_MAX
|
||||
#$def_getpagesize GETPAGESIZE
|
||||
#$def_sysconf_pagesize SYSCONF_PAGESIZE
|
||||
#$def_bsd_signals BSD_SIGNALS
|
||||
#$def_posix_signals POSIX_SIGNALS
|
||||
#$def_align_8byte ALIGN_8BYTE
|
||||
#$def_coff COFF
|
||||
#$def_ecoff ECOFF
|
||||
#$def_xcoff XCOFF
|
||||
#$def_elf ELF
|
||||
#$def_macho MACH_O
|
||||
#$def_convex CONVEX_AOUT
|
||||
#$def_hp9k HP9K
|
||||
#$def_hp_shared_libs HPSHLIB
|
||||
#$def_debug_dump DEBUG_DUMP
|
||||
#$def_can_load_obj CAN_LOAD_OBJ
|
||||
#$def_use_ld USE_LD
|
||||
#$def_use_rld USE_RLD
|
||||
#$def_use_shl USE_SHL
|
||||
#$def_use_dlopen USE_DLOPEN
|
||||
# define LOAD_LIBRARIES "${load_libraries}"
|
||||
#$def_cachectl_h CACHECTL_H $cachectl_h
|
||||
#$def_fionread_h FIONREAD_H $fionread_include
|
||||
# $def_atexit ATEXIT
|
||||
#$def_syms_begin_with SYMS_BEGIN_WITH $syms_begin_char
|
||||
#$def_can_dump CAN_DUMP
|
||||
# define SEG_SIZ ${segment_size-unused}
|
||||
# define FILE_TEXT_START ${file_text_start-unused}
|
||||
# define MEM_TEXT_START ${mem_text_start-unused}
|
||||
# define TEXT_LENGTH_ADJ ${text_length_adj-unused}
|
||||
# define COFF_PAGESIZE ${coff_pagesize-unused}
|
||||
# $def_fchmod_broken FCHMOD_BROKEN
|
||||
#$def_termio TERMIO
|
||||
#$def_flush_bsd FLUSH_BSD
|
||||
#$def_flush_fpurge FLUSH_FPURGE
|
||||
#$def_flush_tiocflush FLUSH_TIOCFLUSH
|
||||
#$def_flush_tcflsh FLUSH_TCFLSH
|
||||
#$def_use_alloca USE_ALLOCA
|
||||
#$def_include_alloca_h INCLUDE_ALLOCA_H
|
||||
#$def_pragma_alloca PRAGMA_ALLOCA
|
||||
#$def_max_stack_size MAX_STACK_SIZE $max_stack_size
|
||||
#$def_generational_gc GENERATIONAL_GC
|
||||
#$def_mprotect HAS_MPROTECT
|
||||
#$def_mprotect_mmap MPROTECT_MMAP
|
||||
#$def_sigsegv_siginfo SIGSEGV_SIGINFO
|
||||
#$def_sigsegv_sigcontext SIGSEGV_SIGCONTEXT
|
||||
#$def_sigsegv_arg4 SIGSEGV_ARG4
|
||||
#$def_sigsegv_aix SIGSEGV_AIX
|
||||
#$def_sigsegv_hpux SIGSEGV_HPUX
|
||||
$def_index
|
||||
$def_bcopy
|
||||
$def_bzero
|
||||
$def_bcmp
|
||||
#define AOUT_H $aout_h
|
||||
#define SCM_DIR "$install_dir/runtime/scm"
|
||||
#define OBJ_DIR "$install_dir/runtime/obj"
|
||||
#define HEAP_SIZE $default_heap_size
|
||||
#define FIND_AOUT defined(USE_LD) || defined(CAN_DUMP)\\
|
||||
|| defined(INIT_OBJECTS)
|
||||
#if !defined(WANT_PROTOTYPES) && !defined(NO_PROTOTYPES)
|
||||
# $def_want_proto WANT_PROTOTYPES
|
||||
# $def_no_proto NO_PROTOTYPES
|
||||
#endif
|
||||
#$def_ansi_cpp ANSI_CPP
|
||||
#define SYSTEMTYPE "$system"
|
||||
#define GETGROUPS_TYPE $getgroups_type
|
||||
#define LD_NAME "$ld"
|
||||
#define LDFLAGS_SHARED "$ldflags_shared"
|
||||
#define INC_LDFLAGS "$incremental_ldflags"
|
||||
#$def_utime_h UTIME_H
|
||||
#define INIT_PREFIX "$init_prefix"
|
||||
#define FINIT_PREFIX "$finit_prefix"
|
||||
#define ELK_MAJOR $major
|
||||
#define ELK_MINOR $minor
|
||||
EOT
|
||||
@@ -0,0 +1,56 @@
|
||||
/* Definitions that were used in older versions of Elk, but are now
|
||||
* obsolete and should not be used any longer.
|
||||
*/
|
||||
|
||||
#define Declare_C_Strings Alloca_Begin
|
||||
#define Make_C_String Get_Strsym_Stack
|
||||
#define Dispose_C_Strings Alloca_End
|
||||
|
||||
#define Val(x) Cdr(x)
|
||||
|
||||
#define FIXNUM_FITS_UNSIGNED UFIXNUM_FITS
|
||||
#define SETFAST(x,y) ((x) = (y))
|
||||
|
||||
#define Make_Fixnum Make_Integer
|
||||
|
||||
/* The names of a few functions implementing primitives have been changed
|
||||
* for consistency:
|
||||
*/
|
||||
#define P_Setcar P_Set_Car
|
||||
#define P_Setcdr P_Set_Cdr
|
||||
#define P_With_Input P_With_Input_From_File
|
||||
#define P_With_Output P_With_Output_To_File
|
||||
#define P_Call_With_Input P_Call_With_Input_File
|
||||
#define P_Call_With_Output P_Call_With_Output_File
|
||||
#define P_Call_CC P_Call_With_Current_Continuation
|
||||
#define P_Promise_Env P_Promise_Environment
|
||||
#define P_Procedure_Env P_Procedure_Environment
|
||||
#define P_Control_Point_Env P_Control_Point_Environment
|
||||
#define P_Curr_Input_Port P_Current_Input_Port
|
||||
#define P_Curr_Output_Port P_Current_Output_Port
|
||||
#define P_Env_List P_Environment_To_List
|
||||
#define P_Char_Lower_Case P_Char_Lower_Casep
|
||||
#define P_Char_Upper_Case P_Char_Upper_Casep
|
||||
#define P_Char_Alphabetic P_Char_Alphabeticp
|
||||
#define P_Char_Numeric P_Char_Numericp
|
||||
#define P_Char_Whitespace P_Char_Whitespacep
|
||||
#define P_Chr_Eq P_Char_Eq
|
||||
#define P_Chr_Less P_Char_Less
|
||||
#define P_Chr_Greater P_Char_Greater
|
||||
#define P_Chr_Eq_Less P_Char_Eq_Less
|
||||
#define P_Chr_Eq_Greater P_Char_Eq_Greater
|
||||
#define P_Chr_CI_Eq P_Char_CI_Eq
|
||||
#define P_Chr_CI_Less P_Char_CI_Less
|
||||
#define P_Chr_CI_Greater P_Char_CI_Greater
|
||||
#define P_Chr_CI_Eq_Less P_Char_CI_Eq_Less
|
||||
#define P_Chr_CI_Eq_Greater P_Char_CI_Eq_Greater
|
||||
#define P_Str_Eq P_String_Eq
|
||||
#define P_Str_Less P_String_Less
|
||||
#define P_Str_Greater P_String_Greater
|
||||
#define P_Str_Eq_Less P_String_Eq_Less
|
||||
#define P_Str_Eq_Greater P_String_Eq_Greater
|
||||
#define P_Str_CI_Eq P_String_CI_Eq
|
||||
#define P_Str_CI_Less P_String_CI_Less
|
||||
#define P_Str_CI_Greater P_String_CI_Greater
|
||||
#define P_Str_CI_Eq_Less P_String_CI_Eq_Less
|
||||
#define P_Str_CI_Eq_Greater P_String_CI_Eq_Greater
|
||||
@@ -0,0 +1,23 @@
|
||||
/* These must be defined as macros, because they use Alloca().
|
||||
*/
|
||||
|
||||
#define Get_String_Stack(_from,_to) {\
|
||||
int _len;\
|
||||
Check_Type(_from, T_String);\
|
||||
_len = STRING(_from)->size;\
|
||||
Alloca ((_to), char*, _len+1);\
|
||||
bcopy (STRING(_from)->data, (_to), _len);\
|
||||
(_to)[_len] = '\0';\
|
||||
}
|
||||
|
||||
#define Get_Strsym_Stack(_from,_to) {\
|
||||
int _len;\
|
||||
if (TYPE(_from) == T_Symbol)\
|
||||
(_from) = SYMBOL(_from)->name;\
|
||||
else if (TYPE(_from) != T_String)\
|
||||
Wrong_Type_Combination ((_from), "string or symbol");\
|
||||
_len = STRING(_from)->size;\
|
||||
Alloca ((_to), char*, _len+1);\
|
||||
bcopy (STRING(_from)->data, (_to), _len);\
|
||||
(_to)[_len] = '\0';\
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
extern int Intr_Was_Ignored;
|
||||
extern unsigned long Intr_Level;
|
||||
|
||||
#ifdef POSIX_SIGNALS
|
||||
extern sigset_t Sigset_Old, Sigset_Block;
|
||||
#else
|
||||
#ifdef BSD_SIGNALS
|
||||
extern int Sigmask_Old, Sigmask_Block;
|
||||
#else
|
||||
C_LINKAGE_BEGIN
|
||||
extern void Intr_Handler P_((int));
|
||||
C_LINKAGE_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BSD_SIGNALS
|
||||
# ifndef sigmask
|
||||
# define sigmask(n) (1 << ((n)-1))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define Disable_Interrupts {\
|
||||
if (Intr_Level++ == 0) Force_Disable_Interrupts;\
|
||||
}
|
||||
|
||||
#define Enable_Interrupts {\
|
||||
if (Intr_Level > 0 && --Intr_Level == 0) Force_Enable_Interrupts;\
|
||||
}
|
||||
|
||||
#ifdef BSD_SIGNALS
|
||||
#define Force_Disable_Interrupts (void)sigblock (Sigmask_Block)
|
||||
#define Force_Enable_Interrupts (void)sigsetmask (Sigmask_Old)
|
||||
#else
|
||||
#ifdef POSIX_SIGNALS
|
||||
#define Force_Disable_Interrupts (void)sigprocmask (SIG_BLOCK, &Sigset_Block,\
|
||||
(sigset_t *)0)
|
||||
#define Force_Enable_Interrupts (void)sigprocmask (SIG_SETMASK, &Sigset_Old,\
|
||||
(sigset_t *)0)
|
||||
#else
|
||||
#define Force_Disable_Interrupts {\
|
||||
if (!Intr_Was_Ignored) (void)signal (SIGINT, SIG_IGN);\
|
||||
}
|
||||
#define Force_Enable_Interrupts {\
|
||||
if (!Intr_Was_Ignored) (void)signal (SIGINT, Intr_Handler);\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,466 @@
|
||||
/* This include file declares all symbols exported by the interpreter
|
||||
* kernel that may be used by applications or extensions.
|
||||
*/
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
|
||||
/* Autoloading
|
||||
*/
|
||||
extern Object P_Autoload P_((Object, Object));
|
||||
|
||||
/* Bignums
|
||||
*/
|
||||
extern Object Make_Uninitialized_Bignum P_((int));
|
||||
extern Bignum_Normalize_In_Place P_((struct S_Bignum *));
|
||||
|
||||
/* Boolean operators
|
||||
*/
|
||||
extern Object P_Booleanp P_((Object));
|
||||
extern Object P_Not P_((Object));
|
||||
extern Object P_Eq P_((Object, Object));
|
||||
extern Object P_Eqv P_((Object, Object));
|
||||
extern Object P_Equal P_((Object, Object));
|
||||
extern Object P_Empty_List_Is_False P_((Object));
|
||||
extern int Eqv P_((Object, Object));
|
||||
extern int Equal P_((Object, Object));
|
||||
|
||||
/* Characters
|
||||
*/
|
||||
extern Object Make_Char P_((int));
|
||||
extern Object P_Charp P_((Object));
|
||||
extern Object P_Char_Upcase P_((Object));
|
||||
extern Object P_Char_Downcase P_((Object));
|
||||
extern Object P_Char_Eq P_((Object, Object));
|
||||
extern Object P_Char_Less P_((Object, Object));
|
||||
extern Object P_Char_Greater P_((Object, Object));
|
||||
extern Object P_Char_Eq_Less P_((Object, Object));
|
||||
extern Object P_Char_Eq_Greater P_((Object, Object));
|
||||
extern Object P_Char_CI_Eq P_((Object, Object));
|
||||
extern Object P_Char_CI_Less P_((Object, Object));
|
||||
extern Object P_Char_CI_Greater P_((Object, Object));
|
||||
extern Object P_Char_CI_Eq_Less P_((Object, Object));
|
||||
extern Object P_Char_CI_Eq_Greater P_((Object, Object));
|
||||
extern Object P_Char_Upper_Casep P_((Object));
|
||||
extern Object P_Char_Lower_Casep P_((Object));
|
||||
extern Object P_Char_Alphabeticp P_((Object));
|
||||
extern Object P_Char_Numericp P_((Object));
|
||||
extern Object P_Char_Whitespacep P_((Object));
|
||||
extern Object P_Char_To_Integer P_((Object));
|
||||
extern Object P_Integer_To_Char P_((Object));
|
||||
|
||||
/* Continuations
|
||||
*/
|
||||
extern Object P_Call_With_Current_Continuation P_((Object));
|
||||
extern Object P_Dynamic_Wind P_((Object, Object, Object));
|
||||
extern Object P_Control_Pointp P_((Object));
|
||||
extern Object P_Control_Point_Environment P_((Object));
|
||||
|
||||
/* Scheme strings --> C Strings
|
||||
*/
|
||||
extern char *Get_String P_((Object));
|
||||
extern char *Get_Strsym P_((Object));
|
||||
|
||||
/* Debugging
|
||||
*/
|
||||
extern Object P_Backtrace_List P_((int, Object*));
|
||||
|
||||
/* Dump
|
||||
*/
|
||||
extern Object P_Dump P_((Object));
|
||||
|
||||
/* Lexical bindings, environments
|
||||
*/
|
||||
extern Object P_The_Environment P_((void));
|
||||
extern Object P_Define P_((Object));
|
||||
extern Object P_Set P_((Object));
|
||||
extern Object P_Environment_To_List P_((Object));
|
||||
extern Object P_Define_Macro P_((Object));
|
||||
extern Object P_Boundp P_((Object));
|
||||
extern Object P_Global_Environment P_((void));
|
||||
extern Object P_Environmentp P_((Object));
|
||||
extern Object The_Environment, Global_Environment;
|
||||
|
||||
/* Error handling
|
||||
*/
|
||||
extern Primitive_Error P_((ELLIPSIS));
|
||||
extern Fatal_Error P_((ELLIPSIS));
|
||||
extern Range_Error P_((Object));
|
||||
extern Panic P_((const char*));
|
||||
extern Object P_Error P_((int, Object*));
|
||||
extern Object P_Reset P_((void));
|
||||
extern const char *Error_Tag; /* will be removed in the near future */
|
||||
extern const char *Get_Error_Tag P_((void));
|
||||
extern void Set_Error_Tag P_((const char *));
|
||||
extern void Set_App_Name P_((char *));
|
||||
|
||||
/* Interrupts
|
||||
*/
|
||||
extern Object P_Disable_Interrupts P_((void));
|
||||
extern Object P_Enable_Interrupts P_((void));
|
||||
extern void Signal_Exit P_((int));
|
||||
|
||||
/* Features
|
||||
*/
|
||||
extern Object P_Features P_((void));
|
||||
extern Object P_Featurep P_((Object));
|
||||
extern Object P_Provide P_((Object));
|
||||
extern Object P_Require P_((int, Object*));
|
||||
|
||||
/* Memory allocation, garbage collection
|
||||
*/
|
||||
extern int GC_Debug;
|
||||
extern Object Alloc_Object P_((int, int, int));
|
||||
extern Register_Before_GC P_((void (*)(void)));
|
||||
extern Register_After_GC P_((void (*)(void)));
|
||||
extern Object P_Collect P_((void));
|
||||
extern Object P_Garbage_Collect_Status P_((int, Object *));
|
||||
#ifdef GENERATIONAL_GC
|
||||
extern Object P_Collect_Incremental P_((void));
|
||||
#endif
|
||||
|
||||
/* Files and ports
|
||||
*/
|
||||
extern Object Curr_Input_Port, Curr_Output_Port;
|
||||
extern Object Standard_Input_Port, Standard_Output_Port;
|
||||
extern Reset_IO P_((int));
|
||||
extern Object P_Current_Input_Port P_((void));
|
||||
extern Object P_Current_Output_Port P_((void));
|
||||
extern Object P_Input_Portp P_((Object));
|
||||
extern Object P_Output_Portp P_((Object));
|
||||
extern Object P_Open_Input_File P_((Object));
|
||||
extern Object P_Open_Output_File P_((Object));
|
||||
extern Object P_Open_Input_Output_File P_((Object));
|
||||
extern Object P_Eof_Objectp P_((Object));
|
||||
extern Object P_With_Input_From_File P_((Object, Object));
|
||||
extern Object P_With_Output_To_File P_((Object, Object));
|
||||
extern Object P_Call_With_Input_File P_((Object, Object));
|
||||
extern Object P_Call_With_Output_File P_((Object, Object));
|
||||
extern Object P_Open_Input_String P_((Object));
|
||||
extern Object P_Open_Output_String P_((void));
|
||||
extern Object P_Port_File_Name P_((Object));
|
||||
extern Object P_Tilde_Expand P_((Object));
|
||||
extern Object P_File_Existsp P_((Object));
|
||||
extern Object P_Close_Input_Port P_((Object));
|
||||
extern Object P_Close_Output_Port P_((Object));
|
||||
extern Object P_Port_Line_Number P_((Object));
|
||||
extern Object Terminate_File P_((Object));
|
||||
extern Object Make_Port P_((int, FILE*, Object));
|
||||
extern int Path_Max P_((void));
|
||||
|
||||
/* Loading of files
|
||||
*/
|
||||
extern Object P_Load P_((int, Object*));
|
||||
extern void Load_Source_Port P_((Object));
|
||||
extern void Load_File P_((char *));
|
||||
|
||||
/* Pairs and lists
|
||||
*/
|
||||
extern Object P_Cons P_((Object, Object));
|
||||
extern Object P_Car P_((Object));
|
||||
extern Object P_Cdr P_((Object));
|
||||
extern Object P_Set_Car P_((Object, Object));
|
||||
extern Object P_Set_Cdr P_((Object, Object));
|
||||
extern Object P_Listp P_((Object));
|
||||
extern Object P_List P_((int, Object*));
|
||||
extern Object P_Length P_((Object));
|
||||
extern Object P_Nullp P_((Object));
|
||||
extern Object P_Pairp P_((Object));
|
||||
extern Object P_Cxr P_((Object, Object));
|
||||
extern Object P_Cddr P_((Object));
|
||||
extern Object P_Cdar P_((Object));
|
||||
extern Object P_Cadr P_((Object));
|
||||
extern Object P_Caar P_((Object));
|
||||
extern Object P_Cdddr P_((Object));
|
||||
extern Object P_Cddar P_((Object));
|
||||
extern Object P_Cdadr P_((Object));
|
||||
extern Object P_Cdaar P_((Object));
|
||||
extern Object P_Caddr P_((Object));
|
||||
extern Object P_Cadar P_((Object));
|
||||
extern Object P_Caadr P_((Object));
|
||||
extern Object P_Caaar P_((Object));
|
||||
extern Object P_Caaaar P_((Object));
|
||||
extern Object P_Caaadr P_((Object));
|
||||
extern Object P_Caadar P_((Object));
|
||||
extern Object P_Caaddr P_((Object));
|
||||
extern Object P_Cadaar P_((Object));
|
||||
extern Object P_Cadadr P_((Object));
|
||||
extern Object P_Caddar P_((Object));
|
||||
extern Object P_Cadddr P_((Object));
|
||||
extern Object P_Cdaaar P_((Object));
|
||||
extern Object P_Cdaadr P_((Object));
|
||||
extern Object P_Cdadar P_((Object));
|
||||
extern Object P_Cdaddr P_((Object));
|
||||
extern Object P_Cddaar P_((Object));
|
||||
extern Object P_Cddadr P_((Object));
|
||||
extern Object P_Cdddar P_((Object));
|
||||
extern Object P_Cddddr P_((Object));
|
||||
extern Object P_Append P_((int, Object*));
|
||||
extern Object P_Append_Set P_((int, Object*));
|
||||
extern Object P_Last_Pair P_((Object));
|
||||
extern Object P_Reverse P_((Object));
|
||||
extern Object P_Reverse_Set P_((Object));
|
||||
extern Object P_List_Tail P_((Object, Object));
|
||||
extern Object P_List_Ref P_((Object, Object));
|
||||
extern Object P_Assq P_((Object, Object));
|
||||
extern Object P_Assv P_((Object, Object));
|
||||
extern Object P_Assoc P_((Object, Object));
|
||||
extern Object P_Memq P_((Object, Object));
|
||||
extern Object P_Memv P_((Object, Object));
|
||||
extern Object P_Member P_((Object, Object));
|
||||
extern Object P_Make_List P_((Object, Object));
|
||||
extern Object Copy_List P_((Object));
|
||||
extern int Fast_Length P_((Object));
|
||||
extern Object Const_Cons P_((Object, Object));
|
||||
|
||||
/* Startup and termination
|
||||
*/
|
||||
extern Object P_Command_Line_Args P_((void));
|
||||
extern Object P_Exit P_((int, Object*));
|
||||
extern void Elk_Init P_((int, char **av, int, char *));
|
||||
|
||||
/* malloc() and realloc()
|
||||
*/
|
||||
extern char *Safe_Malloc P_((unsigned));
|
||||
extern char *Safe_Realloc P_((char*, unsigned));
|
||||
|
||||
/* Numbers
|
||||
*/
|
||||
extern Object Make_Integer P_((int));
|
||||
extern Object Make_Unsigned P_((unsigned));
|
||||
extern Object Make_Long P_((long));
|
||||
extern Object Make_Unsigned_Long P_((unsigned long));
|
||||
extern Object Make_Reduced_Flonum P_((double));
|
||||
extern Object Make_Flonum P_((double));
|
||||
extern Object P_Numberp P_((Object));
|
||||
extern Object P_Complexp P_((Object));
|
||||
extern Object P_Realp P_((Object));
|
||||
extern Object P_Rationalp P_((Object));
|
||||
extern Object P_Integerp P_((Object));
|
||||
extern Object P_Abs P_((Object));
|
||||
extern Object P_Zerop P_((Object));
|
||||
extern Object P_Positivep P_((Object));
|
||||
extern Object P_Negativep P_((Object));
|
||||
extern Object P_Oddp P_((Object));
|
||||
extern Object P_Evenp P_((Object));
|
||||
extern Object P_Exactp P_((Object));
|
||||
extern Object P_Inexactp P_((Object));
|
||||
extern Object P_Exact_To_Inexact P_((Object));
|
||||
extern Object P_Inexact_To_Exact P_((Object));
|
||||
extern Object P_Inc P_((Object));
|
||||
extern Object P_Dec P_((Object));
|
||||
extern Object P_Generic_Equal P_((int, Object*));
|
||||
extern Object P_Generic_Less P_((int, Object*));
|
||||
extern Object P_Generic_Greater P_((int, Object*));
|
||||
extern Object P_Generic_Eq_Less P_((int, Object*));
|
||||
extern Object P_Generic_Eq_Greater P_((int, Object*));
|
||||
extern Object P_Generic_Plus P_((int, Object*));
|
||||
extern Object P_Generic_Minus P_((int, Object*));
|
||||
extern Object P_Generic_Multiply P_((int, Object*));
|
||||
extern Object P_Generic_Divide P_((int, Object*));
|
||||
extern Object P_Quotient P_((Object, Object));
|
||||
extern Object P_Remainder P_((Object, Object));
|
||||
extern Object P_Modulo P_((Object, Object));
|
||||
extern Object P_Gcd P_((int, Object*));
|
||||
extern Object P_Lcm P_((int, Object*));
|
||||
extern Object P_Floor P_((Object));
|
||||
extern Object P_Ceiling P_((Object));
|
||||
extern Object P_Truncate P_((Object));
|
||||
extern Object P_Round P_((Object));
|
||||
extern Object P_Sqrt P_((Object));
|
||||
extern Object P_Exp P_((Object));
|
||||
extern Object P_Log P_((Object));
|
||||
extern Object P_Sin P_((Object));
|
||||
extern Object P_Cos P_((Object));
|
||||
extern Object P_Tan P_((Object));
|
||||
extern Object P_Asin P_((Object));
|
||||
extern Object P_Acos P_((Object));
|
||||
extern Object P_Atan P_((int, Object*));
|
||||
extern Object P_Min P_((int, Object*));
|
||||
extern Object P_Max P_((int, Object*));
|
||||
extern Object P_Random P_((void));
|
||||
extern Object P_Srandom P_((Object));
|
||||
extern Object P_Number_To_String P_((int, Object*));
|
||||
extern double Get_Double P_((Object));
|
||||
extern Get_Integer P_((Object));
|
||||
extern unsigned Get_Unsigned P_((Object));
|
||||
extern long Get_Long P_((Object));
|
||||
extern unsigned long Get_Unsigned_Long P_((Object));
|
||||
extern Get_Exact_Integer P_((Object));
|
||||
extern unsigned Get_Exact_Unsigned P_((Object));
|
||||
extern long Get_Exact_Long P_((Object));
|
||||
extern unsigned long Get_Exact_Unsigned_Long P_((Object));
|
||||
|
||||
/* Onfork handlers
|
||||
*/
|
||||
extern Register_Onfork P_((void (*)(void)));
|
||||
extern void Call_Onfork P_((void));
|
||||
|
||||
/* Define_Primitive()
|
||||
*/
|
||||
extern Define_Primitive P_((Object (*)(ELLIPSIS), const char*, int, int,
|
||||
enum discipline));
|
||||
|
||||
/* Output
|
||||
*/
|
||||
extern Object P_Write P_((int, Object*));
|
||||
extern Object P_Display P_((int, Object*));
|
||||
extern Object P_Write_Char P_((int, Object*));
|
||||
extern Object P_Newline P_((int, Object*));
|
||||
extern Object P_Format P_((int, Object*));
|
||||
extern Object P_Clear_Output_Port P_((int, Object*));
|
||||
extern Object P_Flush_Output_Port P_((int, Object*));
|
||||
extern Object P_Print P_((int, Object*));
|
||||
extern Object P_Get_Output_String P_((Object));
|
||||
extern Check_Output_Port P_((Object));
|
||||
extern Discard_Output P_((Object));
|
||||
extern Printf P_((ELLIPSIS));
|
||||
extern Print_Object P_((Object, Object, int, int, int));
|
||||
extern General_Print_Object P_((Object, Object, int));
|
||||
extern Format P_((Object, const char*, int, int, Object*));
|
||||
extern int Saved_Errno;
|
||||
|
||||
/* Evaluator, procedures, macros
|
||||
*/
|
||||
extern Object Eval P_((Object));
|
||||
extern Object P_Eval P_((int, Object*));
|
||||
extern Object P_Apply P_((int, Object*));
|
||||
extern Object Funcall P_((Object, Object, int));
|
||||
extern Object P_Lambda P_((Object));
|
||||
extern Object P_Map P_((int, Object*));
|
||||
extern Object P_Procedure_Environment P_((Object));
|
||||
extern Object P_Procedure_Lambda P_((Object));
|
||||
extern Object P_For_Each P_((int, Object*));
|
||||
extern Object P_Procedurep P_((Object));
|
||||
extern Object P_Macro P_((Object));
|
||||
extern Object P_Macro_Body P_((Object));
|
||||
extern Object P_Macro_Expand P_((Object));
|
||||
extern Object P_Primitivep P_((Object));
|
||||
extern Object P_Compoundp P_((Object));
|
||||
extern Object P_Macrop P_((Object));
|
||||
extern Check_Procedure P_((Object));
|
||||
|
||||
/* Delay and force
|
||||
*/
|
||||
extern Object P_Delay P_((Object));
|
||||
extern Object P_Force P_((Object));
|
||||
extern Object P_Promisep P_((Object));
|
||||
extern Object P_Promise_Environment P_((Object));
|
||||
|
||||
/* Input
|
||||
*/
|
||||
extern Object P_Read P_((int, Object*));
|
||||
extern Object P_Read_Char P_((int, Object*));
|
||||
extern Object P_Peek_Char P_((int, Object*));
|
||||
extern Object P_Char_Readyp P_((int, Object*));
|
||||
extern Object P_Unread_Char P_((int, Object*));
|
||||
extern Object P_Read_String P_((int, Object*));
|
||||
extern Object P_Clear_Input_Port P_((int, Object*));
|
||||
extern Object General_Read P_((Object, int));
|
||||
extern Check_Input_Port P_((Object));
|
||||
extern Discard_Input P_((Object));
|
||||
extern void Define_Reader P_((int, READFUN));
|
||||
|
||||
/* Special forms
|
||||
*/
|
||||
extern Object P_Quote P_((Object));
|
||||
extern Object P_If P_((Object));
|
||||
extern Object P_Let P_((Object));
|
||||
extern Object P_Letseq P_((Object));
|
||||
extern Object P_Letrec P_((Object));
|
||||
extern Object P_Case P_((Object));
|
||||
extern Object P_Cond P_((Object));
|
||||
extern Object P_And P_((Object));
|
||||
extern Object P_Or P_((Object));
|
||||
extern Object P_Do P_((Object));
|
||||
extern Object P_Quasiquote P_((Object));
|
||||
extern Object P_Fluid_Let P_((Object));
|
||||
extern Object P_Begin P_((Object));
|
||||
extern Object P_Begin1 P_((Object));
|
||||
|
||||
/* Strings
|
||||
*/
|
||||
extern Object Make_String P_((const char*, int));
|
||||
extern Object Make_Const_String P_((const char*, int));
|
||||
extern Object P_Make_String P_((int, Object*));
|
||||
extern Object P_Stringp P_((Object));
|
||||
extern Object P_String P_((int, Object*));
|
||||
extern Object P_String_To_Number P_((int, Object*));
|
||||
extern Object P_String_Eq P_((Object, Object));
|
||||
extern Object P_String_Less P_((Object, Object));
|
||||
extern Object P_String_Greater P_((Object, Object));
|
||||
extern Object P_String_Eq_Less P_((Object, Object));
|
||||
extern Object P_String_Eq_Greater P_((Object, Object));
|
||||
extern Object P_String_CI_Eq P_((Object, Object));
|
||||
extern Object P_String_CI_Less P_((Object, Object));
|
||||
extern Object P_String_CI_Greater P_((Object, Object));
|
||||
extern Object P_String_CI_Eq_Less P_((Object, Object));
|
||||
extern Object P_String_CI_Eq_Greater P_((Object, Object));
|
||||
extern Object P_String_Length P_((Object));
|
||||
extern Object P_String_Ref P_((Object, Object));
|
||||
extern Object P_String_Set P_((Object, Object, Object));
|
||||
extern Object P_Substring P_((Object, Object, Object));
|
||||
extern Object P_String_Copy P_((Object));
|
||||
extern Object P_String_Append P_((int, Object*));
|
||||
extern Object P_List_To_String P_((Object));
|
||||
extern Object P_String_To_List P_((Object));
|
||||
extern Object P_Substring_Fill P_((Object, Object, Object, Object));
|
||||
extern Object P_String_Fill P_((Object, Object));
|
||||
extern Object P_Substringp P_((Object, Object));
|
||||
extern Object P_CI_Substringp P_((Object, Object));
|
||||
|
||||
/* Symbols, variables, frequently used Scheme objects
|
||||
*/
|
||||
extern Object Null, True, False, Void, Newline, Eof;
|
||||
extern Object Intern P_((const char*));
|
||||
extern Object CI_Intern P_((const char*));
|
||||
extern Object P_Oblist P_((void));
|
||||
extern Object P_Symbolp P_((Object));
|
||||
extern Object P_Symbol_To_String P_((Object));
|
||||
extern Object P_String_To_Symbol P_((Object));
|
||||
extern Object P_Put P_((int, Object*));
|
||||
extern Object P_Get P_((Object, Object));
|
||||
extern Object P_Symbol_Plist P_((Object));
|
||||
extern void Define_Variable P_((Object*, const char*, Object));
|
||||
extern void Define_Symbol P_((Object *, const char*));
|
||||
extern Object Sym_Else;
|
||||
extern Object Var_Get P_((Object));
|
||||
extern void Var_Set P_((Object, Object));
|
||||
extern int Var_Is_True P_((Object));
|
||||
extern unsigned long Symbols_To_Bits P_((Object, int, SYMDESCR*));
|
||||
extern Object Bits_To_Symbols P_((unsigned long, int, SYMDESCR*));
|
||||
|
||||
/* Termination functions
|
||||
*/
|
||||
extern void Register_Object P_((Object, GENERIC, PFO, int));
|
||||
extern void Deregister_Object P_((Object));
|
||||
extern Object Find_Object P_((ELLIPSIS));
|
||||
extern void Terminate_Group P_((GENERIC));
|
||||
extern void Terminate_Type P_((int));
|
||||
|
||||
/* Types, Define_Type()
|
||||
*/
|
||||
extern TYPEDESCR *Types;
|
||||
extern Object P_Type P_((Object));
|
||||
extern Wrong_Type P_((Object, int));
|
||||
extern Wrong_Type_Combination P_((Object, const char*));
|
||||
extern Define_Type P_((int, const char*, int (*)(Object), int,
|
||||
int (*)(Object, Object), int (*)(Object, Object),
|
||||
int (*)(Object, Object, int, int, int),
|
||||
int (*)(Object*, int (*)(Object*)) ));
|
||||
|
||||
/* Vectors
|
||||
*/
|
||||
extern Object Make_Vector P_((int, Object));
|
||||
extern Object Make_Const_Vector P_((int, Object));
|
||||
extern Object P_Make_Vector P_((int, Object*));
|
||||
extern Object P_Vectorp P_((Object));
|
||||
extern Object P_Vector P_((int, Object*));
|
||||
extern Object P_Vector_Length P_((Object));
|
||||
extern Object P_Vector_Ref P_((Object, Object));
|
||||
extern Object P_Vector_Set P_((Object, Object, Object));
|
||||
extern Object P_Vector_To_List P_((Object));
|
||||
extern Object P_List_To_Vector P_((Object));
|
||||
extern Object P_Vector_Fill P_((Object, Object));
|
||||
extern Object P_Vector_Copy P_((Object));
|
||||
|
||||
C_LINKAGE_END
|
||||
@@ -0,0 +1,39 @@
|
||||
/* These definitions are not tunable. Do not change them.
|
||||
*/
|
||||
|
||||
|
||||
#if __STDC__ || defined(__cplusplus)
|
||||
# undef WANT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#ifdef WANT_PROTOTYPES
|
||||
# define ELK_USE_PROTOTYPES
|
||||
# define ELLIPSIS
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define ELK_USE_PROTOTYPES
|
||||
# define ELLIPSIS ...
|
||||
# define C_LINKAGE_BEGIN extern "C" {
|
||||
# define C_LINKAGE_END }
|
||||
#else
|
||||
# define C_LINKAGE_BEGIN
|
||||
# define C_LINKAGE_END
|
||||
#endif
|
||||
|
||||
#if __STDC__ && !defined(__cplusplus)
|
||||
# define ELK_USE_PROTOTYPES
|
||||
# define ELLIPSIS
|
||||
#endif
|
||||
|
||||
#ifdef NO_PROTOTYPES
|
||||
# undef ELK_USE_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#ifdef ELK_USE_PROTOTYPES
|
||||
# define P_(args) args
|
||||
#else
|
||||
# define P_(args) ()
|
||||
# define ELLIPSIS
|
||||
# define const
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
extern GCNODE *GC_List;
|
||||
|
||||
#define TAG_FUN -1
|
||||
#define TAG_TCFUN -2
|
||||
#define TAG_ARGS -3
|
||||
#define TAG_ENV -4
|
||||
|
||||
#define GC_Node GCNODE gc1
|
||||
#define GC_Node2 GCNODE gc1, gc2
|
||||
#define GC_Node3 GCNODE gc1, gc2, gc3
|
||||
#define GC_Node4 GCNODE gc1, gc2, gc3, gc4
|
||||
#define GC_Node5 GCNODE gc1, gc2, gc3, gc4, gc5
|
||||
#define GC_Node6 GCNODE gc1, gc2, gc3, gc4, gc5, gc6
|
||||
#define GC_Node7 GCNODE gc1, gc2, gc3, gc4, gc5, gc6, gc7
|
||||
|
||||
#define GC_Link(x) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x; gc1.next = GC_List; GC_List = &gc1;\
|
||||
}
|
||||
|
||||
#define GC_Link2(x1,x2) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1; GC_List = &gc2;\
|
||||
}
|
||||
|
||||
#define GC_Link3(x1,x2,x3) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1;\
|
||||
gc3.gclen = 0; gc3.gcobj = &x3; gc3.next = &gc2; GC_List = &gc3;\
|
||||
}
|
||||
|
||||
#define GC_Link4(x1,x2,x3,x4) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1;\
|
||||
gc3.gclen = 0; gc3.gcobj = &x3; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3; GC_List = &gc4;\
|
||||
}
|
||||
|
||||
/* see src/proc.c */
|
||||
#define GC_Link4_Tag_Primitive(args,fun,env,x4) {\
|
||||
gc1.gclen = TAG_ARGS; gc1.gcobj = &args; gc1.next = GC_List;\
|
||||
gc2.gclen = Tail_Call ? TAG_TCFUN : TAG_FUN;\
|
||||
gc2.gcobj = &fun; gc2.next = &gc1;\
|
||||
gc3.gclen = TAG_ENV; gc3.gcobj = &env; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3; GC_List = &gc4;\
|
||||
}
|
||||
|
||||
#define GC_Link5(x1,x2,x3,x4,x5) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1;\
|
||||
gc3.gclen = 0; gc3.gcobj = &x3; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3;\
|
||||
gc5.gclen = 0; gc5.gcobj = &x5; gc5.next = &gc4; GC_List = &gc5;\
|
||||
}
|
||||
|
||||
#define GC_Link6(x1,x2,x3,x4,x5,x6) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1;\
|
||||
gc3.gclen = 0; gc3.gcobj = &x3; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3;\
|
||||
gc5.gclen = 0; gc5.gcobj = &x5; gc5.next = &gc4;\
|
||||
gc6.gclen = 0; gc6.gcobj = &x6; gc6.next = &gc5; GC_List = &gc6;\
|
||||
}
|
||||
|
||||
#define GC_Link7(x1,x2,x3,x4,x5,x6,x7) {\
|
||||
gc1.gclen = 0; gc1.gcobj = &x1; gc1.next = GC_List;\
|
||||
gc2.gclen = 0; gc2.gcobj = &x2; gc2.next = &gc1;\
|
||||
gc3.gclen = 0; gc3.gcobj = &x3; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3;\
|
||||
gc5.gclen = 0; gc5.gcobj = &x5; gc5.next = &gc4;\
|
||||
gc6.gclen = 0; gc6.gcobj = &x6; gc6.next = &gc5;\
|
||||
gc7.gclen = 0; gc7.gcobj = &x7; gc7.next = &gc6; GC_List = &gc7;\
|
||||
}
|
||||
|
||||
/* see src/proc.c */
|
||||
#define GC_Link7_Tag_Compound(args,fun,env,x4,x5,x6,x7) {\
|
||||
gc1.gclen = TAG_ARGS;\
|
||||
gc1.gcobj = &args; gc1.next = GC_List;\
|
||||
gc2.gclen = Tail_Call ? TAG_TCFUN : TAG_FUN;\
|
||||
gc2.gcobj = &fun; gc2.next = &gc1;\
|
||||
gc3.gclen = TAG_ENV;\
|
||||
gc3.gcobj = &env; gc3.next = &gc2;\
|
||||
gc4.gclen = 0; gc4.gcobj = &x4; gc4.next = &gc3;\
|
||||
gc5.gclen = 0; gc5.gcobj = &x5; gc5.next = &gc4;\
|
||||
gc6.gclen = 0; gc6.gcobj = &x6; gc6.next = &gc5;\
|
||||
gc7.gclen = 0; gc7.gcobj = &x7; gc7.next = &gc6; GC_List = &gc7;\
|
||||
}
|
||||
|
||||
#define GC_Unlink (GC_List = gc1.next)
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern Func_Global_GC_Link P_((Object*));
|
||||
C_LINKAGE_END
|
||||
|
||||
#define Global_GC_Link(x) Func_Global_GC_Link(&x)
|
||||
@@ -0,0 +1,145 @@
|
||||
/* Functions and variables that are used by more than one source file of
|
||||
* the kernel. Not available to extensions and applications.
|
||||
*/
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
|
||||
/* autoload.c
|
||||
*/
|
||||
extern Object V_Autoload_Notifyp;
|
||||
extern Object Do_Autoload P_((Object, Object));
|
||||
|
||||
/* bignum.c
|
||||
*/
|
||||
extern int Bignum_Zero P_((Object));
|
||||
extern int Bignum_Positive P_((Object));
|
||||
extern int Bignum_Negative P_((Object));
|
||||
extern int Bignum_Even P_((Object));
|
||||
extern Object Make_Bignum P_((const char*, int, int));
|
||||
extern Object Integer_To_Bignum P_((int));
|
||||
extern Object Bignum_Divide P_((Object, Object));
|
||||
extern Object Bignum_Abs P_((Object));
|
||||
extern Object Bignum_Plus P_((Object, Object));
|
||||
extern Object Bignum_Minus P_((Object, Object));
|
||||
extern Object Bignum_Fixnum_Multiply P_((Object, Object));
|
||||
extern Object Bignum_Multiply P_((Object, Object));
|
||||
extern Object Bignum_Fixnum_Divide P_((Object, Object));
|
||||
extern Object Double_To_Bignum P_((double));
|
||||
extern Object Unsigned_To_Bignum P_((unsigned));
|
||||
extern Object Long_To_Bignum P_((long));
|
||||
extern Object Unsigned_Long_To_Bignum P_((unsigned long));
|
||||
extern unsigned Bignum_To_Unsigned P_((Object));
|
||||
extern unsigned long Bignum_To_Unsigned_Long P_((Object));
|
||||
extern long Bignum_To_Long P_((Object));
|
||||
extern Object Bignum_To_String P_((Object, int));
|
||||
extern double Bignum_To_Double P_((Object));
|
||||
extern Bignum_Equal P_((Object, Object));
|
||||
extern Bignum_Greater P_((Object, Object));
|
||||
extern Bignum_Less P_((Object, Object));
|
||||
extern Bignum_Eq_Less P_((Object, Object));
|
||||
extern Bignum_Eq_Greater P_((Object, Object));
|
||||
|
||||
/* cont.c
|
||||
*/
|
||||
extern WIND *First_Wind, *Last_Wind;
|
||||
extern Object Internal_Call_CC P_((int, Object));
|
||||
|
||||
/* dump.c
|
||||
*/
|
||||
extern Object Dump_Control_Point;
|
||||
|
||||
/* env.c
|
||||
*/
|
||||
extern Object Add_Binding P_((Object, Object, Object));
|
||||
extern Object Lookup_Symbol P_((Object, int));
|
||||
|
||||
/* error.c
|
||||
*/
|
||||
extern Object Arg_True;
|
||||
extern char *appname;
|
||||
|
||||
/* exception.c
|
||||
*/
|
||||
extern void Install_Intr_Handler P_((void));
|
||||
|
||||
/* heap.c
|
||||
*/
|
||||
#ifndef GENERATIONAL_GC
|
||||
extern char *Hp, *Heap_Start, *Heap_End, *Free_Start, *Free_End;
|
||||
#endif
|
||||
extern int GC_In_Progress;
|
||||
|
||||
/* io.c
|
||||
*/
|
||||
extern Object General_Open_File P_((Object, int, Object));
|
||||
|
||||
/* load.c
|
||||
*/
|
||||
extern char *Loader_Input;
|
||||
extern Object V_Load_Path, V_Load_Noisilyp, V_Load_Libraries;
|
||||
extern void Check_Loadarg P_((Object));
|
||||
extern Object General_Load P_((Object, Object));
|
||||
|
||||
/* list.c
|
||||
*/
|
||||
extern Object General_Assoc P_((Object, Object, int));
|
||||
|
||||
/* main.c
|
||||
*/
|
||||
extern char *stkbase, *A_Out_Name;
|
||||
extern int Stack_Grows_Down;
|
||||
extern int Max_Stack, Interpreter_Initialized, Was_Dumped;
|
||||
extern char *Brk_On_Dump;
|
||||
extern int Verb_Load, Verb_Init, Case_Insensitive;
|
||||
extern SYMTAB *The_Symbols;
|
||||
extern void Exit_Handler P_((void));
|
||||
#ifndef ATEXIT
|
||||
extern void exit P_((int));
|
||||
#endif
|
||||
|
||||
/* math.c
|
||||
*/
|
||||
extern char *Flonum_To_String P_((Object));
|
||||
|
||||
/* proc.c
|
||||
*/
|
||||
extern Object Sym_Lambda, Sym_Macro;
|
||||
extern Funcall_Control_Point P_((Object, Object, int));
|
||||
extern Object Make_Primitive
|
||||
P_((Object(*)(ELLIPSIS), const char*, int, int, enum discipline));
|
||||
|
||||
/* read.c
|
||||
*/
|
||||
extern Object Sym_Quote;
|
||||
extern Object Sym_Quasiquote, Sym_Unquote, Sym_Unquote_Splicing;
|
||||
extern Object Parse_Number P_((Object, const char*, int));
|
||||
|
||||
/* stab.c
|
||||
*/
|
||||
extern SYMTAB *Snarf_Symbols P_((ELLIPSIS)); /* varying args */
|
||||
extern SYMTAB *Open_File_And_Snarf_Symbols P_((char *));
|
||||
|
||||
/* stkmem.c
|
||||
*/
|
||||
#ifndef USE_ALLOCA
|
||||
extern Object Save_GC_Nodes P_((void));
|
||||
#endif
|
||||
|
||||
/* string.c
|
||||
*/
|
||||
extern char Char_Map[];
|
||||
extern Object General_Make_String P_((const char*, int, int));
|
||||
|
||||
/* symbol.c
|
||||
*/
|
||||
extern Object Unbound, Special, Zero, One;
|
||||
|
||||
/* type.c
|
||||
*/
|
||||
extern Num_Types, Max_Type;
|
||||
|
||||
/* vector.c
|
||||
*/
|
||||
extern Object List_To_Vector P_((Object, int));
|
||||
|
||||
C_LINKAGE_END
|
||||
@@ -0,0 +1,24 @@
|
||||
/* The `wrapper' include file used by the interpreter.
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "funcproto.h"
|
||||
#include "param.h"
|
||||
#include "object.h"
|
||||
#include "intern.h"
|
||||
#include "extern.h"
|
||||
#include "misc.h"
|
||||
#include "exception.h"
|
||||
#include "gc.h"
|
||||
#include "type.h"
|
||||
#include "stkmem.h"
|
||||
#include "cstring.h"
|
||||
#include "compat.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef __GNUC__
|
||||
# define __asm__ asm
|
||||
#endif
|
||||
|
||||
#ifndef HUGE
|
||||
# define HUGE HUGE_VAL
|
||||
#endif
|
||||
|
||||
|
||||
/* Arithmetic shift right for compilers that don't sign extend:
|
||||
*/
|
||||
#if (-1 >> 1) < 0
|
||||
# define ASR(n,s) ((n) >>= (s))
|
||||
#else
|
||||
# define NBITS(v) ((sizeof v) * 8)
|
||||
# define HIBIT(v,n) (NBITS(v) - (n))
|
||||
# define ASR(n,s) ((n) >>= (s),\
|
||||
((n) & (1 << (HIBIT((n),(s)) - 1)) ?\
|
||||
((n) |= ~(((unsigned)1 << HIBIT((n),(s))) - 1)) :\
|
||||
(n)))
|
||||
#endif
|
||||
|
||||
extern Object False2;
|
||||
|
||||
#define Nullp(x) (TYPE(x) == T_Null)
|
||||
#define Truep(x) (!EQ(x,False) && !EQ(x,False2))
|
||||
#define Car(x) PAIR(x)->car
|
||||
#define Cdr(x) PAIR(x)->cdr
|
||||
#define Cons P_Cons
|
||||
#define Begin P_Begin
|
||||
#define Assq(x,y) General_Assoc(x,y,0)
|
||||
#define Print(x) General_Print_Object (x, Curr_Output_Port, 0)
|
||||
#define Numeric(t) (t == T_Fixnum || t == T_Flonum || t == T_Bignum)
|
||||
|
||||
#define Whitespace(c) (c == ' ' || c == '\t' || c == '\014' || c == '\n')
|
||||
#define Delimiter(c) (c == ';' || c == ')' || c == '(' || c == '"')
|
||||
|
||||
|
||||
/* Align heap addresses */
|
||||
#ifdef ALIGN_8BYTE
|
||||
# define ALIGN(ptr) ((ptr) = (char *)(((long)(ptr) + 7) & ~7))
|
||||
#else
|
||||
# define ALIGN(ptr) ((ptr) = (char *)(((long)(ptr) + 3) & ~3))
|
||||
#endif
|
||||
|
||||
/* Normalize stack addresses */
|
||||
#define NORM(addr) ((long)(addr) + delta)
|
||||
|
||||
|
||||
/* Used in special forms: */
|
||||
extern int Tail_Call;
|
||||
|
||||
#define TC_Prolog register _t = Tail_Call
|
||||
#define TC_Disable Tail_Call = 0
|
||||
#define TC_Enable Tail_Call = _t
|
||||
|
||||
|
||||
/* Macros to be used by readers registered with Define_Reader().
|
||||
* They operate on variables c, port, f, and str.
|
||||
*/
|
||||
#define Reader_Getc {\
|
||||
c = str ? String_Getc (port) : getc (f);\
|
||||
if (c == '\n') PORT(port)->lno++;\
|
||||
}
|
||||
|
||||
#define Reader_Ungetc {\
|
||||
if (str) String_Ungetc (port,c); else (void)ungetc (c,f);\
|
||||
if (c == '\n') if (PORT(port)->lno > 1) PORT(port)->lno--;\
|
||||
}
|
||||
|
||||
#define Reader_Tweak_Stream {\
|
||||
if (!str && (feof (f) || ferror (f))) clearerr (f);\
|
||||
}
|
||||
|
||||
#define Reader_Sharp_Eof {\
|
||||
Reader_Tweak_Stream;\
|
||||
Reader_Error (port, "end of file after `#'");\
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
/* The Scheme object representation, and a few other important
|
||||
* data types.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned long data;
|
||||
int tag;
|
||||
} Object;
|
||||
|
||||
#define FIXBITS (8 * sizeof(int))
|
||||
#define SIGNBIT ((unsigned)1 << (FIXBITS-1))
|
||||
#define CONSTBIT 1
|
||||
#define TYPEBITS (8 * sizeof(int) - 1)
|
||||
#define MAX_TYPE ((1 << TYPEBITS) - 1)
|
||||
|
||||
#define UFIXNUM_FITS(i) (((i) & SIGNBIT) == 0)
|
||||
#define FIXNUM_FITS(i) 1
|
||||
|
||||
#define TYPE(x) ((x).tag >> 1)
|
||||
|
||||
#define FIXNUM(x) ((int)(x).data)
|
||||
#define CHAR(x) ((int)(x).data)
|
||||
|
||||
#define POINTER(x) ((x).data)
|
||||
#define SETPOINTER(x,p) ((x).data = (unsigned long)(p))
|
||||
#define SET(x,t,p) ((x).tag = (int)t << 1, (x).data = (unsigned long)(p))
|
||||
|
||||
#define ISCONST(x) ((x).tag & CONSTBIT)
|
||||
#define SETCONST(x) ((x).tag |= CONSTBIT)
|
||||
|
||||
#define EQ(x,y) ((x).data == (y).data && (x).tag == (y).tag)
|
||||
|
||||
/* GC related macros:
|
||||
*/
|
||||
#define WAS_FORWARDED(obj) (TYPE(*(Object *)POINTER(obj)) == T_Broken_Heart)
|
||||
#define UPDATE_OBJ(obj) SETPOINTER(obj, POINTER(*(Object *)POINTER(obj)))
|
||||
|
||||
#ifdef GENERATIONAL_GC
|
||||
|
||||
typedef int gcspace_t; /* type used for space and type arrays */
|
||||
typedef unsigned long gcptr_t; /* type used for pointers */
|
||||
typedef unsigned long pageno_t; /* type used for page numbers */
|
||||
typedef unsigned long addrarith_t; /* type used for address arithmetic */
|
||||
|
||||
extern gcspace_t *space;
|
||||
extern gcspace_t current_space;
|
||||
C_LINKAGE_BEGIN
|
||||
extern Visit P_((Object*)); /* required for REVIVE_OBJ below */
|
||||
C_LINKAGE_END
|
||||
|
||||
# ifdef ARRAY_BROKEN
|
||||
extern pageno_t pagebase;
|
||||
# else
|
||||
# define pagebase ((pageno_t)0)
|
||||
# endif
|
||||
|
||||
# define PAGEBYTES 512
|
||||
# define PAGE_TO_OBJ(p) ((Object *) (((p) + pagebase) * PAGEBYTES))
|
||||
# define OBJ_TO_PAGE(p) ((((gcptr_t)POINTER(p)) / PAGEBYTES) - pagebase)
|
||||
# define STABLE(x) ((~space[(x)]) & 1)
|
||||
# define MAKEOBJ(o,t,p) (SET(o, t, p))
|
||||
# define IS_ALIVE(obj) ((WAS_FORWARDED(obj)) || \
|
||||
(STABLE(OBJ_TO_PAGE(obj))) || \
|
||||
(space[OBJ_TO_PAGE(obj)] == current_space))
|
||||
# define REVIVE_OBJ(obj) Visit (&obj);
|
||||
#else
|
||||
# define IS_ALIVE(obj) WAS_FORWARDED(obj)
|
||||
# define REVIVE_OBJ(obj)
|
||||
#endif
|
||||
|
||||
/* Fixed types. Cannot use enum, because the set of types is extensible:
|
||||
*/
|
||||
#define T_Fixnum 0 /* Must be 0 */
|
||||
#define T_Bignum 1
|
||||
#define T_Flonum 2
|
||||
#define T_Null 3 /* empty list */
|
||||
#define T_Boolean 4 /* #t (1) and #f (0) */
|
||||
#define T_Unbound 5 /* only used internally */
|
||||
#define T_Special 6 /* only used internally */
|
||||
#define T_Character 7
|
||||
#define T_Symbol 8
|
||||
#define T_Pair 9
|
||||
#define T_Environment 10 /* A pair */
|
||||
#define T_String 11
|
||||
#define T_Vector 12
|
||||
#define T_Primitive 13 /* Primitive procedure */
|
||||
#define T_Compound 14 /* Compound procedure */
|
||||
#define T_Control_Point 15
|
||||
#define T_Promise 16 /* Result of (delay expression) */
|
||||
#define T_Port 17
|
||||
#define T_End_Of_File 18
|
||||
#define T_Autoload 19
|
||||
#define T_Macro 20
|
||||
#define T_Broken_Heart 21 /* only used internally */
|
||||
#ifdef GENERATIONAL_GC
|
||||
# define T_Align_8Byte 22 /* only used internally */
|
||||
# define T_Freespace 23 /* only used internally */
|
||||
#endif
|
||||
|
||||
#define BIGNUM(x) ((struct S_Bignum *)POINTER(x))
|
||||
#define FLONUM(x) ((struct S_Flonum *)POINTER(x))
|
||||
#define STRING(x) ((struct S_String *)POINTER(x))
|
||||
#define VECTOR(x) ((struct S_Vector *)POINTER(x))
|
||||
#define SYMBOL(x) ((struct S_Symbol *)POINTER(x))
|
||||
#define PAIR(x) ((struct S_Pair *)POINTER(x))
|
||||
#define PRIM(x) ((struct S_Primitive *)POINTER(x))
|
||||
#define COMPOUND(x) ((struct S_Compound *)POINTER(x))
|
||||
#define CONTROL(x) ((struct S_Control *)POINTER(x))
|
||||
#define PROMISE(x) ((struct S_Promise *)POINTER(x))
|
||||
#define PORT(x) ((struct S_Port *)POINTER(x))
|
||||
#define AUTOLOAD(x) ((struct S_Autoload *)POINTER(x))
|
||||
#define MACRO(x) ((struct S_Macro *)POINTER(x))
|
||||
|
||||
typedef unsigned short gran_t; /* Granularity of bignums */
|
||||
|
||||
struct S_Bignum {
|
||||
Object minusp;
|
||||
unsigned size; /* Number of ushorts allocated */
|
||||
unsigned usize; /* Number of ushorts actually used */
|
||||
gran_t data[1]; /* Data, lsw first */
|
||||
};
|
||||
|
||||
struct S_Flonum {
|
||||
Object tag; /* Each S_Foo must start with an Object */
|
||||
double val;
|
||||
};
|
||||
|
||||
struct S_Symbol {
|
||||
Object value;
|
||||
Object next;
|
||||
Object name; /* A string */
|
||||
Object plist;
|
||||
};
|
||||
|
||||
struct S_Pair {
|
||||
Object car, cdr;
|
||||
};
|
||||
|
||||
struct S_String {
|
||||
Object tag;
|
||||
int size;
|
||||
char data[1];
|
||||
};
|
||||
|
||||
struct S_Vector {
|
||||
Object tag;
|
||||
int size;
|
||||
Object data[1];
|
||||
};
|
||||
|
||||
enum discipline { EVAL, NOEVAL, VARARGS };
|
||||
struct S_Primitive {
|
||||
Object tag;
|
||||
Object (*fun) P_((ELLIPSIS));
|
||||
const char *name;
|
||||
int minargs;
|
||||
int maxargs; /* Or MANY */
|
||||
enum discipline disc;
|
||||
};
|
||||
#define MANY 100
|
||||
|
||||
struct S_Compound {
|
||||
Object closure; /* (lambda (args) form ...) */
|
||||
Object env; /* Procedure's environment */
|
||||
int min_args, max_args;
|
||||
int numforms;
|
||||
Object name;
|
||||
};
|
||||
|
||||
typedef struct wind {
|
||||
struct wind *next, *prev;
|
||||
Object inout; /* Pair of thunks */
|
||||
} WIND;
|
||||
|
||||
typedef struct funct {
|
||||
struct funct *next;
|
||||
char *name;
|
||||
void (*func) P_((void));
|
||||
} FUNCT;
|
||||
|
||||
typedef struct gcnode {
|
||||
struct gcnode *next;
|
||||
int gclen;
|
||||
Object *gcobj;
|
||||
} GCNODE;
|
||||
|
||||
typedef struct mem_node {
|
||||
struct mem_node *next;
|
||||
unsigned len;
|
||||
unsigned long refcnt;
|
||||
} MEM_NODE;
|
||||
|
||||
#if defined(vax) || defined(__vax__)
|
||||
typedef int jmp_buf[17];
|
||||
#else
|
||||
# include <setjmp.h>
|
||||
#endif
|
||||
|
||||
struct S_Control {
|
||||
Object env;
|
||||
GCNODE *gclist;
|
||||
MEM_NODE *memlist;
|
||||
Object memsave; /* string */
|
||||
Object gcsave; /* vector */
|
||||
WIND *firstwind, *lastwind;
|
||||
int tailcall;
|
||||
unsigned delta;
|
||||
#ifdef GENERATIONAL_GC
|
||||
int reloc;
|
||||
#endif
|
||||
jmp_buf j;
|
||||
int size;
|
||||
unsigned long intrlevel;
|
||||
char stack[1]; /* must be word aligned */
|
||||
};
|
||||
|
||||
struct S_Promise {
|
||||
Object env;
|
||||
Object thunk;
|
||||
int done;
|
||||
};
|
||||
|
||||
struct S_Port {
|
||||
Object name; /* string */
|
||||
short flags;
|
||||
char unread;
|
||||
int ptr;
|
||||
FILE *file;
|
||||
unsigned lno;
|
||||
int (*closefun) P_((FILE*));
|
||||
};
|
||||
#define P_OPEN 1 /* flags */
|
||||
#define P_INPUT 2
|
||||
#define P_STRING 4
|
||||
#define P_UNREAD 8
|
||||
#define P_BIDIR 16
|
||||
|
||||
#define IS_INPUT(port) (PORT(port)->flags & (P_INPUT|P_BIDIR))
|
||||
#define IS_OUTPUT(port) ((PORT(port)->flags & (P_INPUT|P_BIDIR)) != P_INPUT)
|
||||
|
||||
struct S_Autoload {
|
||||
Object files;
|
||||
Object env;
|
||||
};
|
||||
|
||||
struct S_Macro {
|
||||
Object body;
|
||||
int min_args, max_args;
|
||||
Object name;
|
||||
};
|
||||
|
||||
|
||||
/* "size" is called with one object and returns the size of the object.
|
||||
* If "size" is NOFUNC, then "const_size" is taken instead.
|
||||
* "eqv" and "equal" are called with two objects and return 0 or 1.
|
||||
* NOFUNC may be passed instead (then eqv and equal always return #f).
|
||||
* "print" is called with an object, a port, a flag indicating whether
|
||||
* the object is to be printed "raw" (a la display), the print-depth,
|
||||
* and the print-length.
|
||||
* "visit" is called with a pointer to an object and a function.
|
||||
* For each component of the object, the function must be called with
|
||||
* a pointer to the component. NOFUNC may be supplied.
|
||||
*/
|
||||
typedef struct {
|
||||
int haspointer;
|
||||
const char *name;
|
||||
int (*size) P_((Object));
|
||||
int const_size;
|
||||
int (*eqv) P_((Object, Object));
|
||||
int (*equal) P_((Object, Object));
|
||||
int (*print) P_((Object, Object, int, int, int));
|
||||
int (*visit) P_((Object*, int (*)(Object*)));
|
||||
} TYPEDESCR;
|
||||
|
||||
#ifdef ELK_USE_PROTOTYPES
|
||||
# define NOFUNC 0
|
||||
#else
|
||||
# define NOFUNC ((int (*)())0)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct sym {
|
||||
struct sym *next;
|
||||
char *name;
|
||||
unsigned long value;
|
||||
} SYM;
|
||||
|
||||
typedef struct {
|
||||
SYM *first;
|
||||
char *strings;
|
||||
} SYMTAB;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int type;
|
||||
} SYMPREFIX;
|
||||
|
||||
#define PR_EXTENSION 0 /* Elk extension initializers/finalizers */
|
||||
#define PR_CONSTRUCTOR 1 /* C++ static constructors/destructors */
|
||||
|
||||
|
||||
/* PFO, GENERIC, and MATCHFUN exist for backwards compatibility
|
||||
*/
|
||||
typedef Object (*PFO) P_((Object));
|
||||
typedef int (*MATCHFUN) P_((ELLIPSIS));
|
||||
#define GENERIC char*
|
||||
|
||||
typedef struct weak_node {
|
||||
struct weak_node *next;
|
||||
Object obj;
|
||||
PFO term;
|
||||
GENERIC group;
|
||||
char flags;
|
||||
} WEAK_NODE;
|
||||
|
||||
/* flags */
|
||||
#define WK_LEADER 1
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
unsigned long val;
|
||||
} SYMDESCR;
|
||||
|
||||
|
||||
/* Function that can be registered as a reader by Define_Reader():
|
||||
*/
|
||||
typedef Object (*READFUN) P_((Object, int, int));
|
||||
@@ -0,0 +1,56 @@
|
||||
/* These definitions are not intended to be tunable. Do not change
|
||||
* them unless you _must_.
|
||||
*/
|
||||
|
||||
|
||||
/* Name of Scheme file which is always loaded on startup:
|
||||
*/
|
||||
#define INITFILE "initscheme.scm"
|
||||
|
||||
|
||||
/* Name of environment variable holding initial load-path:
|
||||
*/
|
||||
#define LOADPATH_ENV "ELK_LOADPATH"
|
||||
|
||||
|
||||
/* Size of `obarray' (symbol hash table):
|
||||
*/
|
||||
#define OBARRAY_SIZE 1009
|
||||
|
||||
|
||||
/* Approximate size of gap between beginning of stack and `stkbase'
|
||||
* (subtracted from stack limit on startup):
|
||||
*/
|
||||
#define STACK_MARGIN (64*1024)
|
||||
|
||||
|
||||
/* Minimum number of bytes that must be reclaimed by a run of the
|
||||
* stop-and-copy garbage collector:
|
||||
*/
|
||||
#define HEAP_MARGIN (HEAP_SIZE/10*1024)
|
||||
|
||||
|
||||
/* The buffers maintained by output string ports grow in increments
|
||||
* of STRING_GROW_SIZE when written:
|
||||
*/
|
||||
#define STRING_GROW_SIZE 64
|
||||
|
||||
|
||||
/* Initial print depth and print length:
|
||||
*/
|
||||
#define DEF_PRINT_DEPTH 20
|
||||
#define DEF_PRINT_LEN 1000
|
||||
|
||||
|
||||
/* Offset to compensate for differences in argv/environment between base
|
||||
* a.out and dumped a.out on startup (see src/main.c):
|
||||
*/
|
||||
#ifdef CAN_DUMP
|
||||
# define INITIAL_STK_OFFSET (20*1024) /* 2*NCARGS */
|
||||
#endif
|
||||
|
||||
|
||||
/* Number of static string buffers cyclically reused by Get_String()
|
||||
* and Get_Strsym():
|
||||
*/
|
||||
#define NUMSTRBUFS 3
|
||||
@@ -0,0 +1,23 @@
|
||||
/* The `wrapper' include file used by extensions and applications.
|
||||
*/
|
||||
|
||||
#ifndef SCHEME_H
|
||||
#define SCHEME_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "funcproto.h"
|
||||
#include "param.h"
|
||||
#include "object.h"
|
||||
#include "extern.h"
|
||||
#include "misc.h"
|
||||
#include "exception.h"
|
||||
#include "gc.h"
|
||||
#include "type.h"
|
||||
#include "stkmem.h"
|
||||
#include "cstring.h"
|
||||
#include "compat.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifdef USE_ALLOCA
|
||||
|
||||
#ifdef INCLUDE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
/* #pragma must be indented to prevent some C-compilers from complaining
|
||||
* about "undefined control".
|
||||
*/
|
||||
#ifdef PRAGMA_ALLOCA
|
||||
#pragma alloca
|
||||
#endif
|
||||
|
||||
#if !defined(alloca) && !defined(__GNUC__)
|
||||
C_LINKAGE_BEGIN
|
||||
extern char *alloca P_((int));
|
||||
C_LINKAGE_END
|
||||
#endif
|
||||
|
||||
/* MIPS cc under Ultrix 4.2 requires argument to alloca() to be
|
||||
* parenthesized if it's a compound expression.
|
||||
*
|
||||
* Declare variable in Alloca_Begin and reference it in Alloca to make
|
||||
* sure users won't forget Alloca_Begin when using macros like
|
||||
* Get_String_Stack().
|
||||
*/
|
||||
#define Alloca_Begin int _Check_Alloca_Begin
|
||||
#define Alloca(ret,type,size) (_Check_Alloca_Begin = 0,\
|
||||
(ret) = (type)alloca((size)))
|
||||
#define Alloca_End
|
||||
|
||||
#else /* USE_ALLOCA */
|
||||
|
||||
extern MEM_NODE *Mem_List;
|
||||
extern char *Mem_Alloc P_((unsigned));
|
||||
|
||||
#define Alloca_Begin MEM_NODE *_mem_first = 0
|
||||
#define Alloca(ret,type,size) {\
|
||||
register MEM_NODE *_p;\
|
||||
_p = (MEM_NODE*)Mem_Alloc ((unsigned)(size) + sizeof(MEM_NODE));\
|
||||
_p->next = Mem_List;\
|
||||
_p->len = (size);\
|
||||
_p->refcnt = 1;\
|
||||
Mem_List = _p;\
|
||||
if (_mem_first == 0) _mem_first = _p;\
|
||||
(ret) = (type)(_p+1);\
|
||||
}
|
||||
#define Alloca_End {\
|
||||
register MEM_NODE *_p, *_q;\
|
||||
if (_mem_first != 0) {\
|
||||
_p = Mem_List;\
|
||||
do {\
|
||||
_q = _p;\
|
||||
_p = _p->next;\
|
||||
if (--_q->refcnt == 0)\
|
||||
free ((char *)_q);\
|
||||
} while (_q != _mem_first);\
|
||||
Mem_List = _p;\
|
||||
}\
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Miscellaneous macros for type-checking Scheme objects.
|
||||
*/
|
||||
|
||||
#define Check_Type(x,t) {\
|
||||
if (TYPE(x) != t) Wrong_Type (x, t);\
|
||||
}
|
||||
|
||||
#define Check_List(x) {\
|
||||
if (TYPE(x) != T_Pair && !Nullp (x)) Wrong_Type_Combination (x, "list");\
|
||||
}
|
||||
|
||||
#define Check_Number(x) {\
|
||||
register t = TYPE(x);\
|
||||
if (!Numeric (t)) Wrong_Type_Combination (x, "number");\
|
||||
}
|
||||
|
||||
/* This should be renamed; it checks whether x is an *exact* integer.
|
||||
*/
|
||||
#define Check_Integer(x) {\
|
||||
register t = TYPE(x);\
|
||||
if (t != T_Fixnum && t != T_Bignum) Wrong_Type (x, T_Fixnum);\
|
||||
}
|
||||
|
||||
#define Check_Mutable(x) {\
|
||||
if (ISCONST(x))\
|
||||
Primitive_Error ("attempt to modify constant");\
|
||||
}
|
||||
Reference in New Issue
Block a user