diff options
author | Toni <matzeton@googlemail.com> | 2021-08-18 12:34:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 11:34:16 +0200 |
commit | 8d0c7b1faeed1e3df6e6f90658559f373bbf63fb (patch) | |
tree | 8ef500067f538f23652986c7b844f299a0e92ef3 /src | |
parent | 677b513f70ade895ef28be744245803238100489 (diff) |
Fixed Mingw64 build, SonerCloud-CI and more. (#1273)
* Added ARM build and unit test run for SonarCloud-CI.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
* Fixed Mingw64 build.
* adapted to SonarCloud-CI workflow
* removed broken and incomplete Windows example (tested on VS2017/VS2019)
* removed unnecessary include (e.g. pthread.h for the library which does not make use of it)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_includes.h | 5 | ||||
-rw-r--r-- | src/include/ndpi_unix.h | 3 | ||||
-rw-r--r-- | src/include/ndpi_win32.h | 19 | ||||
-rw-r--r-- | src/lib/ndpi_classify.c | 6 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 24 | ||||
-rw-r--r-- | src/lib/third_party/src/ahocorasick.c | 5 |
6 files changed, 13 insertions, 49 deletions
diff --git a/src/include/ndpi_includes.h b/src/include/ndpi_includes.h index 197f32fce..3b87dda65 100644 --- a/src/include/ndpi_includes.h +++ b/src/include/ndpi_includes.h @@ -38,7 +38,6 @@ #else #include <sys/types.h> #include <sys/param.h> -#include <pthread.h> #include <arpa/inet.h> #include <sys/time.h> #include <sys/socket.h> @@ -57,10 +56,6 @@ #if defined __NetBSD__ || defined __OpenBSD__ #include <netinet/in_systm.h> -#if defined __OpenBSD__ -#include <pthread.h> - -#endif #endif #endif #endif diff --git a/src/include/ndpi_unix.h b/src/include/ndpi_unix.h index 6e6987bfd..f4901761e 100644 --- a/src/include/ndpi_unix.h +++ b/src/include/ndpi_unix.h @@ -28,9 +28,6 @@ #include <netinet/in.h> #if defined(__NetBSD__) || defined(__OpenBSD__) #include <netinet/in_systm.h> -#if defined(__OpenBSD__) -#include <pthread.h> -#endif #endif #endif diff --git a/src/include/ndpi_win32.h b/src/include/ndpi_win32.h index b79a880e8..03f1389df 100644 --- a/src/include/ndpi_win32.h +++ b/src/include/ndpi_win32.h @@ -76,25 +76,10 @@ typedef uint u_int32_t; typedef uint u_int; typedef unsigned __int64 u_int64_t; -#define pthread_t HANDLE -#define pthread_mutex_t HANDLE -#define pthread_rwlock_t pthread_mutex_t -#define pthread_rwlock_init pthread_mutex_init -#define pthread_rwlock_wrlock pthread_mutex_lock -#define pthread_rwlock_rdlock pthread_mutex_lock -#define pthread_rwlock_unlock pthread_mutex_unlock -#define pthread_rwlock_destroy pthread_mutex_destroy +#define gmtime_r(a, b) memcpy(b, gmtime(a), sizeof(struct tm)) -#define gmtime_r(a, b) memcpy(b, gmtime(a), sizeof(struct tm)) - -#define in_addr_t unsigned long - -extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */); - -#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */) -#define strtok_r strtok_s #define timegm _mkgmtime -extern struct tm* localtime_r(const time_t* timep, struct tm* r); +#define sleep(a /* sec */) Sleep(1000*a /* ms */) #endif /* __NDPI_WIN32_H__ */ diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c index a7a02cb4e..bea56afef 100644 --- a/src/lib/ndpi_classify.c +++ b/src/lib/ndpi_classify.c @@ -688,7 +688,13 @@ ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len) gettimeofday(&tv, NULL); nowtime = tv.tv_sec; +#ifdef WIN32 + /* localtime() on Windows is thread-safe */ + struct tm * nowtm_r_ptr = localtime(&nowtime); + nowtm_r = *nowtm_r_ptr; +#else localtime_r(&nowtime, &nowtm_r); +#endif strftime(tmbuf, NDPI_TIMESTAMP_LEN, "%H:%M:%S", &nowtm_r); snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec); } diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index c4535c768..38c0d7a86 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -7065,30 +7065,6 @@ char *ndpi_revision() { /* ****************************************************** */ -#ifdef WIN32 - -/* https://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows */ -int gettimeofday(struct timeval *tp, struct timezone *tzp) { - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) - // until 00:00:00 January 1, 1970 - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime(&system_time); - SystemTimeToFileTime(&system_time, &file_time); - time = ((uint64_t) file_time.dwLowDateTime); - time += ((uint64_t) file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long) ((time - EPOCH) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); - return(0); -} -#endif - int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b) { int i; diff --git a/src/lib/third_party/src/ahocorasick.c b/src/lib/third_party/src/ahocorasick.c index f29f558dc..d9dccac2c 100644 --- a/src/lib/third_party/src/ahocorasick.c +++ b/src/lib/third_party/src/ahocorasick.c @@ -677,8 +677,13 @@ void ac_automata_dump(AC_AUTOMATA_t * thiz, FILE *file) { ai.bufstr[0] = '\0'; ac_automata_walk(thiz,dump_node_common,dump_node_str,(void *)&ai); +#ifdef WIN32 + fprintf(ai.file,"---\n mem size %lu avg node size %d, node one char %d, <=8c %d, >8c %d, range %d\n---DUMP-END-\n", + (long unsigned int)ai.memcnt,(int)ai.memcnt/(thiz->all_nodes_num+1),(int)ai.node_oc,(int)ai.node_8c,(int)ai.node_xc,(int)ai.node_xr); +#else fprintf(ai.file,"---\n mem size %zu avg node size %d, node one char %d, <=8c %d, >8c %d, range %d\n---DUMP-END-\n", ai.memcnt,(int)ai.memcnt/(thiz->all_nodes_num+1),(int)ai.node_oc,(int)ai.node_8c,(int)ai.node_xc,(int)ai.node_xr); +#endif } #endif |