diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index bc684af9..769ba5de 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c @@ -18,13 +18,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - #define NUM_PORTS 3 static uint16_t ports[NUM_PORTS] = {1234, 33445, 25643}; diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 36707e0f..33110441 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c @@ -17,15 +17,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - - #define NUM_GROUP_TOX 32 static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 479b0eb8..6ed84098 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c @@ -571,14 +571,6 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port) { } - -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - #define NUM_DHT_FRIENDS 20 START_TEST(test_DHT_test) diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h index 5cec575c..e5860449 100644 --- a/auto_tests/helpers.h +++ b/auto_tests/helpers.h @@ -7,6 +7,14 @@ #include #include +#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) +#include +#define c_sleep(x) Sleep(x) +#else +#include +#define c_sleep(x) usleep(1000*(x)) +#endif + #define DEFTESTCASE(NAME) \ TCase *tc_##NAME = tcase_create(#NAME); \ tcase_add_test(tc_##NAME, test_##NAME); \ diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 05264927..c52bbb58 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c @@ -18,13 +18,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - static void do_onion(Onion *onion) { networking_poll(onion->net, NULL); diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c index 6d0640c3..061425bd 100644 --- a/auto_tests/save_friend_test.c +++ b/auto_tests/save_friend_test.c @@ -12,14 +12,6 @@ #include #include -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - struct test_data { uint8_t name[TOX_MAX_NAME_LENGTH]; uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH]; diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index 48f5671c..77c611d9 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c @@ -17,14 +17,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - /* The Travis-CI container responds poorly to ::1 as a localhost address * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */ #ifdef FORCE_TESTS_IPV6 diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index b44bbb0c..1a1a715d 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c @@ -17,14 +17,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) { if (*((uint32_t *)userdata) != 974536) { diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index d9074ac0..f3557226 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c @@ -27,14 +27,6 @@ #include "helpers.h" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - /* The Travis-CI container responds poorly to ::1 as a localhost address * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */ #ifdef FORCE_TESTS_IPV6 diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index 79f552de..2885d8be 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c @@ -22,15 +22,6 @@ #include "../toxcore/util.h" -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else -#include -#define c_sleep(x) usleep(1000*x) -#endif - - #define TEST_REGULAR_AV 1 #define TEST_REGULAR_A 1 #define TEST_REGULAR_V 1 diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 1a10db44..83a7b313 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c @@ -21,16 +21,10 @@ #include "../toxcore/tox.h" #include "../toxcore/util.h" -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -#include -#define c_sleep(x) Sleep(1*x) -#else +#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) #include -#include -#define c_sleep(x) usleep(1000*x) #endif - typedef struct { bool incoming; uint32_t state; diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index f4dd5a65..78139de0 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -50,15 +50,6 @@ #define DHT_MOTD "This is a test motd" #endif -/* Sleep function (x = milliseconds) */ -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#define c_sleep(x) Sleep(1*x) -#else -#include -#include -#define c_sleep(x) usleep(1000*x) -#endif - #define PORT 33445 diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 536217fe..6e65bf3a 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c @@ -41,16 +41,8 @@ #include -//Sleep function (x = milliseconds) -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) - -#define c_sleep(x) Sleep(1*x) - -#else +#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32) #include -#include -#define c_sleep(x) usleep(1000*x) - #endif #define PORT 33445 diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index c1a63da8..7dc773b2 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c @@ -47,15 +47,8 @@ #include "../toxcore/Messenger.h" #include "misc_tools.c" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) - -#define c_sleep(x) Sleep(1*x) - -#else +#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32) #include -#include -#define c_sleep(x) usleep(1000*x) -#define PORT 33445 #endif diff --git a/testing/av_test.c b/testing/av_test.c index 8aaebfe7..4d09d023 100644 --- a/testing/av_test.c +++ b/testing/av_test.c @@ -73,7 +73,7 @@ extern "C" { #include #include -#define c_sleep(x) usleep(1000*x) +#define c_sleep(x) usleep(1000*(x)) #define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X) diff --git a/testing/dns3_test.c b/testing/dns3_test.c index 821f3b4b..4c03fc52 100644 --- a/testing/dns3_test.c +++ b/testing/dns3_test.c @@ -3,15 +3,6 @@ #include "../toxdns/toxdns.h" #include "misc_tools.c" -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) - -#define c_sleep(x) Sleep(1*x) - -#else -#define c_sleep(x) usleep(1000*x) - -#endif - static uint32_t create_packet(uint8_t *packet, uint8_t *string, uint8_t str_len, uint8_t id) { memset(packet, 0, str_len + 13 + 16); diff --git a/testing/misc_tools.c b/testing/misc_tools.c index f0e12526..f6e76e46 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c @@ -31,6 +31,15 @@ #include #include +//Sleep function (x = milliseconds) +#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) +#include +#define c_sleep(x) Sleep(x) +#else +#include +#define c_sleep(x) usleep(1000*(x)) +#endif + // You are responsible for freeing the return value! uint8_t *hex_string_to_bin(const char *hex_string) { diff --git a/testing/nTox.c b/testing/nTox.c index d02a1652..73038622 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -48,10 +48,10 @@ #include #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) -#define c_sleep(x) Sleep(1*x) +#define c_sleep(x) Sleep(x) #else #include -#define c_sleep(x) usleep(1000*x) +#define c_sleep(x) usleep(1000*(x)) #endif static void new_lines(char const *line); diff --git a/testing/tox_shell.c b/testing/tox_shell.c index f983f4e9..43e0b544 100644 --- a/testing/tox_shell.c +++ b/testing/tox_shell.c @@ -43,9 +43,6 @@ #include #endif #include -#include - -#define c_sleep(x) usleep(1000*x) static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata) { diff --git a/testing/tox_sync.c b/testing/tox_sync.c index d2fc41ca..10fc047e 100644 --- a/testing/tox_sync.c +++ b/testing/tox_sync.c @@ -38,9 +38,6 @@ #include "../toxcore/tox.h" #include "misc_tools.c" -#include -#define c_sleep(x) usleep(1000*x) - #include #include #include