[Mesa-dev] [PATCH 1/2] program/hash_table.c: rename to program/prog_hash_table.c

Jordan Justen jordan.l.justen at intel.com
Mon Dec 3 14:52:40 PST 2012


Removes a collision of the object file name for main/hash_table
and program/hash_table.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/glsl/Makefile.am                   |    4 +-
 src/glsl/SConscript                    |    2 +-
 src/glsl/builtin_compiler/Makefile.am  |    2 +-
 src/glsl/glcpp/Makefile.am             |    2 +-
 src/mesa/Android.libmesa_glsl_utils.mk |    4 +-
 src/mesa/SConscript                    |    2 +-
 src/mesa/program/hash_table.c          |  235 --------------------------------
 src/mesa/program/prog_hash_table.c     |  235 ++++++++++++++++++++++++++++++++
 src/mesa/sources.mak                   |    2 +-
 9 files changed, 244 insertions(+), 244 deletions(-)
 delete mode 100644 src/mesa/program/hash_table.c
 create mode 100644 src/mesa/program/prog_hash_table.c

diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index ea76176..2ba439c 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -49,14 +49,14 @@ libglsl_la_LIBADD = glcpp/libglcpp.la
 libglsl_la_LDFLAGS =
 
 glsl_compiler_SOURCES = \
-	$(top_srcdir)/src/mesa/program/hash_table.c \
+	$(top_srcdir)/src/mesa/program/prog_hash_table.c \
 	$(top_srcdir)/src/mesa/program/symbol_table.c \
 	$(GLSL_COMPILER_CXX_FILES)
 
 glsl_compiler_LDADD = libglsl.la
 
 glsl_test_SOURCES = \
-	$(top_srcdir)/src/mesa/program/hash_table.c \
+	$(top_srcdir)/src/mesa/program/prog_hash_table.c \
 	$(top_srcdir)/src/mesa/program/symbol_table.c \
 	$(GLSL_SRCDIR)/standalone_scaffolding.cpp \
 	test.cpp \
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index 0cf25c0..d146407 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -58,7 +58,7 @@ if env['crosscompile'] and not env['embedded']:
 else:
     # Copy these files to avoid generation object files into src/mesa/program
     env.Prepend(CPPPATH = ['#src/mesa/program'])
-    env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE'))
+    env.Command('prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
     env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
 
     compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
diff --git a/src/glsl/builtin_compiler/Makefile.am b/src/glsl/builtin_compiler/Makefile.am
index d6f85a7..5fad35d 100644
--- a/src/glsl/builtin_compiler/Makefile.am
+++ b/src/glsl/builtin_compiler/Makefile.am
@@ -55,7 +55,7 @@ builtin_compiler_SOURCES = \
 	$(GLSL_BUILDDIR)/glsl_parser.cc \
 	$(LIBGLSL_FILES) \
 	$(LIBGLSL_CXX_FILES) \
-	$(top_srcdir)/src/mesa/program/hash_table.c \
+	$(top_srcdir)/src/mesa/program/prog_hash_table.c \
 	$(top_srcdir)/src/mesa/program/symbol_table.c \
 	$(GLSL_COMPILER_CXX_FILES) \
 	builtin_stubs.cpp
diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am
index 04d8cda..d8d39d2 100644
--- a/src/glsl/glcpp/Makefile.am
+++ b/src/glsl/glcpp/Makefile.am
@@ -46,7 +46,7 @@ libglcpp_la_SOURCES = \
 
 glcpp_SOURCES = \
 	../ralloc.c \
-	$(top_srcdir)/src/mesa/program/hash_table.c \
+	$(top_srcdir)/src/mesa/program/prog_hash_table.c \
 	glcpp.c
 
 glcpp_LDADD = libglcpp.la
diff --git a/src/mesa/Android.libmesa_glsl_utils.mk b/src/mesa/Android.libmesa_glsl_utils.mk
index 4802757..5ae946f 100644
--- a/src/mesa/Android.libmesa_glsl_utils.mk
+++ b/src/mesa/Android.libmesa_glsl_utils.mk
@@ -36,7 +36,7 @@ include $(CLEAR_VARS)
 LOCAL_MODULE := libmesa_glsl_utils
 
 LOCAL_SRC_FILES := \
-	program/hash_table.c \
+	program/prog_hash_table.c \
 	program/symbol_table.c
 
 include $(MESA_COMMON_MK)
@@ -52,7 +52,7 @@ LOCAL_MODULE := libmesa_glsl_utils
 LOCAL_IS_HOST_MODULE := true
 
 LOCAL_SRC_FILES := \
-	program/hash_table.c \
+	program/prog_hash_table.c \
 	program/symbol_table.c
 
 include $(MESA_COMMON_MK)
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index be1ed5f..1afa412 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -293,7 +293,7 @@ env.Append(CPPPATH = [Dir('.').abspath])
 
 program_sources = [
     'program/arbprogparse.c',
-    'program/hash_table.c',
+    'program/prog_hash_table.c',
     'program/ir_to_mesa.cpp',
     'program/program.c',
     'program/program_parse_extra.c',
diff --git a/src/mesa/program/hash_table.c b/src/mesa/program/hash_table.c
deleted file mode 100644
index f45ed46..0000000
--- a/src/mesa/program/hash_table.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright © 2008 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file hash_table.c
- * \brief Implementation of a generic, opaque hash table data type.
- *
- * \author Ian Romanick <ian.d.romanick at intel.com>
- */
-
-#include "main/imports.h"
-#include "main/simple_list.h"
-#include "hash_table.h"
-
-struct node {
-   struct node *next;
-   struct node *prev;
-};
-
-struct hash_table {
-    hash_func_t    hash;
-    hash_compare_func_t  compare;
-
-    unsigned num_buckets;
-    struct node buckets[1];
-};
-
-
-struct hash_node {
-    struct node link;
-    const void *key;
-    void *data;
-};
-
-
-struct hash_table *
-hash_table_ctor(unsigned num_buckets, hash_func_t hash,
-                hash_compare_func_t compare)
-{
-    struct hash_table *ht;
-    unsigned i;
-
-
-    if (num_buckets < 16) {
-        num_buckets = 16;
-    }
-
-    ht = malloc(sizeof(*ht) + ((num_buckets - 1) 
-				     * sizeof(ht->buckets[0])));
-    if (ht != NULL) {
-        ht->hash = hash;
-        ht->compare = compare;
-        ht->num_buckets = num_buckets;
-
-        for (i = 0; i < num_buckets; i++) {
-            make_empty_list(& ht->buckets[i]);
-        }
-    }
-
-    return ht;
-}
-
-
-void
-hash_table_dtor(struct hash_table *ht)
-{
-   hash_table_clear(ht);
-   free(ht);
-}
-
-
-void
-hash_table_clear(struct hash_table *ht)
-{
-   struct node *node;
-   struct node *temp;
-   unsigned i;
-
-
-   for (i = 0; i < ht->num_buckets; i++) {
-      foreach_s(node, temp, & ht->buckets[i]) {
-	 remove_from_list(node);
-	 free(node);
-      }
-
-      assert(is_empty_list(& ht->buckets[i]));
-   }
-}
-
-
-static struct hash_node *
-get_node(struct hash_table *ht, const void *key)
-{
-    const unsigned hash_value = (*ht->hash)(key);
-    const unsigned bucket = hash_value % ht->num_buckets;
-    struct node *node;
-
-    foreach(node, & ht->buckets[bucket]) {
-       struct hash_node *hn = (struct hash_node *) node;
-
-       if ((*ht->compare)(hn->key, key) == 0) {
-	  return hn;
-       }
-    }
-
-    return NULL;
-}
-
-void *
-hash_table_find(struct hash_table *ht, const void *key)
-{
-   struct hash_node *hn = get_node(ht, key);
-
-   return (hn == NULL) ? NULL : hn->data;
-}
-
-void
-hash_table_insert(struct hash_table *ht, void *data, const void *key)
-{
-    const unsigned hash_value = (*ht->hash)(key);
-    const unsigned bucket = hash_value % ht->num_buckets;
-    struct hash_node *node;
-
-    node = calloc(1, sizeof(*node));
-
-    node->data = data;
-    node->key = key;
-
-    insert_at_head(& ht->buckets[bucket], & node->link);
-}
-
-bool
-hash_table_replace(struct hash_table *ht, void *data, const void *key)
-{
-    const unsigned hash_value = (*ht->hash)(key);
-    const unsigned bucket = hash_value % ht->num_buckets;
-    struct node *node;
-    struct hash_node *hn;
-
-    foreach(node, & ht->buckets[bucket]) {
-       hn = (struct hash_node *) node;
-
-       if ((*ht->compare)(hn->key, key) == 0) {
-	  hn->data = data;
-	  return true;
-       }
-    }
-
-    hn = calloc(1, sizeof(*hn));
-
-    hn->data = data;
-    hn->key = key;
-
-    insert_at_head(& ht->buckets[bucket], & hn->link);
-    return false;
-}
-
-void
-hash_table_remove(struct hash_table *ht, const void *key)
-{
-   struct node *node = (struct node *) get_node(ht, key);
-   if (node != NULL) {
-      remove_from_list(node);
-      free(node);
-      return;
-   }
-}
-
-void
-hash_table_call_foreach(struct hash_table *ht,
-			void (*callback)(const void *key,
-					 void *data,
-					 void *closure),
-			void *closure)
-{
-   unsigned bucket;
-
-   for (bucket = 0; bucket < ht->num_buckets; bucket++) {
-      struct node *node, *temp;
-      foreach_s(node, temp, &ht->buckets[bucket]) {
-	 struct hash_node *hn = (struct hash_node *) node;
-
-	 callback(hn->key, hn->data, closure);
-      }
-   }
-}
-
-unsigned
-hash_table_string_hash(const void *key)
-{
-    const char *str = (const char *) key;
-    unsigned hash = 5381;
-
-
-    while (*str != '\0') {
-        hash = (hash * 33) + *str;
-        str++;
-    }
-
-    return hash;
-}
-
-
-unsigned
-hash_table_pointer_hash(const void *key)
-{
-   return (unsigned)((uintptr_t) key / sizeof(void *));
-}
-
-
-int
-hash_table_pointer_compare(const void *key1, const void *key2)
-{
-   return key1 == key2 ? 0 : 1;
-}
diff --git a/src/mesa/program/prog_hash_table.c b/src/mesa/program/prog_hash_table.c
new file mode 100644
index 0000000..f45ed46
--- /dev/null
+++ b/src/mesa/program/prog_hash_table.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file hash_table.c
+ * \brief Implementation of a generic, opaque hash table data type.
+ *
+ * \author Ian Romanick <ian.d.romanick at intel.com>
+ */
+
+#include "main/imports.h"
+#include "main/simple_list.h"
+#include "hash_table.h"
+
+struct node {
+   struct node *next;
+   struct node *prev;
+};
+
+struct hash_table {
+    hash_func_t    hash;
+    hash_compare_func_t  compare;
+
+    unsigned num_buckets;
+    struct node buckets[1];
+};
+
+
+struct hash_node {
+    struct node link;
+    const void *key;
+    void *data;
+};
+
+
+struct hash_table *
+hash_table_ctor(unsigned num_buckets, hash_func_t hash,
+                hash_compare_func_t compare)
+{
+    struct hash_table *ht;
+    unsigned i;
+
+
+    if (num_buckets < 16) {
+        num_buckets = 16;
+    }
+
+    ht = malloc(sizeof(*ht) + ((num_buckets - 1) 
+				     * sizeof(ht->buckets[0])));
+    if (ht != NULL) {
+        ht->hash = hash;
+        ht->compare = compare;
+        ht->num_buckets = num_buckets;
+
+        for (i = 0; i < num_buckets; i++) {
+            make_empty_list(& ht->buckets[i]);
+        }
+    }
+
+    return ht;
+}
+
+
+void
+hash_table_dtor(struct hash_table *ht)
+{
+   hash_table_clear(ht);
+   free(ht);
+}
+
+
+void
+hash_table_clear(struct hash_table *ht)
+{
+   struct node *node;
+   struct node *temp;
+   unsigned i;
+
+
+   for (i = 0; i < ht->num_buckets; i++) {
+      foreach_s(node, temp, & ht->buckets[i]) {
+	 remove_from_list(node);
+	 free(node);
+      }
+
+      assert(is_empty_list(& ht->buckets[i]));
+   }
+}
+
+
+static struct hash_node *
+get_node(struct hash_table *ht, const void *key)
+{
+    const unsigned hash_value = (*ht->hash)(key);
+    const unsigned bucket = hash_value % ht->num_buckets;
+    struct node *node;
+
+    foreach(node, & ht->buckets[bucket]) {
+       struct hash_node *hn = (struct hash_node *) node;
+
+       if ((*ht->compare)(hn->key, key) == 0) {
+	  return hn;
+       }
+    }
+
+    return NULL;
+}
+
+void *
+hash_table_find(struct hash_table *ht, const void *key)
+{
+   struct hash_node *hn = get_node(ht, key);
+
+   return (hn == NULL) ? NULL : hn->data;
+}
+
+void
+hash_table_insert(struct hash_table *ht, void *data, const void *key)
+{
+    const unsigned hash_value = (*ht->hash)(key);
+    const unsigned bucket = hash_value % ht->num_buckets;
+    struct hash_node *node;
+
+    node = calloc(1, sizeof(*node));
+
+    node->data = data;
+    node->key = key;
+
+    insert_at_head(& ht->buckets[bucket], & node->link);
+}
+
+bool
+hash_table_replace(struct hash_table *ht, void *data, const void *key)
+{
+    const unsigned hash_value = (*ht->hash)(key);
+    const unsigned bucket = hash_value % ht->num_buckets;
+    struct node *node;
+    struct hash_node *hn;
+
+    foreach(node, & ht->buckets[bucket]) {
+       hn = (struct hash_node *) node;
+
+       if ((*ht->compare)(hn->key, key) == 0) {
+	  hn->data = data;
+	  return true;
+       }
+    }
+
+    hn = calloc(1, sizeof(*hn));
+
+    hn->data = data;
+    hn->key = key;
+
+    insert_at_head(& ht->buckets[bucket], & hn->link);
+    return false;
+}
+
+void
+hash_table_remove(struct hash_table *ht, const void *key)
+{
+   struct node *node = (struct node *) get_node(ht, key);
+   if (node != NULL) {
+      remove_from_list(node);
+      free(node);
+      return;
+   }
+}
+
+void
+hash_table_call_foreach(struct hash_table *ht,
+			void (*callback)(const void *key,
+					 void *data,
+					 void *closure),
+			void *closure)
+{
+   unsigned bucket;
+
+   for (bucket = 0; bucket < ht->num_buckets; bucket++) {
+      struct node *node, *temp;
+      foreach_s(node, temp, &ht->buckets[bucket]) {
+	 struct hash_node *hn = (struct hash_node *) node;
+
+	 callback(hn->key, hn->data, closure);
+      }
+   }
+}
+
+unsigned
+hash_table_string_hash(const void *key)
+{
+    const char *str = (const char *) key;
+    unsigned hash = 5381;
+
+
+    while (*str != '\0') {
+        hash = (hash * 33) + *str;
+        str++;
+    }
+
+    return hash;
+}
+
+
+unsigned
+hash_table_pointer_hash(const void *key)
+{
+   return (unsigned)((uintptr_t) key / sizeof(void *));
+}
+
+
+int
+hash_table_pointer_compare(const void *key1, const void *key2)
+{
+   return key1 == key2 ? 0 : 1;
+}
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 54e58c2..d6c8996 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -247,7 +247,7 @@ STATETRACKER_FILES = \
 
 PROGRAM_FILES = \
 	$(SRCDIR)program/arbprogparse.c \
-	$(SRCDIR)program/hash_table.c \
+	$(SRCDIR)program/prog_hash_table.c \
 	$(SRCDIR)program/ir_to_mesa.cpp \
 	$(SRCDIR)program/program.c \
 	$(SRCDIR)program/program_parse_extra.c \
-- 
1.7.10.4



More information about the mesa-dev mailing list