diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-17 17:36:16 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-17 17:36:16 +0100 |
| commit | ec9593e2ff0856d78b37df3a977a753be82bfddc (patch) | |
| tree | 684dad42207f48125db40ce0afb32046cdba1726 /tools | |
| parent | ac3a91f4f173e7a38c70d5cd0caf5a025642312b (diff) | |
| download | nissy-core-ec9593e2ff0856d78b37df3a977a753be82bfddc.tar.gz nissy-core-ec9593e2ff0856d78b37df3a977a753be82bfddc.zip | |
Fix alignment
Diffstat (limited to '')
| -rw-r--r-- | tools/tool.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/tool.h b/tools/tool.h index c6fafbc..96e7f27 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -8,6 +8,13 @@ | |||
| 8 | 8 | ||
| 9 | #include "../src/nissy.h" | 9 | #include "../src/nissy.h" |
| 10 | 10 | ||
| 11 | #if defined(_WIN32) | ||
| 12 | #define wrap_aligned_alloc(align, size) malloc(size) | ||
| 13 | #else | ||
| 14 | #define wrap_aligned_alloc(align, size) \ | ||
| 15 | (((size) % (align) == 0) ? aligned_alloc((align), (size)) : malloc(size)) | ||
| 16 | #endif | ||
| 17 | |||
| 11 | static void log_stderr(const char *, void *); | 18 | static void log_stderr(const char *, void *); |
| 12 | static double timerun(void (*)(void)); | 19 | static double timerun(void (*)(void)); |
| 13 | static void writetable(const unsigned char *, int64_t, const char *); | 20 | static void writetable(const unsigned char *, int64_t, const char *); |
| @@ -117,7 +124,7 @@ generatetable( | |||
| 117 | return -1; | 124 | return -1; |
| 118 | } | 125 | } |
| 119 | 126 | ||
| 120 | *buf = malloc(size); | 127 | *buf = wrap_aligned_alloc((size_t)64, size); |
| 121 | gensize = nissy_gendata(solver, size, *buf); | 128 | gensize = nissy_gendata(solver, size, *buf); |
| 122 | 129 | ||
| 123 | if (gensize != size) { | 130 | if (gensize != size) { |
| @@ -156,7 +163,7 @@ getdata( | |||
| 156 | } else { | 163 | } else { |
| 157 | printf("Reading tables from file %s\n", filename); | 164 | printf("Reading tables from file %s\n", filename); |
| 158 | size = nissy_solverinfo(solver, dataid); | 165 | size = nissy_solverinfo(solver, dataid); |
| 159 | *buf = malloc(size); | 166 | *buf = wrap_aligned_alloc((size_t)64, size); |
| 160 | sizeread = fread(*buf, size, 1, f); | 167 | sizeread = fread(*buf, size, 1, f); |
| 161 | fclose(f); | 168 | fclose(f); |
| 162 | if (sizeread != 1) { | 169 | if (sizeread != 1) { |
