]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
filenames.h: #include "hashtab.h".
authorDoug Evans <dje@google.com>
Fri, 13 Jul 2012 22:12:28 +0000 (22:12 +0000)
committerDoug Evans <devans@gcc.gnu.org>
Fri, 13 Jul 2012 22:12:28 +0000 (22:12 +0000)
include/
* filenames.h: #include "hashtab.h".
(filename_hash, filename_eq): Declare.
libiberty/
* filename_cmp.c (filename_hash, filename_eq): New functions.

From-SVN: r189472

include/ChangeLog
include/filenames.h
libiberty/ChangeLog
libiberty/filename_cmp.c

index bf2a03295034f8732e5dbdf9dc18077fffad41eb..57f812de6c3d06add9be2d5de0e38826e4786a62 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-13  Doug Evans  <dje@google.com>
+
+       * filenames.h: #include "hashtab.h".
+       (filename_hash, filename_eq): Declare.
+
 2012-06-18  Doug Evans  <dje@google.com>
 
        * dwarf2.def (DW_OP): Add DW_OP_GNU_const_index.
index 75ec3302d1d0a9764c86efaf2c25fd69c0708c6a..e799a51b6ad014d74581da6d92ce337be896c86a 100644 (file)
@@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 #ifndef FILENAMES_H
 #define FILENAMES_H
 
+#include "hashtab.h" /* for hashval_t */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -84,6 +86,10 @@ extern int filename_cmp (const char *s1, const char *s2);
 extern int filename_ncmp (const char *s1, const char *s2,
                          size_t n);
 
+extern hashval_t filename_hash (const void *s);
+
+extern int filename_eq (const void *s1, const void *s2);
+
 #ifdef __cplusplus
 }
 #endif
index 9628e2c4ae3230d67f9e7896f441b936409b64da..4ece5ab7474cf34c750fa7306a1daf7951b04d64 100644 (file)
@@ -1,3 +1,7 @@
+2012-07-13  Doug Evans  <dje@google.com>
+
+       * filename_cmp.c (filename_hash, filename_eq): New functions.
+
 2012-06-29  Andreas Schwab  <schwab@linux-m68k.org>
 
        * copying-lib.texi (Library Copying): Don't use @heading inside
index 5179f8dd14ff40b3ebcefc1c36d9ee9f278ed53c..9e16d242086d499a795f1d8f954fc4964c391b8e 100644 (file)
@@ -141,3 +141,52 @@ filename_ncmp (const char *s1, const char *s2, size_t n)
   return 0;
 #endif
 }
+
+/*
+
+@deftypefn Extension hashval_t filename_hash (const void *@var{s})
+
+Return the hash value for file name @var{s} that will be compared
+using filename_cmp.
+This function is for use with hashtab.c hash tables.
+
+@end deftypefn
+
+*/
+
+hashval_t
+filename_hash (const void *s)
+{
+  /* The cast is for -Wc++-compat.  */
+  const unsigned char *str = (const unsigned char *) s;
+  hashval_t r = 0;
+  unsigned char c;
+
+  while ((c = *str++) != 0)
+    {
+      if (c == '\\')
+       c = '/';
+      c = TOLOWER (c);
+      r = r * 67 + c - 113;
+    }
+
+  return r;
+}
+
+/*
+
+@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2})
+
+Return non-zero if file names @var{s1} and @var{s2} are equivalent.
+This function is for use with hashtab.c hash tables.
+
+@end deftypefn
+
+*/
+
+int
+filename_eq (const void *s1, const void *s2)
+{
+  /* The casts are for -Wc++-compat.  */
+  return filename_cmp ((const char *) s1, (const char *) s2) == 0;
+}