From aeb0f4a799257c8d0a49836badc8e0ba69b12a94 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 13:13:05 +0300 Subject: [PATCH 01/13] Make sure math::vector,point are trivially default constructible --- libs/math/include/psemek/math/detail/array.hpp | 4 ++++ libs/math/include/psemek/math/point.hpp | 5 +---- libs/math/include/psemek/math/vector.hpp | 5 +---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/math/include/psemek/math/detail/array.hpp b/libs/math/include/psemek/math/detail/array.hpp index fd835628..73a7704e 100644 --- a/libs/math/include/psemek/math/detail/array.hpp +++ b/libs/math/include/psemek/math/detail/array.hpp @@ -43,6 +43,8 @@ namespace psemek::math::detail T data[N]; + type() = default; + type(dynamic_dimensions){} dynamic_dimensions dimensions() const { return {}; } @@ -59,6 +61,8 @@ namespace psemek::math::detail { static constexpr std::size_t size = 0; + type() = default; + type(dynamic_dimensions<0>){} dynamic_dimensions<0> dimensions() const { return {}; } diff --git a/libs/math/include/psemek/math/point.hpp b/libs/math/include/psemek/math/point.hpp index d1dc97c1..afbc199f 100644 --- a/libs/math/include/psemek/math/point.hpp +++ b/libs/math/include/psemek/math/point.hpp @@ -26,9 +26,7 @@ namespace psemek::math : coords(dimensions) {} - point() - : coords({}) - {} + point() = default; explicit point(std::size_t size) requires (N == dynamic) : coords({.size = size}) @@ -37,7 +35,6 @@ namespace psemek::math template requires(N != dynamic && sizeof...(Args) == N && detail::all_convertible_to::value) point(Args && ... args) - : coords({}) { auto out = values().begin(); ((*out++ = args), ...); diff --git a/libs/math/include/psemek/math/vector.hpp b/libs/math/include/psemek/math/vector.hpp index 977f244a..d0319e5f 100644 --- a/libs/math/include/psemek/math/vector.hpp +++ b/libs/math/include/psemek/math/vector.hpp @@ -29,9 +29,7 @@ namespace psemek::math : coords(dimensions) {} - vector() - : coords({}) - {} + vector() = default; explicit vector(std::size_t size) requires (N == dynamic) : coords({.size = size}) @@ -40,7 +38,6 @@ namespace psemek::math template requires(N != dynamic && sizeof...(Args) == N && detail::all_convertible_to::value) vector(Args && ... args) - : coords({}) { auto out = values().begin(); ((*out++ = args), ...); From 500646bfe9b46600bcb54ff73de1152094582533 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 13:13:54 +0300 Subject: [PATCH 02/13] Fix util::reversed() to support both begin()/end() methods and free functions --- libs/util/include/psemek/util/range.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/util/include/psemek/util/range.hpp b/libs/util/include/psemek/util/range.hpp index 35d1859f..a18c00ef 100644 --- a/libs/util/include/psemek/util/range.hpp +++ b/libs/util/include/psemek/util/range.hpp @@ -83,8 +83,8 @@ namespace psemek::util template auto reversed(Range const & r) { - auto it1 = begin(r); - auto it2 = end(r); + auto it1 = xbegin(r); + auto it2 = xend(r); using ReverseIterator = std::reverse_iterator; return range{std::make_reverse_iterator(it2), std::make_reverse_iterator(it1)}; From e5d356e1fc8ac26f5b5c4c53ca94ee8d33885cb8 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 13:52:38 +0300 Subject: [PATCH 03/13] Remove Boost.Math from COMPONENTS when finding boost in config mode --- libs/util/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/util/CMakeLists.txt b/libs/util/CMakeLists.txt index 9a0ec058..a900afa6 100644 --- a/libs/util/CMakeLists.txt +++ b/libs/util/CMakeLists.txt @@ -1,4 +1,6 @@ -find_package(Boost COMPONENTS math REQUIRED CONFIG) +# Boost.Math is header-only +# Required for statistics.hpp +find_package(Boost REQUIRED CONFIG) file(GLOB_RECURSE PSEMEK_UTIL_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/*.hpp") file(GLOB_RECURSE PSEMEK_UTIL_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "source/*.cpp") From 0cc148f6532d6cdb933cf0d0ff80800faad97ecd Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 14:38:24 +0300 Subject: [PATCH 04/13] Fix missing include in math/detail/array.hpp --- libs/math/include/psemek/math/detail/array.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/math/include/psemek/math/detail/array.hpp b/libs/math/include/psemek/math/detail/array.hpp index 73a7704e..2b5c15a8 100644 --- a/libs/math/include/psemek/math/detail/array.hpp +++ b/libs/math/include/psemek/math/detail/array.hpp @@ -3,6 +3,8 @@ #include #include +#include + namespace psemek::math::detail { From 5a6975b3f47ad1b0077c2493ebf755088ee2f62e Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 14:39:12 +0300 Subject: [PATCH 05/13] Fix subobject initialization in math/detail/array_2d.hpp --- libs/math/include/psemek/math/detail/array_2d.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/math/include/psemek/math/detail/array_2d.hpp b/libs/math/include/psemek/math/detail/array_2d.hpp index 98f0075f..1d53c32a 100644 --- a/libs/math/include/psemek/math/detail/array_2d.hpp +++ b/libs/math/include/psemek/math/detail/array_2d.hpp @@ -67,7 +67,7 @@ namespace psemek::math::detail : rows(dimensions.rows.size) {} - dynamic_dimensions_2d dimensions() const { return {.rows = rows}; } + dynamic_dimensions_2d dimensions() const { return {.rows = {rows}}; } T const * operator[](std::size_t) const { throw empty_array_exception{}; } T * operator[](std::size_t) { throw empty_array_exception{}; } @@ -103,7 +103,7 @@ namespace psemek::math::detail : columns(dimensions.columns.size) {} - dynamic_dimensions_2d<0, dynamic> dimensions() const { return {.columns = columns}; } + dynamic_dimensions_2d<0, dynamic> dimensions() const { return {.columns = {columns}}; } T const * operator[](std::size_t) const { throw empty_array_exception{}; } T * operator[](std::size_t) { throw empty_array_exception{}; } @@ -141,7 +141,7 @@ namespace psemek::math::detail , data(std::make_unique_for_overwrite(rows * columns)) {} - dynamic_dimensions_2d dimensions() const { return {.columns = columns}; } + dynamic_dimensions_2d dimensions() const { return {.columns = {columns}}; } T * operator[] (std::size_t row) { @@ -178,7 +178,7 @@ namespace psemek::math::detail , data(std::make_unique_for_overwrite(rows * columns)) {} - dynamic_dimensions_2d dimensions() const { return {.rows = rows}; } + dynamic_dimensions_2d dimensions() const { return {.rows = {rows}}; } T * operator[] (std::size_t row) { @@ -216,7 +216,7 @@ namespace psemek::math::detail , data(std::make_unique_for_overwrite(rows * columns)) {} - dynamic_dimensions_2d dimensions() const { return {.rows = rows, .columns = columns}; } + dynamic_dimensions_2d dimensions() const { return {.rows = {rows}, .columns = {columns}}; } T * operator[] (std::size_t row) { From 99978c3241fdd3719c88bd42e5219a45439a6936 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 14:40:08 +0300 Subject: [PATCH 06/13] Add util::mutexed --- libs/util/include/psemek/util/mutexed.hpp | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 libs/util/include/psemek/util/mutexed.hpp diff --git a/libs/util/include/psemek/util/mutexed.hpp b/libs/util/include/psemek/util/mutexed.hpp new file mode 100644 index 00000000..9427518e --- /dev/null +++ b/libs/util/include/psemek/util/mutexed.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +namespace psemek::util +{ + + template + struct mutexed + { + mutexed() = default; + + mutexed(mutexed const &) = delete; + mutexed(mutexed &&) = delete; + + mutexed & operator = (mutexed const &) = delete; + mutexed & operator = (mutexed &&) = delete; + + mutexed(T && value) + : value_(std::move(value)) + {} + + template + mutexed(std::in_place_t, Args && ... args) + : value_(std::forward(args)...) + {} + + T load() const + { + std::lock_guard lock{mutex_}; + return value_; + } + + void store(T && new_value) + { + std::lock_guard lock{mutex_}; + value_ = std::move(new_value); + } + + T exchange(T && new_value) const + { + std::lock_guard lock{mutex_}; + std::swap(value_, new_value); + return new_value; + } + + private: + T value_; + mutable Mutex mutex_; + }; + +} From a9094975bea34fe28ffabd6c494ceeaabc457f3b Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 14:40:47 +0300 Subject: [PATCH 07/13] Use util::mutexed in audio::channel if atomic_ptr is not supported --- libs/audio/include/psemek/audio/channel.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/audio/include/psemek/audio/channel.hpp b/libs/audio/include/psemek/audio/channel.hpp index 75081f07..c82f6e40 100644 --- a/libs/audio/include/psemek/audio/channel.hpp +++ b/libs/audio/include/psemek/audio/channel.hpp @@ -1,8 +1,14 @@ #pragma once -#include +#include + +#include +#ifdef __cpp_lib_atomic_shared_ptr + #include +#else + #include +#endif -#include #include namespace psemek::audio @@ -37,7 +43,11 @@ namespace psemek::audio } private: - std::atomic stream_; + #ifdef __cpp_lib_atomic_shared_ptr + std::atomic stream_; + #else + util::mutexed stream_; + #endif }; using channel_ptr = std::shared_ptr; From c0a60cbdc8da859c23a08a704ad10039e03ef5e6 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:27:02 +0300 Subject: [PATCH 08/13] Remove unused boost/stacktrace include --- libs/log/source/log.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/log/source/log.cpp b/libs/log/source/log.cpp index 582f8341..9b271072 100644 --- a/libs/log/source/log.cpp +++ b/libs/log/source/log.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include From f251b1b07f163589a29483f42f15127ec8ddfa7a Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:27:15 +0300 Subject: [PATCH 09/13] Fix util::mutexed::exchange --- libs/util/include/psemek/util/mutexed.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/util/include/psemek/util/mutexed.hpp b/libs/util/include/psemek/util/mutexed.hpp index 9427518e..da0373b2 100644 --- a/libs/util/include/psemek/util/mutexed.hpp +++ b/libs/util/include/psemek/util/mutexed.hpp @@ -38,7 +38,7 @@ namespace psemek::util value_ = std::move(new_value); } - T exchange(T && new_value) const + T exchange(T && new_value) { std::lock_guard lock{mutex_}; std::swap(value_, new_value); From e3030416cec7b28e55123f457d7606bca6d5dbf3 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:27:28 +0300 Subject: [PATCH 10/13] Replace sprintf with snprintf in stb_image_write.h --- libs/gfx/include/psemek/gfx/detail/stb_image_write.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gfx/include/psemek/gfx/detail/stb_image_write.h b/libs/gfx/include/psemek/gfx/detail/stb_image_write.h index e4b32ed1..151eacaa 100644 --- a/libs/gfx/include/psemek/gfx/detail/stb_image_write.h +++ b/libs/gfx/include/psemek/gfx/detail/stb_image_write.h @@ -773,7 +773,7 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f #ifdef __STDC_LIB_EXT1__ len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else - len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); + len = snprintf(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); From 44d4deca222fd6175304f1b2615a874f08e29642 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:28:24 +0300 Subject: [PATCH 11/13] Use system_clock in event journal time printing --- libs/journal/source/event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/journal/source/event.cpp b/libs/journal/source/event.cpp index 4ebc68c6..62d43b17 100644 --- a/libs/journal/source/event.cpp +++ b/libs/journal/source/event.cpp @@ -8,7 +8,7 @@ namespace psemek::journal std::string current_time() { - const auto now = std::chrono::high_resolution_clock::now(); + const auto now = std::chrono::system_clock::now(); return std::format("{:%FT%TZ}", now); } From cd87a325d064f708daf81d2e0cf6bd046f196ef7 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:28:47 +0300 Subject: [PATCH 12/13] Remove template operator<< for dummy stacktrace in util::exception --- libs/util/include/psemek/util/exception.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/util/include/psemek/util/exception.hpp b/libs/util/include/psemek/util/exception.hpp index 48ada36c..8890529c 100644 --- a/libs/util/include/psemek/util/exception.hpp +++ b/libs/util/include/psemek/util/exception.hpp @@ -16,8 +16,7 @@ namespace psemek::util #else struct stacktrace { - template - friend Stream & operator << (Stream & stream, stacktrace) + friend std::ostream & operator << (std::ostream & stream, stacktrace) { stream << "(stacktrace disabled)\n"; return stream; From 940c2bb07e7b4edb301385953fe1dbd44b3ffc48 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 30 Jun 2026 15:29:00 +0300 Subject: [PATCH 13/13] Only use --whole-archive on android --- package/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package/CMakeLists.txt b/package/CMakeLists.txt index b3b510a0..940fc5a3 100644 --- a/package/CMakeLists.txt +++ b/package/CMakeLists.txt @@ -49,9 +49,13 @@ function(psemek_add_executable_impl target is_application) target_link_libraries(${target} PUBLIC psemek) if(${is_application}) - target_link_libraries(${target} PUBLIC - "-Wl,--whole-archive $ -Wl,--no-whole-archive" - ${PSEMEK_BACKEND_LIBRARY}) + if(ANDROID) + target_link_libraries(${target} PUBLIC + "-Wl,--whole-archive $ -Wl,--no-whole-archive" + ${PSEMEK_BACKEND_LIBRARY}) + else() + target_link_libraries(${target} PUBLIC ${PSEMEK_BACKEND_LIBRARY}) + endif() endif() install(TARGETS ${target})