Cleanup: move hash and ghash utils to C++
Also see #103343. Pull Request: https://projects.blender.org/blender/blender/pulls/117761
This commit is contained in:
parent
9aa20a0979
commit
319b911784
|
@ -182,11 +182,11 @@ add_library(bli_lib
|
|||
"../../../source/blender/blenlib/intern/path_util.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_dynstr.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_ghash.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_ghash_utils.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_ghash_utils.cc"
|
||||
"../../../source/blender/blenlib/intern/BLI_linklist.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_memarena.c"
|
||||
"../../../source/blender/blenlib/intern/BLI_mempool.c"
|
||||
"../../../source/blender/blenlib/intern/hash_mm2a.c"
|
||||
"../../../source/blender/blenlib/intern/hash_mm2a.cc"
|
||||
"../../../source/blender/blenlib/intern/string_utils.c"
|
||||
"../../../source/blender/blenlib/intern/system.c"
|
||||
)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "BKE_cryptomatte.h"
|
||||
|
||||
#include "BLI_hash_mm3.h"
|
||||
#include "BLI_hash_mm3.hh"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "BLI_binary_search.hh"
|
||||
#include "BLI_fileops.hh"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_utils.hh"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_hash_mm3.h"
|
||||
#include "BLI_hash_mm3.hh"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ double BLI_gset_calc_quality(GSet *gs);
|
|||
/* -------------------------------------------------------------------- */
|
||||
/** \name GHash/GSet Utils
|
||||
*
|
||||
* Defined in `BLI_ghash_utils.c`
|
||||
* Defined in `BLI_ghash_utils.cc`
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <cstdio>
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
/**
|
||||
* Compute MD5 message digest for 'len' bytes beginning at 'buffer'.
|
||||
|
@ -27,7 +27,3 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock);
|
|||
int BLI_hash_md5_stream(FILE *stream, void *resblock);
|
||||
|
||||
char *BLI_hash_md5_to_hexdigest(const void *resblock, char r_hex_digest[33]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -10,10 +10,6 @@
|
|||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BLI_HashMurmur2A {
|
||||
uint32_t hash;
|
||||
uint32_t tail;
|
||||
|
@ -33,7 +29,3 @@ uint32_t BLI_hash_mm2a_end(BLI_HashMurmur2A *mm2);
|
|||
* Non-incremental version, quicker for small keys.
|
||||
*/
|
||||
uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -10,12 +10,4 @@
|
|||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -29,7 +29,7 @@ set(SRC
|
|||
intern/BLI_dynstr.c
|
||||
intern/BLI_filelist.cc
|
||||
intern/BLI_ghash.c
|
||||
intern/BLI_ghash_utils.c
|
||||
intern/BLI_ghash_utils.cc
|
||||
intern/BLI_heap.c
|
||||
intern/BLI_heap_simple.c
|
||||
intern/BLI_index_range.cc
|
||||
|
@ -77,9 +77,9 @@ set(SRC
|
|||
intern/generic_virtual_array.cc
|
||||
intern/generic_virtual_vector_array.cc
|
||||
intern/gsqueue.c
|
||||
intern/hash_md5.c
|
||||
intern/hash_mm2a.c
|
||||
intern/hash_mm3.c
|
||||
intern/hash_md5.cc
|
||||
intern/hash_mm2a.cc
|
||||
intern/hash_mm3.cc
|
||||
intern/hash_tables.cc
|
||||
intern/implicit_sharing.cc
|
||||
intern/index_mask.cc
|
||||
|
@ -242,9 +242,9 @@ set(SRC
|
|||
BLI_gsqueue.h
|
||||
BLI_hash.h
|
||||
BLI_hash.hh
|
||||
BLI_hash_md5.h
|
||||
BLI_hash_mm2a.h
|
||||
BLI_hash_mm3.h
|
||||
BLI_hash_md5.hh
|
||||
BLI_hash_mm2a.hh
|
||||
BLI_hash_mm3.hh
|
||||
BLI_hash_tables.hh
|
||||
BLI_heap.h
|
||||
BLI_heap_simple.h
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_ghash.h" /* own include */
|
||||
#include "BLI_hash_mm2a.h"
|
||||
#include "BLI_hash_mm2a.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
/* keep last */
|
||||
|
@ -136,7 +136,7 @@ uint BLI_ghashutil_strhash_p(const void *ptr)
|
|||
const signed char *p;
|
||||
uint h = 5381;
|
||||
|
||||
for (p = ptr; *p != '\0'; p++) {
|
||||
for (p = static_cast<const signed char *>(ptr); *p != '\0'; p++) {
|
||||
h = (uint)((h << 5) + h) + (uint)*p;
|
||||
}
|
||||
|
||||
|
@ -144,18 +144,18 @@ uint BLI_ghashutil_strhash_p(const void *ptr)
|
|||
}
|
||||
uint BLI_ghashutil_strhash_p_murmur(const void *ptr)
|
||||
{
|
||||
const uchar *key = ptr;
|
||||
const uchar *key = static_cast<const uchar *>(ptr);
|
||||
|
||||
return BLI_hash_mm2(key, strlen((const char *)key) + 1, 0);
|
||||
}
|
||||
bool BLI_ghashutil_strcmp(const void *a, const void *b)
|
||||
{
|
||||
return (a == b) ? false : !STREQ(a, b);
|
||||
return (a == b) ? false : !STREQ(static_cast<const char *>(a), static_cast<const char *>(b));
|
||||
}
|
||||
|
||||
GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second)
|
||||
{
|
||||
GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair");
|
||||
GHashPair *pair = static_cast<GHashPair *>(MEM_mallocN(sizeof(GHashPair), "GHashPair"));
|
||||
pair->first = first;
|
||||
pair->second = second;
|
||||
return pair;
|
||||
|
@ -163,15 +163,15 @@ GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second)
|
|||
|
||||
uint BLI_ghashutil_pairhash(const void *ptr)
|
||||
{
|
||||
const GHashPair *pair = ptr;
|
||||
const GHashPair *pair = static_cast<const GHashPair *>(ptr);
|
||||
uint hash = BLI_ghashutil_ptrhash(pair->first);
|
||||
return hash ^ BLI_ghashutil_ptrhash(pair->second);
|
||||
}
|
||||
|
||||
bool BLI_ghashutil_paircmp(const void *a, const void *b)
|
||||
{
|
||||
const GHashPair *A = a;
|
||||
const GHashPair *B = b;
|
||||
const GHashPair *A = static_cast<const GHashPair *>(a);
|
||||
const GHashPair *B = static_cast<const GHashPair *>(b);
|
||||
|
||||
return ((A->first != B->first) || (A->second != B->second));
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_compute_context.hh"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include <sstream>
|
||||
|
||||
namespace blender {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "BLI_hash_md5.h" /* own include */
|
||||
#include "BLI_hash_md5.hh" /* own include */
|
||||
|
||||
#if defined HAVE_LIMITS_H || defined _LIBC
|
||||
# include <limits.h>
|
||||
|
@ -114,7 +114,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
|
|||
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
|
||||
|
||||
md5_uint32 correct_words[16];
|
||||
const md5_uint32 *words = buffer;
|
||||
const md5_uint32 *words = static_cast<const md5_uint32 *>(buffer);
|
||||
size_t nwords = len / sizeof(md5_uint32);
|
||||
const md5_uint32 *endp = words + nwords;
|
||||
md5_uint32 A = ctx->A;
|
||||
|
@ -259,7 +259,7 @@ static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ct
|
|||
*/
|
||||
static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
md5_uint32 *digest = resbuf;
|
||||
md5_uint32 *digest = static_cast<md5_uint32 *>(resbuf);
|
||||
digest[0] = SWAP(ctx->A);
|
||||
digest[1] = SWAP(ctx->B);
|
||||
digest[2] = SWAP(ctx->C);
|
||||
|
@ -268,7 +268,8 @@ static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
|
|||
return resbuf;
|
||||
}
|
||||
|
||||
/* Top level public functions. */
|
||||
/*
|
||||
Top level public functions. */
|
||||
|
||||
int BLI_hash_md5_stream(FILE *stream, void *resblock)
|
||||
{
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#include "BLI_hash_mm2a.h" /* own include */
|
||||
#include "BLI_hash_mm2a.hh" /* own include */
|
||||
|
||||
/* Helpers. */
|
||||
#define MM2A_M 0x5bd1e995
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_hash_mm3.h" /* own include */
|
||||
#include "BLI_hash_mm3.hh" /* own include */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <stdlib.h>
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "BLI_hash_mm2a.h"
|
||||
#include "BLI_hash_mm2a.hh"
|
||||
|
||||
/* NOTE: Reference results are taken from reference implementation
|
||||
* (cpp code, CMurmurHash2A variant):
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
|
||||
#include "BPy_Convert.h"
|
||||
|
||||
#include "BLI_hash_mm2a.hh"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "BLI_hash_mm2a.h"
|
||||
|
||||
using namespace Freestyle;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "DNA_material_types.h"
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_hash_mm2a.h"
|
||||
#include "BLI_hash_mm2a.hh"
|
||||
#include "BLI_link_utils.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_utils.hh"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "IMB_imbuf.hh"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "testing/testing.h"
|
||||
|
||||
#include "BLI_fileops.hh"
|
||||
#include "BLI_hash_mm2a.h"
|
||||
#include "BLI_hash_mm2a.hh"
|
||||
|
||||
#include "ply_import.hh"
|
||||
#include "ply_import_buffer.hh"
|
||||
|
|
|
@ -48,7 +48,7 @@ file(GENERATE OUTPUT ${dna_header_string_file} CONTENT "${DNA_FILE_LIST}")
|
|||
set(SRC_BLENLIB
|
||||
../../blenlib/intern/BLI_assert.c
|
||||
../../blenlib/intern/BLI_ghash.c
|
||||
../../blenlib/intern/BLI_ghash_utils.c
|
||||
../../blenlib/intern/BLI_ghash_utils.cc
|
||||
../../blenlib/intern/BLI_linklist.c
|
||||
../../blenlib/intern/BLI_memarena.c
|
||||
../../blenlib/intern/BLI_mempool.c
|
||||
|
@ -57,7 +57,7 @@ set(SRC_BLENLIB
|
|||
../../blenlib/intern/string.c
|
||||
|
||||
# Dependency of BLI_ghash.c
|
||||
../../blenlib/intern/hash_mm2a.c
|
||||
../../blenlib/intern/hash_mm2a.cc
|
||||
|
||||
# Dependencies of BLI_mempool.c when ASAN is enabled.
|
||||
../../blenlib/intern/gsqueue.c
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_hash_mm3.h"
|
||||
#include "BLI_hash_mm3.hh"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "BLI_cpp_types.hh"
|
||||
#include "BLI_dot_export.hh"
|
||||
#include "BLI_hash.h"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include "BLI_lazy_threading.hh"
|
||||
#include "BLI_map.hh"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_hash_md5.h"
|
||||
#include "BLI_hash_md5.hh"
|
||||
#include "BLI_implicit_sharing.hh"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
|
Loading…
Reference in New Issue