Convert "unsigned long long" to "uint64_t"
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 5s

Missed during previous changes using stdint.h .
This commit is contained in:
Stephen Seo 2024-09-21 11:55:26 +09:00
parent 5068a1b90d
commit 4a69d281de
4 changed files with 22 additions and 26 deletions

View file

@ -19,14 +19,12 @@
#include "linear_congruential_gen.h" #include "linear_congruential_gen.h"
unsigned long long simple_archiver_algo_lcg(unsigned long long seed, uint64_t simple_archiver_algo_lcg(uint64_t seed, uint64_t a, uint64_t c) {
unsigned long long a,
unsigned long long c) {
// "m" is implicity 2^64. // "m" is implicity 2^64.
return seed * a + c; return seed * a + c;
} }
unsigned long long simple_archiver_algo_lcg_defaults(unsigned long long seed) { uint64_t simple_archiver_algo_lcg_defaults(uint64_t seed) {
// "m" is implicity 2^64. // "m" is implicity 2^64.
return seed * SC_ALGO_LCG_DEFAULT_A + SC_ALGO_LCG_DEFAULT_C; return seed * SC_ALGO_LCG_DEFAULT_A + SC_ALGO_LCG_DEFAULT_C;
} }

View file

@ -20,13 +20,14 @@
#ifndef SEODISPARATE_COM_ALGORITHMS_LINEAR_CONGRUENTIAL_GEN_H_ #ifndef SEODISPARATE_COM_ALGORITHMS_LINEAR_CONGRUENTIAL_GEN_H_
#define SEODISPARATE_COM_ALGORITHMS_LINEAR_CONGRUENTIAL_GEN_H_ #define SEODISPARATE_COM_ALGORITHMS_LINEAR_CONGRUENTIAL_GEN_H_
// Standard library includes.
#include <stdint.h>
#define SC_ALGO_LCG_DEFAULT_A 0x9ABD #define SC_ALGO_LCG_DEFAULT_A 0x9ABD
#define SC_ALGO_LCG_DEFAULT_C 0x2A9A9A9 #define SC_ALGO_LCG_DEFAULT_C 0x2A9A9A9
unsigned long long simple_archiver_algo_lcg(unsigned long long seed, uint64_t simple_archiver_algo_lcg(uint64_t seed, uint64_t a, uint64_t c);
unsigned long long a,
unsigned long long c);
unsigned long long simple_archiver_algo_lcg_defaults(unsigned long long seed); uint64_t simple_archiver_algo_lcg_defaults(uint64_t seed);
#endif #endif

View file

@ -74,13 +74,13 @@ int simple_archiver_hash_map_internal_pick_in_list(void *data, void *ud) {
: 0; : 0;
} }
unsigned long long simple_archiver_hash_map_internal_key_to_hash( uint64_t simple_archiver_hash_map_internal_key_to_hash(const void *key,
const void *key, size_t key_size) { size_t key_size) {
unsigned long long seed = 0; uint64_t seed = 0;
unsigned long long temp = 0; uint64_t temp = 0;
size_t count = 0; size_t count = 0;
for (size_t idx = 0; idx < key_size; ++idx) { for (size_t idx = 0; idx < key_size; ++idx) {
temp |= ((unsigned long long)*((uint8_t *)key + idx)) << (8 * count); temp |= ((uint64_t) * ((uint8_t *)key + idx)) << (8 * count);
++count; ++count;
if (count >= 8) { if (count >= 8) {
count = 0; count = 0;
@ -193,8 +193,7 @@ int simple_archiver_hash_map_insert(SDArchiverHashMap *hash_map, void *value,
data->value_cleanup_fn = value_cleanup_fn; data->value_cleanup_fn = value_cleanup_fn;
data->key_cleanup_fn = key_cleanup_fn; data->key_cleanup_fn = key_cleanup_fn;
unsigned long long hash = uint64_t hash = simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
hash_map->buckets_size; hash_map->buckets_size;
int result = simple_archiver_list_add_front( int result = simple_archiver_list_add_front(
hash_map->buckets[hash], data, hash_map->buckets[hash], data,
@ -226,8 +225,7 @@ int simple_archiver_hash_map_insert(SDArchiverHashMap *hash_map, void *value,
void *simple_archiver_hash_map_get(const SDArchiverHashMap *hash_map, void *simple_archiver_hash_map_get(const SDArchiverHashMap *hash_map,
const void *key, size_t key_size) { const void *key, size_t key_size) {
unsigned long long hash = uint64_t hash = simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
hash_map->buckets_size; hash_map->buckets_size;
SDArchiverLLNode *node = hash_map->buckets[hash]->head; SDArchiverLLNode *node = hash_map->buckets[hash]->head;
@ -246,8 +244,7 @@ void *simple_archiver_hash_map_get(const SDArchiverHashMap *hash_map,
int simple_archiver_hash_map_remove(SDArchiverHashMap *hash_map, void *key, int simple_archiver_hash_map_remove(SDArchiverHashMap *hash_map, void *key,
size_t key_size) { size_t key_size) {
unsigned long long hash = uint64_t hash = simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
simple_archiver_hash_map_internal_key_to_hash(key, key_size) %
hash_map->buckets_size; hash_map->buckets_size;
SDArchiverHashMapKeyData key_data; SDArchiverHashMapKeyData key_data;

View file

@ -286,8 +286,8 @@ int main(void) {
// Deterministic randomization. // Deterministic randomization.
for (uint32_t idx = max - 1; idx-- > 0;) { for (uint32_t idx = max - 1; idx-- > 0;) {
uint32_t other_idx = simple_archiver_algo_lcg_defaults(idx) % uint32_t other_idx =
(unsigned long long)(idx + 1); simple_archiver_algo_lcg_defaults(idx) % (uint64_t)(idx + 1);
if (max - 1 != other_idx) { if (max - 1 != other_idx) {
uint32_t temp = array[max - 1]; uint32_t temp = array[max - 1];
array[max - 1] = array[other_idx]; array[max - 1] = array[other_idx];
@ -354,8 +354,8 @@ int main(void) {
// Deterministic randomization. // Deterministic randomization.
for (uint32_t idx = max - 1; idx-- > 0;) { for (uint32_t idx = max - 1; idx-- > 0;) {
uint32_t other_idx = simple_archiver_algo_lcg_defaults(idx) % uint32_t other_idx =
(unsigned long long)(idx + 1); simple_archiver_algo_lcg_defaults(idx) % (uint64_t)(idx + 1);
if (max - 1 != other_idx) { if (max - 1 != other_idx) {
uint32_t temp = array[max - 1]; uint32_t temp = array[max - 1];
array[max - 1] = array[other_idx]; array[max - 1] = array[other_idx];