diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 09:58:17 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 09:58:17 +0200 |
| commit | 3c8f8c2e60cd089679cf5da5160baaf35977b220 (patch) | |
| tree | 8b49c64260e33c714ccacc2e3a1b27582bdfe4a7 | |
| parent | 16cf844396181e743403b046c06a21f1dca39426 (diff) | |
| download | nissy-core-3c8f8c2e60cd089679cf5da5160baaf35977b220.tar.gz nissy-core-3c8f8c2e60cd089679cf5da5160baaf35977b220.zip | |
Added next table offset to tableinfo
| -rw-r--r-- | src/solvers/tables.h | 6 | ||||
| -rw-r--r-- | test/090_tables_readwrite/00_table.in | 1 | ||||
| -rw-r--r-- | test/090_tables_readwrite/00_table.out | 1 | ||||
| -rw-r--r-- | test/090_tables_readwrite/tables_readwrite_tests.c | 3 |
4 files changed, 10 insertions, 1 deletions
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index be0209f..9598a09 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -9,7 +9,8 @@ | |||
| 9 | #define INFO_OFFSET_BITS (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) | 9 | #define INFO_OFFSET_BITS (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) |
| 10 | #define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) | 10 | #define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) |
| 11 | #define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) | 11 | #define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) |
| 12 | #define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) | 12 | #define INFO_OFFSET_NEXT (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) |
| 13 | #define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_NEXT + sizeof(uint64_t)) | ||
| 13 | #define INFO_DISTRIBUTION_LEN 21 | 14 | #define INFO_DISTRIBUTION_LEN 21 |
| 14 | 15 | ||
| 15 | typedef struct { | 16 | typedef struct { |
| @@ -21,6 +22,7 @@ typedef struct { | |||
| 21 | uint8_t bits; | 22 | uint8_t bits; |
| 22 | uint8_t base; | 23 | uint8_t base; |
| 23 | uint8_t maxvalue; | 24 | uint8_t maxvalue; |
| 25 | uint64_t next; | ||
| 24 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | 26 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 25 | } tableinfo_t; | 27 | } tableinfo_t; |
| 26 | 28 | ||
| @@ -49,6 +51,7 @@ readtableinfo(const void *buf, tableinfo_t *info) | |||
| 49 | info->bits = *OFFSET(buf, INFO_OFFSET_BITS); | 51 | info->bits = *OFFSET(buf, INFO_OFFSET_BITS); |
| 50 | info->base = *OFFSET(buf, INFO_OFFSET_BASE); | 52 | info->base = *OFFSET(buf, INFO_OFFSET_BASE); |
| 51 | info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); | 53 | info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); |
| 54 | info->next = *(const uint64_t* )OFFSET(buf, INFO_OFFSET_NEXT); | ||
| 52 | memcpy(info->distribution, OFFSET(buf, INFO_OFFSET_DISTRIBUTION), | 55 | memcpy(info->distribution, OFFSET(buf, INFO_OFFSET_DISTRIBUTION), |
| 53 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | 56 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); |
| 54 | 57 | ||
| @@ -85,6 +88,7 @@ writetableinfo(const tableinfo_t *info, void *buf) | |||
| 85 | *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; | 88 | *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; |
| 86 | *OFFSET(buf, INFO_OFFSET_BASE) = info->base; | 89 | *OFFSET(buf, INFO_OFFSET_BASE) = info->base; |
| 87 | *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; | 90 | *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; |
| 91 | *(uint64_t *)OFFSET(buf, INFO_OFFSET_NEXT) = info->next; | ||
| 88 | 92 | ||
| 89 | memcpy(OFFSET(buf, INFO_OFFSET_DISTRIBUTION), info->distribution, | 93 | memcpy(OFFSET(buf, INFO_OFFSET_DISTRIBUTION), info->distribution, |
| 90 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | 94 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); |
diff --git a/test/090_tables_readwrite/00_table.in b/test/090_tables_readwrite/00_table.in index 1816242..a35f13a 100644 --- a/test/090_tables_readwrite/00_table.in +++ b/test/090_tables_readwrite/00_table.in | |||
| @@ -7,6 +7,7 @@ Test solver | |||
| 7 | 2 | 7 | 2 |
| 8 | 0 | 8 | 0 |
| 9 | 20 | 9 | 20 |
| 10 | 100000000512 | ||
| 10 | 11 | ||
| 11 | 100 | 12 | 100 |
| 12 | 101 | 13 | 101 |
diff --git a/test/090_tables_readwrite/00_table.out b/test/090_tables_readwrite/00_table.out index 1816242..a35f13a 100644 --- a/test/090_tables_readwrite/00_table.out +++ b/test/090_tables_readwrite/00_table.out | |||
| @@ -7,6 +7,7 @@ Test solver | |||
| 7 | 2 | 7 | 2 |
| 8 | 0 | 8 | 0 |
| 9 | 20 | 9 | 20 |
| 10 | 100000000512 | ||
| 10 | 11 | ||
| 11 | 100 | 12 | 100 |
| 12 | 101 | 13 | 101 |
diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c index 97b8ab7..b062460 100644 --- a/test/090_tables_readwrite/tables_readwrite_tests.c +++ b/test/090_tables_readwrite/tables_readwrite_tests.c | |||
| @@ -13,6 +13,7 @@ typedef struct { | |||
| 13 | uint8_t bits; | 13 | uint8_t bits; |
| 14 | uint8_t base; | 14 | uint8_t base; |
| 15 | uint8_t maxvalue; | 15 | uint8_t maxvalue; |
| 16 | uint64_t next; | ||
| 16 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | 17 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; |
| 17 | } tableinfo_t; | 18 | } tableinfo_t; |
| 18 | 19 | ||
| @@ -45,6 +46,7 @@ tableinfo_t test_readinfo(void) { | |||
| 45 | ret.bits = (uint8_t)readn(); | 46 | ret.bits = (uint8_t)readn(); |
| 46 | ret.base = (uint8_t)readn(); | 47 | ret.base = (uint8_t)readn(); |
| 47 | ret.maxvalue = (uint8_t)readn(); | 48 | ret.maxvalue = (uint8_t)readn(); |
| 49 | ret.next = readn(); | ||
| 48 | 50 | ||
| 49 | fgets(emptyline, 2, stdin); | 51 | fgets(emptyline, 2, stdin); |
| 50 | 52 | ||
| @@ -67,6 +69,7 @@ void test_writeinfo(tableinfo_t info) { | |||
| 67 | printf("%" PRIu8 "\n", info.bits); | 69 | printf("%" PRIu8 "\n", info.bits); |
| 68 | printf("%" PRIu8 "\n", info.base); | 70 | printf("%" PRIu8 "\n", info.base); |
| 69 | printf("%" PRIu8 "\n", info.maxvalue); | 71 | printf("%" PRIu8 "\n", info.maxvalue); |
| 72 | printf("%" PRIu64 "\n", info.next); | ||
| 70 | printf("\n"); | 73 | printf("\n"); |
| 71 | 74 | ||
| 72 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) | 75 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) |
