mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-17 18:36:21 +03:00
Reformat the codebase with the clang-format 18.
This commit is contained in:
parent
0a6215c171
commit
f1bba4a87c
346 changed files with 18286 additions and 17770 deletions
101
test/unit/hash.c
101
test/unit/hash.c
|
|
@ -39,24 +39,32 @@ typedef enum {
|
|||
static int
|
||||
hash_variant_bits(hash_variant_t variant) {
|
||||
switch (variant) {
|
||||
case hash_variant_x86_32: return 32;
|
||||
case hash_variant_x86_128: return 128;
|
||||
case hash_variant_x64_128: return 128;
|
||||
default: not_reached();
|
||||
case hash_variant_x86_32:
|
||||
return 32;
|
||||
case hash_variant_x86_128:
|
||||
return 128;
|
||||
case hash_variant_x64_128:
|
||||
return 128;
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
hash_variant_string(hash_variant_t variant) {
|
||||
switch (variant) {
|
||||
case hash_variant_x86_32: return "hash_x86_32";
|
||||
case hash_variant_x86_128: return "hash_x86_128";
|
||||
case hash_variant_x64_128: return "hash_x64_128";
|
||||
default: not_reached();
|
||||
case hash_variant_x86_32:
|
||||
return "hash_x86_32";
|
||||
case hash_variant_x86_128:
|
||||
return "hash_x86_128";
|
||||
case hash_variant_x64_128:
|
||||
return "hash_x64_128";
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
#define KEY_SIZE 256
|
||||
#define KEY_SIZE 256
|
||||
static void
|
||||
hash_variant_verify_key(hash_variant_t variant, uint8_t *key) {
|
||||
const int hashbytes = hash_variant_bits(variant) / 8;
|
||||
|
|
@ -79,20 +87,24 @@ hash_variant_verify_key(hash_variant_t variant, uint8_t *key) {
|
|||
switch (variant) {
|
||||
case hash_variant_x86_32: {
|
||||
uint32_t out;
|
||||
out = hash_x86_32(key, i, 256-i);
|
||||
memcpy(&hashes[i*hashbytes], &out, hashbytes);
|
||||
out = hash_x86_32(key, i, 256 - i);
|
||||
memcpy(&hashes[i * hashbytes], &out, hashbytes);
|
||||
break;
|
||||
} case hash_variant_x86_128: {
|
||||
}
|
||||
case hash_variant_x86_128: {
|
||||
uint64_t out[2];
|
||||
hash_x86_128(key, i, 256-i, out);
|
||||
memcpy(&hashes[i*hashbytes], out, hashbytes);
|
||||
hash_x86_128(key, i, 256 - i, out);
|
||||
memcpy(&hashes[i * hashbytes], out, hashbytes);
|
||||
break;
|
||||
} case hash_variant_x64_128: {
|
||||
}
|
||||
case hash_variant_x64_128: {
|
||||
uint64_t out[2];
|
||||
hash_x64_128(key, i, 256-i, out);
|
||||
memcpy(&hashes[i*hashbytes], out, hashbytes);
|
||||
hash_x64_128(key, i, 256 - i, out);
|
||||
memcpy(&hashes[i * hashbytes], out, hashbytes);
|
||||
break;
|
||||
} default: not_reached();
|
||||
}
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,36 +114,50 @@ hash_variant_verify_key(hash_variant_t variant, uint8_t *key) {
|
|||
uint32_t out = hash_x86_32(hashes, hashes_size, 0);
|
||||
memcpy(final, &out, sizeof(out));
|
||||
break;
|
||||
} case hash_variant_x86_128: {
|
||||
}
|
||||
case hash_variant_x86_128: {
|
||||
uint64_t out[2];
|
||||
hash_x86_128(hashes, hashes_size, 0, out);
|
||||
memcpy(final, out, sizeof(out));
|
||||
break;
|
||||
} case hash_variant_x64_128: {
|
||||
}
|
||||
case hash_variant_x64_128: {
|
||||
uint64_t out[2];
|
||||
hash_x64_128(hashes, hashes_size, 0, out);
|
||||
memcpy(final, out, sizeof(out));
|
||||
break;
|
||||
} default: not_reached();
|
||||
}
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
|
||||
computed =
|
||||
((uint32_t)final[0] << 0) |
|
||||
((uint32_t)final[1] << 8) |
|
||||
((uint32_t)final[2] << 16) |
|
||||
((uint32_t)final[3] << 24);
|
||||
computed = ((uint32_t) final[0] << 0) | ((uint32_t) final[1] << 8)
|
||||
| ((uint32_t) final[2] << 16) | ((uint32_t) final[3] << 24);
|
||||
|
||||
switch (variant) {
|
||||
#ifdef JEMALLOC_BIG_ENDIAN
|
||||
case hash_variant_x86_32: expected = 0x6213303eU; break;
|
||||
case hash_variant_x86_128: expected = 0x266820caU; break;
|
||||
case hash_variant_x64_128: expected = 0xcc622b6fU; break;
|
||||
case hash_variant_x86_32:
|
||||
expected = 0x6213303eU;
|
||||
break;
|
||||
case hash_variant_x86_128:
|
||||
expected = 0x266820caU;
|
||||
break;
|
||||
case hash_variant_x64_128:
|
||||
expected = 0xcc622b6fU;
|
||||
break;
|
||||
#else
|
||||
case hash_variant_x86_32: expected = 0xb0f57ee3U; break;
|
||||
case hash_variant_x86_128: expected = 0xb3ece62aU; break;
|
||||
case hash_variant_x64_128: expected = 0x6384ba69U; break;
|
||||
case hash_variant_x86_32:
|
||||
expected = 0xb0f57ee3U;
|
||||
break;
|
||||
case hash_variant_x86_128:
|
||||
expected = 0xb3ece62aU;
|
||||
break;
|
||||
case hash_variant_x64_128:
|
||||
expected = 0x6384ba69U;
|
||||
break;
|
||||
#endif
|
||||
default: not_reached();
|
||||
default:
|
||||
not_reached();
|
||||
}
|
||||
|
||||
expect_u32_eq(computed, expected,
|
||||
|
|
@ -141,8 +167,8 @@ hash_variant_verify_key(hash_variant_t variant, uint8_t *key) {
|
|||
|
||||
static void
|
||||
hash_variant_verify(hash_variant_t variant) {
|
||||
#define MAX_ALIGN 16
|
||||
uint8_t key[KEY_SIZE + (MAX_ALIGN - 1)];
|
||||
#define MAX_ALIGN 16
|
||||
uint8_t key[KEY_SIZE + (MAX_ALIGN - 1)];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MAX_ALIGN; i++) {
|
||||
|
|
@ -169,8 +195,5 @@ TEST_END
|
|||
|
||||
int
|
||||
main(void) {
|
||||
return test(
|
||||
test_hash_x86_32,
|
||||
test_hash_x86_128,
|
||||
test_hash_x64_128);
|
||||
return test(test_hash_x86_32, test_hash_x86_128, test_hash_x64_128);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue