Skip to content
38 changes: 37 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,40 @@ jobs:
- name: Test (vs2019)
if: runner.os == 'Windows'
run: "& ./bin/test.exe"


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"
14 changes: 14 additions & 0 deletions netcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

// ------------------------------------------------------------------
Expand Down Expand Up @@ -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 <winsock2.h>
#include <ws2def.h>
#include <ws2tcpip.h>
#include <ws2ipdef.h>
#include <iphlpapi.h>
#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 <iphlpapi.h>
#ifdef _MSC_VER
#pragma comment( lib, "IPHLPAPI.lib" )
#endif // #ifdef _MSC_VER

#elif NETCODE_PLATFORM == NETCODE_PLATFORM_MAC || NETCODE_PLATFORM == NETCODE_PLATFORM_UNIX

Expand Down Expand Up @@ -478,7 +488,9 @@ typedef UINT32 QOS_FLOWID, *PQOS_FLOWID;
#endif // #ifdef __MINGW32__
#include <qos2.h>

#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 )
{
Expand Down Expand Up @@ -5217,7 +5229,9 @@ double netcode_time()

// windows

#ifndef NOMINMAX
#define NOMINMAX
#endif // #ifndef NOMINMAX
#include <windows.h>

void netcode_sleep( double time )
Expand Down
8 changes: 6 additions & 2 deletions netcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
12 changes: 12 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 4 additions & 0 deletions sodium/sodium_randombytes_salsa20_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down