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/tables.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/tables.h')
| -rw-r--r-- | src/solvers/tables.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index b7a1079..3db1d1e 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | STATIC uint64_t read_unaligned_u64( | 1 | STATIC uint64_t read_unaligned_u64( |
| 2 | const unsigned char [static sizeof(uint64_t)]); | 2 | const unsigned char [SIZE(sizeof(uint64_t))]); |
| 3 | STATIC void write_unaligned_u64( | 3 | STATIC void write_unaligned_u64( |
| 4 | unsigned char [static sizeof(uint64_t)], uint64_t); | 4 | unsigned char [SIZE(sizeof(uint64_t))], uint64_t); |
| 5 | STATIC int64_t readtableinfo( | 5 | STATIC int64_t readtableinfo( |
| 6 | size_t, const unsigned char *, tableinfo_t [static 1]); | 6 | size_t, const unsigned char *, tableinfo_t [NON_NULL]); |
| 7 | STATIC int64_t readtableinfo_n( | 7 | STATIC int64_t readtableinfo_n( |
| 8 | size_t, const unsigned char *, uint8_t, tableinfo_t [static 1]); | 8 | size_t, const unsigned char *, uint8_t, tableinfo_t [NON_NULL]); |
| 9 | STATIC int64_t writetableinfo( | 9 | STATIC int64_t writetableinfo( |
| 10 | const tableinfo_t [static 1], size_t, unsigned char *); | 10 | const tableinfo_t [NON_NULL], size_t, unsigned char *); |
| 11 | STATIC void append_name(tableinfo_t [static 1], const char *); | 11 | STATIC void append_name(tableinfo_t [NON_NULL], const char *); |
| 12 | 12 | ||
| 13 | STATIC uint64_t | 13 | STATIC uint64_t |
| 14 | read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) | 14 | read_unaligned_u64(const unsigned char buf[SIZE(sizeof(uint64_t))]) |
| 15 | { | 15 | { |
| 16 | uint64_t ret; | 16 | uint64_t ret; |
| 17 | 17 | ||
| @@ -21,7 +21,7 @@ read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | STATIC void | 23 | STATIC void |
| 24 | write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) | 24 | write_unaligned_u64(unsigned char buf[SIZE(sizeof(uint64_t))], uint64_t x) |
| 25 | { | 25 | { |
| 26 | memcpy(buf, &x, sizeof(uint64_t)); | 26 | memcpy(buf, &x, sizeof(uint64_t)); |
| 27 | } | 27 | } |
| @@ -30,7 +30,7 @@ STATIC int64_t | |||
| 30 | readtableinfo( | 30 | readtableinfo( |
| 31 | size_t buf_size, | 31 | size_t buf_size, |
| 32 | const unsigned char *buf, | 32 | const unsigned char *buf, |
| 33 | tableinfo_t info[static 1] | 33 | tableinfo_t info[NON_NULL] |
| 34 | ) | 34 | ) |
| 35 | { | 35 | { |
| 36 | size_t i; | 36 | size_t i; |
| @@ -75,7 +75,7 @@ readtableinfo_n( | |||
| 75 | size_t buf_size, | 75 | size_t buf_size, |
| 76 | const unsigned char *buf, | 76 | const unsigned char *buf, |
| 77 | uint8_t n, | 77 | uint8_t n, |
| 78 | tableinfo_t info[static 1] | 78 | tableinfo_t info[NON_NULL] |
| 79 | ) | 79 | ) |
| 80 | { | 80 | { |
| 81 | int64_t ret; | 81 | int64_t ret; |
| @@ -89,7 +89,7 @@ readtableinfo_n( | |||
| 89 | 89 | ||
| 90 | STATIC int64_t | 90 | STATIC int64_t |
| 91 | writetableinfo( | 91 | writetableinfo( |
| 92 | const tableinfo_t info[static 1], | 92 | const tableinfo_t info[NON_NULL], |
| 93 | size_t data_size, | 93 | size_t data_size, |
| 94 | unsigned char *buf | 94 | unsigned char *buf |
| 95 | ) | 95 | ) |
| @@ -138,9 +138,9 @@ writetableinfo( | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | STATIC void | 140 | STATIC void |
| 141 | append_name(tableinfo_t info[static 1], const char *str) | 141 | append_name(tableinfo_t info[NON_NULL], const char *str) |
| 142 | { | 142 | { |
| 143 | int i, j; | 143 | size_t i, j; |
| 144 | 144 | ||
| 145 | for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) | 145 | for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) |
| 146 | info->solver[j] = str[i]; | 146 | info->solver[j] = str[i]; |
