diff options
author | aunsane <aunsane@gmail.com> | 2018-03-03 16:35:09 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-03-03 16:35:33 +0300 |
commit | fa58f69fe117640e29cefb1b699bede4d045bc2f (patch) | |
tree | a1bf8406d63e2b246bebdc572ceccfaabcffa359 /protocols/Tox/libtox/src/toxcore/util.c | |
parent | 0e8f5a3aa5f5e73b413c5646444751783e367f2b (diff) |
Tox:
- updated toxcore due to release v0.2
- removed message correction
- reworked nodes update
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/util.c')
-rw-r--r-- | protocols/Tox/libtox/src/toxcore/util.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/util.c b/protocols/Tox/libtox/src/toxcore/util.c index 92bbb68c1f..b7a8fda653 100644 --- a/protocols/Tox/libtox/src/toxcore/util.c +++ b/protocols/Tox/libtox/src/toxcore/util.c @@ -27,7 +27,9 @@ #include "config.h" #endif +#ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 +#endif #include "util.h" @@ -46,7 +48,7 @@ static uint64_t unix_base_time_value; void unix_time_update(void) { if (unix_base_time_value == 0) { - unix_base_time_value = ((uint64_t)time(NULL) - (current_time_monotonic() / 1000ULL)); + unix_base_time_value = ((uint64_t)time(nullptr) - (current_time_monotonic() / 1000ULL)); } unix_time_value = (current_time_monotonic() / 1000ULL) + unix_base_time_value; @@ -128,7 +130,6 @@ int load_state(load_state_callback_func load_state_callback, Logger *log, void * } - uint16_t type; uint32_t length_sub, cookie_type; uint32_t size_head = sizeof(uint32_t) * 2; @@ -150,9 +151,8 @@ int load_state(load_state_callback_func load_state_callback, Logger *log, void * return -1; } - type = lendian_to_host16(cookie_type & 0xFFFF); - - int ret = load_state_callback(outer, data, length_sub, type); + const uint16_t type = lendian_to_host16(cookie_type & 0xFFFF); + const int ret = load_state_callback(outer, data, length_sub, type); if (ret == -1) { return -1; @@ -193,3 +193,13 @@ int create_recursive_mutex(pthread_mutex_t *mutex) return 0; } + +int32_t max_s32(int32_t a, int32_t b) +{ + return a > b ? a : b; +} + +uint64_t min_u64(uint64_t a, uint64_t b) +{ + return a < b ? a : b; +} |