aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nissy.c73
-rw-r--r--src/nissy.h13
-rw-r--r--src/solvers/h48/gendata_cocsep.h12
-rw-r--r--src/solvers/h48/gendata_h48.h120
-rw-r--r--src/solvers/tables.h50
5 files changed, 234 insertions, 34 deletions
diff --git a/src/nissy.c b/src/nissy.c
index a2da73d..44efb83 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -12,8 +12,11 @@
12 12
13#include "nissy.h" 13#include "nissy.h"
14 14
15STATIC int parse_h48_options(const char *, uint8_t *, uint8_t *, uint8_t *); 15int parse_h48_options(const char *, uint8_t *, uint8_t *, uint8_t *);
16STATIC int64_t write_result(cube_t, char [static 22]); 16STATIC int64_t write_result(cube_t, char [static 22]);
17STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN],
18 const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t);
19STATIC bool checkdata(const void *, const tableinfo_t *);
17 20
18/* TODO: add option to get DR, maybe C-only, E-only, eo... */ 21/* TODO: add option to get DR, maybe C-only, E-only, eo... */
19#define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } 22#define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F }
@@ -25,7 +28,7 @@ struct {
25 GETCUBE_OPTIONS(NULL, NULL) 28 GETCUBE_OPTIONS(NULL, NULL)
26}; 29};
27 30
28STATIC int 31int
29parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth) 32parse_h48_options(const char *buf, uint8_t *h, uint8_t *k, uint8_t *maxdepth)
30{ 33{
31 bool h_valid, k_valid, maxdepth_valid; 34 bool h_valid, k_valid, maxdepth_valid;
@@ -63,6 +66,52 @@ parse_h48_options_error:
63 return -1; 66 return -1;
64} 67}
65 68
69STATIC bool
70checkdata(const void *buf, const tableinfo_t *info)
71{
72 uint64_t distr[INFO_DISTRIBUTION_LEN];
73
74 if (!strncmp(info->solver, "cocsep", 6)) {
75 getdistribution_cocsep(
76 (uint32_t *)((char *)buf + INFOSIZE), distr);
77 } else if (!strncmp(info->solver, "h48", 3)) {
78 getdistribution_h48((uint8_t *)buf + INFOSIZE, distr,
79 info->h48h, info->bits);
80 } else {
81 LOG("checkdata: unknown solver %s\n", info->solver);
82 return false;
83 }
84
85 return distribution_equal(info->distribution, distr, info->maxvalue);
86}
87
88STATIC bool
89distribution_equal(
90 const uint64_t expected[static INFO_DISTRIBUTION_LEN],
91 const uint64_t actual[static INFO_DISTRIBUTION_LEN],
92 uint8_t maxvalue
93)
94{
95 int wrong;
96 uint8_t i;
97
98 for (i = 0, wrong = 0; i <= MAX(maxvalue, 20); i++) {
99 if (expected[i] != actual[i]) {
100 wrong++;
101 LOG("Value %" PRIu8 ": expected %" PRIu64 ", found %"
102 PRIu64 "\n", i, expected[i], actual[i]);
103 }
104 }
105
106 if (wrong > 0) {
107 LOG("checkdata: %d wrong values\n", wrong);
108 } else {
109 LOG("checkdata: table is consistent with info\n");
110 }
111
112 return wrong > 0;
113}
114
66STATIC int64_t 115STATIC int64_t
67write_result(cube_t cube, char result[static 22]) 116write_result(cube_t cube, char result[static 22])
68{ 117{
@@ -276,6 +325,26 @@ nissy_gendata(
276} 325}
277 326
278int64_t 327int64_t
328nissy_checkdata(
329 const char *solver,
330 const char *options,
331 const void *data
332)
333{
334 char *buf;
335 tableinfo_t info;
336
337 for (buf = (char *)data; readtableinfo(buf, &info); buf += info.next) {
338 if (!checkdata(buf, &info))
339 return 1;
340 if (info.next == 0)
341 break;
342 }
343
344 return 0;
345}
346
347int64_t
279nissy_solve( 348nissy_solve(
280 const char cube[static 22], 349 const char cube[static 22],
281 const char *solver, 350 const char *solver,
diff --git a/src/nissy.h b/src/nissy.h
index 336130c..0545556 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -86,6 +86,19 @@ int64_t nissy_gendata(
86 void *generated_data 86 void *generated_data
87); 87);
88 88
89/* Temporarily added to test h48 intermediate tables */
90int64_t nissy_derivedata(
91 const char *options,
92 const void *fulltable,
93 void *generated_data
94);
95
96int64_t nissy_checkdata(
97 const char *solver,
98 const char *options,
99 const void *data
100);
101
89/* Print information on a data table via the provided callback writer */ 102/* Print information on a data table via the provided callback writer */
90int64_t nissy_datainfo( 103int64_t nissy_datainfo(
91 const void *table, 104 const void *table,
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
26STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *); 26STATIC size_t gendata_cocsep(void *, uint64_t *, cube_t *);
27STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *); 27STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t *);
28STATIC void getdistribution_cocsep(const uint32_t *, uint64_t [static 21]);
28 29
29STATIC_INLINE int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); 30STATIC_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
161STATIC void
162getdistribution_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
160STATIC_INLINE bool 172STATIC_INLINE bool
161get_visited(const uint8_t *a, int64_t i) 173get_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 *);
103STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *); 103STATIC size_t gendata_h48k2_realcoord(gendata_h48_arg_t *);
104STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg); 104STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t *arg);
105STATIC void * gendata_h48k2_runthread(void *); 105STATIC void * gendata_h48k2_runthread(void *);
106STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *, uint8_t); 106STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t *);
107STATIC void getdistribution_h48(const uint8_t *,
108 uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t);
107 109
108STATIC uint32_t *get_cocsepdata_ptr(const void *); 110STATIC uint32_t *get_cocsepdata_ptr(const void *);
109STATIC uint8_t *get_h48data_ptr(const void *); 111STATIC uint8_t *get_h48data_ptr(const void *);
110 112
111STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); 113STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t);
112STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t); 114STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t);
113STATIC_INLINE uint8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint8_t *); 115STATIC_INLINE uint8_t get_h48_bound(
116 cube_t, uint32_t, uint8_t, uint8_t, uint8_t *);
117
118size_t gendata_h48_derive(uint8_t, const void *, void *);
114 119
115STATIC uint64_t 120STATIC uint64_t
116gendata_h48short(gendata_h48short_arg_t *arg) 121gendata_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
603gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) 609gendata_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
639STATIC tableinfo_t 648STATIC tableinfo_t
640makeinfo_h48k2(gendata_h48_arg_t *arg, uint8_t base) 649makeinfo_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
674STATIC void
675getdistribution_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
665STATIC uint32_t * 693STATIC uint32_t *
666get_cocsepdata_ptr(const void *data) 694get_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
727size_t
728gendata_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
794gendata_h48_derive_return_size:
795 return cocsepsize + h48size;
796
797gendata_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
24typedef struct { 24typedef 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
40STATIC bool readtableinfo(const void *, tableinfo_t *); 40STATIC 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}

Generated with cgit - Back to sebastiano.tronto.net