[Glibc-bsd-commits] r2528 - trunk/glibc-ports/kfreebsd

Aurelien Jarno aurel32 at alioth.debian.org
Sun May 24 00:55:23 UTC 2009


Author: aurel32
Date: 2009-05-24 00:55:23 +0000 (Sun, 24 May 2009)
New Revision: 2528

Added:
   trunk/glibc-ports/kfreebsd/dl-sysdep.h
Modified:
   trunk/glibc-ports/kfreebsd/configure
   trunk/glibc-ports/kfreebsd/configure.in
   trunk/glibc-ports/kfreebsd/dl-osinfo.h
   trunk/glibc-ports/kfreebsd/dl-sysdep.c
   trunk/glibc-ports/kfreebsd/kernel-features.h
Log:
The GNU libc internally assumes that the kernel version is stored using the
Linux way, that is the major, minor, and subminor all get a byte with the
major number being in the highest byte.

Use the same format for kFreeBSD.



Modified: trunk/glibc-ports/kfreebsd/configure
===================================================================
--- trunk/glibc-ports/kfreebsd/configure	2009-05-23 21:28:23 UTC (rev 2527)
+++ trunk/glibc-ports/kfreebsd/configure	2009-05-24 00:55:23 UTC (rev 2528)
@@ -59,7 +59,7 @@
 #if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
 #define __FreeBSD_kernel_version __FreeBSD_version
 #endif
-#if !defined __FreeBSD_kernel_version || __FreeBSD_kernel_version <  (6 *10000+ 4 *100+ 0) /* 6.0.0 */
+#if !defined __FreeBSD_kernel_version || __FreeBSD_kernel_version <  (6 *65536+ 4 *256+ 0) /* 6.0.0 */
 eat flaming death
 #endif
 _ACEOF
@@ -129,8 +129,8 @@
 esac
 if test -n "$minimum_kernel"; then
 
-  user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/'`))
-  arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/'`))
+  user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
+  arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
 
   if test $user_version -lt $arch_version; then
     { echo "$as_me:$LINENO: WARNING: minimum kernel version reset to $arch_minimum_kernel" >&5
@@ -146,7 +146,7 @@
 if test -n "$minimum_kernel"; then
   echo "$as_me:$LINENO: checking for kernel header at least $minimum_kernel" >&5
 echo $ECHO_N "checking for kernel header at least $minimum_kernel... $ECHO_C" >&6
-  decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 10000 + \2 * 100 + \3)/'`;
+  decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
   abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */

Modified: trunk/glibc-ports/kfreebsd/configure.in
===================================================================
--- trunk/glibc-ports/kfreebsd/configure.in	2009-05-23 21:28:23 UTC (rev 2527)
+++ trunk/glibc-ports/kfreebsd/configure.in	2009-05-24 00:55:23 UTC (rev 2528)
@@ -38,7 +38,7 @@
 #endif
 #if !defined __FreeBSD_kernel_version || __FreeBSD_kernel_version < ]dnl
 patsubst(LIBC_KFREEBSD_VERSION,[^\([^.]*\)\.\([^.]*\)\.\([^.]*\)$],dnl
-[ (\1 *10000+ \2 *100+ \3) /* \1.\2.\3 */])[
+[ (\1 *65536+ \2 *256+ \3) /* \1.\2.\3 */])[
 eat flaming death
 #endif],
 	     libc_cv_kfreebsdVER='TOO OLD!',
@@ -86,8 +86,8 @@
 esac
 if test -n "$minimum_kernel"; then
   changequote(,)
-  user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/'`))
-  arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/'`))
+  user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
+  arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
   changequote([,])
   if test $user_version -lt $arch_version; then
     AC_MSG_WARN([minimum kernel version reset to $arch_minimum_kernel])
@@ -102,7 +102,7 @@
 if test -n "$minimum_kernel"; then
   AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
 changequote(,)dnl
-  decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 10000 + \2 * 100 + \3)/'`;
+  decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
   abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 changequote([,])dnl
   AC_EGREP_CPP([eat flaming death], [#include <osreldate.h>

Modified: trunk/glibc-ports/kfreebsd/dl-osinfo.h
===================================================================
--- trunk/glibc-ports/kfreebsd/dl-osinfo.h	2009-05-23 21:28:23 UTC (rev 2527)
+++ trunk/glibc-ports/kfreebsd/dl-osinfo.h	2009-05-24 00:55:23 UTC (rev 2528)
@@ -39,63 +39,26 @@
 }
 #endif
 
-
-#define DL_SYSDEP_OSCHECK(FATAL) \
+#define DL_SYSDEP_OSCHECK(FATAL)					      \
   do {									      \
-    /* Test whether the kernel is new enough.  This test is only	      \
-       performed if the library is not compiled to run on all		      \
-       kernels.  */							      \
-    if (__KFREEBSD_KERNEL_VERSION > 0)					      \
+    /* Test whether the kernel is new enough.  This test is only performed    \
+       if the library is not compiled to run on all kernels.  */	      \
+									      \
+    int version = _dl_discover_osversion ();				      \
+    if (__builtin_expect (version >= 0, 1))				      \
       {									      \
-	char bufmem[64];						      \
-	char *buf = bufmem;						      \
-	unsigned int version;						      \
-	int parts;							      \
-	char *cp;							      \
-	struct utsname uts;						      \
+	if (__builtin_expect (GLRO(dl_osversion) == 0, 1)		      \
+	    || GLRO(dl_osversion) > version)				      \
+	  GLRO(dl_osversion) = version;					      \
 									      \
-	/* Try the uname syscall */					      \
-	if (! __uname (&uts))					      	      \
-	  {							      	      \
-	    /* Now convert it into a number.  The string consists of at most  \
-	       three parts.  */						      \
-	    version = 0;						      \
-	    parts = 0;							      \
-            buf = uts.release;						      \
-	    cp = buf;							      \
-	    while ((*cp >= '0') && (*cp <= '9'))			      \
-	      {								      \
-	        unsigned int here = *cp++ - '0';			      \
-									      \
-	        while ((*cp >= '0') && (*cp <= '9'))			      \
-	          {							      \
-		    here *= 10;						      \
-		    here += *cp++ - '0';				      \
-	          }							      \
-									      \
-	        ++parts;						      \
-	        version *= 100;						      \
-	        version |= here;					      \
-									      \
-	        if (*cp++ != '.')					      \
-	          /* Another part following?  */			      \
-	          break;						      \
-	      }								      \
-									      \
-	    if (parts == 2)						      \
-	      version *= 100;						      \
-									      \
-	    if (parts == 1)						      \
-	      version *= 10000;						      \
-									      \
-	    /* Now we can test with the required version.  */		      \
-	    if (version < __KFREEBSD_KERNEL_VERSION)			      \
-	      /* Not sufficent.  */					      \
-	      FATAL ("FATAL: kernel too old\n");			      \
-									      \
-	    GLRO(dl_osversion) = version;				      \
-          }								      \
+	/* Now we can test with the required version.  */		      \
+	if (__KFREEBSD_KERNEL_VERSION > 0 && 				      \
+	    version < __KFREEBSD_KERNEL_VERSION)   			      \
+	  /* Not sufficent.  */						      \
+	  FATAL ("FATAL: kernel too old\n");				      \
       }									      \
+    else if (__KFREEBSD_KERNEL_VERSION > 0)				      \
+      FATAL ("FATAL: cannot determine kernel version\n");		      \
   } while (0)
 
 static inline uintptr_t __attribute__ ((always_inline))

Modified: trunk/glibc-ports/kfreebsd/dl-sysdep.c
===================================================================
--- trunk/glibc-ports/kfreebsd/dl-sysdep.c	2009-05-23 21:28:23 UTC (rev 2527)
+++ trunk/glibc-ports/kfreebsd/dl-sysdep.c	2009-05-24 00:55:23 UTC (rev 2528)
@@ -23,9 +23,56 @@
 #include <string.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/utsname.h>
 #include <ldsodefs.h>
 #include <kernel-features.h>
 
 #ifdef SHARED
 # include <elf/dl-sysdep.c>
 #endif
+
+int
+attribute_hidden
+_dl_discover_osversion (void)
+{
+  char bufmem[64];
+  char *buf = bufmem;
+  unsigned int version;
+  int parts;
+  char *cp;
+  struct utsname uts;
+
+  /* Try the uname syscall */
+  if (__uname (&uts))
+    return -1;
+
+  /* Now convert it into a number.  The string consists of at most
+     three parts.  */
+  version = 0;
+  parts = 0;
+  buf = uts.release;
+  cp = buf;
+  while ((*cp >= '0') && (*cp <= '9'))
+    {
+      unsigned int here = *cp++ - '0';
+
+      while ((*cp >= '0') && (*cp <= '9'))
+	{
+	  here *= 10;
+	  here += *cp++ - '0';
+	}
+
+      ++parts;
+      version <<= 8;
+      version |= here;
+
+      if (*cp++ != '.' || parts == 3)
+	/* Another part following?  */
+	break;
+    }
+
+  if (parts < 3)
+    version <<= 8 * (3 - parts);
+
+  return version;
+}

Added: trunk/glibc-ports/kfreebsd/dl-sysdep.h
===================================================================
--- trunk/glibc-ports/kfreebsd/dl-sysdep.h	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/dl-sysdep.h	2009-05-24 00:55:23 UTC (rev 2528)
@@ -0,0 +1,26 @@
+/* System-specific settings for dynamic linker code.  Linux version.
+   Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include_next <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+/* Get version of the OS.  */
+extern int _dl_discover_osversion (void) attribute_hidden;
+# define HAVE_DL_DISCOVER_OSVERSION	1
+#endif

Modified: trunk/glibc-ports/kfreebsd/kernel-features.h
===================================================================
--- trunk/glibc-ports/kfreebsd/kernel-features.h	2009-05-23 21:28:23 UTC (rev 2527)
+++ trunk/glibc-ports/kfreebsd/kernel-features.h	2009-05-24 00:55:23 UTC (rev 2528)
@@ -23,10 +23,10 @@
 # define __KFREEBSD_KERNEL_VERSION	0
 #endif
 
-/* We assume for __KFREEBSD_KERNEL_VERSION the same encoding used in
-   osreldate.h.  I.e., the major, minor, and subminor are all
-   concatenated, with two digits for each.  This means we can do
-   numeric comparisons.
+/* The encoding for __KFREEBSD_KERNEL_VERSION is defined the following
+   way: the major, minor, and subminor all get a byte with the major
+   number being in the highest byte.  This means we can do numeric
+   comparisons.
 
    In the following we will define certain symbols depending on
    whether the describes kernel feature is available in the kernel




More information about the Glibc-bsd-commits mailing list