diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml new file mode 100644 index 0000000..fc35606 --- /dev/null +++ b/.forgejo/workflows/compile.yaml @@ -0,0 +1,18 @@ +name: Compile Cytoplasm +run-name: Compile Cytoplasm on ${{ forgejo.actor }} +on: [push, pull_request] + +jobs: + "Compile Cytoplasm": + strategy: + matrix: + os: [alpine] + arch: [aarch64] + runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Configure Cytoplasm + run: ./configure + - name: Build Cytoplasm + run: make diff --git a/.gitea/workflows/compile.yaml b/.gitea/workflows/compile.yaml deleted file mode 100644 index 1185758..0000000 --- a/.gitea/workflows/compile.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Compile Cytoplasm -run-name: Compile Cytoplasm on ${{ gitea.actor }} -on: [push] - -jobs: - "Compile Cytoplasm": - strategy: - matrix: - os: [debian-v12.4, alpine-v3.19, openbsd-v7.4, freebsd-v14.0, netbsd-v9.3] - arch: [x86, x86_64] - exclude: - # 32-bit OpenBSD does not behave well in QEMU. Even when using - # QEMU to emulate i386, it utilizes 100% of its CPU core and is - # still extremely sluggish. Thus, we don't have a working 32-bit - # OpenBSD runner, so exclude it from the matrix configuration. - - os: openbsd-v7.4 - arch: x86 - runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] - steps: - - name: Check out repository - uses: actions/checkout@v3 - - name: Configure Cytoplasm - run: ./configure - - name: Build Cytoplasm - run: make diff --git a/configure b/configure index 38e2145..1593fd5 100755 --- a/configure +++ b/configure @@ -37,7 +37,7 @@ case "$(uname)" in # These systems typically use GCC. SCRIPT_ARGS="${SCRIPT_ARGS} --cc=gcc" ;; - OpenBSD|FreeBSD) + OpenBSD|FreeBSD|Darwin) # These systems typically use Clang. SCRIPT_ARGS="${SCRIPT_ARGS} --cc=clang" ;; diff --git a/include/Cytoplasm/Platform.h b/include/Cytoplasm/Platform.h new file mode 100644 index 0000000..c18e7d7 --- /dev/null +++ b/include/Cytoplasm/Platform.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2022-2024 Jordan Bancino <@jordan:bancino.net> + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef CYTOPLASM_PLATFORM_H +#define CYTOPLASM_PLATFORM_H + +/*** + * @Nm Platform + * @Nd A simple macro header that determines what platform the application + * is being built for. + * @Dd September 21, 2024 + */ + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) + #define PLATFORM_WINDOWS + + #ifdef _WIN64 + #define PLATFORM_WIN64 + #else + #define PLATFORM_WIN32 + #endif +#elif __APPLE__ + #define PLATFORM_DARWIN + + #include + #if TARGET_IPHONE_SIMULATOR + #define PLATFORM_IPHONE + #elif TARGET_OS_MACCATALYST + #define PLATFORM_CATALYST + #elif TARGET_OS_IPHONE + #define PLATFORM_IPHONE + #elif TARGET_OS_MAC + #define PLATFORM_MAC + #else + # error "Unknown Apple platform" + #endif +#elif __ANDROID__ + #define PLATFORM_ANDROID +#elif __linux__ + #define PLATFORM_LINUX +#elif __unix__ + #define PLATFORM_UNIX +#elif defined(_POSIX_VERSION) + #define PLATFORM_POSIX +#else +# error "Unknown compiler" +#endif + +#endif /* CYTOPLASM_PLATFORM_H */ diff --git a/src/Util.c b/src/Util.c index 962ff0b..e01ae4f 100644 --- a/src/Util.c +++ b/src/Util.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -89,6 +90,10 @@ UtilTsMillis(void) return ts; } +#ifdef PLATFORM_DARWIN +#define st_mtim st_mtimespec +#endif + uint64_t UtilLastModified(char *path) { @@ -105,6 +110,10 @@ UtilLastModified(char *path) return ts; } +#ifdef PLATFORM_DARWIN +#undef st_mtim +#endif + int UtilMkdir(const char *dir, const mode_t mode) {