diff options
| author | eunhhu <[email protected]> | 2026-10-01 18:19:14 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-01 18:19:14 +0100 |
| commit | 8450156e98ee49484f3fadad791d5684f9576f8b (patch) | |
| tree | f49de4bdf2dd7d45e2c3da097243ff9391ef59bb /core | |
| parent | 1c378188e66ed9a14a3f1053ea7385ddcbe8db27 (diff) | |
| download | pure-8450156e98ee49484f3fadad791d5684f9576f8b.tar.gz pure-8450156e98ee49484f3fadad791d5684f9576f8b.zip | |
Build with clang, and the core and store on macOS, again
Apple clang 21 (an M3) and clang 19 refused what gcc let pass (research
029):
- PURE_FIELD_REST was an enum of UINT32_MAX, past an int (C17): a macro.
- a store's publish copied an entry rebuild left unset when the record
was not found (the copy was never used): copied when it was made.
- the log's image writer kept a count only Linux's sync_file_range uses.
- ",{" + (row == from) read as adding an int to a string: said plainly.
- the tests: mkdtemp, hidden by _POSIX_C_SOURCE on macOS, needs
_DARWIN_C_SOURCE; a string split so that \x80 and a stay apart is
bracketed; a count left over and a malloc measure only glibc has.
The core's and the store's tests pass on the Mac.
Diffstat (limited to 'core')
| -rw-r--r-- | core/module.h | 2 | ||||
| -rw-r--r-- | core/test-module.c | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/module.h b/core/module.h index 2cc3109..162a8b1 100644 --- a/core/module.h +++ b/core/module.h @@ -113,7 +113,7 @@ enum { PURE_TIMER_LONGEST = 86400000, PURE_SOURCE = 64 }; * they are not whole. */ typedef enum { PURE_FIELD_U32 = 1, PURE_FIELD_BYTES = 2, PURE_FIELD_NUMBER = 3, PURE_FIELD_TEXT = 4, PURE_FIELD_ROWS = 5, PURE_FIELD_BOOL = 6, PURE_FIELD_I64 = 7 } PureFieldType; -enum { PURE_FIELD_REST = UINT32_MAX }; +#define PURE_FIELD_REST UINT32_MAX /* a macro: an enum's values are ints (C17) */ /* A field held in its payload's prefix (a u32, a number, a bool, an i64), and the bytes it takes there. */ static inline bool pure_field_fixed(uint8_t type) { return type == PURE_FIELD_U32 || type == PURE_FIELD_NUMBER || type == PURE_FIELD_BOOL || type == PURE_FIELD_I64; diff --git a/core/test-module.c b/core/test-module.c index 46da5f1..c91bd2c 100644 --- a/core/test-module.c +++ b/core/test-module.c @@ -1,4 +1,7 @@ #define _POSIX_C_SOURCE 200809L +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE /* mkdtemp, which _POSIX_C_SOURCE hides there */ +#endif #include "module.h" #include "module-save.h" #include "module-store.h" @@ -781,7 +784,8 @@ enum { CUL = PURE_OP_CUR_LOAD, CS = PURE_OP_CUR_STORE, CM = PURE_OP_CUR_MOVE, TI static void texts(void) { static const S nums[] = {{"edits", 0}}; static const T textual[] = {{"note", 1, 0}, {"at", 2, 1}, {"title", 1, 1}}; - static const char *const constants[] = {"\xea\xb0\x80" "a\nbc", "\xeb\xa9\x94\xeb\xaa\xa8", "XYZ", + static const char *const constants[] = {("\xea\xb0\x80" "a\nbc"), /* apart: \x80a would be one escape */ + "\xeb\xa9\x94\xeb\xaa\xa8", "XYZ", " \xc2\xb7 ", "\xec\x9e\x90"}; static const I inputs[] = { {"typed", NULL, PURE_KIND_TEXT, false, NULL, 0}, KEY("left", "ArrowLeft"), KEY("right", "ArrowRight"), @@ -1113,7 +1117,7 @@ static void list_trees(void) { PureList *copies[SHARES]; Model shared[SHARES] = {{0}}; PureRetired retired[SHARES + 1] = {{0}}; - unsigned first = 0, held = 0, splits_seen = 0; + unsigned first = 0, held = 0; uint64_t epoch = 0; /* the copies', one after another */ size_t largest = 0, events = 0, undone = 0; for (unsigned event = 0; event < 6000; ++event) { @@ -1159,7 +1163,6 @@ static void list_trees(void) { pure_undo_commit(&undo); ++events; largest = model.count > largest ? model.count : largest; - splits_seen += model.count > 32; if (event % 7 == 0) CHECK(same_items(list, &model)); /* A save every few events: its records after the stored ones, or now * and then the items stored whole with none after them. */ @@ -1488,7 +1491,7 @@ static void list_mutations(void) { for (size_t at = 0; at < pure_list_count(app.lists[s]); ++at) for (unsigned f = 0; f < record->count; ++f) { PureCell cell = pure_list_get(app.lists[s], at, f); - if ((module_b.record_field_type[record->first + f] == PURE_RECORD_TEXT)) + if (module_b.record_field_type[record->first + f] == PURE_RECORD_TEXT) CHECK(pure_utf8_valid((PureSpan){cell.text, cell.size})); else CHECK(isfinite(cell.num)); } @@ -3823,7 +3826,9 @@ static void snapshot_held(Spec spec, void (*event)(PureApp *, uint32_t *)) { CHECK(held); Shown before = {was, 0, sizeof(was)}, shown = {shown_text, 0, sizeof(shown_text)}; describe(&app, &before); +#ifdef __GLIBC__ size_t used[3] = {0, 0, 0}; +#endif for (unsigned half = 0; half < 2; ++half) { #ifdef __GLIBC__ used[half] = mallinfo2().uordblks; |
