From 7df0c09d3f943ab68cbe8d3179de4b1df164e16d Mon Sep 17 00:00:00 2001 From: Tomas Maly Date: Tue, 2 Apr 2024 03:43:04 +0200 Subject: [PATCH] macos-14 --- .github/workflows/tests.yml | 44 +++++++++++++++++--- externals/jpeg/CMakeLists.txt | 2 +- sources/include/cage-core/core.h | 3 ++ sources/include/cage-core/math.h | 53 ++++++++++++++---------- sources/libcore/filesystem/realFiles.cpp | 3 +- sources/libcore/network/net.cpp | 12 ++++-- sources/libcore/network/net.h | 11 ++++- 7 files changed, 93 insertions(+), 35 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2a1bf11e..64331fa1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: cmake --version git --version - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -106,7 +106,7 @@ jobs: ${{ matrix.compiler.cc }} --version ${{ matrix.compiler.cxx }} --version - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -191,7 +191,7 @@ jobs: clang++ --version git --version - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -228,7 +228,7 @@ jobs: sudo apt-get update sudo apt-get install -y xorg-dev nasm libssl-dev clang-15 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -275,7 +275,7 @@ jobs: sudo apt-get update sudo apt-get install -y xorg-dev nasm valgrind libssl-dev g++-13 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -295,3 +295,37 @@ jobs: cd build/result/relwithdebinfo valgrind ${{ matrix.options.flags }} --tool=${{ matrix.options.tool }} ./cage-test-core + + Macos: + name: macos-${{ matrix.os-version }}-${{ matrix.build-config }} + runs-on: macos-${{ matrix.os-version }} + strategy: + fail-fast: false + matrix: + os-version: [14] + build-config: [debug, release] + + - name: Versions + run: | + cmake --version + git --version + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure + run: | + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} .. + + - name: Build + run: | + cd build + cmake --build . -- -j3 + + - name: Tests + run: | + cd build/result/${{ matrix.build-config }} + ./cage-test-core diff --git a/externals/jpeg/CMakeLists.txt b/externals/jpeg/CMakeLists.txt index f4b3333e..1ef14c2a 100644 --- a/externals/jpeg/CMakeLists.txt +++ b/externals/jpeg/CMakeLists.txt @@ -6,7 +6,7 @@ message(STATUS "---------------------------------------------------------------- include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/jpeg") -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT APPLE) if(WIN32) set(CMAKE_ASM_NASM_COMPILER "${CMAKE_CURRENT_SOURCE_DIR}/yasm/win64/bin/yasm.exe" CACHE INTERNAL "" FORCE) set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DWIN64 -D__x86_64__ -D\"EXTN(name)=name\"") # target_compile_definitions does not work with nasm diff --git a/sources/include/cage-core/core.h b/sources/include/cage-core/core.h index ea2ed2e5..e7ab3b49 100644 --- a/sources/include/cage-core/core.h +++ b/sources/include/cage-core/core.h @@ -625,6 +625,9 @@ namespace cage GCHL_GENERATE(bool, 5); #undef GCHL_GENERATE + // stupid macos + CAGE_FORCE_INLINE StringizerBase &operator+(std::size_t other) requires(!std::is_same_v) { return *this + uint64(other); } + // allow to use l-value-reference operator overloads with r-value-reference Stringizer template CAGE_FORCE_INLINE constexpr StringizerBase &operator+(const T &other) && diff --git a/sources/include/cage-core/math.h b/sources/include/cage-core/math.h index e424bf2c..35ecf116 100644 --- a/sources/include/cage-core/math.h +++ b/sources/include/cage-core/math.h @@ -25,6 +25,13 @@ namespace cage GCHL_GENERATE(float); GCHL_GENERATE(double); #undef GCHL_GENERATE + + // stupid macos + template + requires(!std::is_same_v) + CAGE_FORCE_INLINE constexpr Real(std::size_t other) noexcept : value((value_type)other) + {} + explicit constexpr Real(Rads other) noexcept; explicit constexpr Real(Degs other) noexcept; @@ -635,71 +642,71 @@ namespace cage CAGE_CORE_API Transform operator+(Vec3 l, Transform r) noexcept; #define GCHL_GENERATE(OPERATOR) \ - CAGE_FORCE_INLINE constexpr Real &operator OPERATOR##=(Real &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Real &operator OPERATOR##=(Real & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads &l, Rads r) noexcept \ + CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads & l, Rads r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs &l, Degs r) noexcept \ + CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs & l, Degs r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 &l, Vec2 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 & l, Vec2 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 &l, Vec3 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 & l, Vec3 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 &l, Vec4 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 & l, Vec4 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i &l, Vec2i r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i & l, Vec2i r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i &l, sint32 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i & l, sint32 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i &l, Vec3i r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i & l, Vec3i r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i &l, sint32 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i & l, sint32 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i &l, Vec4i r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i & l, Vec4i r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i &l, sint32 r) noexcept \ + CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i & l, sint32 r) noexcept \ { \ return l = l OPERATOR r; \ } @@ -710,11 +717,11 @@ namespace cage GCHL_GENERATE(%); #undef GCHL_GENERATE #define GCHL_GENERATE(OPERATOR) \ - CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat &l, Quat r) noexcept \ + CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat & l, Quat r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } @@ -724,19 +731,19 @@ namespace cage GCHL_GENERATE(/); #undef GCHL_GENERATE #define GCHL_GENERATE(OPERATOR) \ - CAGE_FORCE_INLINE Mat3 &operator OPERATOR##=(Mat3 &l, Mat3 r) noexcept \ + CAGE_FORCE_INLINE Mat3 &operator OPERATOR##=(Mat3 & l, Mat3 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE Mat4 &operator OPERATOR##=(Mat4 &l, Mat4 r) noexcept \ + CAGE_FORCE_INLINE Mat4 &operator OPERATOR##=(Mat4 & l, Mat4 r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Mat3 &operator OPERATOR##=(Mat3 &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Mat3 &operator OPERATOR##=(Mat3 & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } \ - CAGE_FORCE_INLINE constexpr Mat4 &operator OPERATOR##=(Mat4 &l, Real r) noexcept \ + CAGE_FORCE_INLINE constexpr Mat4 &operator OPERATOR##=(Mat4 & l, Real r) noexcept \ { \ return l = l OPERATOR r; \ } diff --git a/sources/libcore/filesystem/realFiles.cpp b/sources/libcore/filesystem/realFiles.cpp index d58c8b19..6e6d89bd 100644 --- a/sources/libcore/filesystem/realFiles.cpp +++ b/sources/libcore/filesystem/realFiles.cpp @@ -12,6 +12,7 @@ #endif #ifdef CAGE_SYSTEM_MAC #include + #include #endif #include "files.h" @@ -668,7 +669,7 @@ namespace cage uint32 len = sizeof(buffer); if (_NSGetExecutablePath(buffer, &len) != 0) CAGE_THROW_ERROR(Exception, "_NSGetExecutablePath"); - len = detail::strlen(buffer); + len = std::strlen(buffer); return pathSimplify(String({ buffer, buffer + len })); #else #error This operating system is not supported diff --git a/sources/libcore/network/net.cpp b/sources/libcore/network/net.cpp index ea06a129..170b37e5 100644 --- a/sources/libcore/network/net.cpp +++ b/sources/libcore/network/net.cpp @@ -243,12 +243,18 @@ namespace cage Sock::Sock(int family, int type, int protocol) : family(family), type(type), protocol(protocol) { networkInitialize(); - // SOCK_CLOEXEC -> close the socket on exec #ifdef CAGE_SYSTEM_WINDOWS descriptor = socket(family, type, protocol); -#else +#elif defined(CAGE_SYSTEM_LINUX) + // SOCK_CLOEXEC -> close the socket on exec descriptor = socket(family, type | SOCK_CLOEXEC, protocol); -#endif // CAGE_SYSTEM_WINDOWS +#elif defined(CAGE_SYSTEM_MAC) + descriptor = socket(family, type, protocol); + // FD_CLOEXEC -> close the socket on exec + fcntl(descriptor, F_SETFD, FD_CLOEXEC); +#else + #error This operating system is not supported +#endif if (descriptor == INVALID_SOCKET) CAGE_THROW_ERROR(SystemError, "socket creation failed (socket)", WSAGetLastError()); } diff --git a/sources/libcore/network/net.h b/sources/libcore/network/net.h index db8c1ea6..0d44c49a 100644 --- a/sources/libcore/network/net.h +++ b/sources/libcore/network/net.h @@ -8,17 +8,17 @@ #include "../incWin.h" #include #include + typedef char raw_type; #define POLLRDHUP 0 #undef POLLPRI // WSAPoll rejects POLLPRI with an error #define POLLPRI 0 - #undef near - #undef far #else #include #include + #include #include #include #include @@ -26,6 +26,7 @@ typedef char raw_type; #include #include #include + typedef void raw_type; typedef int SOCKET; #define WSAGetLastError() errno @@ -38,6 +39,12 @@ typedef int SOCKET; #endif +#ifdef CAGE_SYSTEM_MAC + #ifndef POLLRDHUP + #define POLLRDHUP 0x2000 + #endif +#endif + #include #include #include