2008-03-13 10:19:23 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Copyright 2008 VMware, Inc.
|
2008-03-13 10:19:23 +00:00
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* 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, sub license, 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 NON-INFRINGEMENT.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
2008-03-13 10:19:23 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
2020-02-05 19:52:38 +00:00
|
|
|
#include "util/u_pointer.h"
|
2008-08-25 00:48:55 +01:00
|
|
|
#include "util/u_hash_table.h"
|
2008-03-13 10:19:23 +00:00
|
|
|
|
2020-02-05 19:27:21 +00:00
|
|
|
#if DETECT_OS_UNIX
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
|
2008-03-13 10:19:23 +00:00
|
|
|
|
2020-02-05 19:19:40 +00:00
|
|
|
static uint32_t
|
|
|
|
pointer_hash(const void *key)
|
2020-02-05 19:10:48 +00:00
|
|
|
{
|
|
|
|
return _mesa_hash_pointer(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 19:19:40 +00:00
|
|
|
static bool
|
|
|
|
pointer_equal(const void *a, const void *b)
|
2020-02-05 19:10:48 +00:00
|
|
|
{
|
2020-02-05 19:19:40 +00:00
|
|
|
return a == b;
|
2020-02-05 19:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 19:47:36 +00:00
|
|
|
struct hash_table *
|
2020-02-05 19:10:48 +00:00
|
|
|
util_hash_table_create_ptr_keys(void)
|
|
|
|
{
|
2020-02-05 19:47:36 +00:00
|
|
|
return _mesa_hash_table_create(NULL, pointer_hash, pointer_equal);
|
2020-02-05 19:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 19:19:40 +00:00
|
|
|
static uint32_t hash_fd(const void *key)
|
2020-02-05 19:27:21 +00:00
|
|
|
{
|
|
|
|
#if DETECT_OS_UNIX
|
|
|
|
int fd = pointer_to_intptr(key);
|
|
|
|
struct stat stat;
|
|
|
|
|
|
|
|
fstat(fd, &stat);
|
|
|
|
|
|
|
|
return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 19:19:40 +00:00
|
|
|
static bool equal_fd(const void *key1, const void *key2)
|
2020-02-05 19:27:21 +00:00
|
|
|
{
|
|
|
|
#if DETECT_OS_UNIX
|
|
|
|
int fd1 = pointer_to_intptr(key1);
|
|
|
|
int fd2 = pointer_to_intptr(key2);
|
|
|
|
struct stat stat1, stat2;
|
|
|
|
|
|
|
|
fstat(fd1, &stat1);
|
|
|
|
fstat(fd2, &stat2);
|
|
|
|
|
2020-02-05 19:19:40 +00:00
|
|
|
return stat1.st_dev == stat2.st_dev &&
|
|
|
|
stat1.st_ino == stat2.st_ino &&
|
|
|
|
stat1.st_rdev == stat2.st_rdev;
|
2020-02-05 19:27:21 +00:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-05 19:47:36 +00:00
|
|
|
struct hash_table *
|
2020-02-05 19:27:21 +00:00
|
|
|
util_hash_table_create_fd_keys(void)
|
|
|
|
{
|
2020-02-05 19:47:36 +00:00
|
|
|
return _mesa_hash_table_create(NULL, hash_fd, equal_fd);
|
2008-03-13 10:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
2020-02-05 19:47:36 +00:00
|
|
|
util_hash_table_get(struct hash_table *ht,
|
2009-10-17 11:45:04 +01:00
|
|
|
void *key)
|
2008-03-13 10:19:23 +00:00
|
|
|
{
|
2020-02-05 19:47:36 +00:00
|
|
|
struct hash_entry *entry = _mesa_hash_table_search(ht, key);
|
2008-03-13 10:19:23 +00:00
|
|
|
|
2020-02-05 19:47:36 +00:00
|
|
|
return entry ? entry->data : NULL;
|
2008-03-13 10:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-18 12:01:14 +00:00
|
|
|
enum pipe_error
|
2020-02-05 19:47:36 +00:00
|
|
|
util_hash_table_foreach(struct hash_table *ht,
|
|
|
|
enum pipe_error (*callback)
|
2009-10-16 16:27:56 +01:00
|
|
|
(void *key, void *value, void *data),
|
2020-02-05 19:47:36 +00:00
|
|
|
void *data)
|
2008-03-18 12:01:14 +00:00
|
|
|
{
|
2020-02-05 19:47:36 +00:00
|
|
|
hash_table_foreach(ht, entry) {
|
|
|
|
enum pipe_error error = callback((void*)entry->key, entry->data, data);
|
|
|
|
if (error != PIPE_OK)
|
|
|
|
return error;
|
2008-03-18 12:01:14 +00:00
|
|
|
}
|
2018-05-09 20:06:33 +01:00
|
|
|
return PIPE_OK;
|
|
|
|
}
|