Skip to content

Commit

Permalink
Merge pull request #875 from jalius/master
Browse files Browse the repository at this point in the history
Update to support MSYS2/GCC
  • Loading branch information
ArthurKetels authored Jan 27, 2025
2 parents 83c6264 + 49f2d8a commit 2752dc2
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 564 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ if(WIN32)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
if(MSVC)
message(STATUS "Win32 MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
else()
message(STATUS "Win32 non-MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
endif()
set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
elseif(UNIX AND NOT APPLE)
set(OS "linux")
Expand Down
305 changes: 0 additions & 305 deletions osal/win32/inttypes.h

This file was deleted.

13 changes: 7 additions & 6 deletions osal/win32/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ static double qpc2usec;

#define USECS_PER_SEC 1000000

int osal_getrelativetime(struct timeval *tv, struct timezone *tz)
static int osal_getrelativetime(struct timeval *tv, struct timezone *tz)
{
int64_t wintime, usecs;
(void)tz;
if(!sysfrequency)
{
timeBeginPeriod(1);
Expand All @@ -33,7 +34,7 @@ int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME system_time;
int64 system_time64, usecs;

(void)tz;
/* The offset variable is required to switch from Windows epoch (January 1, 1601) to
* Unix epoch (January 1, 1970). Number of days between both epochs: 134.774
*
Expand Down Expand Up @@ -130,23 +131,23 @@ void osal_free(void *ptr)
free(ptr);
}

int osal_thread_create(void **thandle, int stacksize, void *func, void *param)
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
{
*thandle = CreateThread(NULL, stacksize, func, param, 0, NULL);
*(OSAL_THREAD_HANDLE*)thandle = CreateThread(NULL, stacksize, func, param, 0, NULL);
if(!thandle)
{
return 0;
}
return 1;
}

int osal_thread_create_rt(void **thandle, int stacksize, void *func, void *param)
int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param)
{
int ret;
ret = osal_thread_create(thandle, stacksize, func, param);
if (ret)
{
ret = SetThreadPriority(*thandle, THREAD_PRIORITY_TIME_CRITICAL);
ret = SetThreadPriority(thandle, THREAD_PRIORITY_TIME_CRITICAL);
}
return ret;
}
10 changes: 9 additions & 1 deletion osal/win32/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern "C"
{
#endif

#define WIN32_LEAN_AND_MEAN // Exclude some conflicting definitions in windows header
#include <windows.h>
// define if debug printf is needed
//#define EC_DEBUG

Expand All @@ -21,11 +23,17 @@ extern "C"
#endif

#ifndef PACKED
#define PACKED_BEGIN __pragma(pack(push, 1))
#define PACKED
#ifdef __GNUC__
#define PACKED_BEGIN _Pragma("pack(push,1)")
#define PACKED_END _Pragma("pack(pop)")
#else
#define PACKED_BEGIN __pragma(pack(push, 1))
#define PACKED_END __pragma(pack(pop))
#endif

#endif

#define OSAL_THREAD_HANDLE HANDLE
#define OSAL_THREAD_FUNC void
#define OSAL_THREAD_FUNC_RT void
Expand Down
Loading

0 comments on commit 2752dc2

Please sign in to comment.