Skip to content

Commit

Permalink
moved windows-gettimeofday() from benchmark.c to n2n.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan007 committed Jul 21, 2020
1 parent 0ab9f32 commit 252ce97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
22 changes: 22 additions & 0 deletions src/n2n.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,25 @@ int sock_equal(const n2n_sock_t * a,
return(1);
}

/* *********************************************** */

#if defined(WIN32) && !defined(__GNUC__)
static int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm.tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
#endif
20 changes: 0 additions & 20 deletions tools/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,6 @@

#include "n2n.h"

#if defined(WIN32) && !defined(__GNUC__)
static int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm.tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
#endif

uint8_t PKT_CONTENT[]={
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
Expand Down

0 comments on commit 252ce97

Please sign in to comment.