Move c_sleep to helpers.h and misc_tools.h

Also fix a mistake with forgotten braces around parameter
This commit is contained in:
Diadlo 2017-03-03 21:30:11 +03:00
parent a1f9df48d6
commit 50c526e1a5
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
20 changed files with 23 additions and 123 deletions

View File

@ -18,13 +18,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define NUM_PORTS 3
static uint16_t ports[NUM_PORTS] = {1234, 33445, 25643};

View File

@ -17,15 +17,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#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,

View File

@ -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 <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define NUM_DHT_FRIENDS 20
START_TEST(test_DHT_test)

View File

@ -7,6 +7,14 @@
#include <check.h>
#include <stdio.h>
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*(x))
#endif
#define DEFTESTCASE(NAME) \
TCase *tc_##NAME = tcase_create(#NAME); \
tcase_add_test(tc_##NAME, test_##NAME); \

View File

@ -18,13 +18,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
static void do_onion(Onion *onion)
{
networking_poll(onion->net, NULL);

View File

@ -12,14 +12,6 @@
#include <stdlib.h>
#include <string.h>
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#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];

View File

@ -17,14 +17,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#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

View File

@ -17,14 +17,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#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) {

View File

@ -27,14 +27,6 @@
#include "helpers.h"
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#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

View File

@ -22,15 +22,6 @@
#include "../toxcore/util.h"
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define TEST_REGULAR_AV 1
#define TEST_REGULAR_A 1
#define TEST_REGULAR_V 1

View File

@ -21,16 +21,10 @@
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
#include <pthread.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
typedef struct {
bool incoming;
uint32_t state;

View File

@ -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 <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define PORT 33445

View File

@ -41,16 +41,8 @@
#include <string.h>
//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 <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif
#define PORT 33445

View File

@ -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 <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#define PORT 33445
#endif

View File

@ -73,7 +73,7 @@ extern "C" {
#include <time.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#define c_sleep(x) usleep(1000*(x))
#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X)

View File

@ -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);

View File

@ -31,6 +31,15 @@
#include <stdlib.h>
#include <string.h>
//Sleep function (x = milliseconds)
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#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)
{

View File

@ -48,10 +48,10 @@
#include <time.h>
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#define c_sleep(x) usleep(1000*(x))
#endif
static void new_lines(char const *line);

View File

@ -43,9 +43,6 @@
#include <pty.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata)
{

View File

@ -38,9 +38,6 @@
#include "../toxcore/tox.h"
#include "misc_tools.c"
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#include <arpa/inet.h>
#include <dirent.h>
#include <netinet/in.h>