checkdata.h (1769B)
1 STATIC long long checkdata_coord( 2 const char *, unsigned long long, const unsigned char *); 3 4 STATIC long long 5 checkdata_coord( 6 const char *solver, 7 unsigned long long data_size, 8 const unsigned char *data 9 ) 10 { 11 coord_t *coord; 12 const unsigned char *table; 13 tableinfo_t info; 14 int64_t err; 15 uint64_t actual_distribution[INFO_DISTRIBUTION_LEN]; 16 17 if ((size_t)data % 8 != 0) { 18 LOG("[checkdata] Error: buffer is not 8-byte aligned\n"); 19 return NISSY_ERROR_DATA; 20 } 21 22 parse_coord_and_axis(solver, &coord, NULL); 23 if (coord == NULL) { 24 LOG("[cehckdata] Unknown coordinate solver '%s'\n", solver); 25 return NISSY_ERROR_DATA; 26 } 27 28 table = data + INFOSIZE; 29 err = readtableinfo(data_size, data, &info); 30 if (err != NISSY_OK) { 31 LOG("[checkdata] Data is corrupt\n"); 32 return err; 33 } 34 35 if (info.type != TABLETYPE_PRUNING) { 36 LOG("[checkdata] Skipping '%s'\n", info.solver); 37 table += info.next; 38 err = readtableinfo_n(data_size, data, 2, &info); 39 if (err != NISSY_OK) { 40 LOG("[checkdata] Data is corrupt\n"); 41 return err; 42 } 43 } 44 45 LOG("[checkdata] Checking distribution for '%s' from " 46 "table preamble\n", info.solver); 47 if (!distribution_equal(coord->pruning_distribution, 48 info.distribution, coord->pruning_max)) { 49 LOG("[checkdata] Distribution from the table preamble does " 50 "not match the expected one\n"); 51 return NISSY_ERROR_DATA; 52 } 53 54 LOG("\n[checkdata] Checking distribution for '%s' from " 55 "actual table\n", info.solver); 56 getdistribution(table, actual_distribution, &info); 57 if (!distribution_equal(coord->pruning_distribution, 58 actual_distribution, coord->pruning_max)) { 59 LOG("[checkdata] Distribution from the actual table does " 60 "not match the expected one\n"); 61 return NISSY_ERROR_DATA; 62 } 63 64 return NISSY_OK; 65 }