Skip to content

Commit 7846c1d

Browse files
committed
Try run on apple silicon.
1 parent f3cfd9a commit 7846c1d

File tree

4 files changed

+528
-263
lines changed

4 files changed

+528
-263
lines changed

.github/workflows/cmake.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
os: [ubuntu-latest, windows-latest, macOS-latest]
13+
os: [ubuntu-latest, windows-latest, macos-11, macos-14]
1414
type: [Debug, RelWithDebInfo, MinSizeRel, Release]
15-
compiler: [default, clang, gcc]
15+
compiler: [default, clang, gcc, tcc]
1616
exclude:
17-
- {os: "macOS-latest", compiler: "clang"}
18-
- {os: "windows-latest", compiler: "gcc"}
19-
- {os: "macOS-latest", compiler: "gcc"}
17+
- {os: "macos-11", compiler: "clang"}
18+
- {os: "macos-11", compiler: "gcc"}
19+
- {os: "macos-11", compiler: "tcc"}
20+
- {os: "macos-14", compiler: "clang"}
21+
- {os: "macos-14", compiler: "gcc"}
22+
- {os: "macos-14", compiler: "tcc"}
2023
- {os: "ubuntu-latest", compiler: "default"}
2124
- {os: "ubuntu-latest", compiler: "default"}
25+
- {os: "windows-latest", compiler: "gcc"}
26+
- {os: "windows-latest", compiler: "tcc"}
2227
runs-on: ${{ matrix.os }}
2328

2429
steps:
@@ -29,7 +34,7 @@ jobs:
2934

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

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

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

hashmap.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,26 @@
8181
#pragma clang diagnostic push
8282
#pragma clang diagnostic ignored "-Wunused-function"
8383
#pragma clang diagnostic ignored "-Wstatic-in-inline"
84+
85+
#if __has_warning("-Wunsafe-buffer-usage")
86+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
87+
#endif
88+
#endif
89+
90+
#if defined(__TINYC__)
91+
#define HASHMAP_ATTRIBUTE(a) __attribute((a))
92+
#else
93+
#define HASHMAP_ATTRIBUTE(a) __attribute__((a))
8494
#endif
8595

8696
#if defined(_MSC_VER)
8797
#define HASHMAP_WEAK __inline
88-
#elif defined(__clang__) || defined(__GNUC__)
89-
#define HASHMAP_WEAK __attribute__((weak))
98+
#elif defined(__MINGW32__) || defined(__MINGW64__)
99+
#define HASHMAP_WEAK static HASHMAP_ATTRIBUTE(used)
100+
#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__)
101+
#define HASHMAP_WEAK HASHMAP_ATTRIBUTE(weak)
90102
#else
91-
#error Non clang, non gcc, non MSVC compiler found!
103+
#error Non clang, non gcc, non MSVC, non tcc compiler found!
92104
#endif
93105

94106
#if defined(_MSC_VER)
@@ -701,7 +713,14 @@ HASHMAP_ALWAYS_INLINE hashmap_uint32_t hashmap_clz(const hashmap_uint32_t x) {
701713
#if defined(_MSC_VER)
702714
unsigned long result;
703715
_BitScanReverse(&result, x);
704-
return 31 - HASHMAP_CAST(hashmap_uint32_t, result);
716+
return 31u - HASHMAP_CAST(hashmap_uint32_t, result);
717+
#elif defined(__TINYC__)
718+
union {
719+
double d;
720+
hashmap_uint64_t u;
721+
} u;
722+
u.d = HASHMAP_CAST(double, x) + 0.5;
723+
return 1054u - HASHMAP_CAST(hashmap_uint32_t, u.u >> 52);
705724
#else
706725
return HASHMAP_CAST(hashmap_uint32_t, __builtin_clz(x));
707726
#endif

test/test.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#define NOEXCEPT
1515
#endif
1616

17+
#if defined(__clang__)
18+
#if __has_warning("-Wunsafe-buffer-usage")
19+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
20+
#endif
21+
#endif
22+
1723
#include <string.h>
1824

1925
MY_TEST_WRAPPER(create) {

0 commit comments

Comments
 (0)