Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try run on apple silicon. #35

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macos-11, macos-14]
type: [Debug, RelWithDebInfo, MinSizeRel, Release]
compiler: [default, clang, gcc]
compiler: [default, clang, gcc, tcc]
exclude:
- {os: "macOS-latest", compiler: "clang"}
- {os: "windows-latest", compiler: "gcc"}
- {os: "macOS-latest", compiler: "gcc"}
- {os: "macos-11", compiler: "clang"}
- {os: "macos-11", compiler: "gcc"}
- {os: "macos-11", compiler: "tcc"}
- {os: "macos-14", compiler: "clang"}
- {os: "macos-14", compiler: "gcc"}
- {os: "macos-14", compiler: "tcc"}
- {os: "ubuntu-latest", compiler: "default"}
- {os: "ubuntu-latest", compiler: "default"}
- {os: "windows-latest", compiler: "gcc"}
- {os: "windows-latest", compiler: "tcc"}
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -29,7 +34,7 @@ jobs:

- name: Setup dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y gcc-10 g++-10 clang
run: sudo apt-get install -y gcc-10 g++-10 clang tcc

- name: Configure CMake
shell: bash
Expand All @@ -43,6 +48,12 @@ jobs:
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10

- name: Configure CMake with TCC (Ubuntu)
shell: bash
if: matrix.compiler == 'tcc' && startsWith(matrix.os, 'ubuntu')
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=tcc -DCMAKE_CXX_COMPILER=g++-10

- name: Configure CMake with Clang (Ubuntu)
shell: bash
if: (matrix.compiler == 'clang') && startsWith(matrix.os, 'ubuntu')
Expand Down
27 changes: 23 additions & 4 deletions hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,26 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wstatic-in-inline"

#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif
#endif

#if defined(__TINYC__)
#define HASHMAP_ATTRIBUTE(a) __attribute((a))
#else
#define HASHMAP_ATTRIBUTE(a) __attribute__((a))
#endif

#if defined(_MSC_VER)
#define HASHMAP_WEAK __inline
#elif defined(__clang__) || defined(__GNUC__)
#define HASHMAP_WEAK __attribute__((weak))
#elif defined(__MINGW32__) || defined(__MINGW64__)
#define HASHMAP_WEAK static HASHMAP_ATTRIBUTE(used)
#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__)
#define HASHMAP_WEAK HASHMAP_ATTRIBUTE(weak)
#else
#error Non clang, non gcc, non MSVC compiler found!
#error Non clang, non gcc, non MSVC, non tcc compiler found!
#endif

#if defined(_MSC_VER)
Expand Down Expand Up @@ -701,7 +713,14 @@ HASHMAP_ALWAYS_INLINE hashmap_uint32_t hashmap_clz(const hashmap_uint32_t x) {
#if defined(_MSC_VER)
unsigned long result;
_BitScanReverse(&result, x);
return 31 - HASHMAP_CAST(hashmap_uint32_t, result);
return 31u - HASHMAP_CAST(hashmap_uint32_t, result);
#elif defined(__TINYC__)
union {
double d;
hashmap_uint64_t u;
} u;
u.d = HASHMAP_CAST(double, x) + 0.5;
return 1054u - HASHMAP_CAST(hashmap_uint32_t, u.u >> 52);
#else
return HASHMAP_CAST(hashmap_uint32_t, __builtin_clz(x));
#endif
Expand Down
6 changes: 6 additions & 0 deletions test/test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#define NOEXCEPT
#endif

#if defined(__clang__)
#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif
#endif

#include <string.h>

MY_TEST_WRAPPER(create) {
Expand Down
Loading
Loading