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/gendata_h48.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/gendata_h48.h')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index b37bcfb..53b1fad 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | STATIC long long gendata_h48_dispatch( | 1 | STATIC long long gendata_h48_dispatch( |
| 2 | const char *, unsigned long long, unsigned char *); | 2 | const char *, unsigned long long, unsigned char *); |
| 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); | 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); |
| 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); | 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [NON_NULL]); |
| 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); | 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [NON_NULL]); |
| 6 | STATIC wrapthread_return_t gendata_h48_runthread(void *); | 6 | STATIC wrapthread_return_t gendata_h48_runthread(void *); |
| 7 | 7 | ||
| 8 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); | 8 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [NON_NULL]); |
| 9 | STATIC_INLINE bool gendata_h48_dfs_stop( | 9 | STATIC_INLINE bool gendata_h48_dfs_stop( |
| 10 | cube_t, int8_t, h48_dfs_arg_t [static 1]); | 10 | cube_t, int8_t, h48_dfs_arg_t [NON_NULL]); |
| 11 | STATIC void gendata_h48_dfs(h48_dfs_arg_t [static 1]); | 11 | STATIC void gendata_h48_dfs(h48_dfs_arg_t [NON_NULL]); |
| 12 | STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [static 1]); | 12 | STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [NON_NULL]); |
| 13 | 13 | ||
| 14 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); | 14 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); |
| 15 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); | 15 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); |
| @@ -19,7 +19,7 @@ STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t); | |||
| 19 | STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); | 19 | STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); |
| 20 | STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); | 20 | STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); |
| 21 | STATIC_INLINE uint8_t get_h48_pval_and_min( | 21 | STATIC_INLINE uint8_t get_h48_pval_and_min( |
| 22 | const unsigned char *, uint64_t, uint8_t [static 1]); | 22 | const unsigned char *, uint64_t, uint8_t [NON_NULL]); |
| 23 | 23 | ||
| 24 | STATIC long long | 24 | STATIC long long |
| 25 | gendata_h48_dispatch( | 25 | gendata_h48_dispatch( |
| @@ -43,7 +43,7 @@ gendata_h48_dispatch( | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | STATIC uint64_t | 45 | STATIC uint64_t |
| 46 | gendata_h48short(gendata_h48short_arg_t arg[static 1]) | 46 | gendata_h48short(gendata_h48short_arg_t arg[NON_NULL]) |
| 47 | { | 47 | { |
| 48 | uint8_t i, m; | 48 | uint8_t i, m; |
| 49 | uint64_t coord; | 49 | uint64_t coord; |
| @@ -77,7 +77,7 @@ gendata_h48short(gendata_h48short_arg_t arg[static 1]) | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | STATIC int64_t | 79 | STATIC int64_t |
| 80 | gendata_h48(gendata_h48_arg_t arg[static 1]) | 80 | gendata_h48(gendata_h48_arg_t arg[NON_NULL]) |
| 81 | { | 81 | { |
| 82 | uint64_t size, cocsepsize, h48size, eoesepsize; | 82 | uint64_t size, cocsepsize, h48size, eoesepsize; |
| 83 | long long r; | 83 | long long r; |
| @@ -149,7 +149,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | STATIC void | 151 | STATIC void |
| 152 | gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) | 152 | gendata_h48_maintable(gendata_h48_arg_t arg[NON_NULL]) |
| 153 | { | 153 | { |
| 154 | /* | 154 | /* |
| 155 | * A good base value for the h48 tables have few positions with value | 155 | * A good base value for the h48 tables have few positions with value |
| @@ -264,7 +264,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) | |||
| 264 | velocity = count; | 264 | velocity = count; |
| 265 | 265 | ||
| 266 | /* We plan to log 10 times */ | 266 | /* We plan to log 10 times */ |
| 267 | sleeptime = (100*(nshort-velocity)) / velocity; | 267 | sleeptime = (int)((100*(nshort-velocity)) / velocity); |
| 268 | 268 | ||
| 269 | done = count; | 269 | done = count; |
| 270 | while (nshort - done > (velocity * sleeptime) / 1000) { | 270 | while (nshort - done > (velocity * sleeptime) / 1000) { |
| @@ -320,7 +320,7 @@ gendata_h48_runthread(void *arg) | |||
| 320 | mutex = H48_LINE(coord) % CHUNKS; | 320 | mutex = H48_LINE(coord) % CHUNKS; |
| 321 | wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); | 321 | wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); |
| 322 | set_h48_pval(dfsarg->table, coordext, 0); | 322 | set_h48_pval(dfsarg->table, coordext, 0); |
| 323 | set_h48_pvalmin(dfsarg->table, coordmin, kv.val); | 323 | set_h48_pvalmin(dfsarg->table, coordmin, (uint8_t)kv.val); |
| 324 | wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); | 324 | wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); |
| 325 | } else { | 325 | } else { |
| 326 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); | 326 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); |
| @@ -332,7 +332,7 @@ gendata_h48_runthread(void *arg) | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | STATIC void | 334 | STATIC void |
| 335 | gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) | 335 | gendata_h48_dfs(h48_dfs_arg_t arg[NON_NULL]) |
| 336 | { | 336 | { |
| 337 | int8_t d; | 337 | int8_t d; |
| 338 | uint8_t m[4]; | 338 | uint8_t m[4]; |
| @@ -411,7 +411,7 @@ gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) | |||
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | STATIC_INLINE void | 413 | STATIC_INLINE void |
| 414 | gendata_h48_mark(gendata_h48_mark_t arg[static 1]) | 414 | gendata_h48_mark(gendata_h48_mark_t arg[NON_NULL]) |
| 415 | { | 415 | { |
| 416 | uint8_t oldval, newval, v; | 416 | uint8_t oldval, newval, v; |
| 417 | uint64_t coord, coordext, coordmin; | 417 | uint64_t coord, coordext, coordmin; |
| @@ -435,7 +435,7 @@ gendata_h48_mark(gendata_h48_mark_t arg[static 1]) | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | STATIC_INLINE bool | 437 | STATIC_INLINE bool |
| 438 | gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) | 438 | gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[NON_NULL]) |
| 439 | { | 439 | { |
| 440 | uint64_t val; | 440 | uint64_t val; |
| 441 | uint64_t coord, coordext; | 441 | uint64_t coord, coordext; |
| @@ -463,7 +463,7 @@ gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) | |||
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | STATIC tableinfo_t | 465 | STATIC tableinfo_t |
| 466 | makeinfo_h48(gendata_h48_arg_t arg[static 1]) | 466 | makeinfo_h48(gendata_h48_arg_t arg[NON_NULL]) |
| 467 | { | 467 | { |
| 468 | tableinfo_t info; | 468 | tableinfo_t info; |
| 469 | 469 | ||
| @@ -533,7 +533,7 @@ STATIC_INLINE uint8_t | |||
| 533 | get_h48_pval_and_min( | 533 | get_h48_pval_and_min( |
| 534 | const unsigned char *table, | 534 | const unsigned char *table, |
| 535 | uint64_t coord_noext, | 535 | uint64_t coord_noext, |
| 536 | uint8_t pval_min[static 1] | 536 | uint8_t pval_min[NON_NULL] |
| 537 | ) | 537 | ) |
| 538 | { | 538 | { |
| 539 | uint64_t iext, imin; | 539 | uint64_t iext, imin; |
