From 60296951552817e838bec6063b32ec48cffbc399 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 26 Feb 2025 13:26:40 +0100 Subject: [PATCH] replacing std thread by tinycthread --- Sources/PulseInternal.c | 2 +- Xmake/packages/t/tinycthread/xmake.lua | 21 +++++++++++++++++++++ xmake.lua | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Xmake/packages/t/tinycthread/xmake.lua diff --git a/Sources/PulseInternal.c b/Sources/PulseInternal.c index 7436db6..b1d1322 100644 --- a/Sources/PulseInternal.c +++ b/Sources/PulseInternal.c @@ -4,7 +4,7 @@ #include "PulseInternal.h" -#include +#include PulseThreadID PulseGetThreadID() { diff --git a/Xmake/packages/t/tinycthread/xmake.lua b/Xmake/packages/t/tinycthread/xmake.lua new file mode 100644 index 0000000..5238675 --- /dev/null +++ b/Xmake/packages/t/tinycthread/xmake.lua @@ -0,0 +1,21 @@ +package("tiny-c-thread") + set_homepage("https://github.com/tinycthread/tinycthread") + set_description("A small, portable implementation of the C11 threads API.") + set_license("MIT") + + add_urls("https://github.com/tinycthread/tinycthread.git") + + on_install(function (package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("tiny-c-thread") + set_kind("static") + add_files("source/*.c") + add_headerfiles("source/*.h") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:has_ctypes("thrd_t", {configs = {languages = "c11"}, includes = "tinycthread.h"})) + end) diff --git a/xmake.lua b/xmake.lua index c034fd4..88d8e90 100644 --- a/xmake.lua +++ b/xmake.lua @@ -2,6 +2,8 @@ -- This file is part of "Pulse" -- For conditions of distribution and use, see copyright notice in LICENSE +add_repositories("local-repo Xmake") + local backends = { Vulkan = { option = "vulkan", @@ -72,6 +74,8 @@ if is_plat("wasm") then backends.Vulkan = nil end +add_requires("tiny-c-thread") + for name, module in pairs(backends) do if has_config(module.option) then if module.packages then @@ -85,6 +89,7 @@ target("pulse_gpu") add_defines("PULSE_BUILD") add_headerfiles("Sources/*.h", { prefixdir = "private", install = false }) add_headerfiles("Sources/*.inl", { prefixdir = "private", install = false }) + add_packages("tiny-c-thread") add_files("Sources/*.c")