This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Move some cache definitions around



To avoid duplication in glibc, I'm moving some definitions from
dl-cache.c to dl-cache.h.  This way I can include "dl-cache.h" in
ldconfig without duplication.

I'm working currently on enhancing ldconfig to support hwcaps and like
to present the smaller patches separatly if possible.  A patch for
ldconfig which uses this will come later.

Can I commit this, Uli?

Andreas

2000-05-05  Andreas Jaeger  <aj@suse.de>

	* sysdeps/generic/dl-cache.c (_dl_cache_libcmp): Moved from here...
	* sysdeps/generic/dl-cache.h (_dl_cache_libcmp): ...to here.
	* sysdeps/generic/dl-cache.c (LD_SO_CACHE): Moved from here...
	* sysdeps/generic/dl-cache.h (LD_SO_CACHE): ...to here.
	* sysdeps/generic/dl-cache.c (CACHEMAGIC): Moved from here...
	* sysdeps/generic/dl-cache.h (CACHEMAGIC): ...to here.

============================================================
Index: sysdeps/generic/dl-cache.h
--- sysdeps/generic/dl-cache.h	1999/06/09 11:41:38	1.1
+++ sysdeps/generic/dl-cache.h	2000/05/05 09:44:30
@@ -1,5 +1,5 @@
 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 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
@@ -21,3 +21,48 @@
 
 #define _dl_cache_check_flags(flags)			\
   ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
+
+
+#ifndef LD_SO_CACHE
+# define LD_SO_CACHE "/etc/ld.so.cache"
+#endif
+
+#define CACHEMAGIC "ld.so-1.7.0"
+
+static int
+_dl_cache_libcmp (const char *p1, const char *p2)
+{
+  while (*p1 != '\0')
+    {
+      if (*p1 >= '0' && *p1 <= '9')
+        {
+          if (*p2 >= '0' && *p2 <= '9')
+            {
+	      /* Must compare this numerically.  */
+	      int val1;
+	      int val2;
+
+	      val1 = *p1++ - '0';
+	      val2 = *p2++ - '0';
+	      while (*p1 >= '0' && *p1 <= '9')
+	        val1 = val1 * 10 + *p1++ - '0';
+	      while (*p2 >= '0' && *p2 <= '9')
+	        val2 = val2 * 10 + *p2++ - '0';
+	      if (val1 != val2)
+		return val1 - val2;
+	    }
+	  else
+            return 1;
+        }
+      else if (*p2 >= '0' && *p2 <= '9')
+        return -1;
+      else if (*p1 != *p2)
+        return *p1 - *p2;
+      else
+	{
+	  ++p1;
+	  ++p2;
+	}
+    }
+  return *p1 - *p2;
+}
============================================================
Index: sysdeps/generic/dl-cache.c
--- sysdeps/generic/dl-cache.c	2000/03/23 20:28:06	1.20
+++ sysdeps/generic/dl-cache.c	2000/05/05 09:44:30
@@ -28,12 +28,6 @@
 					 size_t *filesize_ptr,
 					 int mmap_prot);
 
-#ifndef LD_SO_CACHE
-# define LD_SO_CACHE "/etc/ld.so.cache"
-#endif
-
-#define CACHEMAGIC "ld.so-1.7.0"
-
 struct cache_file
   {
     char magic[sizeof CACHEMAGIC - 1];
@@ -55,46 +49,6 @@
 /* This is the cache ID we expect.  Normally it is 3 for glibc linked
    binaries.  */
 int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
-
-/* Helper function which must match the one in ldconfig, so that
-   we rely on the same sort order.  */
-static int
-_dl_cache_libcmp (const char *p1, const char *p2)
-{
-  while (*p1 != '\0')
-    {
-      if (*p1 >= '0' && *p1 <= '9')
-        {
-          if (*p2 >= '0' && *p2 <= '9')
-            {
-	      /* Must compare this numerically.  */
-	      int val1;
-	      int val2;
-
-	      val1 = *p1++ - '0';
-	      val2 = *p2++ - '0';
-	      while (*p1 >= '0' && *p1 <= '9')
-	        val1 = val1 * 10 + *p1++ - '0';
-	      while (*p2 >= '0' && *p2 <= '9')
-	        val2 = val2 * 10 + *p2++ - '0';
-	      if (val1 != val2)
-		return val1 - val2;
-	    }
-	  else
-            return 1;
-        }
-      else if (*p2 >= '0' && *p2 <= '9')
-        return -1;
-      else if (*p1 != *p2)
-        return *p1 - *p2;
-      else
-	{
-	  ++p1;
-	  ++p2;
-	}
-    }
-  return *p1 - *p2;
-}
 
 
 /* Look up NAME in ld.so.cache and return the file name stored there,

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]