diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-28 17:47:49 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-28 17:47:49 +0200 |
| commit | 3429b552bc4367136f015c182f723ee977bb55a3 (patch) | |
| tree | 06e3aa276bccdbc5fa57f4679438d95a7808f1e1 | |
| parent | 954a9f9100e8f30e0303a3815c4104526aceb4a0 (diff) | |
| download | nissy-core-3429b552bc4367136f015c182f723ee977bb55a3.tar.gz nissy-core-3429b552bc4367136f015c182f723ee977bb55a3.zip | |
Solved alignment UB issue
Diffstat (limited to '')
| -rw-r--r-- | src/solvers/tables.h | 50 | ||||
| -rw-r--r-- | test/090_tables_readwrite/tables_readwrite_tests.c | 6 | ||||
| -rw-r--r-- | test/100_gendata_cocsep/gendata_cocsep_tests.c | 6 | ||||
| -rw-r--r-- | test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | 6 |
4 files changed, 36 insertions, 32 deletions
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index bad3b2c..a668988 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -7,34 +7,34 @@ | |||
| 7 | #define TABLETYPE_PRUNING 0 | 7 | #define TABLETYPE_PRUNING 0 |
| 8 | #define TABLETYPE_SPECIAL 1 | 8 | #define TABLETYPE_SPECIAL 1 |
| 9 | 9 | ||
| 10 | #define INFO_OFFSET_SOLVER 0 | 10 | #define INFO_OFFSET_DISTRIBUTION 0 |
| 11 | #define INFO_OFFSET_TYPE INFO_SOLVER_STRLEN | 11 | #define INFO_OFFSET_TYPE (INFO_DISTRIBUTION_LEN * sizeof(uint64_t)) |
| 12 | #define INFO_OFFSET_INFOSIZE (INFO_OFFSET_TYPE + sizeof(uint64_t)) | 12 | #define INFO_OFFSET_INFOSIZE (INFO_OFFSET_TYPE + sizeof(uint64_t)) |
| 13 | #define INFO_OFFSET_FULLSIZE (INFO_OFFSET_INFOSIZE + sizeof(uint64_t)) | 13 | #define INFO_OFFSET_FULLSIZE (INFO_OFFSET_INFOSIZE + sizeof(uint64_t)) |
| 14 | #define INFO_OFFSET_HASH (INFO_OFFSET_FULLSIZE + sizeof(uint64_t)) | 14 | #define INFO_OFFSET_HASH (INFO_OFFSET_FULLSIZE + sizeof(uint64_t)) |
| 15 | #define INFO_OFFSET_ENTRIES (INFO_OFFSET_HASH + sizeof(uint64_t)) | 15 | #define INFO_OFFSET_ENTRIES (INFO_OFFSET_HASH + sizeof(uint64_t)) |
| 16 | #define INFO_OFFSET_CLASSES (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) | 16 | #define INFO_OFFSET_CLASSES (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) |
| 17 | #define INFO_OFFSET_H48H (INFO_OFFSET_CLASSES + sizeof(uint64_t)) | 17 | #define INFO_OFFSET_NEXT (INFO_OFFSET_CLASSES + sizeof(uint64_t)) |
| 18 | #define INFO_OFFSET_SOLVER (INFO_OFFSET_NEXT + sizeof(uint64_t)) | ||
| 19 | #define INFO_OFFSET_H48H (INFO_OFFSET_SOLVER + INFO_SOLVER_STRLEN) | ||
| 18 | #define INFO_OFFSET_BITS (INFO_OFFSET_H48H + sizeof(uint8_t)) | 20 | #define INFO_OFFSET_BITS (INFO_OFFSET_H48H + sizeof(uint8_t)) |
| 19 | #define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) | 21 | #define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) |
| 20 | #define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) | 22 | #define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) |
| 21 | #define INFO_OFFSET_NEXT (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) | ||
| 22 | #define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_NEXT + sizeof(uint64_t)) | ||
| 23 | 23 | ||
| 24 | typedef struct { | 24 | typedef struct { |
| 25 | char solver[INFO_SOLVER_STRLEN]; | 25 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 26 | uint64_t type; | 26 | uint64_t type; |
| 27 | uint64_t infosize; | 27 | uint64_t infosize; |
| 28 | uint64_t fullsize; | 28 | uint64_t fullsize; |
| 29 | uint64_t hash; | 29 | uint64_t hash; |
| 30 | uint64_t entries; | 30 | uint64_t entries; |
| 31 | uint64_t classes; /* Used only by cocsepdata, for now */ | 31 | uint64_t classes; /* Used only by cocsepdata, for now */ |
| 32 | uint64_t next; | ||
| 33 | char solver[INFO_SOLVER_STRLEN]; | ||
| 32 | uint8_t h48h; /* Specific to H48 tables */ | 34 | uint8_t h48h; /* Specific to H48 tables */ |
| 33 | uint8_t bits; | 35 | uint8_t bits; |
| 34 | uint8_t base; | 36 | uint8_t base; |
| 35 | uint8_t maxvalue; | 37 | uint8_t maxvalue; |
| 36 | uint64_t next; | ||
| 37 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 38 | } tableinfo_t; | 38 | } tableinfo_t; |
| 39 | 39 | ||
| 40 | STATIC bool readtableinfo(const void *, tableinfo_t *); | 40 | STATIC bool readtableinfo(const void *, tableinfo_t *); |
| @@ -54,21 +54,24 @@ readtableinfo(const void *buf, tableinfo_t *info) | |||
| 54 | return false; | 54 | return false; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | memcpy(info->solver, OFFSET(buf, INFO_OFFSET_SOLVER), | 57 | memcpy(info->distribution, OFFSET(buf, INFO_OFFSET_DISTRIBUTION), |
| 58 | INFO_SOLVER_STRLEN); | 58 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); |
| 59 | |||
| 59 | info->type = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_TYPE); | 60 | info->type = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_TYPE); |
| 60 | info->infosize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_INFOSIZE); | 61 | info->infosize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_INFOSIZE); |
| 61 | info->fullsize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE); | 62 | info->fullsize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE); |
| 62 | info->hash = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_HASH); | 63 | info->hash = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_HASH); |
| 63 | info->entries = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES); | 64 | info->entries = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES); |
| 64 | info->classes = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES); | 65 | info->classes = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES); |
| 66 | info->next = *(const uint64_t* )OFFSET(buf, INFO_OFFSET_NEXT); | ||
| 67 | |||
| 68 | memcpy(info->solver, OFFSET(buf, INFO_OFFSET_SOLVER), | ||
| 69 | INFO_SOLVER_STRLEN); | ||
| 70 | |||
| 65 | info->h48h = *OFFSET(buf, INFO_OFFSET_H48H); | 71 | info->h48h = *OFFSET(buf, INFO_OFFSET_H48H); |
| 66 | info->bits = *OFFSET(buf, INFO_OFFSET_BITS); | 72 | info->bits = *OFFSET(buf, INFO_OFFSET_BITS); |
| 67 | info->base = *OFFSET(buf, INFO_OFFSET_BASE); | 73 | info->base = *OFFSET(buf, INFO_OFFSET_BASE); |
| 68 | info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); | 74 | info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); |
| 69 | info->next = *(const uint64_t* )OFFSET(buf, INFO_OFFSET_NEXT); | ||
| 70 | memcpy(info->distribution, OFFSET(buf, INFO_OFFSET_DISTRIBUTION), | ||
| 71 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 72 | 75 | ||
| 73 | return true; | 76 | return true; |
| 74 | } | 77 | } |
| @@ -98,6 +101,17 @@ writetableinfo(const tableinfo_t *info, void *buf) | |||
| 98 | return false; | 101 | return false; |
| 99 | } | 102 | } |
| 100 | 103 | ||
| 104 | memcpy(OFFSET(buf, INFO_OFFSET_DISTRIBUTION), info->distribution, | ||
| 105 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 106 | |||
| 107 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_TYPE) = info->type; | ||
| 108 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_INFOSIZE) = info->infosize; | ||
| 109 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE) = info->fullsize; | ||
| 110 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_HASH) = info->hash; | ||
| 111 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES) = info->entries; | ||
| 112 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES) = info->classes; | ||
| 113 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_NEXT) = info->next; | ||
| 114 | |||
| 101 | memcpy(OFFSET(buf, INFO_OFFSET_SOLVER), info->solver, | 115 | memcpy(OFFSET(buf, INFO_OFFSET_SOLVER), info->solver, |
| 102 | INFO_SOLVER_STRLEN); | 116 | INFO_SOLVER_STRLEN); |
| 103 | 117 | ||
| @@ -106,20 +120,10 @@ writetableinfo(const tableinfo_t *info, void *buf) | |||
| 106 | if (*OFFSET(buf, i) == 0) | 120 | if (*OFFSET(buf, i) == 0) |
| 107 | *OFFSET(buf, i) = 0; | 121 | *OFFSET(buf, i) = 0; |
| 108 | 122 | ||
| 109 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_TYPE) = info->type; | ||
| 110 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_INFOSIZE) = info->infosize; | ||
| 111 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE) = info->fullsize; | ||
| 112 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_HASH) = info->hash; | ||
| 113 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES) = info->entries; | ||
| 114 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES) = info->classes; | ||
| 115 | *OFFSET(buf, INFO_OFFSET_H48H) = info->h48h; | 123 | *OFFSET(buf, INFO_OFFSET_H48H) = info->h48h; |
| 116 | *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; | 124 | *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; |
| 117 | *OFFSET(buf, INFO_OFFSET_BASE) = info->base; | 125 | *OFFSET(buf, INFO_OFFSET_BASE) = info->base; |
| 118 | *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; | 126 | *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; |
| 119 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_NEXT) = info->next; | ||
| 120 | |||
| 121 | memcpy(OFFSET(buf, INFO_OFFSET_DISTRIBUTION), info->distribution, | ||
| 122 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 123 | 127 | ||
| 124 | return true; | 128 | return true; |
| 125 | } | 129 | } |
diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c index e1c2015..73c4e21 100644 --- a/test/090_tables_readwrite/tables_readwrite_tests.c +++ b/test/090_tables_readwrite/tables_readwrite_tests.c | |||
| @@ -5,19 +5,19 @@ | |||
| 5 | #define INFO_DISTRIBUTION_LEN 21 | 5 | #define INFO_DISTRIBUTION_LEN 21 |
| 6 | 6 | ||
| 7 | typedef struct { | 7 | typedef struct { |
| 8 | char solver[INFO_SOLVER_STRLEN]; | 8 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 9 | uint64_t type; | 9 | uint64_t type; |
| 10 | uint64_t infosize; | 10 | uint64_t infosize; |
| 11 | uint64_t fullsize; | 11 | uint64_t fullsize; |
| 12 | uint64_t hash; | 12 | uint64_t hash; |
| 13 | uint64_t entries; | 13 | uint64_t entries; |
| 14 | uint64_t classes; | 14 | uint64_t classes; |
| 15 | uint64_t next; | ||
| 16 | char solver[INFO_SOLVER_STRLEN]; | ||
| 15 | uint8_t h48h; | 17 | uint8_t h48h; |
| 16 | uint8_t bits; | 18 | uint8_t bits; |
| 17 | uint8_t base; | 19 | uint8_t base; |
| 18 | uint8_t maxvalue; | 20 | uint8_t maxvalue; |
| 19 | uint64_t next; | ||
| 20 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 21 | } tableinfo_t; | 21 | } tableinfo_t; |
| 22 | 22 | ||
| 23 | bool readtableinfo(const void *, tableinfo_t *); | 23 | bool readtableinfo(const void *, tableinfo_t *); |
diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index 7630a71..62f52fb 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c | |||
| @@ -6,19 +6,19 @@ | |||
| 6 | #define COCSEP_CLASSES 3393 | 6 | #define COCSEP_CLASSES 3393 |
| 7 | 7 | ||
| 8 | typedef struct { | 8 | typedef struct { |
| 9 | char solver[INFO_SOLVER_STRLEN]; | 9 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 10 | uint64_t type; | 10 | uint64_t type; |
| 11 | uint64_t infosize; | 11 | uint64_t infosize; |
| 12 | uint64_t fullsize; | 12 | uint64_t fullsize; |
| 13 | uint64_t hash; | 13 | uint64_t hash; |
| 14 | uint64_t entries; | 14 | uint64_t entries; |
| 15 | uint64_t classes; /* Used only by cocsepdata, for now */ | 15 | uint64_t classes; /* Used only by cocsepdata, for now */ |
| 16 | uint64_t next; | ||
| 17 | char solver[INFO_SOLVER_STRLEN]; | ||
| 16 | uint8_t h48h; | 18 | uint8_t h48h; |
| 17 | uint8_t bits; | 19 | uint8_t bits; |
| 18 | uint8_t base; | 20 | uint8_t base; |
| 19 | uint8_t maxvalue; | 21 | uint8_t maxvalue; |
| 20 | uint64_t next; | ||
| 21 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 22 | } tableinfo_t; | 22 | } tableinfo_t; |
| 23 | 23 | ||
| 24 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 24 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
diff --git a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c index c37de3e..7c5b441 100644 --- a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c +++ b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | |||
| @@ -6,19 +6,19 @@ | |||
| 6 | #define INFO_DISTRIBUTION_LEN 21 | 6 | #define INFO_DISTRIBUTION_LEN 21 |
| 7 | 7 | ||
| 8 | typedef struct { | 8 | typedef struct { |
| 9 | char solver[INFO_SOLVER_STRLEN]; | 9 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 10 | uint64_t type; | 10 | uint64_t type; |
| 11 | uint64_t infosize; | 11 | uint64_t infosize; |
| 12 | uint64_t fullsize; | 12 | uint64_t fullsize; |
| 13 | uint64_t hash; | 13 | uint64_t hash; |
| 14 | uint64_t entries; | 14 | uint64_t entries; |
| 15 | uint64_t classes; /* Used only by cocsepdata, for now */ | 15 | uint64_t classes; /* Used only by cocsepdata, for now */ |
| 16 | uint64_t next; | ||
| 17 | char solver[INFO_SOLVER_STRLEN]; | ||
| 16 | uint8_t h48h; | 18 | uint8_t h48h; |
| 17 | uint8_t bits; | 19 | uint8_t bits; |
| 18 | uint8_t base; | 20 | uint8_t base; |
| 19 | uint8_t maxvalue; | 21 | uint8_t maxvalue; |
| 20 | uint64_t next; | ||
| 21 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 22 | } tableinfo_t; | 22 | } tableinfo_t; |
| 23 | 23 | ||
| 24 | typedef struct { | 24 | typedef struct { |
