diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
| commit | fc41f7917531693680b5baf71ffe38c47333fe84 (patch) | |
| tree | a6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/h48/map.h | |
| parent | fe534f1497da6447153064d7bba00243000f803b (diff) | |
| download | nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.tar.gz nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.zip | |
Make the project build with Microsoft's broken C compiler.
MSVC is not fully C11-compliant, even when compiling with /std:c11.
Some changes were needed to make the codebase compatible. Notably, the
notation a[static N] and a[n] for function parameters of array type is
not supported, so that had to be hidden behind a macro. Atomic types
are also an experimental feature, apparently, but at least they work
with the correct compiler flag.
One thing that MSVC does well, however, is warning on integer conversions
on /W4 level. I am not sure if Clang and GCC have something similar,
so I took this chance to fix some of these.
Diffstat (limited to 'src/solvers/h48/map.h')
| -rw-r--r-- | src/solvers/h48/map.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index b603ee3..c9cfb06 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); | 1 | STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 2 | STATIC void h48map_clear(h48map_t [static 1]); | 2 | STATIC void h48map_clear(h48map_t [NON_NULL]); |
| 3 | STATIC void h48map_destroy(h48map_t [static 1]); | 3 | STATIC void h48map_destroy(h48map_t [NON_NULL]); |
| 4 | STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); | 4 | STATIC uint64_t h48map_lookup(h48map_t [NON_NULL], uint64_t); |
| 5 | STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); | 5 | STATIC void h48map_insertmin(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 6 | STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); | 6 | STATIC uint64_t h48map_value(h48map_t [NON_NULL], uint64_t); |
| 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); | 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]); |
| 8 | 8 | ||
| 9 | STATIC void | 9 | STATIC void |
| 10 | h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) | 10 | h48map_create(h48map_t map[NON_NULL], uint64_t capacity, uint64_t randomizer) |
| 11 | { | 11 | { |
| 12 | map->capacity = capacity; | 12 | map->capacity = capacity; |
| 13 | map->randomizer = randomizer; | 13 | map->randomizer = randomizer; |
| @@ -17,20 +17,20 @@ h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | STATIC void | 19 | STATIC void |
| 20 | h48map_clear(h48map_t map[static 1]) | 20 | h48map_clear(h48map_t map[NON_NULL]) |
| 21 | { | 21 | { |
| 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); | 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); |
| 23 | map->n = 0; | 23 | map->n = 0; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | STATIC void | 26 | STATIC void |
| 27 | h48map_destroy(h48map_t map[static 1]) | 27 | h48map_destroy(h48map_t map[NON_NULL]) |
| 28 | { | 28 | { |
| 29 | free(map->table); | 29 | free(map->table); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | STATIC_INLINE uint64_t | 32 | STATIC_INLINE uint64_t |
| 33 | h48map_lookup(h48map_t map[static 1], uint64_t x) | 33 | h48map_lookup(h48map_t map[NON_NULL], uint64_t x) |
| 34 | { | 34 | { |
| 35 | uint64_t hash, i; | 35 | uint64_t hash, i; |
| 36 | 36 | ||
| @@ -44,7 +44,7 @@ h48map_lookup(h48map_t map[static 1], uint64_t x) | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | STATIC_INLINE void | 46 | STATIC_INLINE void |
| 47 | h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) | 47 | h48map_insertmin(h48map_t map[NON_NULL], uint64_t key, uint64_t val) |
| 48 | { | 48 | { |
| 49 | uint64_t i, oldval, min; | 49 | uint64_t i, oldval, min; |
| 50 | 50 | ||
| @@ -57,13 +57,13 @@ h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | STATIC_INLINE uint64_t | 59 | STATIC_INLINE uint64_t |
| 60 | h48map_value(h48map_t map[static 1], uint64_t key) | 60 | h48map_value(h48map_t map[NON_NULL], uint64_t key) |
| 61 | { | 61 | { |
| 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; | 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | STATIC kvpair_t | 65 | STATIC kvpair_t |
| 66 | h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) | 66 | h48map_nextkvpair(h48map_t map[NON_NULL], uint64_t p[NON_NULL]) |
| 67 | { | 67 | { |
| 68 | kvpair_t kv; | 68 | kvpair_t kv; |
| 69 | uint64_t pair; | 69 | uint64_t pair; |
