aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/map.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
commitfc41f7917531693680b5baf71ffe38c47333fe84 (patch)
treea6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/h48/map.h
parentfe534f1497da6447153064d7bba00243000f803b (diff)
downloadnissy-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.h28
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 @@
1STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); 1STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t);
2STATIC void h48map_clear(h48map_t [static 1]); 2STATIC void h48map_clear(h48map_t [NON_NULL]);
3STATIC void h48map_destroy(h48map_t [static 1]); 3STATIC void h48map_destroy(h48map_t [NON_NULL]);
4STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); 4STATIC uint64_t h48map_lookup(h48map_t [NON_NULL], uint64_t);
5STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); 5STATIC void h48map_insertmin(h48map_t [NON_NULL], uint64_t, uint64_t);
6STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); 6STATIC uint64_t h48map_value(h48map_t [NON_NULL], uint64_t);
7STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); 7STATIC kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]);
8 8
9STATIC void 9STATIC void
10h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) 10h48map_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
19STATIC void 19STATIC void
20h48map_clear(h48map_t map[static 1]) 20h48map_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
26STATIC void 26STATIC void
27h48map_destroy(h48map_t map[static 1]) 27h48map_destroy(h48map_t map[NON_NULL])
28{ 28{
29 free(map->table); 29 free(map->table);
30} 30}
31 31
32STATIC_INLINE uint64_t 32STATIC_INLINE uint64_t
33h48map_lookup(h48map_t map[static 1], uint64_t x) 33h48map_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
46STATIC_INLINE void 46STATIC_INLINE void
47h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) 47h48map_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
59STATIC_INLINE uint64_t 59STATIC_INLINE uint64_t
60h48map_value(h48map_t map[static 1], uint64_t key) 60h48map_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
65STATIC kvpair_t 65STATIC kvpair_t
66h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) 66h48map_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;

Generated with cgit - Back to sebastiano.tronto.net