aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/gendata_h48.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/gendata_h48.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/gendata_h48.h')
-rw-r--r--src/solvers/h48/gendata_h48.h36
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 @@
1STATIC long long gendata_h48_dispatch( 1STATIC long long gendata_h48_dispatch(
2 const char *, unsigned long long, unsigned char *); 2 const char *, unsigned long long, unsigned char *);
3STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); 3STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]);
4STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); 4STATIC int64_t gendata_h48(gendata_h48_arg_t [NON_NULL]);
5STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); 5STATIC void gendata_h48_maintable(gendata_h48_arg_t [NON_NULL]);
6STATIC wrapthread_return_t gendata_h48_runthread(void *); 6STATIC wrapthread_return_t gendata_h48_runthread(void *);
7 7
8STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); 8STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [NON_NULL]);
9STATIC_INLINE bool gendata_h48_dfs_stop( 9STATIC_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]);
11STATIC void gendata_h48_dfs(h48_dfs_arg_t [static 1]); 11STATIC void gendata_h48_dfs(h48_dfs_arg_t [NON_NULL]);
12STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [static 1]); 12STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [NON_NULL]);
13 13
14STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); 14STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *);
15STATIC const unsigned char *get_h48data_constptr(const unsigned char *); 15STATIC 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);
19STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); 19STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t);
20STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); 20STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t);
21STATIC_INLINE uint8_t get_h48_pval_and_min( 21STATIC_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
24STATIC long long 24STATIC long long
25gendata_h48_dispatch( 25gendata_h48_dispatch(
@@ -43,7 +43,7 @@ gendata_h48_dispatch(
43} 43}
44 44
45STATIC uint64_t 45STATIC uint64_t
46gendata_h48short(gendata_h48short_arg_t arg[static 1]) 46gendata_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
79STATIC int64_t 79STATIC int64_t
80gendata_h48(gendata_h48_arg_t arg[static 1]) 80gendata_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
151STATIC void 151STATIC void
152gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) 152gendata_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
334STATIC void 334STATIC void
335gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) 335gendata_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
413STATIC_INLINE void 413STATIC_INLINE void
414gendata_h48_mark(gendata_h48_mark_t arg[static 1]) 414gendata_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
437STATIC_INLINE bool 437STATIC_INLINE bool
438gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) 438gendata_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
465STATIC tableinfo_t 465STATIC tableinfo_t
466makeinfo_h48(gendata_h48_arg_t arg[static 1]) 466makeinfo_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
533get_h48_pval_and_min( 533get_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;

Generated with cgit - Back to sebastiano.tronto.net