From 41913af48d0910d133f08b1356401ab034ca65ea Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 5 Oct 2003 22:52:37 +0000 Subject: [PATCH] * src/libelk.c: + Test for HAVE_STRUCT_RLIMIT, not HAVE_GETRLIMIT. * src/loadlib.c: + Style fixes. git-svn-id: svn://svn.zoy.org/elk/trunk@227 55e467fa-43c5-0310-a8a2-de718669efc6 --- configure.ac | 56 ++++++++++++++++++++++++++++++++++----------------- src/libelk.c | 20 +++++++++--------- src/loadlib.c | 18 ++++++++++------- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/configure.ac b/configure.ac index 8387393..0bfb565 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,25 @@ case "${target_os}" in esac ELK_LIBS="${ELK_LIBS} ${MATH_LIBS}" +# Various required headers +AC_CHECK_HEADERS(pwd.h grp.h sys/resource.h) + +# 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 sys/utime.h sys/wait.h sys/times.h dirent.h netdb.h) +AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime) +AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp environ) +AC_MSG_CHECKING(for __environ in unistd.h) +AC_EGREP_HEADER(__environ, unistd.h, + [AC_MSG_RESULT(yes) + AC_DEFINE(__ENVIRON_IN_UNISTD_H, 1, Define if defines __environ)], + [AC_MSG_RESULT(no)]) +AC_MSG_CHECKING(for environ in unistd.h) +AC_EGREP_HEADER(environ, unistd.h, + [AC_MSG_RESULT(yes) + AC_DEFINE(ENVIRON_IN_UNISTD_H, 1, Define if defines environ)], + [AC_MSG_RESULT(no)]) + # Does the system support the vprintf library function? If not, # availability of the (non-portable) _doprnt function is assumed. AC_CHECK_FUNCS(vprintf) @@ -197,6 +216,7 @@ fi if test "${ac_cv_my_can_load_lib}" = "no"; then AC_CHECK_LIB(kernel32, main, [ELK_LIBS="${ELK_LIBS} -lkernel32" + AC_DEFINE(HAVE_DL_WINDOWS, 1, [Define if you have Windows' LoadLibrary]) ac_cv_my_can_load_lib=yes]) fi @@ -309,6 +329,24 @@ AC_CHECK_HEADERS(termio.h termios.h) # stack size of the running program. If this function is not supported, # set max_stack_size to a (fixed) maximum stack size (in bytes). AC_CHECK_FUNCS(getrlimit) +AC_CACHE_CHECK([for struct rlimit], + [ac_cv_have_struct_rlimit], + [AC_TRY_COMPILE( + [#ifdef HAVE_SYS_TIME_H + # include + #endif + #ifdef HAVE_SYS_RESOURCE_H + # include + #endif + #ifdef HAVE_UNISTD_H + # include + #endif], + [struct rlimit rl;], + ac_cv_have_struct_rlimit=yes, + ac_cv_have_struct_rlimit=no)]) +if test "${ac_cv_have_struct_rlimit}" = "yes"; then + AC_DEFINE(HAVE_STRUCT_RLIMIT, 1, [Define if you have struct rlimit]) +fi AC_DEFINE(DEFAULT_MAX_STACK_SIZE, 1024*1024, [Define default max stack size]) # Is the mprotect system call supported? The generational garbage collector @@ -377,22 +415,6 @@ AC_DEFINE(LD_NAME, "ld", [FIXME HARD]) # __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 sys/utime.h sys/wait.h sys/times.h dirent.h netdb.h) -AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime) -AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp environ) -AC_MSG_CHECKING(for __environ in unistd.h) -AC_EGREP_HEADER(__environ, unistd.h, - [AC_MSG_RESULT(yes) - AC_DEFINE(__ENVIRON_IN_UNISTD_H, 1, Define if defines __environ)], - [AC_MSG_RESULT(no)]) -AC_MSG_CHECKING(for environ in unistd.h) -AC_EGREP_HEADER(environ, unistd.h, - [AC_MSG_RESULT(yes) - AC_DEFINE(ENVIRON_IN_UNISTD_H, 1, Define if defines environ)], - [AC_MSG_RESULT(no)]) - # 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]) @@ -416,8 +438,6 @@ AC_DEFINE_UNQUOTED(LIB_DIR, "${prefix}/lib/elk", [Plugins directory]) #define FIND_AOUT defined(USE_LD) || defined(CAN_DUMP) || defined(INIT_OBJECTS) AC_DEFINE(FIND_AOUT, 1, [FIXME HARD]) -AC_CHECK_HEADERS(pwd.h grp.h sys/resource.h) - dnl dnl Check for available compiler features dnl diff --git a/src/libelk.c b/src/libelk.c index 75e8e44..10e869d 100644 --- a/src/libelk.c +++ b/src/libelk.c @@ -38,8 +38,10 @@ #include #include -#ifdef HAVE_GETRLIMIT -# include +#ifdef HAVE_STRUCT_RLIMIT +# ifdef HAVE_SYS_TIME_H +# include +# endif # ifdef HAVE_SYS_RESOURCE_H # include # endif @@ -49,12 +51,12 @@ # include #endif -#ifdef FIND_AOUT -# ifdef HAVE_UNISTD_H -# include -# else -# include -# endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_SYS_FILE_H +# include #endif #include "kernel.h" @@ -392,7 +394,7 @@ void Init_Everything () { } void Get_Stack_Limit () { -#ifdef HAVE_GETRLIMIT +#ifdef HAVE_STRUCT_RLIMIT struct rlimit rl; if (getrlimit (RLIMIT_STACK, &rl) == -1) { diff --git a/src/loadlib.c b/src/loadlib.c index b2c9ffc..06b9377 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -37,12 +37,16 @@ #include #include -#if defined (HAVE_MACH_O_DYLD_H) -# include -#elif defined (WIN32) +#if defined (HAVE_DL_DYLD) +# if defined (HAVE_MACH_O_DYLD_H) +# include +# endif +#elif defined (HAVE_DL_WINDOWS) # include -#elif defined (HAVE_IMAGE_H) -# include +#elif defined (HAVE_DL_BEOS) +# if defined (HAVE_IMAGE_H) +# include +# endif #elif defined (HAVE_DL_DLOPEN) # if defined (HAVE_DLFCN_H) # include @@ -96,7 +100,7 @@ void Dlopen_File (char *obj) { /* NSUnLinkModule (handle, FALSE); */ -#elif defined (WIN32) +#elif defined (HAVE_DL_WINDOWS) void *handle; if (Verb_Load) @@ -170,7 +174,7 @@ void Dlopen_File (char *obj) { if (sym) sp->value = (unsigned long int)(intptr_t)NSAddressOfSymbol (sym); -#elif defined (WIN32) +#elif defined (HAVE_DL_WINDOWS) sp->value = (unsigned long int)(intptr_t)GetProcAddress (handle, sp->name); #elif defined (HAVE_DL_BEOS)