diff options
| author | ruki <[email protected]> | 2025-11-10 23:20:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-10 23:20:11 +0800 |
| commit | ef701a4dce8b7d9a663e084d1fc0b243ddae9397 (patch) | |
| tree | 45fd20851dd3480bd042dd14af77286c4289d190 /core/src/xmake/hash | |
| parent | 6db4c62a474e380071625fa5cb7743972a562940 (diff) | |
format core code again
Diffstat (limited to 'core/src/xmake/hash')
| -rw-r--r-- | core/src/xmake/hash/md5.c | 4 | ||||
| -rw-r--r-- | core/src/xmake/hash/prefix.h | 14 | ||||
| -rw-r--r-- | core/src/xmake/hash/rand128.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/hash/rand32.c | 4 | ||||
| -rw-r--r-- | core/src/xmake/hash/rand64.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/hash/sha.c | 8 | ||||
| -rw-r--r-- | core/src/xmake/hash/xxhash.c | 32 |
7 files changed, 33 insertions, 33 deletions
diff --git a/core/src/xmake/hash/md5.c b/core/src/xmake/hash/md5.c index 6d18b72ba..56f68d99e 100644 --- a/core/src/xmake/hash/md5.c +++ b/core/src/xmake/hash/md5.c @@ -39,7 +39,7 @@ tb_int_t xm_hash_md5(lua_State *lua) { // is bytes? get data and size if (xm_lua_isinteger(lua, 1) && xm_lua_isinteger(lua, 2)) { tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); - tb_size_t size = (tb_size_t)lua_tointeger(lua, 2); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); @@ -65,7 +65,7 @@ tb_int_t xm_hash_md5(lua_State *lua) { tb_check_return_val(filename, 0); // load data from file - tb_bool_t ok = tb_false; + tb_bool_t ok = tb_false; tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO); if (stream) { // open stream diff --git a/core/src/xmake/hash/prefix.h b/core/src/xmake/hash/prefix.h index 99a8e4e6d..f486105e1 100644 --- a/core/src/xmake/hash/prefix.h +++ b/core/src/xmake/hash/prefix.h @@ -39,9 +39,9 @@ static __tb_inline__ tb_uint64_t xm_hash_xorshift64(tb_uint64_t x) { // http://xorshift.di.unimi.it/xorshift128plus.c static __tb_inline__ tb_uint64_t xm_hash_xorshift128(tb_uint64_t *s) { - tb_uint64_t s1 = s[0]; + tb_uint64_t s1 = s[0]; tb_uint64_t const s0 = s[1]; - s[0] = s0; + s[0] = s0; s1 ^= s1 << 23; s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5); return s[1] + s0; @@ -49,13 +49,13 @@ static __tb_inline__ tb_uint64_t xm_hash_xorshift128(tb_uint64_t *s) { static __tb_inline__ tb_size_t xm_hash_make_cstr(tb_char_t hash[256], tb_byte_t const *data, tb_size_t size) { static tb_char_t const *digits_table = "0123456789abcdef"; - tb_size_t i = 0; - tb_byte_t value; - tb_char_t *s = hash; + tb_size_t i = 0; + tb_byte_t value; + tb_char_t *s = hash; for (i = 0; i < size; ++i) { value = data[i]; - s[0] = digits_table[(value >> 4) & 15]; - s[1] = digits_table[value & 15]; + s[0] = digits_table[(value >> 4) & 15]; + s[1] = digits_table[value & 15]; s += 2; } *s = '\0'; diff --git a/core/src/xmake/hash/rand128.c b/core/src/xmake/hash/rand128.c index 625e75326..888e55e79 100644 --- a/core/src/xmake/hash/rand128.c +++ b/core/src/xmake/hash/rand128.c @@ -37,7 +37,7 @@ tb_int_t xm_hash_rand128(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); static union { - tb_byte_t b[16]; + tb_byte_t b[16]; tb_uint64_t word[2]; } s_seed = { 0 }; if (!s_seed.word[0] && !s_seed.word[1]) { diff --git a/core/src/xmake/hash/rand32.c b/core/src/xmake/hash/rand32.c index 7f5286b8e..9e5b486e4 100644 --- a/core/src/xmake/hash/rand32.c +++ b/core/src/xmake/hash/rand32.c @@ -42,9 +42,9 @@ tb_int_t xm_hash_rand32(lua_State *lua) { } s_seed = xm_hash_xorshift64(s_seed); - tb_char_t s[256]; + tb_char_t s[256]; tb_uint32_t word = (s_seed >> 32) ^ (s_seed & 0xffffffff); - tb_size_t n = xm_hash_make_cstr(s, (tb_byte_t const *)&word, 4); + tb_size_t n = xm_hash_make_cstr(s, (tb_byte_t const *)&word, 4); lua_pushlstring(lua, s, n); return 1; diff --git a/core/src/xmake/hash/rand64.c b/core/src/xmake/hash/rand64.c index ea9539ced..ca761bb31 100644 --- a/core/src/xmake/hash/rand64.c +++ b/core/src/xmake/hash/rand64.c @@ -37,7 +37,7 @@ tb_int_t xm_hash_rand64(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); static union { - tb_byte_t b[8]; + tb_byte_t b[8]; tb_uint64_t word; } s_seed = { 0 }; if (!s_seed.word) { diff --git a/core/src/xmake/hash/sha.c b/core/src/xmake/hash/sha.c index 7ddcab62f..8140c796c 100644 --- a/core/src/xmake/hash/sha.c +++ b/core/src/xmake/hash/sha.c @@ -42,7 +42,7 @@ tb_int_t xm_hash_sha(lua_State *lua) { // is bytes? get data and size if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) { tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); - tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); @@ -51,7 +51,7 @@ tb_int_t xm_hash_sha(lua_State *lua) { tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // compute sha - tb_sha_t sha; + tb_sha_t sha; tb_byte_t buffer[32]; tb_sha_init(&sha, mode); tb_sha_spak(&sha, data, size); @@ -59,7 +59,7 @@ tb_int_t xm_hash_sha(lua_State *lua) { // make sha string tb_char_t s[256]; - tb_size_t n = sha.digest_len << 2; + tb_size_t n = sha.digest_len << 2; tb_size_t len = xm_hash_make_cstr(s, buffer, n); // save result @@ -72,7 +72,7 @@ tb_int_t xm_hash_sha(lua_State *lua) { tb_check_return_val(filename, 0); // load data from file - tb_bool_t ok = tb_false; + tb_bool_t ok = tb_false; tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO); if (stream) { // open stream diff --git a/core/src/xmake/hash/xxhash.c b/core/src/xmake/hash/xxhash.c index a7fe4a985..bd40e47c7 100644 --- a/core/src/xmake/hash/xxhash.c +++ b/core/src/xmake/hash/xxhash.c @@ -51,7 +51,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { // is bytes? get data and size if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) { tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); - tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); @@ -61,19 +61,19 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { // compuate hash tb_byte_t const *buffer = tb_null; - tb_uint32_t value32; - XXH64_hash_t value64; - XXH128_hash_t value128; + tb_uint32_t value32; + XXH64_hash_t value64; + XXH128_hash_t value128; if (mode == 128) { value128 = XM_XXH3_128bits(data, size); - buffer = (tb_byte_t const *)&value128; + buffer = (tb_byte_t const *)&value128; } else if (mode == 64) { value64 = XM_XXH3_64bits(data, size); - buffer = (tb_byte_t const *)&value64; + buffer = (tb_byte_t const *)&value64; } else if (mode == 32) { value64 = XM_XXH3_64bits(data, size); value32 = (value64 >> 32) ^ (value64 & 0xffffffff); - buffer = (tb_byte_t const *)&value32; + buffer = (tb_byte_t const *)&value32; } if (!buffer) { lua_pushnil(lua); @@ -83,7 +83,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { // make xxhash string tb_char_t s[256]; - tb_size_t n = mode >> 3; + tb_size_t n = mode >> 3; tb_size_t len = xm_hash_make_cstr(s, buffer, n); // save result @@ -96,7 +96,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { tb_check_return_val(filename, 0); // load data from file - tb_bool_t ok = tb_false; + tb_bool_t ok = tb_false; tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO); if (stream) { // open stream @@ -139,24 +139,24 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { // compuate hash tb_byte_t const *buffer; - tb_uint32_t value32; - XXH64_hash_t value64; - XXH128_hash_t value128; + tb_uint32_t value32; + XXH64_hash_t value64; + XXH128_hash_t value128; if (mode == 128) { value128 = XM_XXH3_128bits_digest(state); - buffer = (tb_byte_t const *)&value128; + buffer = (tb_byte_t const *)&value128; } else if (mode == 64) { value64 = XM_XXH3_64bits_digest(state); - buffer = (tb_byte_t const *)&value64; + buffer = (tb_byte_t const *)&value64; } else if (mode == 32) { value64 = XM_XXH3_64bits_digest(state); value32 = (value64 >> 32) ^ (value64 & 0xffffffff); - buffer = (tb_byte_t const *)&value32; + buffer = (tb_byte_t const *)&value32; } // make xxhash string tb_char_t s[256]; - tb_size_t n = mode >> 3; + tb_size_t n = mode >> 3; tb_size_t len = xm_hash_make_cstr(s, buffer, n); // save result |
