mesa: Remove prog_hash_table.c
Here we make the prog_hash_table functionally equivalent to the one in util by wrapping the remaing functions that differ. We also move the functions to the header so we can remove the c file. This enables us to do a step-by-step replacement of the table. Signed-off-by: Thomas Helland <thomashelland90@gmail.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
committed by
Timothy Arceri
parent
42ba435fd1
commit
cf4a4820ac
@@ -117,6 +117,5 @@ noinst_LTLIBRARIES = libglsl_util.la
|
||||
libglsl_util_la_SOURCES = \
|
||||
mesa/main/extensions_table.c \
|
||||
mesa/main/imports.c \
|
||||
mesa/program/prog_hash_table.c \
|
||||
mesa/program/symbol_table.c \
|
||||
mesa/program/dummy_errors.c
|
||||
|
||||
@@ -73,7 +73,6 @@ env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', '$SOUR
|
||||
env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
|
||||
# Copy these files to avoid generation object files into src/mesa/program
|
||||
env.Prepend(CPPPATH = ['#src/mesa/program'])
|
||||
env.Command('glsl/prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
|
||||
env.Command('glsl/symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE'))
|
||||
env.Command('glsl/dummy_errors.c', '#src/mesa/program/dummy_errors.c', Copy('$TARGET', '$SOURCE'))
|
||||
|
||||
@@ -82,7 +81,6 @@ compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
|
||||
mesa_objs = env.StaticObject([
|
||||
'glsl/extensions_table.c',
|
||||
'glsl/imports.c',
|
||||
'glsl/prog_hash_table.c',
|
||||
'glsl/symbol_table.c',
|
||||
'glsl/dummy_errors.c',
|
||||
])
|
||||
|
||||
@@ -44,7 +44,6 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_SRC_FILES := \
|
||||
main/extensions_table.c \
|
||||
main/imports.c \
|
||||
program/prog_hash_table.c \
|
||||
program/symbol_table.c \
|
||||
program/dummy_errors.c
|
||||
|
||||
@@ -70,7 +69,6 @@ LOCAL_C_INCLUDES := \
|
||||
LOCAL_SRC_FILES := \
|
||||
main/extensions_table.c \
|
||||
main/imports.c \
|
||||
program/prog_hash_table.c \
|
||||
program/symbol_table.c \
|
||||
program/dummy_errors.c
|
||||
|
||||
|
||||
@@ -527,7 +527,6 @@ PROGRAM_FILES = \
|
||||
program/prog_cache.h \
|
||||
program/prog_execute.c \
|
||||
program/prog_execute.h \
|
||||
program/prog_hash_table.c \
|
||||
program/prog_instruction.c \
|
||||
program/prog_instruction.h \
|
||||
program/prog_noise.c \
|
||||
|
||||
@@ -161,16 +161,17 @@ static inline void hash_table_remove(struct hash_table *ht, const void *key)
|
||||
/**
|
||||
* Compute hash value of a string
|
||||
*
|
||||
* Computes the hash value of a string using the DJB2 algorithm developed by
|
||||
* Professor Daniel J. Bernstein. It was published on comp.lang.c once upon
|
||||
* a time. I was unable to find the original posting in the archives.
|
||||
*
|
||||
* \param key Pointer to a NUL terminated string to be hashed.
|
||||
*
|
||||
* \sa hash_table_string_compare
|
||||
*/
|
||||
extern unsigned hash_table_string_hash(const void *key);
|
||||
|
||||
static unsigned
|
||||
hash_table_string_hash(const void *key)
|
||||
{
|
||||
const char *str = (const char *) key;
|
||||
uint32_t hash = _mesa_hash_string(str);
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two strings used as keys
|
||||
@@ -179,7 +180,11 @@ extern unsigned hash_table_string_hash(const void *key);
|
||||
*
|
||||
* \sa hash_table_string_hash
|
||||
*/
|
||||
bool hash_table_string_compare(const void *a, const void *b);
|
||||
static bool
|
||||
hash_table_string_compare(const void *a, const void *b)
|
||||
{
|
||||
return _mesa_key_string_equal(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute hash value of a pointer
|
||||
@@ -192,17 +197,23 @@ bool hash_table_string_compare(const void *a, const void *b);
|
||||
*
|
||||
* \sa hash_table_pointer_compare
|
||||
*/
|
||||
unsigned
|
||||
hash_table_pointer_hash(const void *key);
|
||||
|
||||
static unsigned
|
||||
hash_table_pointer_hash(const void *key)
|
||||
{
|
||||
return _mesa_hash_pointer(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two pointers used as keys
|
||||
*
|
||||
* \sa hash_table_pointer_hash
|
||||
*/
|
||||
bool
|
||||
hash_table_pointer_compare(const void *key1, const void *key2);
|
||||
static bool
|
||||
hash_table_pointer_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return _mesa_key_pointer_equal(key1, key2);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
hash_table_call_foreach(struct hash_table *ht,
|
||||
|
||||
@@ -1,67 +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@intel.com>
|
||||
*/
|
||||
|
||||
#include "main/imports.h"
|
||||
#include "util/simple_list.h"
|
||||
#include "hash_table.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool hash_table_string_compare(const void *a, const void *b)
|
||||
{
|
||||
return strcmp(a, b) == 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
hash_table_pointer_hash(const void *key)
|
||||
{
|
||||
return (unsigned)((uintptr_t) key / sizeof(void *));
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
hash_table_pointer_compare(const void *key1, const void *key2)
|
||||
{
|
||||
return key1 == key2;
|
||||
}
|
||||
Reference in New Issue
Block a user