diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | src/nissy.c | 22 | ||||
| -rw-r--r-- | src/nissy.h | 6 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 6 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 1 |
5 files changed, 36 insertions, 1 deletions
| @@ -12,7 +12,7 @@ debugrun | |||
| 12 | shell/lasttest.out | 12 | shell/lasttest.out |
| 13 | shell/lasttest.err | 13 | shell/lasttest.err |
| 14 | tables/* | 14 | tables/* |
| 15 | tables-old/* | 15 | tables-old*/* |
| 16 | test/*/runtest | 16 | test/*/runtest |
| 17 | test/.DS_Store | 17 | test/.DS_Store |
| 18 | test/run | 18 | test/run |
diff --git a/src/nissy.c b/src/nissy.c index c21abc0..ffda4b3 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -79,6 +79,8 @@ checkdata(const char *buf, const tableinfo_t *info) | |||
| 79 | } else if (!strncmp(info->solver, "h48", 3)) { | 79 | } else if (!strncmp(info->solver, "h48", 3)) { |
| 80 | getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, | 80 | getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, |
| 81 | info->h48h, info->bits); | 81 | info->h48h, info->bits); |
| 82 | } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { | ||
| 83 | return true; | ||
| 82 | } else { | 84 | } else { |
| 83 | LOG("checkdata: unknown solver %s\n", info->solver); | 85 | LOG("checkdata: unknown solver %s\n", info->solver); |
| 84 | return false; | 86 | return false; |
| @@ -367,6 +369,11 @@ nissy_datainfo( | |||
| 367 | tableinfo_t info; | 369 | tableinfo_t info; |
| 368 | long long ret; | 370 | long long ret; |
| 369 | 371 | ||
| 372 | if ((size_t)data % 8 != 0) { | ||
| 373 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | ||
| 374 | return NISSY_ERROR_DATA; | ||
| 375 | } | ||
| 376 | |||
| 370 | ret = readtableinfo(data_size, data, &info); | 377 | ret = readtableinfo(data_size, data, &info); |
| 371 | if (ret != 0) | 378 | if (ret != 0) |
| 372 | return ret; | 379 | return ret; |
| @@ -439,6 +446,11 @@ nissy_gendata_unsafe( | |||
| 439 | return NISSY_ERROR_NULL_POINTER; | 446 | return NISSY_ERROR_NULL_POINTER; |
| 440 | } | 447 | } |
| 441 | 448 | ||
| 449 | if ((size_t)data % 8 != 0) { | ||
| 450 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | ||
| 451 | return NISSY_ERROR_DATA; | ||
| 452 | } | ||
| 453 | |||
| 442 | arg.buf_size = data_size; | 454 | arg.buf_size = data_size; |
| 443 | arg.buf = data; | 455 | arg.buf = data; |
| 444 | if (!strncmp(solver, "h48", 3)) { | 456 | if (!strncmp(solver, "h48", 3)) { |
| @@ -463,6 +475,11 @@ nissy_checkdata( | |||
| 463 | tableinfo_t info; | 475 | tableinfo_t info; |
| 464 | int64_t err; | 476 | int64_t err; |
| 465 | 477 | ||
| 478 | if ((size_t)data % 8 != 0) { | ||
| 479 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | ||
| 480 | return NISSY_ERROR_DATA; | ||
| 481 | } | ||
| 482 | |||
| 466 | for (buf = (char *)data; | 483 | for (buf = (char *)data; |
| 467 | (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; | 484 | (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; |
| 468 | buf += info.next, data_size -= info.next) | 485 | buf += info.next, data_size -= info.next) |
| @@ -538,6 +555,11 @@ nissy_solve( | |||
| 538 | return NISSY_ERROR_OPTIONS; | 555 | return NISSY_ERROR_OPTIONS; |
| 539 | } | 556 | } |
| 540 | 557 | ||
| 558 | if ((size_t)data % 8 != 0) { | ||
| 559 | LOG("nissy_datainfo: buffere is not 8-byte aligned\n"); | ||
| 560 | return NISSY_ERROR_DATA; | ||
| 561 | } | ||
| 562 | |||
| 541 | if (!strncmp(solver, "h48", 3)) { | 563 | if (!strncmp(solver, "h48", 3)) { |
| 542 | parse_ret = parse_h48_solver(solver, &h, &k); | 564 | parse_ret = parse_h48_solver(solver, &h, &k); |
| 543 | if (parse_ret == NISSY_OK) | 565 | if (parse_ret == NISSY_OK) |
diff --git a/src/nissy.h b/src/nissy.h index 94c604c..6c5a3e6 100644 --- a/src/nissy.h +++ b/src/nissy.h | |||
| @@ -216,11 +216,14 @@ Parameters: | |||
| 216 | data_size - The size of the data buffer. It is advised to use nissy_datasize | 216 | data_size - The size of the data buffer. It is advised to use nissy_datasize |
| 217 | to check how much memory is needed. | 217 | to check how much memory is needed. |
| 218 | data - The return parameter for the generated data. | 218 | data - The return parameter for the generated data. |
| 219 | This buffer must have 8-byte alignment. | ||
| 219 | 220 | ||
| 220 | Return values: | 221 | Return values: |
| 221 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. | 222 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. |
| 222 | NISSY_ERROR_NULL_POINTER - The 'solver' argument is null. | 223 | NISSY_ERROR_NULL_POINTER - The 'solver' argument is null. |
| 223 | NISSY_ERROR_UNKNOWN - An error occurred while generating the data. | 224 | NISSY_ERROR_UNKNOWN - An error occurred while generating the data. |
| 225 | NISSY_ERROR_DATA - The data buffer is invalid, for example because | ||
| 226 | it is not 8-byte aligned. | ||
| 224 | Any value >= 0 - The size of the data, in bytes. | 227 | Any value >= 0 - The size of the data, in bytes. |
| 225 | */ | 228 | */ |
| 226 | long long | 229 | long long |
| @@ -236,6 +239,7 @@ Check that the data is a valid data table for a solver. | |||
| 236 | Parameters: | 239 | Parameters: |
| 237 | data_size - The size of the data buffer. | 240 | data_size - The size of the data buffer. |
| 238 | data - The data for the solver. Can be computed with gendata. | 241 | data - The data for the solver. Can be computed with gendata. |
| 242 | This buffer must have 8-byte alignment. | ||
| 239 | 243 | ||
| 240 | Return values: | 244 | Return values: |
| 241 | NISSY_OK - The data is valid. | 245 | NISSY_OK - The data is valid. |
| @@ -264,6 +268,7 @@ Parameters: | |||
| 264 | the default value THREADS will be used. | 268 | the default value THREADS will be used. |
| 265 | data_size - The size of the data buffer. | 269 | data_size - The size of the data buffer. |
| 266 | data - The data for the solver. Can be computed with gendata. | 270 | data - The data for the solver. Can be computed with gendata. |
| 271 | This buffer must have 8-byte alignment. | ||
| 267 | sols_size - The size of the solutions buffer. | 272 | sols_size - The size of the solutions buffer. |
| 268 | sols - The return parameter for the solutions. The solutions are | 273 | sols - The return parameter for the solutions. The solutions are |
| 269 | separated by a '\n' (newline) and a '\0' (NULL character) | 274 | separated by a '\n' (newline) and a '\0' (NULL character) |
| @@ -278,6 +283,7 @@ Return values: | |||
| 278 | NISSY_ERROR_OPTIONS - One or more of the given options are invalid. | 283 | NISSY_ERROR_OPTIONS - One or more of the given options are invalid. |
| 279 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. | 284 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. |
| 280 | NISSY_ERROR_NULL_POINTER - The 'solver' argument is null. | 285 | NISSY_ERROR_NULL_POINTER - The 'solver' argument is null. |
| 286 | NISSY_ERROR_DATA - The data buffer is invalid. | ||
| 281 | Any value >= 0 - The number of solutions found. | 287 | Any value >= 0 - The number of solutions found. |
| 282 | */ | 288 | */ |
| 283 | long long | 289 | long long |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index ae0b732..fe4b259 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -79,6 +79,12 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 79 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); | 79 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); |
| 80 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; | 80 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; |
| 81 | fallback2size = EOESEP_FULLSIZE; | 81 | fallback2size = EOESEP_FULLSIZE; |
| 82 | |||
| 83 | /* Add padding for 8-bit alignment */ | ||
| 84 | h48size = 8 * DIV_ROUND_UP(h48size, 8); | ||
| 85 | fallbacksize = 8 * DIV_ROUND_UP(fallbacksize, 8); | ||
| 86 | fallback2size = 8 * DIV_ROUND_UP(fallback2size, 8); | ||
| 87 | |||
| 82 | size = cocsepsize + h48size + fallbacksize + fallback2size; | 88 | size = cocsepsize + h48size + fallbacksize + fallback2size; |
| 83 | 89 | ||
| 84 | if (arg->buf == NULL) | 90 | if (arg->buf == NULL) |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 9f0cb78..6277082 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -129,6 +129,7 @@ solve_h48_appendallsym(dfsarg_solve_h48_t *arg) | |||
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | /* The solutions are appended */ | 131 | /* The solutions are appended */ |
| 132 | ret = 0; | ||
| 132 | for (k = 0; k < j && *arg->nsols < arg->maxsolutions; k++) { | 133 | for (k = 0; k < j && *arg->nsols < arg->maxsolutions; k++) { |
| 133 | l = arg->solutions_size - *arg->solutions_used; | 134 | l = arg->solutions_size - *arg->solutions_used; |
| 134 | m = *arg->solutions + *arg->solutions_used; | 135 | m = *arg->solutions + *arg->solutions_used; |
