OSDN Git Service

2004-08-12 Ziemowit Laski <zlaski@apple.com>
[pf3gnuchains/gcc-fork.git] / libobjc / objc / hash.h
index e695012..91a5eba 100644 (file)
@@ -1,20 +1,20 @@
 /* Hash tables for Objective C method dispatch.
-   Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC 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 General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
+along with GCC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
@@ -28,9 +28,14 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __hash_INCLUDE_GNU
 #define __hash_INCLUDE_GNU
 
+#include <objc/objc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #include <stddef.h>
 #include <string.h>
-#include <objc/objc.h>
 
 /*
  * This data structure is used to hold items
@@ -172,10 +177,10 @@ hash_string (cache_ptr cache, const void *key)
 {
   unsigned int ret = 0;
   unsigned int ctr = 0;
+  const char *ckey = (const char *) key;
         
-        
-  while (*(char *) key) {
-    ret ^= *(char *) key++ << ctr;
+  while (*ckey) {
+    ret ^= *ckey++ << ctr;
     ctr = (ctr + 1) % sizeof (void *);
   }
 
@@ -187,7 +192,7 @@ hash_string (cache_ptr cache, const void *key)
 static inline int 
 compare_ptrs (const void *k1, const void *k2)
 {
-  return ! (k1 - k2);
+  return (k1 == k2);
 }
 
 
@@ -200,8 +205,12 @@ compare_strings (const void *k1, const void *k2)
   else if (k1 == 0 || k2 == 0)
     return 0;
   else
-    return ! strcmp (k1, k2);
+    return ! strcmp ((const char *) k1, (const char *) k2);
+}
+
+#ifdef __cplusplus
 }
+#endif /* __cplusplus */
 
 
 #endif /* not __hash_INCLUDE_GNU */