httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] Re: os-linux/1542: /usr/include/bits/resource.h:113: conflicting types for `rlim_t' (fwd)
Date Tue, 16 Dec 1997 07:33:31 GMT
On Wed, 10 Dec 1997, Marc Slemko wrote:

> I would suggest that the time for automatic rlim_t testing is near.
> 
> It is easy to add a "type" test to TestCompile, but the trouble is what
> include files do you use?  For rlim_t, it should be sys/resource.h
> normally but how do you generalize that?
> 
> It may be possible to hardcode rlim_t, but we need to know exactly what
> version of glibc has it, etc.  A pain.

I spent time looking into this.  glibc has a few gotches that are
annoying.  I don't think we can support -Wall warning free compilation
on all versions of glibc...

For example, 2.0.0 through 2.0.4 use "size_t *"  for the third paramter
to accept() and other network functions, whereas 2.0.5 and later use
"socklen_t *".  This is due to evolution of the POSIX spec.  (Using size_t
is broken broken broken, and was a hideous mistake in the spec, it breaks
all old programs that assume that paramter is an "int *" when compiled
on 64-bit systems.  socklen_t is essentially an int.)  However, there is
no way to detect 2.0.x < 2.0.5.

Thankfully rlim_t appears only in glibc 2.1.x, and not earlier.

The following patch is a reasonable attempt to get us -Wall free compiles
on 2.0.5 (and later) and 2.1.x glibc.  The rlim_t change is required
to compile on 2.1.x.  I've tested on glibc 2.0.5 alpha and ppc systems,
and libc5 i386 systems.  The rest I gleaned from looking at various
versions of glibc.

Dean

Index: conf.h
===================================================================
RCS file: /export/home/cvs/apachen/src/main/conf.h,v
retrieving revision 1.162
diff -u -r1.162 conf.h
--- conf.h	1997/12/01 12:10:14	1.162
+++ conf.h	1997/12/16 07:27:14
@@ -310,22 +310,50 @@
 #define HAVE_SYSLOG
 
 #elif defined(LINUX)
+
 #if LINUX > 1
 #include <features.h>
+
+/* libc4 systems probably still work, it probably doesn't define
+ *  __GNU_LIBRARY__
+ * libc5 systems define __GNU_LIBRARY__ == 1, but don't define __GLIBC__
+ * glibc 2.x and later systems define __GNU_LIBRARY__ == 6, but list it as
+ * "deprecated in favour of __GLIBC__"; the value 6 will never be changed.
+ * glibc 1.x systems (i.e. redhat 4.x on sparc/alpha) should have
+ * __GLIBC__ < 2
+ * all glibc based systems need crypt.h
+ */
 #if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
-/* it's a glibc host */
 #include <crypt.h>
-#define NET_SIZE_T size_t
 #endif
+
+/* glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t *
+ * there's no way to discern between these two libraries.  But using int should
+ * be portable because otherwise these libs would be hopelessly broken with
+ * reams of existing networking code.  We'll use socklen_t * for 2.1.x and
+ * later.
+ *
+ * int works for all the earlier libs, and is picked up by default later.
+ */
+#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__
> 0))
+#define NET_SIZE_T socklen_t
+#endif
+
 #define HAVE_SHMGET
 #define USE_MMAP_FILES
 #define HAVE_SYS_RESOURCE_H
+
+/* glibc 2.1 and later finally define rlim_t */
+#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__
< 1)
 typedef int rlim_t;
+#endif
 /* flock is faster ... but hasn't been tested on 1.x systems */
 #define USE_FLOCK_SERIALIZED_ACCEPT
+
 #else
 #define USE_FCNTL_SERIALIZED_ACCEPT
 #endif
+
 #undef HAVE_GMTOFF
 #undef NO_KILLPG
 #undef NO_SETSID


Mime
View raw message