httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject [PATCH] Provide HAVE_XXXX_H defines for C headers (take 3)
Date Thu, 09 Jul 1998 11:00:27 GMT

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 always 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
---------
Rhe 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/ap_configauto.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 "ap_configauto.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 ap_configauto.h file looks like this:

  | /* Automatically generated file - DO NOT EDIT */
  | 
  | /* <dlfcn.h> */
  | #ifndef HAVE_DLFCN_H
  | #define HAVE_DLFCN_H 1
  | #endif
  | 
  | /* <dl.h> */
  | #ifdef HAVE_DL_H
  | #undef HAVE_DL_H
  | #endif
  |   :
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: src/CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.954
diff -u -r1.954 CHANGES
--- CHANGES	1998/07/08 17:46:53	1.954
+++ CHANGES	1998/07/09 10:29:27
@@ -1,5 +1,12 @@
 Changes with Apache 1.3.1
 
+  *) Autogenerate some HAVE_XXXXX_H defines in ap_configauto.h 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 if a system header file exists
+     or not. Instead we now can directly check for their existance.
+     [Ralf S. Engelschall] PR#2093, PR#????
+
   *) Fix yet another signal-based race condition involving nested timers.
      Signals suck.  [Dean Gaudet]
 
Index: src/Configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Configure,v
retrieving revision 1.273
diff -u -r1.273 Configure
--- Configure	1998/07/08 17:46:53	1.273
+++ Configure	1998/07/09 10:48:18
@@ -1203,6 +1203,33 @@
 	;;
 esac
 
+####################################################################
+## Now check for existance of non-standard system header files
+##
+echo " + checking for system header files"
+
+CONFIGAUTO_H="include/ap_configauto.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 */" >$CONFIGAUTO_H
+echo "" >>$CONFIGAUTO_H
+for header in $CHECK_FOR_HEADERS; do
+    echo "/* <$header> */" >>$CONFIGAUTO_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}" >>$CONFIGAUTO_H
+        echo "#define HAVE_${name} 1" >>$CONFIGAUTO_H
+        echo "#endif" >>$CONFIGAUTO_H
+    else
+        eval "HAVE_${name}=0"
+        echo "#ifdef HAVE_${name}" >>$CONFIGAUTO_H
+        echo "#undef HAVE_${name}" >>$CONFIGAUTO_H
+        echo "#endif" >>$CONFIGAUTO_H
+    fi
+    echo "" >>$CONFIGAUTO_H
+done
+
 # SOCKS4 support:
 # We assume that if they are using SOCKS4, then they've
 # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
@@ -1240,6 +1267,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
Index: src/helpers/TestCompile
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/helpers/TestCompile,v
retrieving revision 1.11
diff -u -r1.11 TestCompile
--- TestCompile	1998/04/11 15:45:59	1.11
+++ TestCompile	1998/04/21 12:01:53
@@ -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
 	;;
     *)
Index: src/include/.cvsignore
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/include/.cvsignore,v
retrieving revision 1.1
diff -u -r1.1 .cvsignore
--- .cvsignore	1998/03/08 03:46:25	1.1
+++ .cvsignore	1998/07/08 12:02:14
@@ -1 +1,2 @@
 ap_config.h
+ap_configauto.h
Index: src/include/conf.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/include/conf.h,v
retrieving revision 1.220
diff -u -r1.220 conf.h
--- conf.h	1998/07/08 17:46:59	1.220
+++ conf.h	1998/07/09 10:26:05
@@ -67,6 +67,7 @@
  * See PORTING for a listing of what they mean
  */
 
+#include "ap_configauto.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
 
Index: src/main/http_main.c
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/main/http_main.c,v
retrieving revision 1.370
diff -u -r1.370 http_main.c
--- http_main.c	1998/07/08 16:54:34	1.370
+++ http_main.c	1998/07/09 09:53:39
@@ -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
  */
Index: src/os/unix/os.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/os/unix/os.h,v
retrieving revision 1.25
diff -u -r1.25 os.h
--- os.h	1998/07/06 11:54:30	1.25
+++ os.h	1998/07/08 12:00:50
@@ -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>
Index: src/os/win32/os.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/os/win32/os.h,v
retrieving revision 1.19
diff -u -r1.19 os.h
--- os.h	1998/06/20 11:20:40	1.19
+++ os.h	1998/07/09 10:22:23
@@ -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

Mime
View raw message