return frames;
}
-static int
-debug_flush_pointer_compare(void *key1, void *key2)
-{
- return (key1 == key2) ? 0 : 1;
-}
-
-static unsigned
-debug_flush_pointer_hash(void *key)
-{
- return (unsigned) (uintptr_t) key;
-}
-
struct debug_flush_buf *
debug_flush_buf_create(boolean supports_persistent, unsigned bt_depth)
{
if (!fctx)
goto out_no_ctx;
- fctx->ref_hash = util_hash_table_create(debug_flush_pointer_hash,
- debug_flush_pointer_compare);
+ fctx->ref_hash = util_hash_table_create_ptr_keys();
if (!fctx->ref_hash)
goto out_no_ref_hash;
static unsigned serials_last;
-static unsigned
-hash_ptr(void *p)
-{
- return (unsigned) (uintptr_t) p;
-}
-
-
-static int
-compare_ptr(void *a, void *b)
-{
- if (a == b)
- return 0;
- else if (a < b)
- return -1;
- else
- return 1;
-}
-
-
/**
* Return a small integer serial number for the given pointer.
*/
mtx_lock(&serials_mutex);
if (!serials_hash)
- serials_hash = util_hash_table_create(hash_ptr, compare_ptr);
+ serials_hash = util_hash_table_create_ptr_keys();
serial = (unsigned) (uintptr_t) util_hash_table_get(serials_hash, p);
if (!serial) {
struct util_hash_table* symbols_hash;
static mtx_t symbols_mutex = _MTX_INITIALIZER_NP;
-static unsigned hash_ptr(void* p)
-{
- return (unsigned)(uintptr_t)p;
-}
-
-static int compare_ptr(void* a, void* b)
-{
- if(a == b)
- return 0;
- else if(a < b)
- return -1;
- else
- return 1;
-}
-
/* TODO with some refactoring we might be able to re-use debug_symbol_name_cached()
* instead.. otoh if using libunwind I think u_debug_symbol could just be excluded
* from build?
mtx_lock(&symbols_mutex);
if(!symbols_hash)
- symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);
+ symbols_hash = util_hash_table_create_ptr_keys();
name = util_hash_table_get(symbols_hash, addr);
if(!name)
{
struct util_hash_table* symbols_hash;
static mtx_t symbols_mutex = _MTX_INITIALIZER_NP;
-static unsigned hash_ptr(void* p)
-{
- return (unsigned)(uintptr_t)p;
-}
-
-static int compare_ptr(void* a, void* b)
-{
- if(a == b)
- return 0;
- else if(a < b)
- return -1;
- else
- return 1;
-}
-
const char*
debug_symbol_name_cached(const void *addr)
{
mtx_lock(&symbols_mutex);
if(!symbols_hash)
- symbols_hash = util_hash_table_create(hash_ptr, compare_ptr);
+ symbols_hash = util_hash_table_create_ptr_keys();
name = util_hash_table_get(symbols_hash, (void*)addr);
if(!name)
{
#include "util/u_memory.h"
#include "util/u_hash_table.h"
+#include "util/hash_table.h"
struct util_hash_table
}
+static unsigned
+pointer_hash(void *key)
+{
+ return _mesa_hash_pointer(key);
+}
+
+
+static int
+pointer_compare(void *a, void *b)
+{
+ return a != b;
+}
+
+
+struct util_hash_table *
+util_hash_table_create_ptr_keys(void)
+{
+ return util_hash_table_create(pointer_hash, pointer_compare);
+}
+
+
static inline struct cso_hash_iter
util_hash_table_find_iter(struct util_hash_table *ht,
void *key,
util_hash_table_create(unsigned (*hash)(void *key),
int (*compare)(void *key1, void *key2));
+/**
+ * Create a hash table where the keys are generic pointers.
+ */
+struct util_hash_table *
+util_hash_table_create_ptr_keys(void);
+
enum pipe_error
util_hash_table_set(struct util_hash_table *ht,
#include "lima_bo.h"
#include "lima_util.h"
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
bool lima_bo_table_init(struct lima_screen *screen)
{
- screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
+ screen->bo_handles = util_hash_table_create_ptr_keys();
if (!screen->bo_handles)
return false;
- screen->bo_flink_names = util_hash_table_create(handle_hash, handle_compare);
+ screen->bo_flink_names = util_hash_table_create_ptr_keys();
if (!screen->bo_flink_names)
goto err_out0;
return true;
}
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static const void *
v3d_screen_get_compiler_options(struct pipe_screen *pscreen,
enum pipe_shader_ir ir, unsigned shader)
}
list_inithead(&screen->bo_cache.time_list);
(void)mtx_init(&screen->bo_handles_mutex, mtx_plain);
- screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
+ screen->bo_handles = util_hash_table_create_ptr_keys();
#if defined(USE_V3D_SIMULATOR)
v3d_simulator_init(screen);
}
}
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static bool
vc4_get_chip_info(struct vc4_screen *screen)
{
list_inithead(&screen->bo_cache.time_list);
(void) mtx_init(&screen->bo_handles_mutex, mtx_plain);
- screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
+ screen->bo_handles = util_hash_table_create_ptr_keys();
screen->has_control_flow =
vc4_has_feature(screen, DRM_VC4_PARAM_SUPPORTS_BRANCHES);
unsigned dec_frame_delta;
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static enum pipe_error hash_table_clear_item_callback(void *key, void *value, void *data)
{
struct pipe_video_buffer *video_buffer = (struct pipe_video_buffer *)value;
list_inithead(&priv->codec_data.h264.dpb_list);
- priv->video_buffer_map = util_hash_table_create(handle_hash, handle_compare);
+ priv->video_buffer_map = util_hash_table_create_ptr_keys();
return OMX_ErrorNone;
}
switch (u_reduce_video_profile(context->templat.profile)) {
case PIPE_VIDEO_FORMAT_MPEG4_AVC:
context->desc.h264enc.rate_ctrl.rate_ctrl_method = config->rc;
- context->desc.h264enc.frame_idx = util_hash_table_create(handle_hash, handle_compare);
+ context->desc.h264enc.frame_idx = util_hash_table_create_ptr_keys();
break;
case PIPE_VIDEO_FORMAT_HEVC:
context->desc.h265enc.rc.rate_ctrl_method = config->rc;
- context->desc.h265enc.frame_idx = util_hash_table_create(handle_hash, handle_compare);
+ context->desc.h265enc.frame_idx = util_hash_table_create_ptr_keys();
break;
default:
break;
#define SOS (8 + 4 * 2)
#define MAX_MJPEG_SLICE_HEADER_SIZE (SOI + DQT + DHT + DRI + SOF + SOS)
-static inline unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static inline int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static inline enum pipe_video_chroma_format
ChromaToPipe(int format)
{
0xffffffff, 0, out) == 0;
}
-static unsigned hash_pointer(void *key)
-{
- return _mesa_hash_pointer(key);
-}
-
-static int compare_pointers(void *key1, void *key2)
-{
- return key1 != key2;
-}
-
static bool amdgpu_winsys_unref(struct radeon_winsys *rws)
{
struct amdgpu_screen_winsys *sws = amdgpu_screen_winsys(rws);
/* Look up the winsys from the dev table. */
simple_mtx_lock(&dev_tab_mutex);
if (!dev_tab)
- dev_tab = util_hash_table_create(hash_pointer, compare_pointers);
+ dev_tab = util_hash_table_create_ptr_keys();
/* Initialize the amdgpu device. This should always return the same pointer
* for the same fd. */
pipe_reference_init(&aws->reference, 1);
list_inithead(&aws->global_bo_list);
- aws->bo_export_table = util_hash_table_create(hash_pointer, compare_pointers);
+ aws->bo_export_table = util_hash_table_create_ptr_keys();
(void) simple_mtx_init(&aws->sws_list_lock, mtx_plain);
(void) simple_mtx_init(&aws->global_bo_list_lock, mtx_plain);
return destroy;
}
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static void radeon_pin_threads_to_L3_cache(struct radeon_winsys *ws,
unsigned cache)
{
(void) mtx_init(&ws->hyperz_owner_mutex, mtx_plain);
(void) mtx_init(&ws->cmask_owner_mutex, mtx_plain);
- ws->bo_names = util_hash_table_create(handle_hash, handle_compare);
- ws->bo_handles = util_hash_table_create(handle_hash, handle_compare);
- ws->bo_vas = util_hash_table_create(handle_hash, handle_compare);
+ ws->bo_names = util_hash_table_create_ptr_keys();
+ ws->bo_handles = util_hash_table_create_ptr_keys();
+ ws->bo_vas = util_hash_table_create_ptr_keys();
(void) mtx_init(&ws->bo_handles_mutex, mtx_plain);
(void) mtx_init(&ws->vm32.mutex, mtx_plain);
(void) mtx_init(&ws->vm64.mutex, mtx_plain);
FREE(vswc);
}
-static unsigned vmw_hash_ptr(void *p)
-{
- return (unsigned)(unsigned long)p;
-}
-
-static int vmw_ptr_compare(void *key1, void *key2)
-{
- return (key1 == key2) ? 0 : 1;
-}
-
-
/**
* vmw_svga_winsys_vgpu10_shader_screate - The winsys shader_crate callback
*
if(!vswc->validate)
goto out_no_validate;
- vswc->hash = util_hash_table_create(vmw_hash_ptr, vmw_ptr_compare);
+ vswc->hash = util_hash_table_create_ptr_keys();
if (!vswc->hash)
goto out_no_hash;
return ret;
}
-#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
-
-static unsigned handle_hash(void *key)
-{
- return PTR_TO_UINT(key);
-}
-
-static int handle_compare(void *key1, void *key2)
-{
- return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
-}
-
static struct pipe_fence_handle *
virgl_cs_create_fence(struct virgl_winsys *vws, int fd)
{
qdws);
(void) mtx_init(&qdws->mutex, mtx_plain);
(void) mtx_init(&qdws->bo_handles_mutex, mtx_plain);
- qdws->bo_handles = util_hash_table_create(handle_hash, handle_compare);
- qdws->bo_names = util_hash_table_create(handle_hash, handle_compare);
+ qdws->bo_handles = util_hash_table_create_ptr_keys();
+ qdws->bo_names = util_hash_table_create_ptr_keys();
qdws->base.destroy = virgl_drm_winsys_destroy;
qdws->base.transfer_put = virgl_bo_transfer_put;