Skip to content

Commit

Permalink
Improve C compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
N7Alpha committed Aug 12, 2024
1 parent f45e6c2 commit 2e76f7c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ jobs:
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build (GCC)
run: cmake --build build --config Release
# - name: Configure CMake (Linux TCC)
# run: cmake -S . -B build-tcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=tcc
# - name: Build (TCC)
# run: cmake --build build-tcc --config Release
# Check that our C code is reasonably portable
- name: Build with TCC
run: |
tcc -c Source/ThirdParty/netarch/sam2.c \
-ISource/UnrealLibretro/Private \
-ISource/ThirdParty/zstd/lib \
-ISource/ThirdParty/libjuice/include
build-macos:
runs-on: macos-latest
Expand All @@ -44,4 +47,4 @@ jobs:
- name: Configure CMake (Windows MSVC)
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release
run: cmake --build build --config Release
8 changes: 8 additions & 0 deletions Source/ThirdParty/netarch/sam2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#define SAM2_IMPLEMENTATION
#define SAM2_SERVER
#define SAM2_EXECUTABLE

#define ULNET_IMPLEMENTATION

#include "ulnet.h"
#include "sam2.h"
2 changes: 1 addition & 1 deletion Source/UnrealLibretro/Private/sam2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ int main() {

// Setup signal handler
uv_signal_t sig;
uv_signal_init(&server->loop, &sig);
uv_signal_init(&server.loop, &sig);
sig.data = &server;
uv_signal_start(&sig, on_signal, SIGINT);

Expand Down
11 changes: 10 additions & 1 deletion Source/UnrealLibretro/Private/ulnet.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#ifndef ULNET_H
#define ULNET_H

#include "sam2.h"

#include "juice/juice.h"
typedef struct juice_agent juice_agent_t;
#include "zstd.h"
#include "common/xxhash.h"
#include "fec.h"

#include <stdint.h>
#include <stdbool.h>

#ifndef ULNET_LINKAGE
#ifdef __cplusplus
Expand Down Expand Up @@ -256,8 +260,11 @@ static inline void ulnet__xor_delta(void *dest, void *src, int size) {
((uint8_t *) dest)[i] ^= ((uint8_t *) src)[i];
}
}
#endif

#if defined(ULNET_IMPLEMENTATION)
#ifndef ULNET_C
#define ULNET_C
#if defined(ULNET_IMGUI)
#include "imgui.h"
#include "implot.h"
Expand All @@ -266,6 +273,7 @@ static inline void ulnet__xor_delta(void *dest, void *src, int size) {
#define IMH(statement)
#endif

#include "juice/juice.h"
#include <assert.h>
#include <time.h>

Expand Down Expand Up @@ -1553,3 +1561,4 @@ ULNET_LINKAGE void ulnet_send_save_state(ulnet_session_t *session, juice_agent_t
free(savestate_transfer_payload);
}
#endif
#endif

0 comments on commit 2e76f7c

Please sign in to comment.