* Added more system checks.
* Now builds on Win32. git-svn-id: svn://svn.zoy.org/elk/trunk@130 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
parent
dcf74a9c38
commit
7a028b1c77
17
configure.ac
17
configure.ac
|
@ -52,7 +52,7 @@ AC_CHECK_FUNCS(random)
|
|||
|
||||
# Does the system have the index library function? If not, strchr
|
||||
# will be used.
|
||||
dnl FIXME
|
||||
AC_CHECK_FUNCS(index)
|
||||
|
||||
# Does the system have the bcopy, bzero, and bcmp library functions?
|
||||
# If not, memcpy/memset/memcmp will be used.
|
||||
|
@ -105,10 +105,8 @@ AC_EGREP_HEADER(_SC_PAGESIZE, unistd.h, [
|
|||
# signals (has sigblock and related functions); set reliable_signals=posix
|
||||
# for POSIX-style signals (sigprocmask, sigsets); otherwise old V7/SysV
|
||||
# signal semantics are assumed.
|
||||
if false; then
|
||||
AC_DEFINE(BSD_SIGNALS, 1, [FIXME HARD])
|
||||
fi
|
||||
AC_DEFINE(POSIX_SIGNALS, 1, [FIXME HARD])
|
||||
AC_CHECK_HEADERS(signal.h)
|
||||
AC_CHECK_FUNCS(sigprocmask sigblock)
|
||||
|
||||
# To support dynamic loading of object files and "dump", the system's
|
||||
# a.out format has to be known. Choose one of the following:
|
||||
|
@ -293,9 +291,8 @@ AC_CHECK_HEADERS(termio.h termios.h)
|
|||
# The interpreter uses the getrlimit function to determine the maximum
|
||||
# stack size of the running program. If this function is not supported,
|
||||
# set max_stack_size to a (fixed) maximum stack size (in bytes).
|
||||
if false; then
|
||||
AC_DEFINE(MAX_STACK_SIZE, 1, [FIXME HARD])
|
||||
fi
|
||||
AC_CHECK_FUNCS(getrlimit)
|
||||
AC_DEFINE(DEFAULT_MAX_STACK_SIZE, 1024*1024, [Define default max stack size])
|
||||
|
||||
# Is the mprotect system call supported? The generational garbage collector
|
||||
# requires mprotect to implement incremental GC. $mprotect is ignored if
|
||||
|
@ -339,7 +336,7 @@ fi
|
|||
# function actually extend the stack? If in doubt, extract alloca.o
|
||||
# from the C library and check if it contains the symbols malloc and free.
|
||||
# If this is the case, forget it.
|
||||
AC_DEFINE(USE_ALLOCA, 1, [FIXME HARD])
|
||||
AC_CHECK_FUNCS(alloca)
|
||||
|
||||
# Must <alloca.h> be included to use alloca? Is "#pragma alloca" required?
|
||||
AC_CHECK_HEADERS(alloca.h)
|
||||
|
@ -391,6 +388,8 @@ AC_DEFINE(OBJ_DIR, "/usr/lib/elk", [FIXME HARD])
|
|||
#define FIND_AOUT defined(USE_LD) || defined(CAN_DUMP) || defined(INIT_OBJECTS)
|
||||
AC_DEFINE(FIND_AOUT, 1, [FIXME HARD])
|
||||
|
||||
AC_CHECK_HEADERS(pwd.h sys/resource.h)
|
||||
|
||||
dnl
|
||||
dnl Check for available compiler features
|
||||
dnl
|
||||
|
|
|
@ -28,22 +28,24 @@
|
|||
* THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
extern int Intr_Was_Ignored;
|
||||
extern unsigned long Intr_Level;
|
||||
|
||||
#ifdef POSIX_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK)
|
||||
extern sigset_t Sigset_Old, Sigset_Block;
|
||||
#else
|
||||
#ifdef BSD_SIGNALS
|
||||
#elif defined(HAVE_SIGBLOCK)
|
||||
extern int Sigmask_Old, Sigmask_Block;
|
||||
#else
|
||||
C_LINKAGE_BEGIN
|
||||
extern void Intr_Handler P_((int));
|
||||
C_LINKAGE_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BSD_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK) || ! defined(HAVE_SIGBLOCK)
|
||||
# ifndef sigmask
|
||||
# define sigmask(n) (1 << ((n)-1))
|
||||
# endif
|
||||
|
@ -57,15 +59,14 @@ extern unsigned long Intr_Level;
|
|||
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
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
#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)
|
||||
#elif defined(HAVE_SIGBLOCK)
|
||||
#define Force_Disable_Interrupts (void)sigblock (Sigmask_Block)
|
||||
#define Force_Enable_Interrupts (void)sigsetmask (Sigmask_Old)
|
||||
#else
|
||||
#define Force_Disable_Interrupts {\
|
||||
if (!Intr_Was_Ignored) (void)signal (SIGINT, SIG_IGN);\
|
||||
|
@ -74,4 +75,4 @@ extern unsigned long Intr_Level;
|
|||
if (!Intr_Was_Ignored) (void)signal (SIGINT, Intr_Handler);\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ extern SYMTAB *Open_File_And_Snarf_Symbols P_((char *));
|
|||
|
||||
/* stkmem.c
|
||||
*/
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
extern Object Save_GC_Nodes P_((void));
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#ifndef SCHEME_H
|
||||
#define SCHEME_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "site.h"
|
||||
#include "funcproto.h"
|
||||
#include "param.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef USE_ALLOCA
|
||||
#ifdef HAVE_ALLOCA
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
|
@ -59,7 +59,7 @@ C_LINKAGE_END
|
|||
(ret) = (type)alloca((size)))
|
||||
#define Alloca_End
|
||||
|
||||
#else /* USE_ALLOCA */
|
||||
#else /* HAVE_ALLOCA */
|
||||
|
||||
extern MEM_NODE *Mem_List;
|
||||
extern char *Mem_Alloc P_((unsigned));
|
||||
|
|
|
@ -201,11 +201,7 @@ static Object P_Pause() {
|
|||
Fatal_Error("pause() returned unexpectedly");
|
||||
}
|
||||
|
||||
#if defined(POSIX_SIGNALS) || defined(BSD_SIGNALS)
|
||||
# define RELIABLE_SIGNALS
|
||||
#endif
|
||||
|
||||
#ifdef RELIABLE_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK) || defined(HAVE_SIGBLOCK)
|
||||
|
||||
static Object Handlers;
|
||||
|
||||
|
@ -217,7 +213,7 @@ static Object P_Alarm(Object s) {
|
|||
void General_Handler(int sig) {
|
||||
Object fun, args;
|
||||
|
||||
#ifndef BSD_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK)
|
||||
(void)signal(sig, General_Handler);
|
||||
#endif
|
||||
Set_Error_Tag("signal-handler");
|
||||
|
@ -248,7 +244,7 @@ static Object Action_To_Sym(void (*act)()) {
|
|||
}
|
||||
|
||||
void Add_To_Mask(int sig) {
|
||||
#ifdef POSIX_SIGNALS
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
sigaddset(&Sigset_Block, sig);
|
||||
#else
|
||||
Sigmask_Block |= sigmask(sig);
|
||||
|
@ -258,7 +254,7 @@ void Add_To_Mask(int sig) {
|
|||
}
|
||||
|
||||
void Remove_From_Mask(int sig) {
|
||||
#ifdef POSIX_SIGNALS
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
sigdelset(&Sigset_Block, sig);
|
||||
#else
|
||||
Sigmask_Block &= ~sigmask(sig);
|
||||
|
@ -319,7 +315,7 @@ static Object P_Signal(int argc, Object *argv) {
|
|||
Raise_System_Error("~E");
|
||||
return Truep(old) ? old : Action_To_Sym(disp);
|
||||
}
|
||||
#endif /* RELIABLE_SIGNALS */
|
||||
#endif /* defined(HAVE_SIGPROCMASK) || defined(HAVE_SIGBLOCK) */
|
||||
|
||||
void elk_init_unix_signal() {
|
||||
Define_Symbol(&Sym_Exit, "exit");
|
||||
|
@ -328,7 +324,7 @@ void elk_init_unix_signal() {
|
|||
Def_Prim(P_Kill, "unix-kill", 2, 2, EVAL);
|
||||
Def_Prim(P_List_Signals, "unix-list-signals", 0, 0, EVAL);
|
||||
Def_Prim(P_Pause, "unix-pause", 0, 0, EVAL);
|
||||
#ifdef RELIABLE_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK) || defined(HAVE_SIGBLOCK)
|
||||
Def_Prim(P_Alarm, "unix-alarm", 1, 1, EVAL);
|
||||
Handlers = Make_Vector(NSIG, False);
|
||||
Global_GC_Link(Handlers);
|
||||
|
|
12
src/cont.c
12
src/cont.c
|
@ -98,7 +98,7 @@ convex_longjmp (char *p, int i) {
|
|||
WIND *First_Wind, *Last_Wind;
|
||||
|
||||
static Object Cont_Value;
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
static Object Cont_GCsave;
|
||||
#endif
|
||||
|
||||
|
@ -161,7 +161,7 @@ void Jump_Cont (struct S_Control *cp, Object val) {
|
|||
longjmp (p->j, 1);
|
||||
}
|
||||
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
Object Terminate_Cont (Object cont) {
|
||||
Free_Mem_Nodes (CONTROL(cont)->memlist);
|
||||
return Void;
|
||||
|
@ -190,7 +190,7 @@ Object Internal_Call_CC (int from_dump, Object proc) {
|
|||
|
||||
control = gcsave = Null;
|
||||
GC_Link3 (proc, control, gcsave);
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
gcsave = Save_GC_Nodes ();
|
||||
#endif
|
||||
|
||||
|
@ -220,12 +220,12 @@ Object Internal_Call_CC (int from_dump, Object proc) {
|
|||
to = cp->stack;
|
||||
memcpy (to, p, cp->size);
|
||||
cp->delta = to - p;
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
Register_Object (control, (GENERIC)0, Terminate_Cont, 0);
|
||||
Save_Mem_Nodes (control);
|
||||
#endif
|
||||
if (setjmp (CONTROL(control)->j) != 0) {
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
Restore_GC_Nodes (Cont_GCsave);
|
||||
#endif
|
||||
if (Intr_Level == 0) {
|
||||
|
@ -289,7 +289,7 @@ void Funcall_Control_Point (Object control, Object argl, int eval) {
|
|||
cp = CONTROL(control);
|
||||
Switch_Environment (cp->env);
|
||||
GC_List = cp->gclist;
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
Restore_Mem_Nodes (control);
|
||||
Cont_GCsave = CONTROL(control)->gcsave;
|
||||
#endif
|
||||
|
|
|
@ -39,13 +39,11 @@ extern void Reset () elk_attribute(__noreturn__);
|
|||
int Intr_Was_Ignored;
|
||||
unsigned long int Intr_Level;
|
||||
|
||||
#ifdef POSIX_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK)
|
||||
sigset_t Sigset_Old, Sigset_Block;
|
||||
#else
|
||||
#ifdef BSD_SIGNALS
|
||||
#elif defined(HAVE_SIGBLOCK)
|
||||
int Sigmask_Old, Sigmask_Block;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static Object V_Interrupt_Handler;
|
||||
|
||||
|
@ -59,25 +57,27 @@ void Signal_Exit (int sig) {
|
|||
|
||||
void Init_Exception () {
|
||||
Define_Variable (&V_Interrupt_Handler, "interrupt-handler", Null);
|
||||
#ifdef POSIX_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK)
|
||||
sigemptyset (&Sigset_Block);
|
||||
sigaddset (&Sigset_Block, SIGINT);
|
||||
(void)sigprocmask (0, (sigset_t *)0, &Sigset_Old);
|
||||
#else
|
||||
#ifdef BSD_SIGNALS
|
||||
#elif defined(HAVE_SIGBLOCK)
|
||||
Sigmask_Block = sigmask (SIGINT);
|
||||
Sigmask_Old = sigblock (0);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
(void)signal (SIGHUP, Signal_Exit);
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
(void)signal (SIGPIPE, Signal_Exit);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void Intr_Handler (int sig) {
|
||||
Object fun;
|
||||
|
||||
#ifndef BSD_SIGNALS
|
||||
#if defined(HAVE_SIGPROCMASK) || ! defined(HAVE_SIGBLOCK)
|
||||
(void)signal (SIGINT, Intr_Handler);
|
||||
#endif
|
||||
Set_Error_Tag ("interrupt-handler");
|
||||
|
|
|
@ -1183,7 +1183,7 @@ static void ScanPage (Object *currentp, Object *nextcp) {
|
|||
case T_Control_Point:
|
||||
(CONTROL(obj)->delta) += CONTROL(obj)->reloc;
|
||||
|
||||
#ifdef USE_ALLOCA
|
||||
#ifdef HAVE_ALLOCA
|
||||
Visit_GC_List (CONTROL(obj)->gclist, CONTROL(obj)->delta);
|
||||
#else
|
||||
Visit (&CONTROL(obj)->gcsave);
|
||||
|
|
|
@ -243,7 +243,7 @@ again:
|
|||
case T_Control_Point:
|
||||
Recursive_Visit (&CONTROL(*p)->memsave);
|
||||
CONTROL(*p)->delta += reloc;
|
||||
#ifdef USE_ALLOCA
|
||||
#ifdef HAVE_ALLOCA
|
||||
Visit_GC_List (CONTROL(*p)->gclist, CONTROL(*p)->delta);
|
||||
#else
|
||||
Recursive_Visit (&CONTROL(*p)->gcsave);
|
||||
|
|
16
src/io.c
16
src/io.c
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#ifdef HAVE_PWD_H
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -147,13 +149,16 @@ Object Get_File_Name (Object name) {
|
|||
|
||||
char *Internal_Tilde_Expand (register char *s, register char **dirp) {
|
||||
register char *p;
|
||||
#ifdef HAVE_PWD_H
|
||||
struct passwd *pw, *getpwnam();
|
||||
#endif
|
||||
|
||||
if (*s++ != '~')
|
||||
return 0;
|
||||
for (p = s; *p && *p != '/'; p++)
|
||||
;
|
||||
if (*p == '/') *p++ = 0;
|
||||
#ifdef HAVE_PWD_H
|
||||
if (*s == '\0') {
|
||||
if ((*dirp = getenv ("HOME")) == 0)
|
||||
*dirp = "";
|
||||
|
@ -162,6 +167,9 @@ char *Internal_Tilde_Expand (register char *s, register char **dirp) {
|
|||
Primitive_Error ("unknown user: ~a", Make_String (s, strlen (s)));
|
||||
*dirp = pw->pw_dir;
|
||||
}
|
||||
#else
|
||||
*dirp = "";
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -175,7 +183,8 @@ Object General_File_Operation (Object s, register int op) {
|
|||
switch (op) {
|
||||
case 0: {
|
||||
char *p, *dir;
|
||||
if ((p = Internal_Tilde_Expand (r, &dir)) == 0) {
|
||||
p = Internal_Tilde_Expand (r, &dir);
|
||||
if (p == 0) {
|
||||
Alloca_End;
|
||||
return s;
|
||||
}
|
||||
|
@ -224,7 +233,8 @@ Object Open_File (char *name, int flags, int err) {
|
|||
struct stat st;
|
||||
Alloca_Begin;
|
||||
|
||||
if ((p = Internal_Tilde_Expand (name, &dir))) {
|
||||
p = Internal_Tilde_Expand (name, &dir);
|
||||
if (p) {
|
||||
Alloca (name, char*, strlen (dir) + 1 + strlen (p) + 1);
|
||||
sprintf (name, "%s/%s", dir, p);
|
||||
}
|
||||
|
|
24
src/libelk.c
24
src/libelk.c
|
@ -38,17 +38,19 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef MAX_STACK_SIZE
|
||||
# include <sys/time.h>
|
||||
# include <sys/resource.h>
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
# include <sys/time.h>
|
||||
# ifdef HAVE_SYS_RESOURCES_H
|
||||
# include <sys/resource.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FIND_AOUT
|
||||
# ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# else
|
||||
# include <sys/file.h>
|
||||
# endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# else
|
||||
# include <sys/file.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "kernel.h"
|
||||
|
@ -383,9 +385,7 @@ void Init_Everything () {
|
|||
}
|
||||
|
||||
void Get_Stack_Limit () {
|
||||
#ifdef MAX_STACK_SIZE
|
||||
Max_Stack = MAX_STACK_SIZE;
|
||||
#else
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
struct rlimit rl;
|
||||
|
||||
if (getrlimit (RLIMIT_STACK, &rl) == -1) {
|
||||
|
@ -393,6 +393,8 @@ void Get_Stack_Limit () {
|
|||
exit (1);
|
||||
}
|
||||
Max_Stack = rl.rlim_cur;
|
||||
#else
|
||||
Max_Stack = DEFAULT_MAX_STACK_SIZE;
|
||||
#endif
|
||||
Max_Stack -= STACK_MARGIN;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "kernel.h"
|
||||
|
||||
#ifdef USE_ALLOCA
|
||||
#ifdef HAVE_ALLOCA
|
||||
# define MAX_ARGS_ON_STACK 4
|
||||
#else
|
||||
# define MAX_ARGS_ON_STACK 8
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
|
||||
extern void Flush_Output (Object);
|
||||
|
||||
extern char *index();
|
||||
extern double atof();
|
||||
|
||||
int Skip_Comment (Object);
|
||||
|
@ -659,7 +658,11 @@ Object Parse_Number (Object port, char const *buf, int radix) {
|
|||
return Null;
|
||||
if (p[1] == '+' || p[1] == '-')
|
||||
p++;
|
||||
#ifdef HAVE_INDEX
|
||||
} else if (radix == 16 && !index ("0123456789abcdefABCDEF", c)) {
|
||||
#else
|
||||
} else if (radix == 16 && !strchr ("0123456789abcdefABCDEF", c)) {
|
||||
#endif
|
||||
return Null;
|
||||
} else if (radix < 16 && (c < '0' || c > '0' + radix-1)) {
|
||||
return Null;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "kernel.h"
|
||||
|
||||
#ifndef USE_ALLOCA
|
||||
#ifndef HAVE_ALLOCA
|
||||
|
||||
extern char *malloc();
|
||||
|
||||
|
|
Loading…
Reference in New Issue