From 4dcd9779320cfca7c85e88a9c7141dfb9c6579b0 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 17 Apr 2019 20:04:34 +0100 Subject: [PATCH] Windows build fixes. --- client/client_shared.h | 1 - client/pub_client.c | 24 ++++++++++++++++++++++++ lib/cpp/mosquittopp.h | 2 -- lib/net_mosq_ocsp.c | 8 ++++---- src/logging.c | 6 +----- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/client/client_shared.h b/client/client_shared.h index ca8ae640fb..18686cde7c 100644 --- a/client/client_shared.h +++ b/client/client_shared.h @@ -18,7 +18,6 @@ and the Eclipse Distribution License is available at #define CLIENT_CONFIG_H #include -#include /* pub_client.c modes */ #define MSGMODE_NONE 0 diff --git a/client/pub_client.c b/client/pub_client.c index 3f8020cc5c..cdf89741de 100644 --- a/client/pub_client.c +++ b/client/pub_client.c @@ -22,6 +22,7 @@ and the Eclipse Distribution License is available at #include #include #ifndef WIN32 +#include #include #else #include @@ -45,6 +46,28 @@ static bool connected = true; static bool disconnect_sent = false; static int publish_count = 0; static bool ready_for_repeat = false; + +#ifdef WIN32 +static uint64_t next_publish_tv; + +static void set_repeat_time(void) +{ + uint64_t ticks = GetTickCount64(); + next_publish_tv = ticks + cfg.repeat_delay.tv_sec*1000 + cfg.repeat_delay.tv_usec/1000; +} + +static int check_repeat_time(void) +{ + uint64_t ticks = GetTickCount64(); + + if(ticks > next_publish_tv){ + return 1; + }else{ + return 0; + } +} +#else + static struct timeval next_publish_tv; static void set_repeat_time(void) @@ -72,6 +95,7 @@ static int check_repeat_time(void) } return 0; } +#endif void my_disconnect_callback(struct mosquitto *mosq, void *obj, int rc, const mosquitto_property *properties) { diff --git a/lib/cpp/mosquittopp.h b/lib/cpp/mosquittopp.h index 208924167b..8d2e98b08d 100644 --- a/lib/cpp/mosquittopp.h +++ b/lib/cpp/mosquittopp.h @@ -29,8 +29,6 @@ and the Eclipse Distribution License is available at #if defined(__GNUC__) || defined(__clang__) # define DEPRECATED __attribute__ ((deprecated)) -#elif defined(_MSC_VER) -# define DEPRECATED __declspec(deprecated) #else # define DEPRECATED #endif diff --git a/lib/net_mosq_ocsp.c b/lib/net_mosq_ocsp.c index 76fec3df87..32f2a3e321 100644 --- a/lib/net_mosq_ocsp.c +++ b/lib/net_mosq_ocsp.c @@ -41,15 +41,15 @@ in this Software without prior written authorization of the copyright holder. */ #ifdef WITH_TLS +#include +#include +#include + #include #include #include #include -#include -#include -#include - int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg) { struct mosquitto *mosq = (struct mosquitto *)arg; diff --git a/src/logging.c b/src/logging.c index 6f12bc844e..d956643d13 100644 --- a/src/logging.c +++ b/src/logging.c @@ -58,9 +58,7 @@ static DltContext dltContext; static int get_time(struct tm **ti) { -#ifdef WIN32 - SYSTEMTIME st; -#elif defined(__APPLE__) +#if defined(__APPLE__) struct timeval tv; #else struct timespec ts; @@ -70,8 +68,6 @@ static int get_time(struct tm **ti) #ifdef WIN32 s = time(NULL); - GetLocalTime(&st); - *ns = st.wMilliseconds*1000000L; #elif defined(__APPLE__) gettimeofday(&tv, NULL); s = tv.tv_sec;