util: Add fast-hash.h to simplify xxHash usage

This commit is contained in:
Matt Borgerson 2021-10-24 23:53:08 -07:00 committed by mborgerson
parent a4115cf8b3
commit 8602863f36
4 changed files with 18 additions and 7 deletions

View File

@ -20,9 +20,9 @@
*/
#include "nv2a_int.h"
#include "util/xxHash/xxh3.h"
#include "s3tc.h"
#include "ui/xemu-settings.h"
#include "qemu/fast-hash.h"
#define DBG_SURFACES 0
#define DBG_SURFACE_SYNC 0
@ -433,7 +433,6 @@ static gboolean shader_equal(gconstpointer a, gconstpointer b);
static unsigned int kelvin_map_stencil_op(uint32_t parameter);
static unsigned int kelvin_map_polygon_mode(uint32_t parameter);
static unsigned int kelvin_map_texgen(uint32_t parameter, unsigned int channel);
static uint64_t fast_hash(const uint8_t *data, size_t len);
static void pgraph_reload_surface_scale_factor(NV2AState *d);
static uint32_t pgraph_rdi_read(PGRAPHState *pg,
@ -6825,8 +6824,3 @@ static unsigned int kelvin_map_texgen(uint32_t parameter, unsigned int channel)
}
return texgen;
}
static uint64_t fast_hash(const uint8_t *data, size_t len)
{
return XXH3_64bits(data, len);
}

9
include/qemu/fast-hash.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef QEMU_FAST_HASH_H
#define QEMU_FAST_HASH_H
#include <stdint.h>
#include <string.h>
uint64_t fast_hash(const uint8_t *data, size_t len);
#endif /* QEMU_FAST_HASH_H */

7
util/fast-hash.c Normal file
View File

@ -0,0 +1,7 @@
#include "qemu/fast-hash.h"
#include "util/xxHash/xxh3.h"
uint64_t fast_hash(const uint8_t *data, size_t len)
{
return XXH3_64bits(data, len);
}

View File

@ -47,6 +47,7 @@ util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c'))
util_ss.add(files('guest-random.c'))
util_ss.add(files('yank.c'))
util_ss.add(when: 'CONFIG_WIN32', if_true: files('miniz/miniz.c'))
util_ss.add(files('fast-hash.c'))
if have_user
util_ss.add(files('selfmap.c'))