|
|
@ -30,6 +30,10 @@ Contributors:
|
|
|
|
#define snprintf sprintf_s
|
|
|
|
#define snprintf sprintf_s
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
|
|
|
# include <sys/time.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <mosquitto.h>
|
|
|
|
#include <mosquitto.h>
|
|
|
|
#include "client_shared.h"
|
|
|
|
#include "client_shared.h"
|
|
|
|
|
|
|
|
|
|
|
@ -38,6 +42,8 @@ static int get_time(struct tm **ti, long *ns)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
#ifdef WIN32
|
|
|
|
SYSTEMTIME st;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
|
|
|
struct timeval tv;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
struct timespec ts;
|
|
|
|
struct timespec ts;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -48,6 +54,10 @@ static int get_time(struct tm **ti, long *ns)
|
|
|
|
|
|
|
|
|
|
|
|
GetLocalTime(&st);
|
|
|
|
GetLocalTime(&st);
|
|
|
|
*ns = st.wMilliseconds*1000000L;
|
|
|
|
*ns = st.wMilliseconds*1000000L;
|
|
|
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
|
|
|
s = tv.tv_sec;
|
|
|
|
|
|
|
|
*ns = tv.tv_usec*1000;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
if(clock_gettime(CLOCK_REALTIME, &ts) != 0){
|
|
|
|
if(clock_gettime(CLOCK_REALTIME, &ts) != 0){
|
|
|
|
fprintf(stderr, "Error obtaining system time.\n");
|
|
|
|
fprintf(stderr, "Error obtaining system time.\n");
|
|
|
|