Skip to content

Commit

Permalink
macos-14
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Apr 2, 2024
1 parent c9dbeff commit 7df0c09
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 35 deletions.
44 changes: 39 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
cmake --version
git --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
${{ matrix.compiler.cc }} --version
${{ matrix.compiler.cxx }} --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
clang++ --version
git --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion externals/jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sources/include/cage-core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ namespace cage
GCHL_GENERATE(bool, 5);
#undef GCHL_GENERATE

// stupid macos
CAGE_FORCE_INLINE StringizerBase<N> &operator+(std::size_t other) requires(!std::is_same_v<uint64, std::size_t>) { return *this + uint64(other); }

// allow to use l-value-reference operator overloads with r-value-reference Stringizer
template<class T>
CAGE_FORCE_INLINE constexpr StringizerBase<N> &operator+(const T &other) &&
Expand Down
53 changes: 30 additions & 23 deletions sources/include/cage-core/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ namespace cage
GCHL_GENERATE(float);
GCHL_GENERATE(double);
#undef GCHL_GENERATE

// stupid macos
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
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;

Expand Down Expand Up @@ -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; \
}
Expand All @@ -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; \
}
Expand All @@ -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; \
}
Expand Down
3 changes: 2 additions & 1 deletion sources/libcore/filesystem/realFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#endif
#ifdef CAGE_SYSTEM_MAC
#include <mach-o/dyld.h>
#include <cstring>
#endif

#include "files.h"
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions sources/libcore/network/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
11 changes: 9 additions & 2 deletions sources/libcore/network/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@
#include "../incWin.h"
#include <winsock2.h>
#include <ws2tcpip.h>

typedef char raw_type;
#define POLLRDHUP 0
#undef POLLPRI // WSAPoll rejects POLLPRI with an error
#define POLLPRI 0
#undef near
#undef far

#else

#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

typedef void raw_type;
typedef int SOCKET;
#define WSAGetLastError() errno
Expand All @@ -38,6 +39,12 @@ typedef int SOCKET;

#endif

#ifdef CAGE_SYSTEM_MAC
#ifndef POLLRDHUP
#define POLLRDHUP 0x2000
#endif
#endif

#include <cage-core/debug.h>
#include <cage-core/memoryBuffer.h>
#include <cage-core/networkUtils.h>
Expand Down

0 comments on commit 7df0c09

Please sign in to comment.