diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27c5379..db701a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,4 +51,40 @@ jobs: - name: Test (vs2019) if: runner.os == 'Windows' run: "& ./bin/test.exe" - \ No newline at end of file + + build_and_test_mingw: + name: Build & test (MingW) + + strategy: + matrix: + os: [windows-latest] + configuration: [release, debug] + + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: msys2 {0} + + steps: + - uses: actions/checkout@master + + # Set up msys2/MingW-w64 toolchain + - name: Setup (msys2) + uses: msys2/setup-msys2@v2 + with: + msystem: UCRT64 + update: true + install: >- + mingw-w64-ucrt-x86_64-make + mingw-w64-ucrt-x86_64-premake + mingw-w64-ucrt-x86_64-gcc + + - name: Build (msys2) + run: | + premake5 gmake + mingw32-make clean + mingw32-make all config=${{ matrix.configuration }} + + - name: Test (msys2) + run: "./bin/test.exe" diff --git a/netcode.c b/netcode.c index ad38e9b..5ffc923 100755 --- a/netcode.c +++ b/netcode.c @@ -82,6 +82,10 @@ void netcode_enable_packet_tagging() netcode_packet_tagging_enabled = 1; } +#else + +void netcode_enable_packet_tagging() {} + #endif // #if NETCODE_PACKET_TAGGING // ------------------------------------------------------------------ @@ -157,22 +161,28 @@ void netcode_default_free_function( void * context, void * pointer ) #if NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS + #ifndef NOMINMAX #define NOMINMAX + #endif // #ifndef NOMINMAX #define _WINSOCK_DEPRECATED_NO_WARNINGS #include #include #include #include #include + #ifdef _MSC_VER #pragma comment( lib, "WS2_32.lib" ) #pragma comment( lib, "IPHLPAPI.lib" ) + #endif // #ifdef _MSC_VER #ifdef SetPort #undef SetPort #endif // #ifdef SetPort #include + #ifdef _MSC_VER #pragma comment( lib, "IPHLPAPI.lib" ) + #endif // #ifdef _MSC_VER #elif NETCODE_PLATFORM == NETCODE_PLATFORM_MAC || NETCODE_PLATFORM == NETCODE_PLATFORM_UNIX @@ -478,7 +488,9 @@ typedef UINT32 QOS_FLOWID, *PQOS_FLOWID; #endif // #ifdef __MINGW32__ #include +#ifdef _MSC_VER #pragma comment( lib, "Qwave.lib" ) +#endif // #ifdef _MSC_VER static int netcode_set_socket_codepoint( SOCKET socket, QOS_TRAFFIC_TYPE trafficType, QOS_FLOWID flowId, PSOCKADDR addr ) { @@ -5217,7 +5229,9 @@ double netcode_time() // windows +#ifndef NOMINMAX #define NOMINMAX +#endif // #ifndef NOMINMAX #include void netcode_sleep( double time ) diff --git a/netcode.h b/netcode.h index 0ddaab0..546310a 100755 --- a/netcode.h +++ b/netcode.h @@ -113,12 +113,16 @@ int netcode_init(); void netcode_term(); #ifndef NETCODE_PACKET_TAGGING +#ifndef __MINGW32__ #define NETCODE_PACKET_TAGGING 1 +#else +// At least as of version 14.2.0, the Qwave library is not properly implemented +// in MingW-w64, so packet tagging is disabled by default. +#define NETCODE_PACKET_TAGGING 0 +#endif // #ifndef __MINGW32__ #endif // #ifndef NETCODE_PACKET_TAGGING -#if NETCODE_PACKET_TAGGING void netcode_enable_packet_tagging(); -#endif // #if NETCODE_PACKET_TAGGING struct netcode_address_t { diff --git a/premake5.lua b/premake5.lua index 4c40677..739131e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -35,26 +35,38 @@ project "sodium" project "test" files { "test.cpp" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "soak" files { "soak.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "profile" files { "profile.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "client" files { "client.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "server" files { "server.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "client_server" files { "client_server.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } newaction { diff --git a/sodium/sodium_randombytes_salsa20_random.c b/sodium/sodium_randombytes_salsa20_random.c index 2cf65f5..26619aa 100644 --- a/sodium/sodium_randombytes_salsa20_random.c +++ b/sodium/sodium_randombytes_salsa20_random.c @@ -89,6 +89,10 @@ BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); # endif #endif +#if !defined(TLS) && !defined(__STDC_NO_THREADS__) && \ + defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +# define TLS _Thread_local +#endif #ifndef TLS # ifdef _WIN32 # define TLS __declspec(thread)