Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support MSYS2/GCC #875

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

#include <minwindef.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