summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-26 20:34:26 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-09-03 20:03:47 +0000
commit6872c14e1a02445d945623ee6e85230c5d7ecbce (patch)
tree30d90b93445976e56b96946b6e87b764eddd48a8 /auto_tests
parentd296490a742b226fc17a71cf96ab73fc16719b20 (diff)
Avoid use of global mutable state in mono_time on win32.
This uses a trick to get read-write access to `this` from a `const` member function, similar to C++ `mutable`, but uglier.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/dht_test.c5
-rw-r--r--auto_tests/run_auto_test.h5
2 files changed, 6 insertions, 4 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c
index 232b7d95..f9c09dd5 100644
--- a/auto_tests/dht_test.c
+++ b/auto_tests/dht_test.c
@@ -600,9 +600,10 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port)
600 600
601#define NUM_DHT_FRIENDS 20 601#define NUM_DHT_FRIENDS 20
602 602
603static uint64_t get_clock_callback(void *user_data) 603static uint64_t get_clock_callback(Mono_Time *mono_time, void *user_data)
604{ 604{
605 return *(uint64_t *)user_data; 605 const uint64_t *clock = (const uint64_t *)user_data;
606 return *clock;
606} 607}
607 608
608static void test_DHT_test(void) 609static void test_DHT_test(void)
diff --git a/auto_tests/run_auto_test.h b/auto_tests/run_auto_test.h
index 602ad524..bcbfed55 100644
--- a/auto_tests/run_auto_test.h
+++ b/auto_tests/run_auto_test.h
@@ -42,9 +42,10 @@ static void iterate_all_wait(uint32_t tox_count, Tox **toxes, State *state, uint
42 c_sleep(20); 42 c_sleep(20);
43} 43}
44 44
45static uint64_t get_state_clock_callback(void *user_data) 45static uint64_t get_state_clock_callback(Mono_Time *mono_time, void *user_data)
46{ 46{
47 return ((State *)user_data)->clock; 47 const State *state = (const State *)user_data;
48 return state->clock;
48} 49}
49 50
50static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *state)) 51static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *state))