Skip to content

Commit cfdee7c

Browse files
committed
Try run on apple silicon.
1 parent 06aa578 commit cfdee7c

10 files changed

+931
-323
lines changed

.github/workflows/cmake.yml

+18-7
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-10
37+
run: sudo apt-get install -y gcc-10 g++-10 clang tcc
3338

3439
- name: Configure CMake
3540
shell: bash
@@ -43,11 +48,17 @@ 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')
4960
working-directory: ${{github.workspace}}/build
50-
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10
61+
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
5162

5263
- name: Configure CMake with Clang (Windows)
5364
shell: bash

.github/workflows/sanitizers.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Setup dependencies
2727
if: startsWith(matrix.os, 'ubuntu')
28-
run: sudo apt-get install -y clang-10
28+
run: sudo apt-get install -y clang
2929

3030
- name: Configure CMake (macOS)
3131
shell: bash
@@ -37,7 +37,7 @@ jobs:
3737
shell: bash
3838
if: startsWith(matrix.os, 'ubuntu')
3939
working-directory: ${{github.workspace}}/build
40-
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DJSON_USE_SANITIZER=${{ matrix.sanitizer }}
40+
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DJSON_USE_SANITIZER=${{ matrix.sanitizer }}
4141

4242
- name: Build
4343
working-directory: ${{github.workspace}}/build

json.h

+14-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@
5050
#include <stddef.h>
5151
#include <string.h>
5252

53+
#if defined(__TINYC__)
54+
#define JSON_ATTRIBUTE(a) __attribute((a))
55+
#else
56+
#define JSON_ATTRIBUTE(a) __attribute__((a))
57+
#endif
58+
5359
#if defined(_MSC_VER) || defined(__WATCOMC__)
5460
#define json_weak __inline
55-
#elif defined(__clang__) || defined(__GNUC__)
56-
#define json_weak __attribute__((weak))
61+
#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__)
62+
#define json_weak JSON_ATTRIBUTE(weak)
5763
#else
58-
#error Non clang, non gcc, non MSVC, non WATCOM compiler found!
64+
#error Non clang, non gcc, non MSVC, non tcc, non WATCOM compiler found!
5965
#endif
6066

6167
#ifdef __cplusplus
@@ -435,6 +441,11 @@ typedef struct json_parse_result_s {
435441
/* Who cares if nullptr doesn't work with C++98, we don't use it there! */
436442
#pragma clang diagnostic ignored "-Wc++98-compat"
437443
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
444+
445+
#if __has_warning("-Wunsafe-buffer-usage")
446+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
447+
#endif
448+
438449
#elif defined(_MSC_VER)
439450
#pragma warning(push)
440451

test/allocator.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ UTEST(allocator, null) {
8181
struct json_parse_result_s result;
8282
struct json_value_s *value =
8383
json_parse_ex(payload, strlen(payload), 0, &_::alloc, 0, &result);
84-
struct json_object_s *object = 0;
8584

8685
ASSERT_FALSE(value);
8786

test/allow_c_style_comments.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ UTEST_F_TEARDOWN(allow_c_style_comments) {
151151
struct json_value_s *value = utest_fixture->value;
152152
struct json_object_s *object = 0;
153153
struct json_value_s *value2 = 0;
154-
size_t size = 0;
155-
void *json = 0;
156154

157155
ASSERT_TRUE(value);
158156
ASSERT_TRUE(value->payload);

test/allow_equals_in_object.c

-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ UTEST_F_TEARDOWN(allow_equals_in_object) {
317317
struct json_value_s *value = utest_fixture->value;
318318
struct json_object_s *object = 0;
319319
struct json_value_s *value2 = 0;
320-
size_t size = 0;
321-
void *json = 0;
322320

323321
ASSERT_TRUE(value);
324322
ASSERT_TRUE(value->payload);

test/allow_global_object.c

-2
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ UTEST_F_TEARDOWN(allow_global_object) {
345345
struct json_value_s *value = utest_fixture->value;
346346
struct json_object_s *object = 0;
347347
struct json_value_s *value2 = 0;
348-
size_t size = 0;
349-
void *json = 0;
350348

351349
ASSERT_TRUE(value);
352350
ASSERT_TRUE(value->payload);

test/allow_json5.c

-6
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ UTEST(allow_json5, example1) {
5555
"}";
5656
struct json_value_s *value = json_parse_ex(
5757
payload, strlen(payload), json_parse_flags_allow_json5, 0, 0, 0);
58-
struct json_object_s *object = 0;
59-
struct json_value_s *value2 = 0;
60-
struct json_string_s *string = 0;
6158

6259
ASSERT_TRUE(value);
6360

@@ -111,9 +108,6 @@ UTEST(allow_json5, example2) {
111108
"}\n";
112109
struct json_value_s *value = json_parse_ex(
113110
payload, strlen(payload), json_parse_flags_allow_json5, 0, 0, 0);
114-
struct json_object_s *object = 0;
115-
struct json_value_s *value2 = 0;
116-
struct json_string_s *string = 0;
117111

118112
ASSERT_TRUE(value);
119113

test/allow_no_commas.c

-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ UTEST(allow_no_commas, array_one) {
143143
payload, strlen(payload), json_parse_flags_allow_no_commas, 0, 0, 0);
144144
struct json_array_s *array = 0;
145145
struct json_array_element_s *element = 0;
146-
struct json_value_s *value2 = 0;
147146

148147
ASSERT_TRUE(value);
149148
ASSERT_TRUE(value->payload);
@@ -189,7 +188,6 @@ UTEST_F_TEARDOWN(allow_no_commas) {
189188
struct json_value_s *value = utest_fixture->value;
190189
struct json_array_s *array = 0;
191190
struct json_array_element_s *element = 0;
192-
struct json_value_s *value2 = 0;
193191

194192
ASSERT_TRUE(value);
195193
ASSERT_TRUE(value->payload);

0 commit comments

Comments
 (0)