diff options
| author | enricotenuti <tenutz_27@outlook.it> | 2024-09-29 12:42:31 +0200 |
|---|---|---|
| committer | enricotenuti <tenutz_27@outlook.it> | 2024-09-29 12:42:31 +0200 |
| commit | 7a52b4cd50a40e4bce919b6bd51203d0e9867141 (patch) | |
| tree | 95ab133f9771c4791d5c784f1b3d4822b1dd7d3c /src/solvers | |
| parent | 8fcfb3a33fe053ed2032d58ecc0b5d640c155931 (diff) | |
| parent | 774a824a6c80b5af495f4fb99d98758e3b9f6b81 (diff) | |
| download | nissy-core-7a52b4cd50a40e4bce919b6bd51203d0e9867141.tar.gz nissy-core-7a52b4cd50a40e4bce919b6bd51203d0e9867141.zip | |
Merge remote-tracking branch 'upstream/master'
Merge upstream
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 12 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 120 | ||||
| -rw-r--r-- | src/solvers/tables.h | 50 |
3 files changed, 150 insertions, 32 deletions
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index 2189145..262793b 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -25,6 +25,7 @@ STATIC_INLINE void set_visited(uint8_t *, int64_t); | |||
| 25 | 25 | ||
| 26 | STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 26 | STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 27 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); | 27 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); |
| 28 | STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]); | ||
| 28 | 29 | ||
| 29 | STATIC_INLINE int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); | 30 | STATIC_INLINE int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); |
| 30 | 31 | ||
| @@ -157,6 +158,17 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg) | |||
| 157 | return cc; | 158 | return cc; |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 161 | STATIC void | ||
| 162 | getdistribution_cocsep(const uint32_t *table, uint64_t distr[static 21]) | ||
| 163 | { | ||
| 164 | size_t i; | ||
| 165 | |||
| 166 | memset(distr, 0, 21 * sizeof(uint64_t)); | ||
| 167 | |||
| 168 | for (i = 0; i < COCSEP_TABLESIZE; i++) | ||
| 169 | distr[CBOUND(table[i])]++; | ||
| 170 | } | ||
| 171 | |||
| 160 | STATIC_INLINE bool | 172 | STATIC_INLINE bool |
| 161 | get_visited(const uint8_t *a, int64_t i) | 173 | get_visited(const uint8_t *a, int64_t i) |
| 162 | { | 174 | { |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 3445570..75b7abf 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -103,14 +103,19 @@ STATIC_INLINE bool gendata_h48k2_dfs_stop(cube_t, int8_t, h48k2_dfs_arg_t *); | |||
| 103 | STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *); | 103 | STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *); |
| 104 | STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); | 104 | STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); |
| 105 | STATIC void * gendata_h48k2_runthread(void *); | 105 | STATIC void * gendata_h48k2_runthread(void *); |
| 106 | STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *, uint8_t); | 106 | STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *); |
| 107 | STATIC void getdistribution_h48(const uint8_t *, | ||
| 108 | uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); | ||
| 107 | 109 | ||
| 108 | STATIC uint32_t *get_cocsepdata_ptr(const void *); | 110 | STATIC uint32_t *get_cocsepdata_ptr(const void *); |
| 109 | STATIC uint8_t *get_h48data_ptr(const void *); | 111 | STATIC uint8_t *get_h48data_ptr(const void *); |
| 110 | 112 | ||
| 111 | STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); | 113 | STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); |
| 112 | STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t); | 114 | STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t); |
| 113 | STATIC_INLINE uint8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint8_t *); | 115 | STATIC_INLINE uint8_t get_h48_bound( |
| 116 | cube_t, uint32_t, uint8_t, uint8_t, uint8_t *); | ||
| 117 | |||
| 118 | size_t gendata_h48_derive(uint8_t, const void *, void *); | ||
| 114 | 119 | ||
| 115 | STATIC uint64_t | 120 | STATIC uint64_t |
| 116 | gendata_h48short(gendata_h48short_arg_t *arg) | 121 | gendata_h48short(gendata_h48short_arg_t *arg) |
| @@ -387,7 +392,7 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 387 | [11] = 10 | 392 | [11] = 10 |
| 388 | }; | 393 | }; |
| 389 | 394 | ||
| 390 | uint8_t t, selectedbase, *table; | 395 | uint8_t t, *table; |
| 391 | int64_t j; | 396 | int64_t j; |
| 392 | uint64_t i, ii, inext, count; | 397 | uint64_t i, ii, inext, count; |
| 393 | h48map_t shortcubes; | 398 | h48map_t shortcubes; |
| @@ -414,8 +419,9 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 414 | }; | 419 | }; |
| 415 | gendata_h48short(&shortarg); | 420 | gendata_h48short(&shortarg); |
| 416 | 421 | ||
| 417 | selectedbase = arg->base < 20 ? arg->base : base[arg->h]; | 422 | if (arg->base >= 20) |
| 418 | arg->info = makeinfo_h48k2(arg, selectedbase); | 423 | arg->base = base[arg->h]; |
| 424 | arg->info = makeinfo_h48k2(arg); | ||
| 419 | 425 | ||
| 420 | inext = count = 0; | 426 | inext = count = 0; |
| 421 | pthread_mutex_init(&shortcubes_mutex, NULL); | 427 | pthread_mutex_init(&shortcubes_mutex, NULL); |
| @@ -425,7 +431,7 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 425 | dfsarg[i] = (h48k2_dfs_arg_t){ | 431 | dfsarg[i] = (h48k2_dfs_arg_t){ |
| 426 | .h = arg->h, | 432 | .h = arg->h, |
| 427 | .k = arg->k, | 433 | .k = arg->k, |
| 428 | .base = selectedbase, | 434 | .base = arg->base, |
| 429 | .shortdepth = shortdepth, | 435 | .shortdepth = shortdepth, |
| 430 | .cocsepdata = arg->cocsepdata, | 436 | .cocsepdata = arg->cocsepdata, |
| 431 | .table = table, | 437 | .table = table, |
| @@ -603,14 +609,17 @@ STATIC_INLINE bool | |||
| 603 | gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) | 609 | gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) |
| 604 | { | 610 | { |
| 605 | uint64_t val; | 611 | uint64_t val; |
| 606 | int64_t coord; | 612 | int64_t coord, mutex; |
| 607 | int8_t oldval; | 613 | int8_t oldval; |
| 608 | 614 | ||
| 609 | if (arg->h == 0 || arg->h == 11) { | 615 | if (arg->h == 0 || arg->h == 11) { |
| 610 | /* We are in the "real coordinate" case, we can stop | 616 | /* We are in the "real coordinate" case, we can stop |
| 611 | if this coordinate has already been visited */ | 617 | if this coordinate has already been visited */ |
| 612 | coord = coord_h48(cube, arg->cocsepdata, arg->h); | 618 | coord = coord_h48(cube, arg->cocsepdata, arg->h); |
| 619 | mutex = H48_INDEX(coord, arg->k) % CHUNKS; | ||
| 620 | pthread_mutex_lock(arg->table_mutex[mutex]); | ||
| 613 | oldval = get_h48_pval(arg->table, coord, arg->k); | 621 | oldval = get_h48_pval(arg->table, coord, arg->k); |
| 622 | pthread_mutex_unlock(arg->table_mutex[mutex]); | ||
| 614 | return oldval <= depth; | 623 | return oldval <= depth; |
| 615 | } else { | 624 | } else { |
| 616 | /* With 0 < k < 11 we do not have a "real coordinate". | 625 | /* With 0 < k < 11 we do not have a "real coordinate". |
| @@ -637,7 +646,7 @@ gendata_h48k2_realcoord_runthread(void *arg) | |||
| 637 | } | 646 | } |
| 638 | 647 | ||
| 639 | STATIC tableinfo_t | 648 | STATIC tableinfo_t |
| 640 | makeinfo_h48k2(gendata_h48_arg_t *arg, uint8_t base) | 649 | makeinfo_h48k2(gendata_h48_arg_t *arg) |
| 641 | { | 650 | { |
| 642 | tableinfo_t info; | 651 | tableinfo_t info; |
| 643 | 652 | ||
| @@ -651,7 +660,7 @@ makeinfo_h48k2(gendata_h48_arg_t *arg, uint8_t base) | |||
| 651 | .classes = 0, | 660 | .classes = 0, |
| 652 | .h48h = arg->h, | 661 | .h48h = arg->h, |
| 653 | .bits = 2, | 662 | .bits = 2, |
| 654 | .base = base, | 663 | .base = arg->base, |
| 655 | .maxvalue = 3, | 664 | .maxvalue = 3, |
| 656 | .next = 0, | 665 | .next = 0, |
| 657 | }; | 666 | }; |
| @@ -662,6 +671,25 @@ makeinfo_h48k2(gendata_h48_arg_t *arg, uint8_t base) | |||
| 662 | return info; | 671 | return info; |
| 663 | } | 672 | } |
| 664 | 673 | ||
| 674 | STATIC void | ||
| 675 | getdistribution_h48( | ||
| 676 | const uint8_t *table, | ||
| 677 | uint64_t distr[static INFO_DISTRIBUTION_LEN], | ||
| 678 | uint8_t h, | ||
| 679 | uint8_t k | ||
| 680 | ) { | ||
| 681 | uint8_t val; | ||
| 682 | int64_t i, h48max; | ||
| 683 | |||
| 684 | memset(distr, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 685 | |||
| 686 | h48max = H48_COORDMAX(h); | ||
| 687 | for (i = 0; i < h48max; i++) { | ||
| 688 | val = get_h48_pval(table, i, k); | ||
| 689 | distr[val]++; | ||
| 690 | } | ||
| 691 | } | ||
| 692 | |||
| 665 | STATIC uint32_t * | 693 | STATIC uint32_t * |
| 666 | get_cocsepdata_ptr(const void *data) | 694 | get_cocsepdata_ptr(const void *data) |
| 667 | { | 695 | { |
| @@ -695,3 +723,77 @@ get_h48_bound(cube_t cube, uint32_t cdata, uint8_t h, uint8_t k, uint8_t *table) | |||
| 695 | coord = coord_h48_edges(cube, COCLASS(cdata), TTREP(cdata), h); | 723 | coord = coord_h48_edges(cube, COCLASS(cdata), TTREP(cdata), h); |
| 696 | return get_h48_pval(table, coord, k); | 724 | return get_h48_pval(table, coord, k); |
| 697 | } | 725 | } |
| 726 | |||
| 727 | size_t | ||
| 728 | gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) | ||
| 729 | { | ||
| 730 | size_t cocsepsize, h48size; | ||
| 731 | uint8_t val_full, val_derive, *h48full, *h48derive; | ||
| 732 | int64_t i, j, h48max; | ||
| 733 | gendata_h48_arg_t arg; | ||
| 734 | tableinfo_t cocsepinfo, fulltableinfo; | ||
| 735 | |||
| 736 | /* Initializing values in case of error */ | ||
| 737 | /* TODO cleanup this */ | ||
| 738 | fulltableinfo.bits = 2; | ||
| 739 | fulltableinfo.base = 8; | ||
| 740 | |||
| 741 | readtableinfo_n(fulltable, 2, &fulltableinfo); | ||
| 742 | arg.h = h; | ||
| 743 | arg.k = fulltableinfo.bits; | ||
| 744 | arg.maxdepth = 20; | ||
| 745 | arg.buf = buf; | ||
| 746 | arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 747 | arg.base = fulltableinfo.base; | ||
| 748 | arg.info = makeinfo_h48k2(&arg); | ||
| 749 | |||
| 750 | /* Technically this step is redundant, except that we | ||
| 751 | need selfsim and crep */ | ||
| 752 | cocsepsize = gendata_cocsep(buf, arg.selfsim, arg.crep); | ||
| 753 | arg.h48buf = (uint8_t *)buf + cocsepsize; | ||
| 754 | h48size = H48_TABLESIZE(h, arg.k) + INFOSIZE; | ||
| 755 | |||
| 756 | if (buf == NULL) | ||
| 757 | goto gendata_h48_derive_return_size; | ||
| 758 | |||
| 759 | if (!readtableinfo(buf, &cocsepinfo)) { | ||
| 760 | LOG("gendata_h48: could not read info for cocsep table\n"); | ||
| 761 | goto gendata_h48_derive_error; | ||
| 762 | } | ||
| 763 | |||
| 764 | cocsepinfo.next = cocsepsize; | ||
| 765 | if (!writetableinfo(&cocsepinfo, buf)) { | ||
| 766 | LOG("gendata_h48_derive: could not write info for cocsep table" | ||
| 767 | " with updated 'next' value\n"); | ||
| 768 | goto gendata_h48_derive_error; | ||
| 769 | } | ||
| 770 | |||
| 771 | h48full = (uint8_t *)fulltable + cocsepsize + INFOSIZE; | ||
| 772 | h48derive = (uint8_t *)arg.h48buf + INFOSIZE; | ||
| 773 | memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); | ||
| 774 | memset(arg.info.distribution, 0, | ||
| 775 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 776 | |||
| 777 | h48max = H48_COORDMAX(fulltableinfo.h48h); | ||
| 778 | for (i = 0; i < h48max; i++) { | ||
| 779 | if (i % INT64_C(1000000000) == 0 && i > 0) | ||
| 780 | LOG("Processing %" PRId64 "th coordinate\n", i); | ||
| 781 | j = i >> (int64_t)(fulltableinfo.h48h - h); | ||
| 782 | val_full = get_h48_pval(h48full, i, arg.k); | ||
| 783 | val_derive = get_h48_pval(h48derive, j, arg.k); | ||
| 784 | set_h48_pval(h48derive, j, arg.k, MIN(val_full, val_derive)); | ||
| 785 | } | ||
| 786 | |||
| 787 | getdistribution_h48(h48derive, arg.info.distribution, h, arg.k); | ||
| 788 | |||
| 789 | if (!writetableinfo(&arg.info, arg.h48buf)) { | ||
| 790 | LOG("gendata_h48_derive: could not write info for table\n"); | ||
| 791 | goto gendata_h48_derive_error; | ||
| 792 | } | ||
| 793 | |||
| 794 | gendata_h48_derive_return_size: | ||
| 795 | return cocsepsize + h48size; | ||
| 796 | |||
| 797 | gendata_h48_derive_error: | ||
| 798 | return 0; | ||
| 799 | } | ||
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 | } |
