diff --git a/configure.ac b/configure.ac index 9b34d76..0d64fcf 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,325 @@ AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T -AC_CHECK_HEADERS(unistd.h pwd.h) +# $system should contain the name of this file. It may be used by some +# of the build scripts to do things that are specific to one single +# type of system. +AC_DEFINE(SYSTEMTYPE, "i486-linux-gcc", [FIXME HARD]) + +# Does the system support the vprintf library function? If not, +# availability of the (non-portable) _doprnt function is assumed. +AC_CHECK_FUNCS(vprintf) + +# Does the directory(3) library follow the POSIX conventions (i.e. +# requires the include file and uses "struct dirent")? +# If not, the (obsolete) BSD-style interface with and +# "struct direct" is assumed. +AC_CHECK_FUNCS(dirent) + +# Does the system have the random/srandom library functions? If not, +# rand/srand will be used instead. +AC_CHECK_FUNCS(random) + +# Does the system have the index library function? If not, strchr +# will be used. +dnl FIXME + +# Does the system have the bcopy, bzero, and bcmp library functions? +# If not, memcpy/memset/memcmp will be used. +dnl FIXME + +# Does using the access system call require to be included? +# (Look into the manual page for access if in doubt.) +AC_CHECK_HEADERS(unistd.h) + +# If the FIONREAD ioctl command is defined, which file must be included? +AC_DEFINE(FIONREAD_H, , [FIXME HARD]) + +# What is the name of the a.out include file? +AC_DEFINE(AOUT_H, , [FIXME HARD]) + +# If getdtablesize() is available to determine the maximum number of open +# files per process, set getdtablesize=yes. +# Alternatively, if POSIX-style sysconf() can be called with _SC_OPEN_MAX, +# set sysconf_open_max=yes. +# If neither is set to "yes", an educated guess will be made. +AC_CHECK_FUNCS(getdtablesize) +AC_MSG_CHECKING(for _SC_OPEN_MAX in unistd.h) +AC_EGREP_HEADER(_SC_OPEN_MAX, unistd.h, [ + AC_MSG_RESULT(yes) AC_DEFINE(SC_OPEN_MAX_IN_UNISTD_H, 1, Define if defines _SC_OPEN_MAX) +],[ + AC_MSG_RESULT(no) +]) + +# If POSIX-style pathconf() can be invoked with _PC_PATH_MAX to determine +# the maximum pathname length, set pathconf_path_max=yes. +AC_MSG_CHECKING(for _PC_PATH_MAX in unistd.h) +AC_EGREP_HEADER(_PC_PATH_MAX, unistd.h, [ + AC_MSG_RESULT(yes) AC_DEFINE(PC_PATH_MAX_IN_UNISTD_H, 1, Define if defines _PC_PATH_MAX) +],[ + AC_MSG_RESULT(no) +]) + +# If the system page size can be determined by calling getpagesize() +# set getpagesize=yes. +# Alternatively, if sysconf() can be invoked with _SC_PAGESIZE, set +# sysconf_pagesize=yes. +# These two variables are only required if the generational garbage +# collector is used. +AC_CHECK_FUNCS(getpagesize) +AC_MSG_CHECKING(for _SC_PAGESIZE in unistd.h) +AC_EGREP_HEADER(_SC_PAGESIZE, unistd.h, [ + AC_MSG_RESULT(yes) AC_DEFINE(SC_PAGESIZE_IN_UNISTD_H, 1, Define if defines _SC_PAGESIZE) +],[ + AC_MSG_RESULT(no) +]) + +# Set reliable_signals=bsd if your system supports BSD-style reliable +# 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]) + +# To support dynamic loading of object files and "dump", the system's +# a.out format has to be known. Choose one of the following: +# +# coff ecoff xcoff elf macho hp9k convex +# +# Other values of "aout_format" are interpreted as BSD-style a.out format. +if false; then + AC_DEFINE(COFF, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(ECOFF, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(XCOFF, 1, [FIXME HARD]) +fi +AC_DEFINE(ELF, 1, [FIXME HARD]) +if false; then + AC_DEFINE(MACH_O, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(CONVEX_AOUT, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(HP9K, 1, [FIXME HARD]) +fi + +# Which mechanism should be used to dynamically load object files? +# Possible values currently are: +# +# ld BSD-style incremental loading based on ld -A +# rld NeXT-style rld_load() +# shl HP-UX shl_load() +# dl SysVR4/SunOS5 dlopen() +# +# Leave load_obj empty if dynamic loading is not supported. +AC_DEFINE(CAN_LOAD_OBJ, 1, [FIXME HARD]) +AC_DEFINE(CAN_LOAD_LIB, 1, [FIXME HARD]) +if false; then + AC_DEFINE(USE_LD, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(USE_RLD, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(USE_SHL, 1, [FIXME HARD]) +fi +AC_DEFINE(USE_DLOPEN, 1, [FIXME HARD]) + + # Linker options to produce a shared object from a .o file. + # Only used if load_obj=dl. + AC_DEFINE(LDFLAGS_SHARED, "-shared", [FIXME HARD]) + + # The libraries against which dynamically loaded files are resolved + # at the time they are loaded. + AC_DEFINE(LOAD_LIBRARIES, "", [FIXME HARD]) + + # Additional flags to be passed to the linker for an incremental + # linker run (ld -A). Ignored unless load_obj=ld. + AC_DEFINE(INC_LDFLAGS, "-x -static", [FIXME HARD]) + + # Systems with "aout_format=ecoff" may require a call to the cacheflush + # system call after an object file has been loaded. Which include file + # has to be included in this case? + AC_DEFINE(CACHECTL_H, , [FIXME HARD]) + + # Is the ANSI-C atexit function supported to register an exit handler? + # If not, the exit library function will be redefined and will end in + # a call to _exit. + AC_CHECK_FUNCS(atexit) + +# Do the names of external functions in the symbol table always begin +# with a special character (such as underline)? If so, syms_begin_with +# should hold this character, otherwise leave it empty. +if false; then + AC_DEFINE(SYMS_BEGIN_WITH, 1, [FIXME HARD]) +fi + +# The symbol prefixes of extension initialization and finalization +# functions (without the initial $syms_begin_with). Do not change +# these unless the compiler or linker restricts the length of symbols! +AC_DEFINE(INIT_PREFIX, "elk_init_", [FIXME HARD]) +AC_DEFINE(FINIT_PREFIX, "elk_finit_", [FIXME HARD]) + +# Is the "dump" function supported? +AC_DEFINE(CAN_DUMP, 1, [FIXME HARD]) + + # Is the fchmod system call broken or unavailable? + if false; then + AC_DEFINE(FCHMOD_BROKEN, 1, [FIXME HARD]) + fi + + # These four variables are only relevant if the system has the BSD-style + # a.out format. + # segment_size is the segment size of the system's memory management + # unit, i.e. the number to a multiple of which the size of an a.out + # segment (e.g. .text) is rounded up. + # file_text_start is the file offset at which the text segment starts + # in an a.out file. + # mem_text_start is the starting address of the text segment in memory. + # text_length_adj must be set to "sizeof (struct exec)" if the length of + # the text segment stored in the a.out header includes the a.out header + # itself. + AC_DEFINE(SEG_SIZ, 1024, [FIXME HARD]) + AC_DEFINE(FILE_TEXT_START, N_TXTOFF(hdr), [FIXME HARD]) + AC_DEFINE(MEM_TEXT_START, 0, [FIXME HARD]) + AC_DEFINE(TEXT_LENGTH_ADJ, 0, [FIXME HARD]) + + # Only relevant if "aout_format=coff": the system's pagesize. + AC_DEFINE(COFF_PAGESIZE, 4096, [FIXME HARD]) + + # Only relevant if "aout_format=hp9k" and "load_obj=shl" + AC_DEFINE(HPSHLIB, 1, [FIXME HARD]) + + # Print debug messages when dumping + AC_DEFINE(DEBUG_DUMP, 1, [FIXME HARD]) + +# Is the "termio" terminal interface supported by the system? If not, +# BSD-style tty handling will be used. +AC_DEFINE(TERMIO, 1, [FIXME HARD]) + +# flush_stdio and flush_tty indicate how clear-input/output-port can +# flush (purge) a FILE pointer and a TTY file descriptor. +# Possible values of flush_stdio: +# bsd assume old BSD-style FILE* (with _cnt, _ptr, _base) +# fpurge use 4.4BSD-style fpurge stdio library function +# Possible values of flush_tty: +# tiocflush use TIOCFLUSH ioctl from +# tcflsh use TCFLSH ioctl from +# Leave the variable(s) empty if flushing is not supported. +if false; then + AC_DEFINE(FLUSH_BSD, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(FLUSH_FPURGE, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(FLUSH_TIOCFLUSH, 1, [FIXME HARD]) +fi +AC_DEFINE(FLUSH_TCFLSH, 1, [FIXME HARD]) + +# 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 + +# Is the mprotect system call supported? The generational garbage collector +# requires mprotect to implement incremental GC. $mprotect is ignored if +# generational_gc is set to "no" in the site file. Set mprotect=mmap if +# mprotect is supported, but only for mmap()ed memory. +AC_CHECK_FUNCS(mprotect) +if false; then + AC_DEFINE(MPROTECT_MMAP, 1, [FIXME HARD]) +fi + +# How can a SIGSEGV or SIGBUS signal handler find out the address of +# the faulting memory reference? This variable is only used if +# $mprotect is "yes" or "mmap". Possible values are: +# +# siginfo handler is called with siginfo_t structure (enabled +# by a call to sigaction) +# sigcontext address is in the sigcontext structure (3rd arg, sc_badvaddr) +# arg4 address is delivered to handler as argument #4 +# aix use an AIX-specific hack to get hold of the bad address +# hpux use a HP-UX-specific hack +if false; then + AC_DEFINE(SIGSEGV_SIGINFO, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(SIGSEGV_SIGCONTEXT, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(SIGSEGV_ARG4, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(SIGSEGV_AIX, 1, [FIXME HARD]) +fi +if false; then + AC_DEFINE(SIGSEGV_HPUX, 1, [FIXME HARD]) +fi + +# Does the system support the alloca library function, and does this +# 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]) + +# Must be included to use alloca? Is "#pragma alloca" required? +AC_CHECK_HEADERS(alloca.h) +if false; then + AC_DEFINE(PRAGMA_ALLOCA, 1, [FIXME HARD]) +fi + +# Does the system (or compiler) require certain objects (e.g. doubles) +# to be aligned at 8-byte boundaries? If not, 4-byte alignment will +# be assumed. +if false; then + AC_DEFINE(ALIGN_8BYTE, 1, [FIXME HARD]) +fi + +# The name of the linker. This is usually just "ld", or /usr/ccs/bin/ld +# in SVR4-based systems. +AC_DEFINE(LD_NAME, "ld", [FIXME HARD]) + +# Does your C preprocessor support the ANSI-C ## operator, although +# __STDC__ is not defined? +AC_DEFINE(ANSI_CPP, 1, [FIXME HARD]) + +# The UNIX extension likes to know which of the following system calls, +# library functions, and include files are supported by the system. +AC_CHECK_HEADERS(utime.h) +AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime) +AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp) + +# Element type of the gidset argument of getgroups(); typically int +# or gid_t. Only needed by the UNIX extension. +AC_DEFINE(GETGROUPS_TYPE, gid_t, [FIXME HARD]) + +# Do you want to use the generational garbage collector? If not, the +# stop-and-copy garbage collector will be used. +AC_DEFINE(GENERATIONAL_GC, 1, [FIXME HARD]) + +# The default heap size of the Scheme interpreter in KBytes (if the +# stop-and-copy garbage collector is used). +AC_DEFINE(HEAP_SIZE, 1024, [FIXME HARD]) + +# The directory where all files are installed by running "make install". +# The subdirectories bin, lib, include, and runtime (with various +# subdirectories) are created automatically, but $install_dir isn't. +# Make sure $install_dir doesn't point to the top of the source tree +# (i.e. choose a subdirectory or a directory outside the source tree). +AC_DEFINE(SCM_DIR, "/usr/share/elk", [FIXME HARD]) +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]) dnl dnl Check for available warning flags @@ -41,166 +359,18 @@ fi CFLAGS="${CFLAGS_save}" INCLUDES="${INCLUDES} -I\$(top_srcdir)/include" -dnl -dnl Default values -dnl -AC_DEFINE(REGCOMP, 1, [Foo]) -AC_DEFINE(WAITPID, 1, [Foo]) -AC_DEFINE(WAIT3, 1, [Foo]) -AC_DEFINE(WAIT4, 1, [Foo]) -AC_DEFINE(MKTEMP, 1, [Foo]) -AC_DEFINE(TMPNAM, 1, [Foo]) -AC_DEFINE(TEMPNAM, 1, [Foo]) -AC_DEFINE(GETCWD, 1, [Foo]) -AC_DEFINE(GETWD, 1, [Foo]) -AC_DEFINE(RENAME, 1, [Foo]) -AC_DEFINE(UNAME, 1, [Foo]) -AC_DEFINE(GETHOSTNAME, 1, [Foo]) -AC_DEFINE(GETTIMEOFDAY, 1, [Foo]) -AC_DEFINE(FTIME, 1, [Foo]) -AC_DEFINE(VFORK, 1, [Foo]) -AC_DEFINE(VPRINTF, 1, [Foo]) -AC_DEFINE(DIRENT, 1, [Foo]) -AC_DEFINE(RANDOM, 1, [Foo]) -AC_DEFINE(INCLUDE_UNISTD_H, 1, [Foo]) -if false; then - AC_DEFINE(SYSCONF_OPEN_MAX, 1, [Bar]) -fi -AC_DEFINE(GETDTABLESIZE, 1, [Foo]) -AC_DEFINE(PATHCONF_PATH_MAX, 1, [Foo]) -AC_DEFINE(GETPAGESIZE, 1, [Foo]) -if false; then - AC_DEFINE(SYSCONF_PAGESIZE, 1, [Bar]) -fi -if false; then - AC_DEFINE(BSD_SIGNALS, 1, [Bar]) -fi -AC_DEFINE(POSIX_SIGNALS, 1, [Foo]) -if false; then - AC_DEFINE(ALIGN_8BYTE, 1, [Bar]) -fi -if false; then - AC_DEFINE(COFF, 1, [Bar]) -fi -if false; then - AC_DEFINE(ECOFF, 1, [Bar]) -fi -if false; then - AC_DEFINE(XCOFF, 1, [Bar]) -fi -AC_DEFINE(ELF, 1, [Foo]) -if false; then - AC_DEFINE(MACH_O, 1, [Bar]) -fi -if false; then - AC_DEFINE(CONVEX_AOUT, 1, [Bar]) -fi -if false; then - AC_DEFINE(HP9K, 1, [Bar]) -fi -AC_DEFINE(HPSHLIB, 1, [Foo]) -AC_DEFINE(DEBUG_DUMP, 1, [Foo]) -AC_DEFINE(CAN_LOAD_OBJ, 1, [Foo]) -AC_DEFINE(CAN_LOAD_LIB, 1, [Foo]) -if false; then - AC_DEFINE(USE_LD, 1, [Bar]) -fi -if false; then - AC_DEFINE(USE_RLD, 1, [Bar]) -fi -if false; then - AC_DEFINE(USE_SHL, 1, [Bar]) -fi -AC_DEFINE(USE_DLOPEN, 1, [Foo]) -AC_DEFINE(LOAD_LIBRARIES, "", [Foo]) -AC_DEFINE(CACHECTL_H, , [Foo]) -AC_DEFINE(FIONREAD_H, , [Foo]) -AC_DEFINE(ATEXIT, 1, [Foo]) -if false; then - AC_DEFINE(SYMS_BEGIN_WITH, 1, [Bar]) -fi -AC_DEFINE(CAN_DUMP, 1, [Foo]) -AC_DEFINE(SEG_SIZ, 1024, [Foo]) -AC_DEFINE(FILE_TEXT_START, N_TXTOFF(hdr), [Foo]) -AC_DEFINE(MEM_TEXT_START, 0, [Foo]) -AC_DEFINE(TEXT_LENGTH_ADJ, 0, [Foo]) -AC_DEFINE(COFF_PAGESIZE, 4096, [Foo]) -if false; then - AC_DEFINE(FCHMOD_BROKEN, 1, [Bar]) -fi -AC_DEFINE(TERMIO, 1, [Foo]) -if false; then - AC_DEFINE(FLUSH_BSD, 1, [Bar]) -fi -if false; then - AC_DEFINE(FLUSH_FPURGE, 1, [Bar]) -fi -if false; then - AC_DEFINE(FLUSH_TIOCFLUSH, 1, [Bar]) -fi -AC_DEFINE(FLUSH_TCFLSH, 1, [Foo]) -AC_DEFINE(USE_ALLOCA, 1, [Foo]) -AC_DEFINE(INCLUDE_ALLOCA_H, 1, [Foo]) -if false; then - AC_DEFINE(PRAGMA_ALLOCA, 1, [Bar]) -fi -if false; then - AC_DEFINE(MAX_STACK_SIZE, 1, [Bar]) -fi -AC_DEFINE(GENERATIONAL_GC, 1, [Foo]) -if false; then - AC_DEFINE(HAS_MPROTECT, 1, [Bar]) -fi -if false; then - AC_DEFINE(MPROTECT_MMAP, 1, [Bar]) -fi -if false; then - AC_DEFINE(SIGSEGV_SIGINFO, 1, [Bar]) -fi -if false; then - AC_DEFINE(SIGSEGV_SIGCONTEXT, 1, [Bar]) -fi -if false; then - AC_DEFINE(SIGSEGV_ARG4, 1, [Bar]) -fi -if false; then - AC_DEFINE(SIGSEGV_AIX, 1, [Bar]) -fi -if false; then - AC_DEFINE(SIGSEGV_HPUX, 1, [Bar]) -fi - -AC_DEFINE(AOUT_H, , [Foo]) -AC_DEFINE(SCM_DIR, "/usr/share/elk", [Foo]) -AC_DEFINE(OBJ_DIR, "/usr/lib/elk", [Foo]) -AC_DEFINE(HEAP_SIZE, 1024, [Foo]) -AC_DEFINE(FIND_AOUT, 1, [Foo]) -AC_DEFINE(ANSI_CPP, 1, [Foo]) -AC_DEFINE(SYSTEMTYPE, "i486-linux-gcc", [Foo]) -AC_DEFINE(GETGROUPS_TYPE, gid_t, [Foo]) -AC_DEFINE(LD_NAME, "ld", [Foo]) -AC_DEFINE(LDFLAGS_SHARED, "-shared", [Foo]) -AC_DEFINE(INC_LDFLAGS, "-x -static", [Foo]) -AC_DEFINE(UTIME_H, 1, [Foo]) -AC_DEFINE(INIT_PREFIX, "elk_init_", [Foo]) -AC_DEFINE(FINIT_PREFIX, "elk_finit_", [Foo]) -AC_DEFINE(ELK_MAJOR, 3, [Foo]) -AC_DEFINE(ELK_MINOR, 0, [Foo]) - dnl Export variables AC_SUBST(INCLUDES) AC_OUTPUT([ Makefile autotools/Makefile - config/Makefile debian/Makefile doc/Makefile examples/Makefile lib/Makefile lib/misc/Makefile scm/Makefile - scripts/Makefile src/Makefile util/Makefile ]) diff --git a/include/intern.h b/include/intern.h index cdaaa92..6503438 100644 --- a/include/intern.h +++ b/include/intern.h @@ -94,7 +94,7 @@ 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 +#ifndef HAVE_ATEXIT extern void exit P_((int)); #endif diff --git a/include/stkmem.h b/include/stkmem.h index dccf426..94ebf1d 100644 --- a/include/stkmem.h +++ b/include/stkmem.h @@ -1,6 +1,6 @@ #ifdef USE_ALLOCA -#ifdef INCLUDE_ALLOCA_H +#ifdef HAVE_ALLOCA_H # include #endif diff --git a/lib/misc/regexp.c b/lib/misc/regexp.c index b89de4c..9cb5c2a 100644 --- a/lib/misc/regexp.c +++ b/lib/misc/regexp.c @@ -7,7 +7,7 @@ #include "scheme.h" -#ifdef REGCOMP +#ifdef HAVE_REGCOMP #include #include @@ -199,10 +199,10 @@ static Object P_Match_End(m, n) Object m, n; { #define Def_Prim Define_Primitive -#endif /* REGCOMP */ +#endif /* HAVE_REGCOMP */ elk_init_lib_regexp() { -#ifdef REGCOMP +#ifdef HAVE_REGCOMP T_Regexp = Define_Type(0, "regexp", 0, sizeof(struct S_Regexp), Regexp_Eqv, Regexp_Equal, Regexp_Print, Regexp_Visit); T_Match = Define_Type(0, "regexp-match", Match_Size, 0, diff --git a/lib/unix/fdescr.c b/lib/unix/fdescr.c index db2582c..56498eb 100644 --- a/lib/unix/fdescr.c +++ b/lib/unix/fdescr.c @@ -148,27 +148,21 @@ static Object P_Lseek(fd, off, whence) Object fd, off, whence; { int Num_Filedescriptors() { int ret; -#ifdef OPEN_MAX +#if defined(OPEN_MAX) ret = OPEN_MAX; -#else -#ifdef GETDTABLESIZE +#elif defined(HAVE_GETDTABLESIZE) ret = getdtablesize(); -#else -#ifdef SYSCONF_OPEN_MAX +#elif defined(SC_OPEN_MAX_IN_UNISTD_H) static r; if (r == 0) { if ((r = sysconf(_SC_OPEN_MAX)) == -1) r = 256; } ret = r; -#else -#ifdef NOFILE +#elif defined(NOFILE) ret = NOFILE; #else ret = 256; -#endif -#endif -#endif #endif return ret; } diff --git a/lib/unix/file.c b/lib/unix/file.c index b300b68..f8e6122 100644 --- a/lib/unix/file.c +++ b/lib/unix/file.c @@ -1,6 +1,6 @@ #include "unix.h" -#ifdef UTIME_H +#ifdef HAVE_UTIME_H # include #else struct utimbuf { @@ -8,7 +8,7 @@ struct utimbuf { }; #endif -#ifdef DIRENT +#ifdef HAVE_DIRENT # include #else # include @@ -65,7 +65,7 @@ static Object P_Mkdir(fn, mode) Object fn, mode; { static Object P_Read_Directory(fn) Object fn; { DIR *d; -#ifdef DIRENT +#ifdef HAVE_DIRENT struct dirent *dp; #else struct direct *dp; @@ -96,7 +96,7 @@ static Object P_Read_Directory(fn) Object fn; { } static Object P_Rename(fromfn, tofn) Object fromfn, tofn; { -#ifdef RENAME +#ifdef HAVE_RENAME if (rename(Get_Strsym(fromfn), Get_Strsym(tofn)) == -1) Raise_System_Error2("(~s ~s): ~E", fromfn, tofn); #else diff --git a/lib/unix/process.c b/lib/unix/process.c index 9472439..cf0ec88 100644 --- a/lib/unix/process.c +++ b/lib/unix/process.c @@ -245,7 +245,7 @@ static Object P_System(cmd) Object cmd; { int n, pid, status; char *s = Get_String(cmd); -#ifdef VFORK +#ifdef HAVE_VFORK switch (pid = vfork()) { #else switch (pid = fork()) { @@ -280,7 +280,7 @@ static Object P_Working_Directory() { char *buf; int max = Path_Max()+2; /* getcwd() needs two extra bytes */ Object ret; -#if !defined(GETCWD) && !defined(GETWD) +#if !defined(HAVE_GETCWD) && !defined(HAVE_GETWD) FILE *fp; char *p; #endif @@ -288,7 +288,7 @@ static Object P_Working_Directory() { Alloca(buf, char*, max); Disable_Interrupts; -#ifdef GETCWD +#ifdef HAVE_GETCWD if (getcwd(buf, max) == 0) { Saved_Errno = errno; Alloca_End; @@ -296,7 +296,7 @@ static Object P_Working_Directory() { Raise_System_Error("~E"); } #else -#ifdef GETWD +#ifdef HAVE_GETWD if (getwd(buf) == 0) { Alloca_End; Enable_Interrupts; diff --git a/lib/unix/system.c b/lib/unix/system.c index 86e031d..7298f4c 100644 --- a/lib/unix/system.c +++ b/lib/unix/system.c @@ -1,6 +1,6 @@ #include "unix.h" -#if defined(UNAME) && !defined(GETHOSTNAME) +#if defined(HAVE_UNAME) && !defined(HAVE_GETHOSTNAME) # include #endif @@ -134,11 +134,11 @@ static Object P_Job_Controlp() { } static Object P_System_Info(ret) Object ret; { -#ifdef GETHOSTNAME +#ifdef HAVE_GETHOSTNAME char hostname[MAXHOSTNAMELEN]; char *p = hostname; #else -#ifdef UNAME +#ifdef HAVE_UNAME struct utsname uts; char *p = uts.nodename; #else @@ -150,10 +150,10 @@ static Object P_System_Info(ret) Object ret; { GC_Node; Check_Result_Vector(ret, 3); -#ifdef GETHOSTNAME +#ifdef HAVE_GETHOSTNAME (void)gethostname(hostname, sizeof(hostname)); #else -#ifdef UNAME +#ifdef HAVE_UNAME (void)uname(&uts); #endif #endif diff --git a/lib/unix/temp.c b/lib/unix/temp.c index 71c3cba..d96f120 100644 --- a/lib/unix/temp.c +++ b/lib/unix/temp.c @@ -1,29 +1,29 @@ #include "unix.h" -#ifdef TEMPNAM /* Make sure only one of these is defined (if any) */ -# undef TMPNAM /* Order of preference: tempnam, mktemp, tmpnam */ -# undef MKTEMP +#ifdef HAVE_TEMPNAM /* Make sure only one of these is defined (if any) */ +# undef HAVE_TMPNAM /* Order of preference: tempnam, mktemp, tmpnam */ +# undef HAVE_MKTEMP #endif -#ifdef MKTEMP -# undef TMPNAM -# undef TEMPNAM +#ifdef HAVE_MKTEMP +# undef HAVE_TMPNAM +# undef HAVE_TEMPNAM #endif -#ifdef TMPNAM -# undef TEMPNAM -# undef MKTEMP +#ifdef HAVE_TMPNAM +# undef HAVE_TEMPNAM +# undef HAVE_MKTEMP #endif static Object P_Tempname(argc, argv) int argc; Object *argv; { char *name, *dir = 0, *pref = 0; Object ret; -#ifdef TMPNAM +#ifdef HAVE_TMPNAM extern char *tmpnam(); #else -#ifdef TEMPNAM +#ifdef HAVE_TEMPNAM extern char *tempnam(); #else char buf[1024]; -#ifdef MKTEMP +#ifdef HAVE_MKTEMP extern char *mktemp(); #else char *p, *q; @@ -36,10 +36,10 @@ static Object P_Tempname(argc, argv) int argc; Object *argv; { dir = Get_Strsym(argv[0]); if (argc > 1) pref = Get_Strsym(argv[1]); -#ifdef TMPNAM +#ifdef HAVE_TMPNAM name = tmpnam((char *)0); #else -#ifdef TEMPNAM +#ifdef HAVE_TEMPNAM Disable_Interrupts; /* Make sure result gets freed */ name = tempnam(dir, pref); #else @@ -47,7 +47,7 @@ static Object P_Tempname(argc, argv) int argc; Object *argv; { if (!pref) pref = "elk"; if (strlen(dir) + strlen(pref) > 1000) Primitive_Error("directory/prefix argument too long"); -#ifdef MKTEMP +#ifdef HAVE_MKTEMP sprintf(buf, "%s/%sXXXXXX", dir, pref); name = mktemp(buf); #else @@ -80,7 +80,7 @@ fail: ; Raise_Error("cannot create temp file name"); } ret = Make_String(name, strlen(name)); -#ifdef TEMPNAM +#ifdef HAVE_TEMPNAM free(name); Enable_Interrupts; #endif diff --git a/lib/unix/time.c b/lib/unix/time.c index d63a5d0..2e1b420 100644 --- a/lib/unix/time.c +++ b/lib/unix/time.c @@ -1,10 +1,10 @@ #include "unix.h" -#if !defined(GETTIMEOFDAY) && defined(FTIME) +#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME) # include #endif -#ifdef GETTIMEOFDAY +#ifdef HAVE_GETTIMEOFDAY # include #endif @@ -34,11 +34,11 @@ static Object P_Decode_Time(t, ret, utc) Object t, ret, utc; { static Object P_Nanotime(ret) Object ret; { Object x, y; -#ifdef GETTIMEOFDAY +#ifdef HAVE_GETTIMEOFDAY struct timeval tv; struct timezone tz; #else -#ifdef FTIME +#ifdef HAVE_FTIME struct timeb tb; #else time_t now; @@ -50,7 +50,7 @@ static Object P_Nanotime(ret) Object ret; { x = Null; Check_Result_Vector(ret, 3); GC_Link2(ret, x); -#ifdef GETTIMEOFDAY +#ifdef HAVE_GETTIMEOFDAY (void)gettimeofday(&tv, &tz); x = Cons(Null, Make_Unsigned_Long((unsigned long)tv.tv_usec * 1000)); y = Make_Unsigned_Long((unsigned long)tv.tv_sec); @@ -59,7 +59,7 @@ static Object P_Nanotime(ret) Object ret; { VECTOR(ret)->data[1] = Make_Integer(tz.tz_minuteswest); VECTOR(ret)->data[2] = Make_Integer(tz.tz_dsttime); #else -#ifdef FTIME +#ifdef HAVE_FTIME (void)ftime(&tb); x = Cons(Null, Make_Unsigned_Long((unsigned long)tb.millitm * 1000000)); y = Make_Unsigned_Long((unsigned long)tb.time); diff --git a/lib/unix/unix.h b/lib/unix/unix.h index 078cefd..5f5faf9 100644 --- a/lib/unix/unix.h +++ b/lib/unix/unix.h @@ -8,7 +8,7 @@ #include #include -#ifdef INCLUDE_UNISTD_H +#ifdef HAVE_UNISTD_H # include #endif diff --git a/lib/unix/wait.c b/lib/unix/wait.c index ad4253f..82757d3 100644 --- a/lib/unix/wait.c +++ b/lib/unix/wait.c @@ -4,15 +4,15 @@ #include "unix.h" -#if defined(WAITPID) || defined(WAIT4) +#if defined(HAVE_WAITPID) || defined(HAVE_WAIT4) # define WAIT_PROCESS #endif -#if defined(WAITPID) || defined(WAIT3) || defined(WAIT4) +#if defined(HAVE_WAITPID) || defined(HAVE_WAIT3) || defined(HAVE_WAIT4) # define WAIT_OPTIONS #endif -#if defined(WAIT3) || defined(WAIT4) +#if defined(HAVE_WAIT3) || defined(HAVE_WAIT4) # define WAIT_RUSAGE # include # include @@ -58,15 +58,15 @@ static Object General_Wait(ret, ruret, haspid, pid, options) Check_Result_Vector(ret, 5); Check_Result_Vector(ruret, 2); if (haspid) { -#ifdef WAIT4 +#ifdef HAVE_WAIT4 retpid = wait4(pid, &st, options, &ru); #else -#ifdef WAITPID +#ifdef HAVE_WAITPID retpid = waitpid(pid, &st, options); #endif #endif } else { -#ifdef WAIT3 +#ifdef HAVE_WAIT3 retpid = wait3(&st, options, &ru); #else retpid = wait(&st); diff --git a/src/heap-gen.c b/src/heap-gen.c index 13bb574..dfe9e15 100644 --- a/src/heap-gen.c +++ b/src/heap-gen.c @@ -12,13 +12,13 @@ #include #include #include -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT # include #endif -#ifdef GETPAGESIZE -# define SYSCONF_PAGESIZE +#ifdef HAVE_GETPAGESIZE +# define SC_PAGESIZE_IN_UNISTD_H #endif -#ifdef SYSCONF_PAGESIZE +#ifdef SC_PAGESIZE_IN_UNISTD_H # define link FOO # include # undef link @@ -191,7 +191,7 @@ static void TerminateGC (); #define SET_PROTECT(addr) { PMAP (addr) = 1; protected_pages++; } #define SET_UNPROTECT(addr) { PMAP (addr) = 0; protected_pages--; } -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT # ifndef PROT_RW # define PROT_RW (PROT_READ | PROT_WRITE) # endif @@ -463,7 +463,7 @@ void Make_Heap (int size) { Object heap_obj; pageno_t i; -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT InstallHandler (); #endif @@ -472,14 +472,14 @@ void Make_Heap (int size) { * then calculate the resulting number of heap pages. */ -#ifdef SYSCONF_PAGESIZE +#ifdef SC_PAGESIZE_IN_UNISTD_H if ((bytes_per_pp = sysconf (_SC_PAGESIZE)) == -1) Fatal_Error ("sysconf(_SC_PAGESIZE) failed; can't get pagesize"); #else -#ifdef GETPAGESIZE +#ifdef HAVE_GETPAGESIZE bytes_per_pp = getpagesize (); #else -# ifdef HAS_MPROTECT +# ifdef HAVE_MPROTECT # include "mprotect requires getpagesize or sysconf_pagesize" # else bytes_per_pp = 4096; @@ -1290,7 +1290,7 @@ static int Scanner (pageno_t npages) { return (scanned); } -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT /* the following function handles a page fault. If the fault was caused * by the mutator and incremental collection is enabled, this will result * in scanning the physical page the fault occured on. @@ -1328,7 +1328,7 @@ static void PagefaultHandler (int sig, int code, struct sigcontext *scp, static void PagefaultHandler (int sig, int code, struct sigcontext *scp) { #else -# include "HAS_MPROTECT defined, but missing SIGSEGV_xxx" +# include "HAVE_MPROTECT defined, but missing SIGSEGV_xxx" #endif #endif #endif @@ -1633,7 +1633,7 @@ void Generational_GC_Finalize () { } void Generational_GC_Reinitialize () { -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT InstallHandler (); #endif } @@ -1641,7 +1641,7 @@ void Generational_GC_Reinitialize () { Object Internal_GC_Status (int strat, int flags) { Object list; -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT Object cell; #endif GC_Node; @@ -1650,7 +1650,7 @@ Object Internal_GC_Status (int strat, int flags) { GC_Link (list); switch (strat) { default: /* query or stop-and-copy */ -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT if (inc_collection) { cell = Cons (Sym_Incremental_GC, Null); (void)P_Set_Cdr (list, cell); @@ -1659,7 +1659,7 @@ Object Internal_GC_Status (int strat, int flags) { break; case GC_STRAT_GEN: if (flags == GC_FLAGS_INCR) { -#ifdef HAS_MPROTECT +#ifdef HAVE_MPROTECT inc_collection = 1; cell = Cons (Sym_Incremental_GC, Null); (void)P_Set_Cdr (list, cell); diff --git a/src/io.c b/src/io.c index 753f77d..b595663 100644 --- a/src/io.c +++ b/src/io.c @@ -11,7 +11,7 @@ #include #include -#ifdef PATHCONF_PATH_MAX +#ifdef PC_PATH_MAX_IN_UNISTD_H # include #endif @@ -87,13 +87,11 @@ Object P_Output_Portp (Object x) { } int Path_Max () { -#ifdef PATH_MAX /* POSIX */ +#if defined(PATH_MAX) /* POSIX */ return PATH_MAX; -#else -#ifdef MAXPATHLEN /* 4.3 BSD */ +#elif defined(MAXPATHLEN) /* 4.3 BSD */ return MAXPATHLEN; -#else -#ifdef PATHCONF_PATH_MAX +#elif defined(PC_PATH_MAX_IN_UNISTD_H) static int r; if (r == 0) { if ((r = pathconf ("/", _PC_PATH_MAX)) == -1) @@ -104,8 +102,6 @@ int Path_Max () { #else return 1024; #endif -#endif -#endif } Object Get_File_Name (Object name) { diff --git a/src/libelk.c b/src/libelk.c index 3ae9a6a..b7db2e3 100644 --- a/src/libelk.c +++ b/src/libelk.c @@ -14,7 +14,7 @@ #endif #ifdef FIND_AOUT -# ifdef INCLUDE_UNISTD_H +# ifdef HAVE_UNISTD_H # include # else # include @@ -87,7 +87,7 @@ void Exit_Handler () { Free_Heap (); } -#ifndef ATEXIT +#ifndef HAVE_ATEXIT /* Hack: __GNUC_MINOR__ was introduced together with __attribute__ */ #ifdef __GNUC_MINOR__ extern void _exit() __attribute__ ((noreturn)); @@ -242,7 +242,7 @@ int main (int ac, char **av) { ALIGN(stkbase); Make_Heap (heap); Init_Everything (); -#ifdef ATEXIT +#ifdef HAVE_ATEXIT if (atexit (Exit_Handler) != 0) Fatal_Error ("atexit returned non-zero value"); #endif diff --git a/src/math.c b/src/math.c index c53386b..d601f0d 100644 --- a/src/math.c +++ b/src/math.c @@ -16,7 +16,7 @@ extern int Bignum_To_Integer (Object); Object Generic_Multiply(), Generic_Divide(); void Init_Math () { -#ifdef RANDOM +#ifdef HAVE_RANDOM srandom (getpid ()); #else srand (getpid ()); @@ -1104,7 +1104,7 @@ Object P_Max (int argc, Object *argv) { } Object P_Random () { -#ifdef RANDOM +#ifdef HAVE_RANDOM extern long int random(); return Make_Long (random ()); #else @@ -1113,7 +1113,7 @@ Object P_Random () { } Object P_Srandom (Object x) { -#ifdef RANDOM +#ifdef HAVE_RANDOM srandom (Get_Unsigned (x)); #else srand (Get_Unsigned (x)); diff --git a/src/print.c b/src/print.c index 5450f22..f763625 100644 --- a/src/print.c +++ b/src/print.c @@ -91,7 +91,7 @@ void Print_String (Object port, register char *buf, register int len) { p->ptr += len; } -#ifndef VPRINTF +#ifndef HAVE_VPRINTF void vfprintf (register FILE *f, register char *fmt, va_list ap) { _doprnt (fmt, ap, f); }