forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from adbd5b32d8..e29e185c03
e29e185c03 feat: add ngc events 2b0dc0f46b add ngc related unpack functions b2315c50e0 Add groupchat API function that returns an IP address string for a peer 5f863a5492 feat: Add `to_string` functions for all public enums. 0c998a7598 add real timeout test 68c827609a chore: Move s390x build to post-merge. 028b017d79 perf: Slightly reduce bandwidth usage when there are few nodes. 90f7496819 feat: Enable ubsan on bootstrap nodes. 89b6450d66 test: Add check-c run to bazel build. REVERT: adbd5b32d8 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: e29e185c03fea7337036e5ef4d1d9080a6cee721
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "ccompat.h"
|
||||
#include "util.h"
|
||||
|
||||
/** don't call into system billions of times for no reason */
|
||||
struct Mono_Time {
|
||||
@ -165,7 +166,9 @@ Mono_Time *mono_time_new(const Memory *mem, mono_time_current_time_cb *current_t
|
||||
// Maximum reproducibility. Never return time = 0.
|
||||
mono_time->base_time = 1;
|
||||
#else
|
||||
mono_time->base_time = (uint64_t)time(nullptr) * 1000ULL - current_time_monotonic(mono_time);
|
||||
// Never return time = 0 in case time() returns 0 (e.g. on microcontrollers
|
||||
// without battery-powered RTC or ones where NTP didn't initialise it yet).
|
||||
mono_time->base_time = max_u64(1, (uint64_t)time(nullptr)) * 1000ULL - current_time_monotonic(mono_time);
|
||||
#endif
|
||||
|
||||
mono_time_update(mono_time);
|
||||
|
Reference in New Issue
Block a user