rse 98/07/11 03:24:12
Modified: src CHANGES Configure src/helpers TestCompile src/include .cvsignore conf.h src/main http_main.c src/os/unix os.h src/os/win32 os.h Log: Provide HAVE_XXXX_H defines for C headers (take 3) ================================================== PR#2093, PR#2361, PR#2377, PR#2434, PR#2524, PR#2525, PR#2533, PR#2569 Background ---------- Currently we have some places (especially in conf.h and os/unix/os.h) where we make decisions about the existence of particular header files based on the underlying platform. In general this is sufficient, but expercience showed (especially the Linux/dlfcn.h PRs) that making general implications from platforms to file existance is very problematic because of too much variants and version of particular platforms. Problem ------- The problem is that we decide particular header files exists even when they don't exist. This caused compile time failures and a lot of PRs. Solution -------- The short-hand solution in the past was to use ``-D<PLATFORM>=<VERSION>'' defines instead of ``-D<PLATFORM>'' and use ``#if defined(<PLATFORM>) && <PLATFORM> >= <VERSION>'' instead of ``#ifdef <PLATFORM>''. This is ok for platforms where we really have access to and where we can be sure that a particular platform version has a file or hasn't it. This is not the case for esoteric Unix derivates and not the case of the huge amount of Linux variants. So a long-term solution is needed. As often GNU Autoconf is the father of the idea: We actually check for the existance of particular header files and define HAVE_XXXX_H if ``#include <xxxx.h>'' works (which means xxxx.h exists). The patch --------- The patch actually does the following: 1. It src/Configure another check-cycle is done where we test for various header files which later conditionally can be included via #ifdef HAVE_XXX_H #include <xxx.h> #endif This is done by calling TestCompile with a new command "header" which checks for existing header files. As a result the file include/conf_auto.h is generated containing these HAVE_XXX_H defines. Currently the following header files are tested (can be extended in the future): dlfcn.h dl.h bstring.h crypt.h unistd.h sys/resource.h sys/select.h sys/processor.h 2. In include/conf.h all HAVE_XXX_H defines/undefines were replaced by a single ``#include "conf_auto.h"'' statement at the top. And in all related files the inclusion of such headers are now based on HAVE_XXX_H defines. The generated conf_auto.h file looks like this: | /* Automatically generated file - DO NOT EDIT */ | #ifndef APACHE_CONF_AUTO_H | #define APACHE_CONF_AUTO_H 1 | | /* <dlfcn.h> */ | #ifndef HAVE_DLFCN_H | #define HAVE_DLFCN_H 1 | #endif | | /* <dl.h> */ | #ifdef HAVE_DL_H | #undef HAVE_DL_H | #endif | : | : | #endif /* APACHE_CONF_AUTO_H */ Submitted by: Ralf S. Engelschall Reviewed by: Dean Gaudet, Jim Jagielski PR: 2093, 2361, 2377, 2434, 2524, 2525, 2533, 2569 Revision Changes Path 1.959 +9 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.958 retrieving revision 1.959 diff -u -r1.958 -r1.959 --- CHANGES 1998/07/10 18:29:45 1.958 +++ CHANGES 1998/07/11 10:24:05 1.959 @@ -1,5 +1,14 @@ Changes with Apache 1.3.1 + *) Autogenerate some HAVE_XXXXX_H defines in conf_auto.h (determined via + TestCompile) instead of defining them manually in conf.h based on less + accurate platform definitions. This way we no longer have to fiddle with + OS-type and/or OS-version identifiers to discover whether a system header + file exists or not. Instead we now directly check for the existence of + those esoteric ones. + [Ralf S. Engelschall] PR#2093, PR#2361, PR#2377, PR#2434, + PR#2524, PR#2525, PR#2533, PR#2569 + *) mod_setenvif (BrowserMatch* and friends) will now match a missing field with "^$". [Ken Coar] 1.274 +40 -0 apache-1.3/src/Configure Index: Configure =================================================================== RCS file: /export/home/cvs/apache-1.3/src/Configure,v retrieving revision 1.273 retrieving revision 1.274 diff -u -r1.273 -r1.274 --- Configure 1998/07/08 17:46:53 1.273 +++ Configure 1998/07/11 10:24:05 1.274 @@ -1203,6 +1203,36 @@ ;; esac +#################################################################### +## Now check for existance of non-standard system header files +## +echo " + checking for system header files" + +CONF_AUTO_H="include/conf_auto.h" +CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h sys/resource.h sys/select.h sys/processor.h" + +echo "/* Automatically generated file - DO NOT EDIT */" >$CONF_AUTO_H +echo "#ifndef APACHE_CONF_AUTO_H" >>$CONF_AUTO_H +echo "#define APACHE_CONF_AUTO_H 1" >>$CONF_AUTO_H +echo "" >>$CONF_AUTO_H +for header in $CHECK_FOR_HEADERS; do + echo "/* <$header> */" >>$CONF_AUTO_H + name="`echo $header | sed -e 's:/:_:g' -e 's:\.:_:g' | tr 'a-z' 'A-Z'`" + if ./helpers/TestCompile header $header; then + eval "HAVE_${name}=1" + echo "#ifndef HAVE_${name}" >>$CONF_AUTO_H + echo "#define HAVE_${name} 1" >>$CONF_AUTO_H + echo "#endif" >>$CONF_AUTO_H + else + eval "HAVE_${name}=0" + echo "#ifdef HAVE_${name}" >>$CONF_AUTO_H + echo "#undef HAVE_${name}" >>$CONF_AUTO_H + echo "#endif" >>$CONF_AUTO_H + fi + echo "" >>$CONF_AUTO_H +done +echo "#endif /* APACHE_CONF_AUTO_H */" >>$CONF_AUTO_H + # SOCKS4 support: # We assume that if they are using SOCKS4, then they've # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required, @@ -1240,6 +1270,16 @@ ;; esac fi + +# AIX 4.x support: +# Processor Binding +case "$PLAT" in + *-ibm-aix*) + if [ ".$HAVE_SYS_PROCESSOR_H" = .1 ]; then + CFLAGS="$CFLAGS -DAIX_BIND_PROCESSOR" + fi + ;; +esac #################################################################### ## Find out what modules we want and try and configure things for them 1.12 +20 -1 apache-1.3/src/helpers/TestCompile Index: TestCompile =================================================================== RCS file: /export/home/cvs/apache-1.3/src/helpers/TestCompile,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- TestCompile 1998/04/11 15:45:59 1.11 +++ TestCompile 1998/07/11 10:24:07 1.12 @@ -4,7 +4,7 @@ # # Yet another Apache Configure helper script. # This script tests certain aspects of the compilation -# process. Right now, it can perform 3 tests: +# process. Right now, it can perform 5 tests: # # ./helpers/TestCompile lib <libname> # Which checks to see if <libname> exists on this system @@ -16,6 +16,9 @@ # ./helpers/TestCompile func <function> # Which checks to see if <function> exists # +# ./helpers/TestCompile header <header> +# Which checks to see if header file <header> exists +# # ./helpers/TestCompile sanity # Which does a simple sanity check/test compile # @@ -92,6 +95,22 @@ void main(void) { $2(); } +EOF + ;; + "header") + if [ "x$2" = "x" ]; then + exit + fi + TLIB="" + if [ "$VERBOSE" = "yes" ]; then + ERRDIR="" + else + ERRDIR='2>/dev/null' + fi + TARGET='testfunc' + cat <<EOF >testfunc.c +#include <$2> +void main(void) { } EOF ;; *) 1.2 +1 -0 apache-1.3/src/include/.cvsignore Index: .cvsignore =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 1998/03/08 03:46:25 1.1 +++ .cvsignore 1998/07/11 10:24:08 1.2 @@ -1 +1,2 @@ ap_config.h +conf_auto.h 1.221 +2 -43 apache-1.3/src/include/conf.h Index: conf.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/conf.h,v retrieving revision 1.220 retrieving revision 1.221 diff -u -r1.220 -r1.221 --- conf.h 1998/07/08 17:46:59 1.220 +++ conf.h 1998/07/11 10:24:08 1.221 @@ -67,6 +67,7 @@ * See PORTING for a listing of what they mean */ +#include "conf_auto.h" /* Have to include sys/stat.h before ../os/win32/os.h so we can override stat() properly */ @@ -88,7 +89,6 @@ /* Define one of these according to your system. */ #if defined(MINT) typedef int rlim_t; -#define HAVE_SYS_RESOURCE_H 1 #define JMP_BUF sigjmp_buf #define NO_LONG_DOUBLE #define USE_FLOCK_SERIALIZED_ACCEPT @@ -123,7 +123,6 @@ #elif defined(SUNOS4) #define HAVE_GMTOFF 1 -#define HAVE_SYS_RESOURCE_H 1 #undef NO_KILLPG #undef NO_SETSID char *crypt(const char *pw, const char *salt); @@ -144,8 +143,6 @@ #undef HAVE_GMTOFF #define NO_KILLPG #undef NO_SETSID -#define HAVE_SYS_RESOURCE_H 1 -#define HAVE_DLFCN_H 1 #define bzero(a,b) memset(a,0,b) #if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \ !defined(USE_PTHREAD_SERIALIZED_ACCEPT) @@ -155,7 +152,6 @@ #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES -#define HAVE_CRYPT_H 1 int gethostname(char *name, int namelen); #define HAVE_SYSLOG 1 #define SYS_SIGLIST _sys_siglist @@ -173,15 +169,11 @@ #define USE_SHMGET_SCOREBOARD #define HAVE_MMAP 1 #define USE_MMAP_FILES -#define HAVE_CRYPT_H 1 -#define HAVE_DLFCN_H 1 #define NO_LONG_DOUBLE -#define HAVE_BSTRING_H 1 #define NO_LINGCLOSE #define HAVE_SYSLOG 1 #elif defined(HIUX) -#define HAVE_SYS_RESOURCE_H 1 #undef HAVE_GMTOFF #define NO_KILLPG #undef NO_SETSID @@ -194,7 +186,6 @@ #define HAVE_SYSLOG 1 #elif defined(HPUX) || defined(HPUX10) -#define HAVE_SYS_RESOURCE_H 1 #undef HAVE_GMTOFF #define NO_KILLPG #undef NO_SETSID @@ -218,9 +209,6 @@ #define USE_SHMGET_SCOREBOARD #undef HAVE_GMTOFF #define HAVE_RESOURCE -#define HAVE_CRYPT_H -#undef HAVE_SYS_SELECT_H -#define HAVE_SYS_RESOURCE_H #define USE_FCNTL_SERIALIZED_ACCEPT /* feeling brave? want to try using POSIX mutexes? */ /* #define HAVE_MMAP */ @@ -235,7 +223,6 @@ #undef HAVE_GMTOFF #undef NO_KILLPG #undef NO_SETSID -#define HAVE_SYS_SELECT_H 1 #ifndef __ps2__ #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD @@ -277,7 +264,6 @@ #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES -#define HAVE_CRYPT_H 1 #define NO_LONG_DOUBLE #define HAVE_SYSLOG 1 #define USE_FLOCK_SERIALIZED_ACCEPT @@ -290,7 +276,6 @@ #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES -#define HAVE_CRYPT_H 1 #define NO_LONG_DOUBLE #define HAVE_SYSLOG 1 typedef int rlim_t; @@ -309,7 +294,6 @@ #define NO_SETSID #define NEED_STRDUP #define NO_LINGCLOSE -#define NO_UNISTD_H #undef _POSIX_SOURCE #ifndef FD_CLOEXEC #define FD_CLOEXEC 1 @@ -368,7 +352,6 @@ #define HAVE_SYSLOG 1 #elif defined(LINUX) -#define HAVE_DLFCN_H 1 #if LINUX > 1 #include <features.h> @@ -402,7 +385,6 @@ #define USE_SHMGET_SCOREBOARD #define HAVE_MMAP 1 #define USE_MMAP_FILES -#define HAVE_SYS_RESOURCE_H 1 /* glibc 2.1 and later finally define rlim_t */ #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) @@ -436,12 +418,10 @@ #elif defined(SCO5) -#define HAVE_SYS_SELECT_H 1 #define USE_FCNTL_SERIALIZED_ACCEPT #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES -#define HAVE_SYS_RESOURCE_H 1 #define SecureWare #define HAVE_SYSLOG 1 @@ -527,9 +507,6 @@ #define USE_MMAP_FILES #define HAVE_SHMGET 1 #undef USE_SHMGET_SCOREBOARD /* force use of mmap() scoreboard */ -#define HAVE_CRYPT_H 1 -#define HAVE_SYS_SELECT_H 1 -#define HAVE_SYS_RESOURCE_H 1 #include <sys/time.h> #if UW >= 200 #define _POSIX_SOURCE @@ -551,7 +528,6 @@ #define HAVE_SYSLOG 1 #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(NETBSD) -#define HAVE_SYS_RESOURCE_H 1 #define HAVE_GMTOFF 1 #undef NO_KILLPG #undef NO_SETSID @@ -601,8 +577,6 @@ #if defined(__FreeBSD__) #include <osreldate.h> #endif -#define HAVE_DLFCN_H 1 -#define HAVE_SYS_RESOURCE_H 1 #define HAVE_GMTOFF 1 #undef NO_KILLPG #undef NO_SETSID @@ -638,7 +612,6 @@ #define NEED_INITGROUPS #define NEED_SELECT_H #define NEED_PROCESS_H -#define HAVE_SYS_SELECT_H 1 #include <unix.h> #define HAVE_MMAP 1 #define USE_POSIX_SCOREBOARD @@ -651,13 +624,9 @@ #define HAVE_RESOURCE 1 #undef USE_MMAP_SCOREBOARD #undef USE_SHMGET_SCOREBOARD -#undef HAVE_CRYPT_H -#undef HAVE_SYS_SELECT_H -#define HAVE_SYS_RESOURCE_H 1 #undef USE_FCNTL_SERIALIZED_ACCEPT #undef USE_FLOCK_SERIALIZED_ACCEPT #define USE_LONGJMP -#undef NO_UNISTD_H #undef NO_KILLPG #undef NO_SETSID #undef NO_USE_SIGACTION @@ -679,7 +648,6 @@ #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES -#define HAVE_CRYPT_H 1 #define HAVE_SYSLOG 1 #elif defined(__EMX__) @@ -696,7 +664,6 @@ #define MAXSOCKETS 4096 #define USE_OS2_SCOREBOARD #define NO_RELIABLE_PIPED_LOGS -#define HAVE_SYS_SELECT_H 1 #elif defined(__MACHTEN__) typedef int rlim_t; @@ -744,7 +711,6 @@ #define HAVE_SYSLOG 1 #elif defined(NEWSOS) -#define HAVE_SYS_RESOURCE_H 1 #define HAVE_SHMGET 1 #define USE_SHMGET_SCOREBOARD #define USE_LONGJMP @@ -849,13 +815,6 @@ #define ENUM_BITFIELD(e,n,w) e n : w #endif -/* Do we have sys/resource.h; assume that BSD does. */ -#ifndef HAVE_SYS_RESOURCE_H -#ifdef BSD -#define HAVE_SYS_RESOURCE_H 1 -#endif -#endif /* HAVE_SYS_RESOURCE_H */ - /* * The particular directory style your system supports. If you have dirent.h * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include @@ -964,7 +923,7 @@ #define LOGNAME_MAX 25 #endif -#ifndef NO_UNISTD_H +#ifdef HAVE_UNISTD_H #include <unistd.h> #endif 1.371 +1 -1 apache-1.3/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.370 retrieving revision 1.371 diff -u -r1.370 -r1.371 --- http_main.c 1998/07/08 16:54:34 1.370 +++ http_main.c 1998/07/11 10:24:09 1.371 @@ -3733,7 +3733,7 @@ } if (!pid) { -#if defined(AIX) && (AIX >= 41) +#ifdef AIX_BIND_PROCESSOR /* by default AIX binds to a single processor * this bit unbinds children which will then bind to another cpu */ 1.27 +2 -12 apache-1.3/src/os/unix/os.h Index: os.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/os/unix/os.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- os.h 1998/07/10 18:29:51 1.26 +++ os.h 1998/07/11 10:24:11 1.27 @@ -58,6 +58,8 @@ #ifndef APACHE_OS_H #define APACHE_OS_H +#include "conf.h" + #define PLATFORM "Unix" /* @@ -86,18 +88,6 @@ * Apache modules under run-time via * dynamic shared object (DSO) mechanism */ - -#if defined(HPUX) || defined(HPUX10) -#define HAVE_DL_H 1 -#endif - -#if defined(LINUX) || defined(__FreeBSD__) ||\ - defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(SOLARIS2) || defined(__bsdi__) || \ - defined(IRIX) || defined(SVR4) || defined(OSF1) ||\ - defined(SCO5) -#define HAVE_DLFCN_H 1 -#endif #ifdef HAVE_DL_H #include <dl.h> 1.20 +0 -1 apache-1.3/src/os/win32/os.h Index: os.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- os.h 1998/06/20 11:20:40 1.19 +++ os.h 1998/07/11 10:24:11 1.20 @@ -23,7 +23,6 @@ #define STRICT #endif #define CASE_BLIND_FILESYSTEM -#define NO_UNISTD_H #define NO_WRITEV #define NO_SETSID #define NO_USE_SIGACTION