commit 510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 parent 1d9b8acfeece68c4f55d2499d8aed127f98a383c Author: Sebastiano Tronto <sebastiano@tronto.net> Date: Mon, 21 Apr 2025 14:33:01 +0200 Always use unsigned char * for data buffers Before this commit I was inconsistently using one of void *, char * and uint8_t *. Diffstat:
40 files changed, 285 insertions(+), 263 deletions(-)
diff --git a/cpp/nissy.cpp b/cpp/nissy.cpp @@ -18,11 +18,12 @@ extern "C" { long long nissy_getcube(long long, long long, long long, long long, const char *, char *); long long nissy_solverinfo(const char *, char *); - long long nissy_gendata(const char *, unsigned long long, char *); - long long nissy_checkdata(unsigned long long, const char *); + long long nissy_gendata(const char *, unsigned long long, + unsigned char *); + long long nissy_checkdata(unsigned long long, const unsigned char *); long long nissy_solve(const char *, const char *, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, - const char *, unsigned, char *, long long *); + const unsigned char *, unsigned, char *, long long *); long long nissy_countmoves(const char *); long long nissy_setlogger(void (*)(const char *, void *), void *); } @@ -156,7 +157,7 @@ namespace nissy { { data.resize(size); auto err = nissy_gendata(name.c_str(), - size, reinterpret_cast<char *>(data.data())); + size, reinterpret_cast<unsigned char *>(data.data())); return error{err}; } @@ -169,7 +170,7 @@ namespace nissy { error solver::check_data() { auto err_value = nissy_checkdata(data.size(), - reinterpret_cast<const char *>(data.data())); + reinterpret_cast<const unsigned char *>(data.data())); error err{err_value}; data_checked = err.ok(); return err; @@ -199,7 +200,7 @@ namespace nissy { auto err = nissy_solve(cube.to_string().c_str(), name.c_str(), niss.value, minmoves, maxmoves, maxsols, optimal, threads, data.size(), - reinterpret_cast<const char *>(data.data()), len, + reinterpret_cast<const unsigned char *>(data.data()), len, csols.data(), result.stats.data()); result.err = error{err}; diff --git a/python/nissy_module.c b/python/nissy_module.c @@ -263,7 +263,8 @@ gendata(PyObject *self, PyObject *args) { long long size, err; const char *solver; - char *buf, dataid[NISSY_SIZE_DATAID]; + char dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; if (!PyArg_ParseTuple(args, "s", &solver)) return NULL; @@ -279,7 +280,7 @@ gendata(PyObject *self, PyObject *args) Py_END_ALLOW_THREADS if (check_error(err)) - return PyByteArray_FromStringAndSize(buf, size); + return PyByteArray_FromStringAndSize((char *)buf, size); else return NULL; } @@ -303,7 +304,8 @@ checkdata(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "Y", &data)) return NULL; - result = nissy_checkdata(data->ob_alloc, data->ob_bytes); + result = nissy_checkdata( + data->ob_alloc, (unsigned char *)data->ob_bytes); if (check_error(result)) return Py_True; @@ -348,8 +350,9 @@ solve(PyObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS result = nissy_solve(cube, solver, nissflag, minmoves, maxmoves, - maxsolutions, optimal, threads, data->ob_alloc, data->ob_bytes, - MAX_SOLUTIONS_SIZE, solutions, stats); + maxsolutions, optimal, threads, data->ob_alloc, + (unsigned char *)data->ob_bytes, MAX_SOLUTIONS_SIZE, solutions, + stats); Py_END_ALLOW_THREADS if(!check_error(result)) { diff --git a/shell/shell.c b/shell/shell.c @@ -360,7 +360,8 @@ gendata_exec(args_t *args) { int i; FILE *file; - char *buf, path[MAX_PATH_LENGTH], dataid[NISSY_SIZE_DATAID]; + char path[MAX_PATH_LENGTH], dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; int64_t ret, size; size_t written; @@ -427,7 +428,8 @@ solve_exec(args_t *args) int i; uint8_t nissflag; FILE *file; - char *buf, solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH]; + char solutions[SOLUTIONS_BUFFER_SIZE], path[MAX_PATH_LENGTH]; + unsigned char *buf; char dataid[NISSY_SIZE_DATAID]; long long stats[NISSY_SIZE_SOLVE_STATS]; int64_t ret, gendata_ret, size; diff --git a/src/nissy.c b/src/nissy.c @@ -14,14 +14,14 @@ long long parse_h48_solver( const char *, uint8_t [static 1], uint8_t [static 1]); -STATIC bool checkdata(const char *, const tableinfo_t [static 1]); +STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); STATIC size_t my_strnlen(const char *, size_t); STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); STATIC long long nissy_gendata_unsafe( - const char *, unsigned long long, char *); + const char *, unsigned long long, unsigned char *); #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } struct { @@ -66,7 +66,7 @@ parse_h48_solver_error: } STATIC bool -checkdata(const char *buf, const tableinfo_t info[static 1]) +checkdata(const unsigned char *buf, const tableinfo_t info[static 1]) { uint64_t distr[INFO_DISTRIBUTION_LEN]; @@ -78,10 +78,10 @@ checkdata(const char *buf, const tableinfo_t info[static 1]) getdistribution_cocsep( (uint32_t *)((char *)buf + INFOSIZE), distr); } else if (!strncmp(info->solver, "h48", 3)) { - getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, + getdistribution_h48(buf + INFOSIZE, distr, info->h48h, info->bits); } else if (!strncmp(info->solver, "coordinate solver for ", 22)) { - getdistribution_coord((uint8_t *)buf + INFOSIZE, + getdistribution_coord(buf + INFOSIZE, info->solver + 22, distr); } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { return true; @@ -366,7 +366,7 @@ nissy_getcube( long long nissy_datainfo( uint64_t data_size, - const char data[data_size] + const unsigned char data[data_size] ) { uint8_t i; @@ -405,8 +405,7 @@ nissy_datainfo( } if (info.next != 0) - return nissy_datainfo( - data_size - info.next, (char *)data + info.next); + return nissy_datainfo(data_size - info.next, data + info.next); LOG("\n---------\n"); @@ -452,7 +451,7 @@ long long nissy_gendata( const char *solver, unsigned long long data_size, - char data[data_size] + unsigned char data[data_size] ) { return nissy_gendata_unsafe(solver, data_size, data); @@ -462,7 +461,7 @@ STATIC long long nissy_gendata_unsafe( const char *solver, unsigned long long data_size, - char *data + unsigned char *data ) { long long parse_ret; @@ -497,10 +496,9 @@ nissy_gendata_unsafe( long long nissy_checkdata( unsigned long long data_size, - const char data[data_size] + const unsigned char data[data_size] ) { - char *buf; tableinfo_t info; int64_t err; @@ -509,7 +507,7 @@ nissy_checkdata( return NISSY_ERROR_DATA; } - for (buf = (char *)data; + for (const unsigned char *buf = data; (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; buf += info.next, data_size -= info.next) { @@ -537,7 +535,7 @@ nissy_solve( unsigned optimal, unsigned threads, unsigned long long data_size, - const char data[data_size], + const unsigned char data[data_size], unsigned sols_size, char sols[sols_size], long long stats[static NISSY_SIZE_SOLVE_STATS] diff --git a/src/nissy.h b/src/nissy.h @@ -329,7 +329,7 @@ long long nissy_gendata( const char *solver, unsigned long long data_size, - char data[data_size] + unsigned char data[data_size] ); /* @@ -347,7 +347,7 @@ Return values: long long nissy_checkdata( unsigned long long data_size, - const char data[data_size] + const unsigned char data[data_size] ); /* @@ -395,7 +395,7 @@ nissy_solve( unsigned optimal, unsigned threads, unsigned long long data_size, - const char data[data_size], + const unsigned char data[data_size], unsigned sols_size, char sols[sols_size], long long stats[static NISSY_SIZE_SOLVE_STATS] diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h @@ -1,25 +1,29 @@ STATIC uint64_t coord_coord_generic( - const coord_t [static 1], cube_t, const void *); + const coord_t [static 1], cube_t, const unsigned char *); STATIC cube_t coord_cube_generic( - const coord_t [static 1], uint64_t, const void *); + const coord_t [static 1], uint64_t, const unsigned char *); STATIC bool coord_isnasty_generic( - const coord_t [static 1], uint64_t, const void *); -STATIC size_t coord_gendata_generic(const coord_t [static 1], void *); + const coord_t [static 1], uint64_t, const unsigned char *); +STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); STATIC void append_coord_name(const coord_t [static 1], char *); STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); -STATIC bool coord_can_switch( - const coord_t [static 1], const void *, size_t n, const uint8_t [n]); +STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, + size_t n, const uint8_t [n]); STATIC uint64_t -coord_coord_generic(const coord_t coord[static 1], cube_t c, const void *data) +coord_coord_generic( + const coord_t coord[static 1], + cube_t c, + const unsigned char *data +) { - const char *datanoinfo; + const unsigned char *datanoinfo; const uint32_t *data32; uint32_t d; cube_t tr; - datanoinfo = (const char *)data + INFOSIZE; + datanoinfo = data + INFOSIZE; data32 = (const uint32_t *)datanoinfo; d = data32[coord->sym.coord(c)]; tr = transform(c, COORD_TTREP(d)); @@ -28,13 +32,17 @@ coord_coord_generic(const coord_t coord[static 1], cube_t c, const void *data) } STATIC cube_t -coord_cube_generic(const coord_t coord[static 1], uint64_t i, const void *data) +coord_cube_generic( + const coord_t coord[static 1], + uint64_t i, + const unsigned char *data +) { - const char *datanoinfo; + const unsigned char *datanoinfo; const uint32_t *rep32; cube_t c; - datanoinfo = (const char *)data + INFOSIZE; + datanoinfo = data + INFOSIZE; rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); c = coord->sym.cube(rep32[i / coord->sym.max2]); @@ -45,14 +53,14 @@ STATIC bool coord_isnasty_generic( const coord_t coord[static 1], uint64_t i, - const void *data + const unsigned char *data ) { - const char *datanoinfo; + const unsigned char *datanoinfo; const uint32_t *classttrep, *rep32; uint32_t r; - datanoinfo = (const char *)data + INFOSIZE; + datanoinfo = data + INFOSIZE; classttrep = (const uint32_t *)datanoinfo; rep32 = (const uint32_t *)(datanoinfo + 4 * (size_t)coord->sym.max); r = rep32[i / coord->sym.max2]; @@ -63,11 +71,11 @@ coord_isnasty_generic( STATIC size_t coord_gendata_generic( const coord_t coord[static 1], - void *data + unsigned char *data ) { uint64_t i, j, n, t, nasty; - char *datanoinfo; + unsigned char *datanoinfo; uint32_t *classttrep, *rep; size_t coord_datasize; cube_t c; @@ -78,7 +86,7 @@ coord_gendata_generic( if (data == NULL) return coord_datasize; - datanoinfo = (char *)data + INFOSIZE; + datanoinfo = data + INFOSIZE; classttrep = (uint32_t *)datanoinfo; rep = classttrep + coord->sym.max; memset(data, 0xFF, coord_datasize); @@ -154,7 +162,7 @@ solution_lastqt_cw(const solution_moves_t s[static 1]) STATIC bool coord_can_switch( const coord_t coord[static 1], - const void *data, + const unsigned char *data, size_t n, const uint8_t moves[n] ) diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h @@ -5,10 +5,10 @@ STATIC uint64_t coord_dreoesep_nosym(cube_t); STATIC cube_t invcoord_dreoesep_nosym(uint64_t); STATIC cube_t coordinate_dr_merge(cube_t, cube_t); -STATIC uint64_t coordinate_dr_coord(cube_t, const void *); -STATIC cube_t coordinate_dr_cube(uint64_t, const void *); -STATIC bool coordinate_dr_isnasty(uint64_t, const void *); -STATIC size_t coordinate_dr_gendata(void *); +STATIC uint64_t coordinate_dr_coord(cube_t, const unsigned char *); +STATIC cube_t coordinate_dr_cube(uint64_t, const unsigned char *); +STATIC bool coordinate_dr_isnasty(uint64_t, const unsigned char *); +STATIC size_t coordinate_dr_gendata(unsigned char *); STATIC bool is_eoco_solvable(cube_t); @@ -81,25 +81,25 @@ coordinate_dr_merge(cube_t c1, cube_t c2) } STATIC uint64_t -coordinate_dr_coord(cube_t cube, const void *data) +coordinate_dr_coord(cube_t cube, const unsigned char *data) { return coord_coord_generic(&coordinate_dr, cube, data); } STATIC cube_t -coordinate_dr_cube(uint64_t i, const void *data) +coordinate_dr_cube(uint64_t i, const unsigned char *data) { return coord_cube_generic(&coordinate_dr, i, data); } STATIC bool -coordinate_dr_isnasty(uint64_t i, const void *data) +coordinate_dr_isnasty(uint64_t i, const unsigned char *data) { return coord_isnasty_generic(&coordinate_dr, i, data); } STATIC size_t -coordinate_dr_gendata(void *data) +coordinate_dr_gendata(unsigned char *data) { return coord_gendata_generic(&coordinate_dr, data); } diff --git a/src/solvers/coord/dreo.h b/src/solvers/coord/dreo.h @@ -4,10 +4,10 @@ STATIC uint64_t coord_dresep_nosym(cube_t); STATIC cube_t invcoord_dresep_nosym(uint64_t); STATIC cube_t coordinate_dreo_merge(cube_t, cube_t); -STATIC uint64_t coordinate_dreo_coord(cube_t, const void *); -STATIC cube_t coordinate_dreo_cube(uint64_t, const void *); -STATIC bool coordinate_dreo_isnasty(uint64_t, const void *); -STATIC size_t coordinate_dreo_gendata(void *); +STATIC uint64_t coordinate_dreo_coord(cube_t, const unsigned char *); +STATIC cube_t coordinate_dreo_cube(uint64_t, const unsigned char *); +STATIC bool coordinate_dreo_isnasty(uint64_t, const unsigned char *); +STATIC size_t coordinate_dreo_gendata(unsigned char *); STATIC bool is_dreo_solvable(cube_t); @@ -63,25 +63,25 @@ coordinate_dreo_merge(cube_t c1, cube_t c2) } STATIC uint64_t -coordinate_dreo_coord(cube_t cube, const void *data) +coordinate_dreo_coord(cube_t cube, const unsigned char *data) { return coord_coord_generic(&coordinate_dreo, cube, data); } STATIC cube_t -coordinate_dreo_cube(uint64_t i, const void *data) +coordinate_dreo_cube(uint64_t i, const unsigned char *data) { return coord_cube_generic(&coordinate_dreo, i, data); } STATIC bool -coordinate_dreo_isnasty(uint64_t i, const void *data) +coordinate_dreo_isnasty(uint64_t i, const unsigned char *data) { return coord_isnasty_generic(&coordinate_dreo, i, data); } STATIC size_t -coordinate_dreo_gendata(void *data) +coordinate_dreo_gendata(unsigned char *data) { return coord_gendata_generic(&coordinate_dreo, data); } diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h @@ -1,7 +1,7 @@ -STATIC uint64_t coordinate_eo_coord(cube_t, const void *); -STATIC cube_t coordinate_eo_cube(uint64_t, const void *); -STATIC bool coordinate_eo_isnasty(uint64_t, const void *); -STATIC size_t coordinate_eo_gendata(void *); +STATIC uint64_t coordinate_eo_coord(cube_t, const unsigned char *); +STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *); +STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *); +STATIC size_t coordinate_eo_gendata(unsigned char *); STATIC bool is_eo_even(cube_t); STATIC coord_t coordinate_eo = { @@ -24,13 +24,13 @@ STATIC coord_t coordinate_eo = { }; STATIC uint64_t -coordinate_eo_coord(cube_t c, const void *data) +coordinate_eo_coord(cube_t c, const unsigned char *data) { return (uint64_t)coord_eo(c); } STATIC cube_t -coordinate_eo_cube(uint64_t c, const void *data) +coordinate_eo_cube(uint64_t c, const unsigned char *data) { cube_t cube = SOLVED_CUBE; set_eo(&cube, (int64_t)c); @@ -38,13 +38,13 @@ coordinate_eo_cube(uint64_t c, const void *data) } STATIC bool -coordinate_eo_isnasty(uint64_t c, const void *data) +coordinate_eo_isnasty(uint64_t c, const unsigned char *data) { return false; } STATIC size_t -coordinate_eo_gendata(void *data) +coordinate_eo_gendata(unsigned char *data) { return 0; } diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h @@ -1,21 +1,21 @@ -STATIC size_t gendata_coord(const coord_t [static 1], void *); -STATIC int64_t gendata_coord_dispatch(const char *, void *); +STATIC size_t gendata_coord(const coord_t [static 1], unsigned char *); +STATIC int64_t gendata_coord_dispatch(const char *, unsigned char *); STATIC tableinfo_t genptable_coord( - const coord_t [static 1], const void *, uint8_t *); + const coord_t [static 1], const unsigned char *, unsigned char *); STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); -STATIC uint64_t genptable_coord_fillneighbors( - const coord_t [static 1], const void *, uint64_t, uint8_t, uint8_t *); -STATIC uint64_t genptable_coord_fillfromnew( - const coord_t [static 1], const void *, uint64_t, uint8_t, uint8_t *); -STATIC void getdistribution_coord( - const uint8_t *, const char *, uint64_t [static INFO_DISTRIBUTION_LEN]); +STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1], + const unsigned char *, uint64_t, uint8_t, unsigned char *); +STATIC uint64_t genptable_coord_fillfromnew(const coord_t [static 1], + const unsigned char *, uint64_t, uint8_t, unsigned char *); +STATIC void getdistribution_coord(const unsigned char *, const char *, + uint64_t [static INFO_DISTRIBUTION_LEN]); STATIC uint8_t get_coord_pval( - const coord_t [static 1], const uint8_t *, uint64_t); + const coord_t [static 1], const unsigned char *, uint64_t); STATIC void set_coord_pval( - const coord_t [static 1], uint8_t *, uint64_t, uint8_t); + const coord_t [static 1], unsigned char *, uint64_t, uint8_t); STATIC int64_t -gendata_coord_dispatch(const char *coordstr, void *buf) +gendata_coord_dispatch(const char *coordstr, unsigned char *buf) { coord_t *coord; @@ -30,14 +30,14 @@ gendata_coord_dispatch(const char *coordstr, void *buf) } STATIC size_t -gendata_coord(const coord_t coord[static 1], void *buf) +gendata_coord(const coord_t coord[static 1], unsigned char *buf) { uint64_t coord_dsize, tablesize, ninfo; - void *pruningbuf, *coord_data; - uint8_t *table; + unsigned char *pruningbuf, *coord_data; + unsigned char *table; tableinfo_t coord_data_info, pruning_info; - coord_data = buf == NULL ? NULL : ((uint8_t *)buf) + INFOSIZE; + coord_data = buf == NULL ? NULL : buf + INFOSIZE; coord_dsize = coord->gendata(coord_data); if (coord_dsize == SIZE_MAX) goto gendata_coord_error; @@ -69,12 +69,12 @@ gendata_coord(const coord_t coord[static 1], void *buf) writetableinfo(&coord_data_info, INFOSIZE + coord_dsize, buf); - pruningbuf = ((uint8_t *)buf) + INFOSIZE + coord_dsize; + pruningbuf = buf + INFOSIZE + coord_dsize; } else { pruningbuf = buf; } - table = ((uint8_t *)pruningbuf) + INFOSIZE; + table = pruningbuf + INFOSIZE; pruning_info = genptable_coord(coord, coord_data, table); writetableinfo(&pruning_info, INFOSIZE + tablesize, pruningbuf); @@ -89,8 +89,8 @@ gendata_coord_error: STATIC tableinfo_t genptable_coord( const coord_t coord[static 1], - const void *data, - uint8_t *table + const unsigned char *data, + unsigned char *table ) { uint64_t tablesize, i, d, tot, t, nm; @@ -161,10 +161,10 @@ switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm) STATIC uint64_t genptable_coord_fillneighbors( const coord_t coord[static 1], - const void *data, + const unsigned char *data, uint64_t i, uint8_t d, - uint8_t *table + unsigned char *table ) { bool isnasty; @@ -198,10 +198,10 @@ genptable_coord_fillneighbors( STATIC uint64_t genptable_coord_fillfromnew( const coord_t coord[static 1], - const void *data, + const unsigned char *data, uint64_t i, uint8_t d, - uint8_t *table + unsigned char *table ) { bool found; @@ -251,7 +251,7 @@ genptable_coord_fillfromnew( STATIC void getdistribution_coord( - const uint8_t *table, + const unsigned char *table, const char *coord, uint64_t distr[static INFO_DISTRIBUTION_LEN] ) @@ -274,7 +274,7 @@ getdistribution_coord( STATIC uint8_t get_coord_pval( const coord_t coord[static 1], - const uint8_t *table, + const unsigned char *table, uint64_t i ) { @@ -284,7 +284,7 @@ get_coord_pval( STATIC void set_coord_pval( const coord_t coord[static 1], - uint8_t *table, + unsigned char *table, uint64_t i, uint8_t val ) diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h @@ -8,16 +8,16 @@ typedef struct { uint8_t nissflag; bool lastisnormal; coord_t *coord; - const void *coord_data; - const uint8_t *ptable; + const unsigned char *coord_data; + const unsigned char *ptable; } dfsarg_solve_coord_t; STATIC int64_t solve_coord(cube_t, coord_t [static 1], uint8_t, uint8_t, - uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const void *, - size_t n, char [n]); + uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, + const unsigned char *, size_t n, char [n]); STATIC int64_t solve_coord_dispatch(cube_t, const char *, uint8_t, uint8_t, - uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const void *, size_t n, - char [n]); + uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, const unsigned char *, + size_t n, char [n]); STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [static 1]); STATIC bool solve_coord_dfs_stop(const dfsarg_solve_coord_t [static 1]); STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [static 1]); @@ -209,7 +209,7 @@ solve_coord_dispatch( uint8_t optimal, uint8_t threads, uint64_t data_size, - const void *data, + const unsigned char *data, size_t solutions_size, char sols[solutions_size] ) @@ -248,7 +248,7 @@ solve_coord( uint8_t optimal, uint8_t threads, uint64_t data_size, - const void *data, + const unsigned char *data, size_t solutions_size, char sols[solutions_size] ) @@ -257,8 +257,8 @@ solve_coord( uint8_t t; int64_t ndepth; cube_t c; - const void *coord_data; - const uint8_t *ptable; + const unsigned char *coord_data; + const unsigned char *ptable; dfsarg_solve_coord_t arg; tableinfo_t info; solution_moves_t solution_moves; @@ -280,11 +280,11 @@ solve_coord( if (info.type == TABLETYPE_PRUNING) { /* Only the pruning table */ coord_data = NULL; - ptable = (uint8_t *)data + INFOSIZE; + ptable = data + INFOSIZE; } else { /* Coordinate has extra data */ - coord_data = (uint8_t *)data + INFOSIZE; - ptable = (uint8_t *)data + info.next + INFOSIZE; + coord_data = data + INFOSIZE; + ptable = data + info.next + INFOSIZE; } solution_moves_reset(&solution_moves); diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h @@ -16,10 +16,10 @@ typedef struct { const char name[255]; - uint64_t (*coord)(cube_t, const void *); - cube_t (*cube)(uint64_t, const void *); - bool (*isnasty)(uint64_t, const void *); - size_t (*gendata)(void *); + uint64_t (*coord)(cube_t, const unsigned char *); + cube_t (*cube)(uint64_t, const unsigned char *); + bool (*isnasty)(uint64_t, const unsigned char *); + size_t (*gendata)(unsigned char *); uint64_t max; uint32_t moves_mask; uint64_t trans_mask; diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h @@ -1,4 +1,4 @@ -STATIC size_t gendata_cocsep(char *, uint64_t *, cube_t *); +STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); STATIC void getdistribution_cocsep( const uint32_t [static COCSEP_TABLESIZE], uint64_t [static 21]); @@ -13,7 +13,7 @@ STATIC_INLINE int8_t get_h48_cdata( STATIC size_t gendata_cocsep( - char *buf, + unsigned char *buf, uint64_t *selfsim, cube_t *rep ) diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h @@ -1,7 +1,7 @@ STATIC int64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); STATIC size_t gendata_esep_classes( uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); -STATIC size_t gendata_eoesep(char *, uint8_t); +STATIC size_t gendata_eoesep(unsigned char *, uint8_t); STATIC uint32_t gendata_eoesep_bfs(uint8_t, uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [static EOESEP_BUF], @@ -14,7 +14,7 @@ STATIC bool gendata_eoesep_next(cube_t, uint8_t, uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); STATIC uint8_t get_eoesep_pval( const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t); -STATIC uint8_t get_eoesep_pval_cube(const void *, cube_t); +STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); STATIC void set_eoesep_pval( uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], int64_t, uint8_t); @@ -67,9 +67,10 @@ gendata_esep_classes( } STATIC size_t -gendata_eoesep(char *buf, uint8_t maxdepth) +gendata_eoesep(unsigned char *buf, uint8_t maxdepth) { - uint8_t *buf8, d; + uint8_t d; + unsigned char *buf8; uint16_t rep[ESEP_CLASSES]; uint32_t *esep_classes, done, level; int64_t coord; @@ -81,7 +82,7 @@ gendata_eoesep(char *buf, uint8_t maxdepth) LOG("Computing eoesep data\n"); memset(buf, 0xFF, EOESEP_FULLSIZE); esep_classes = (uint32_t *)(buf + INFOSIZE); - buf8 = (uint8_t *)(buf + INFOSIZE + 4*ESEP_MAX); + buf8 = buf + INFOSIZE + 4*ESEP_MAX; gendata_esep_classes(esep_classes, rep); info = (tableinfo_t) { @@ -258,17 +259,13 @@ get_eoesep_pval( } STATIC uint8_t -get_eoesep_pval_cube(const void *data, cube_t c) +get_eoesep_pval_cube(const unsigned char *data, cube_t c) { int64_t coord; - const uint8_t *table; - const uint32_t *esep_classes; - esep_classes = (const uint32_t *)data; - table = (const uint8_t *)data + 4*ESEP_MAX; - coord = coord_eoesep_sym(c, esep_classes); + coord = coord_eoesep_sym(c, (const uint32_t *)data); - return get_eoesep_pval(table, coord); + return get_eoesep_pval(data + 4*ESEP_MAX, coord); } STATIC void diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h @@ -13,20 +13,20 @@ STATIC_INLINE bool gendata_h48k2_dfs_stop( STATIC void gendata_h48k2_dfs(h48k2_dfs_arg_t [static 1]); STATIC tableinfo_t makeinfo_h48k2(gendata_h48_arg_t [static 1]); STATIC void *getdistribution_h48_runthread(void *); -STATIC void getdistribution_h48(const uint8_t *, +STATIC void getdistribution_h48(const unsigned char *, uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t, uint8_t); -STATIC const uint32_t *get_cocsepdata_constptr(const void *); -STATIC const uint8_t *get_h48data_constptr(const void *); +STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); +STATIC const unsigned char *get_h48data_constptr(const unsigned char *); -STATIC_INLINE uint8_t get_h48_pval(const uint8_t *, int64_t, uint8_t); -STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t); +STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, int64_t, uint8_t); +STATIC_INLINE void set_h48_pval(unsigned char *, int64_t, uint8_t, uint8_t); STATIC_INLINE uint8_t get_h48_pval_atomic( - _Atomic const uint8_t *, int64_t, uint8_t); + _Atomic const unsigned char *, int64_t, uint8_t); STATIC_INLINE void set_h48_pval_atomic( - _Atomic uint8_t *, int64_t, uint8_t, uint8_t); + _Atomic unsigned char *, int64_t, uint8_t, uint8_t); -size_t gendata_h48_derive(uint8_t, const void *, void *); +size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); STATIC uint64_t gendata_h48short(gendata_h48short_arg_t arg[static 1]) @@ -67,7 +67,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) { uint64_t size, cocsepsize, h48size, fallbacksize, fallback2size, of; long long r; - void *cocsepdata_offset; + unsigned char *cocsepdata_offset; tableinfo_t cocsepinfo, h48info, fallbackinfo; gendata_h48_arg_t arg_h0k4; @@ -95,9 +95,9 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) gendata_cocsep(arg->buf, arg->selfsim, arg->crep); - cocsepdata_offset = (char *)arg->buf + INFOSIZE; + cocsepdata_offset = arg->buf + INFOSIZE; arg->cocsepdata = (uint32_t *)cocsepdata_offset; - arg->h48buf = (char *)arg->buf + cocsepsize; + arg->h48buf = (_Atomic unsigned char*)arg->buf + cocsepsize; arg->base = 99; /* TODO: set this somewhere else */ @@ -136,8 +136,8 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) arg_h0k4.base = 0; arg_h0k4.maxdepth = 20; arg_h0k4.buf_size = arg->buf_size - h48size; - arg_h0k4.buf = (char *)arg->buf + cocsepsize + h48size; - arg_h0k4.h48buf = (char *)arg->h48buf + h48size; + arg_h0k4.buf = arg->buf + cocsepsize + h48size; + arg_h0k4.h48buf = arg->h48buf + h48size; gendata_h48h0k4(&arg_h0k4); @@ -145,7 +145,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) /* Add eoesep fallback table */ - gendata_eoesep((char *)arg->buf + (size - fallback2size), 20); + gendata_eoesep(arg->buf + (size - fallback2size), 20); /* Update tableinfo with correct next values */ @@ -157,7 +157,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) } h48info.next = h48size; r = writetableinfo(&h48info, - arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize); + arg->buf_size - cocsepsize, arg->buf + cocsepsize); if (r != NISSY_OK) { LOG("[H48 gendata] Error: could not write info " "for h48 table\n"); @@ -174,8 +174,8 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) of = cocsepsize + h48size; fallbackinfo.next = fallbacksize; - r = writetableinfo(&fallbackinfo, - arg->buf_size - of, (char *)arg->buf + of); + r = writetableinfo( + &fallbackinfo, arg->buf_size - of, arg->buf + of); if (r != NISSY_OK) { LOG("[H48 gendata] Error: could not write info for " "h48 fallback table\n"); @@ -189,7 +189,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) STATIC void gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) { - _Atomic uint8_t *table; + _Atomic unsigned char *table; uint8_t val; int64_t i, sc, done, d, h48max; uint64_t t, tt, isize, cc, bufsize; @@ -212,7 +212,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) .next = 0, }; - table = (_Atomic uint8_t *)arg->h48buf + INFOSIZE; + table = arg->h48buf + INFOSIZE; memset(table, 0xFF, H48_TABLESIZE(0, 4)); h48max = (int64_t)H48_COORDMAX(0); @@ -261,7 +261,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) arg->info.maxvalue = d - 1; bufsize = arg->buf_size - COCSEP_FULLSIZE; - writetableinfo(&arg->info, bufsize, arg->h48buf); + writetableinfo(&arg->info, bufsize, (unsigned char *)arg->h48buf); } STATIC void * @@ -374,7 +374,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1]) }; uint8_t t; - uint8_t *table; + unsigned char *table; int64_t j; uint64_t i, ii, inext, count, bufsize; h48map_t shortcubes; @@ -383,7 +383,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1]) pthread_t thread[THREADS]; pthread_mutex_t shortcubes_mutex, table_mutex[CHUNKS]; - table = (uint8_t *)arg->h48buf + INFOSIZE; + table = (unsigned char *)arg->h48buf + INFOSIZE; memset(table, 0xFF, H48_TABLESIZE(arg->h, arg->k)); LOG("[H48 gendata] Computing depth <=%" PRIu8 "\n", shortdepth) @@ -439,7 +439,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1]) } bufsize = arg->buf_size - COCSEP_FULLSIZE; - writetableinfo(&arg->info, bufsize, arg->h48buf); + writetableinfo(&arg->info, bufsize, (unsigned char *)arg->h48buf); } STATIC void * @@ -653,7 +653,7 @@ STATIC void * getdistribution_h48_runthread(void *arg) { getdistribution_h48_data_t *data = (getdistribution_h48_data_t *)arg; - const uint8_t *table; + const unsigned char *table; uint8_t j, k, m; int64_t i; @@ -671,7 +671,7 @@ getdistribution_h48_runthread(void *arg) STATIC void getdistribution_h48( - const uint8_t *table, + const unsigned char *table, uint64_t distr[static INFO_DISTRIBUTION_LEN], uint8_t h, uint8_t k @@ -708,50 +708,55 @@ getdistribution_h48( } STATIC const uint32_t * -get_cocsepdata_constptr(const void *data) +get_cocsepdata_constptr(const unsigned char *data) { - return (uint32_t *)((char *)data + INFOSIZE); + return (uint32_t *)(data + INFOSIZE); } -STATIC const uint8_t * -get_h48data_constptr(const void *data) +STATIC const unsigned char * +get_h48data_constptr(const unsigned char *data) { - return (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE; + return data + COCSEP_FULLSIZE + INFOSIZE; } STATIC_INLINE uint8_t -get_h48_pval(const uint8_t *table, int64_t i, uint8_t k) +get_h48_pval(const unsigned char *table, int64_t i, uint8_t k) { return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); } STATIC_INLINE uint8_t -get_h48_pval_atomic(_Atomic const uint8_t *table, int64_t i, uint8_t k) +get_h48_pval_atomic(_Atomic const unsigned char *table, int64_t i, uint8_t k) { return (table[H48_INDEX(i, k)] & H48_MASK(i, k)) >> H48_SHIFT(i, k); } STATIC_INLINE void -set_h48_pval(uint8_t *table, int64_t i, uint8_t k, uint8_t val) +set_h48_pval(unsigned char *table, int64_t i, uint8_t k, uint8_t val) { table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) | (val << H48_SHIFT(i, k)); } STATIC_INLINE void -set_h48_pval_atomic(_Atomic uint8_t *table, int64_t i, uint8_t k, uint8_t val) +set_h48_pval_atomic( + _Atomic unsigned char *table, + int64_t i, + uint8_t k, + uint8_t val +) { table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) | (val << H48_SHIFT(i, k)); } size_t -gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) +gendata_h48_derive(uint8_t h, const unsigned char *fulltable, unsigned char *buf) { size_t cocsepsize, h48size; uint8_t val_full, val_derive; - const uint8_t *h48full; - uint8_t *h48derive; + const unsigned char *h48full; + unsigned char *h48derive; int64_t i, j, h48max; uint64_t bufsize; gendata_h48_arg_t arg; @@ -770,14 +775,14 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) arg.k = fulltableinfo.bits; arg.maxdepth = 20; arg.buf = buf; - arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); + arg.cocsepdata = (uint32_t *)(buf + INFOSIZE); arg.base = fulltableinfo.base; arg.info = makeinfo_h48k2(&arg); /* Technically this step is redundant, except that we need selfsim and crep */ cocsepsize = gendata_cocsep(buf, arg.selfsim, arg.crep); - arg.h48buf = (_Atomic uint8_t *)buf + cocsepsize; + arg.h48buf = (_Atomic unsigned char *)buf + cocsepsize; h48size = H48_TABLESIZE(h, arg.k) + INFOSIZE; if (buf == NULL) @@ -798,8 +803,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) goto gendata_h48_derive_error; } - h48full = (const uint8_t *)fulltable + cocsepsize + INFOSIZE; - h48derive = (uint8_t *)arg.h48buf + INFOSIZE; + h48full = fulltable + cocsepsize + INFOSIZE; + h48derive = (unsigned char *)arg.h48buf + INFOSIZE; memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); memset(arg.info.distribution, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); @@ -819,7 +824,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) getdistribution_h48(h48derive, arg.info.distribution, h, arg.k); bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE; - if (writetableinfo(&arg.info, bufsize, arg.h48buf) != NISSY_OK) { + if (writetableinfo(&arg.info, bufsize, (unsigned char *)arg.h48buf) + != NISSY_OK) { LOG("H48 derive gendata] Error: could not write info " "for table\n"); goto gendata_h48_derive_error; diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h @@ -55,7 +55,7 @@ typedef struct { uint8_t maxdepth; uint16_t *n; uint32_t *buf32; - uint8_t *visited; + unsigned char *visited; uint64_t *selfsim; cube_t *rep; } cocsep_dfs_arg_t; @@ -67,8 +67,8 @@ typedef struct { uint8_t maxdepth; tableinfo_t info; uint64_t buf_size; - void *buf; - void *h48buf; + unsigned char *buf; + _Atomic unsigned char *h48buf; uint32_t *cocsepdata; uint64_t selfsim[COCSEP_CLASSES]; cube_t crep[COCSEP_CLASSES]; @@ -85,7 +85,7 @@ typedef struct { typedef struct { uint8_t depth; uint32_t *cocsepdata; - _Atomic uint8_t *table; + _Atomic unsigned char *table; uint64_t *selfsim; cube_t *crep; uint64_t start; @@ -100,7 +100,7 @@ typedef struct { uint8_t base; uint8_t shortdepth; uint32_t *cocsepdata; - uint8_t *table; + unsigned char *table; uint64_t *selfsim; cube_t *crep; h48map_t *shortcubes; @@ -117,8 +117,8 @@ typedef struct { uint8_t k; uint32_t *cocsepdata; uint64_t *selfsim; - uint8_t *table; - _Atomic uint8_t *table_atomic; + unsigned char *table; + _Atomic unsigned char *table_atomic; pthread_mutex_t **table_mutex; } gendata_h48_mark_t; @@ -127,5 +127,5 @@ typedef struct { int64_t max; uint8_t k; uint64_t *distr; - const uint8_t *table; + const unsigned char *table; } getdistribution_h48_data_t; diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h @@ -22,9 +22,9 @@ typedef struct { uint8_t k; uint8_t base; const uint32_t *cocsepdata; - const uint8_t *h48data; - const uint8_t *h48data_fallback_h0k4; - const void *h48data_fallback_eoesep; + const unsigned char *h48data; + const unsigned char *h48data_fallback_h0k4; + const unsigned char *h48data_fallback_eoesep; uint32_t movemask_normal; uint32_t movemask_inverse; int64_t nodes_visited; @@ -53,7 +53,7 @@ STATIC int64_t solve_h48_maketasks( STATIC void *solve_h48_runthread(void *); STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); STATIC int64_t solve_h48(cube_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, - uint64_t, const void *, size_t n, char [n], + uint64_t, const unsigned char *, size_t n, char [n], long long [static NISSY_SIZE_SOLVE_STATS]); STATIC_INLINE bool @@ -349,7 +349,7 @@ solve_h48( uint8_t optimal, uint8_t threads, uint64_t data_size, - const void *data, + const unsigned char *data, size_t solutions_size, char solutions[solutions_size], long long stats[static NISSY_SIZE_SOLVE_STATS] @@ -365,8 +365,8 @@ solve_h48( int64_t nodes_visited, table_lookups, table_fallbacks; tableinfo_t info, fbinfo, fbinfo2; const uint32_t *cocsepdata; - const uint8_t *fallback, *h48data; - const void *fallback2; + const unsigned char *fallback, *h48data; + const unsigned char *fallback2; solution_moves_t solution_moves[THREADS]; solution_settings_t settings; solution_list_t sollist; @@ -379,8 +379,8 @@ solve_h48( if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) goto solve_h48_error_data; - cocsepdata = (uint32_t *)((char *)data + INFOSIZE); - h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE; + cocsepdata = (uint32_t *)(data + INFOSIZE); + h48data = data + COCSEP_FULLSIZE + INFOSIZE; /* Read fallback table(s) */ fallback = NULL; diff --git a/src/solvers/tables.h b/src/solvers/tables.h @@ -1,13 +1,14 @@ -STATIC uint64_t read_unaligned_u64(const char [static sizeof(uint64_t)]); -STATIC void write_unaligned_u64(char [static sizeof(uint64_t)], uint64_t); -STATIC int64_t readtableinfo(size_t n, const char [n], tableinfo_t [static 1]); +STATIC uint64_t read_unaligned_u64(const unsigned char [static sizeof(uint64_t)]); +STATIC void write_unaligned_u64(unsigned char [static sizeof(uint64_t)], uint64_t); +STATIC int64_t readtableinfo( + size_t n, const unsigned char [n], tableinfo_t [static 1]); STATIC int64_t readtableinfo_n( - size_t n, const char [n], uint8_t, tableinfo_t [static 1]); + size_t n, const unsigned char [n], uint8_t, tableinfo_t [static 1]); STATIC int64_t writetableinfo( - const tableinfo_t [static 1], size_t n, char [n]); + const tableinfo_t [static 1], size_t n, unsigned char [n]); STATIC uint64_t -read_unaligned_u64(const char buf[static sizeof(uint64_t)]) +read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) { uint64_t ret; @@ -17,7 +18,7 @@ read_unaligned_u64(const char buf[static sizeof(uint64_t)]) } STATIC void -write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x) +write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) { memcpy(buf, &x, sizeof(uint64_t)); } @@ -25,7 +26,7 @@ write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x) STATIC int64_t readtableinfo( size_t buf_size, - const char buf[buf_size], + const unsigned char buf[buf_size], tableinfo_t info[static 1] ) { @@ -69,7 +70,7 @@ readtableinfo( STATIC int64_t readtableinfo_n( size_t buf_size, - const char buf[buf_size], + const unsigned char buf[buf_size], uint8_t n, tableinfo_t info[static 1] ) @@ -87,12 +88,12 @@ STATIC int64_t writetableinfo( const tableinfo_t info[static 1], size_t data_size, - char buf[data_size] + unsigned char buf[data_size] ) { size_t i; bool end; - char *c; + unsigned char *c; if (data_size < info->fullsize) { LOG("Error writing table: buffer size is too small " @@ -125,10 +126,10 @@ writetableinfo( *c = 0; } - *(uint8_t *)OFFSET(buf, INFO_OFFSET_H48H) = info->h48h; - *(uint8_t *)OFFSET(buf, INFO_OFFSET_BITS) = info->bits; - *(uint8_t *)OFFSET(buf, INFO_OFFSET_BASE) = info->base; - *(uint8_t *)OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; + *OFFSET(buf, INFO_OFFSET_H48H) = (unsigned char)info->h48h; + *OFFSET(buf, INFO_OFFSET_BITS) = (unsigned char)info->bits; + *OFFSET(buf, INFO_OFFSET_BASE) = (unsigned char)info->base; + *OFFSET(buf, INFO_OFFSET_MAXVALUE) = (unsigned char)info->maxvalue; return NISSY_OK; } diff --git a/src/solvers/tables_types_macros.h b/src/solvers/tables_types_macros.h @@ -1,4 +1,4 @@ -#define OFFSET(B, K) (((char *)B) + K) +#define OFFSET(B, K) (((unsigned char *)B) + K) #define INFOSIZE INT64_C(512) #define INFO_SOLVER_STRLEN INT64_C(100) diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c @@ -1,7 +1,7 @@ #include "../test.h" -bool readtableinfo(uint64_t, const char *, tableinfo_t *); -bool writetableinfo(const tableinfo_t *, uint64_t, char *); +bool readtableinfo(uint64_t, const unsigned char *, tableinfo_t *); +bool writetableinfo(const tableinfo_t *, uint64_t, unsigned char *); uint64_t readn(void) { char str[STRLENMAX]; @@ -66,7 +66,7 @@ void test_writeinfo(tableinfo_t info) { } void run(void) { - char buf[INFOSIZE]; + unsigned char buf[INFOSIZE]; tableinfo_t expected, actual; expected = test_readinfo(); diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c @@ -2,11 +2,11 @@ #define BUF_SIZE 2000000 -size_t gendata_cocsep(void *, uint64_t *, cube_t *); -bool readtableinfo(uint64_t, const char *, tableinfo_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); +bool readtableinfo(uint64_t, const unsigned char *, tableinfo_t *); void run(void) { - char buf[BUF_SIZE]; + unsigned char buf[BUF_SIZE]; uint32_t i; uint64_t selfsim[COCSEP_CLASSES]; cube_t rep[COCSEP_CLASSES]; diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c @@ -1,12 +1,12 @@ #include "../test.h" -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); cube_t transform(cube_t, uint8_t); int64_t coord_cocsep(cube_t); void run(void) { uint8_t t; - char buf[2000000]; + unsigned char buf[2000000]; uint32_t *cocsepdata; uint64_t selfsim[COCSEP_CLASSES]; int64_t coord, tcoord; diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c @@ -7,19 +7,19 @@ */ #include "../test.h" -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); int64_t coord_cocsep(cube_t); void run(void) { char str[STRLENMAX]; - char buf[2000000]; + unsigned char buf[2000000]; uint32_t *cocsepdata, data; int64_t coord, coclass; uint64_t selfsim[COCSEP_CLASSES], sim, t; cube_t cube, rep[COCSEP_CLASSES]; gendata_cocsep(buf, selfsim, rep); - cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); + cocsepdata = (uint32_t *)(buf + INFOSIZE); /* All cases in the same test so we do not generate data many times */ diff --git a/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c b/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c @@ -1,6 +1,6 @@ #include "../test.h" -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); int64_t coord_cocsep(cube_t); int bcount(uint64_t x) { @@ -15,7 +15,7 @@ int bcount(uint64_t x) { } void run(void) { - char buf[2000000]; + unsigned char buf[2000000]; int size[65], tot, j; uint64_t i, selfsim[COCSEP_CLASSES], sim; cube_t rep[COCSEP_CLASSES]; diff --git a/test/104_cocsep_ttrep/cocsep_ttrep_tests.c b/test/104_cocsep_ttrep/cocsep_ttrep_tests.c @@ -3,11 +3,11 @@ uint8_t inverse_trans(uint8_t); cube_t transform_corners(cube_t, uint8_t); int64_t coord_cocsep(cube_t); -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); void run(void) { uint8_t t; - char buf[2000000]; + unsigned char buf[2000000]; uint32_t *cocsepdata, tt; uint64_t i, selfsim[COCSEP_CLASSES]; int64_t j, k, l; diff --git a/test/105_gendata_eoesep/gendata_eoesep_tests.c b/test/105_gendata_eoesep/gendata_eoesep_tests.c @@ -23,10 +23,10 @@ The test does not generate the full table. For reference, these are the values: #define ISIZE 512 #define FULLSIZE (ISIZE + (CL*1024) + (4*EMAX)) -char buf[FULLSIZE]; +unsigned char buf[FULLSIZE]; -size_t gendata_eoesep(char [static FULLSIZE], uint8_t); -bool readtableinfo(uint64_t, const char *, tableinfo_t *); +size_t gendata_eoesep(unsigned char [static FULLSIZE], uint8_t); +bool readtableinfo(uint64_t, const unsigned char *, tableinfo_t *); void run(void) { uint32_t i; diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c @@ -1,6 +1,6 @@ #include "../test.h" -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); int64_t coord_h48(cube_t, const uint32_t *, uint8_t); cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); cube_t transform(cube_t, uint8_t); @@ -10,14 +10,14 @@ void run(void) { int i; bool found; uint8_t h, t; - char buf[2000000]; + unsigned char buf[2000000]; uint32_t *cocsepdata; uint64_t selfsim[COCSEP_CLASSES]; int64_t c, cc; cube_t cube, invc, rep[COCSEP_CLASSES]; gendata_cocsep(buf, selfsim, rep); - cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); + cocsepdata = (uint32_t *)(buf + INFOSIZE); i = 1; h = 11; diff --git a/test/112_gendata_h48short/gendata_h48short_tests.c b/test/112_gendata_h48short/gendata_h48short_tests.c @@ -5,7 +5,7 @@ void h48map_create(h48map_t [static 1], uint64_t, uint64_t); void h48map_destroy(h48map_t [static 1]); kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); -size_t gendata_cocsep(void *, uint64_t *, cube_t *); +size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); char str[STRLENMAX]; @@ -25,7 +25,7 @@ uint64_t readl(void) { } void run(void) { - char buf[2000000]; + unsigned char buf[2000000]; h48map_t map; uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; kvpair_t kv, b[MAXPOS]; diff --git a/test/120_gendata_eo/gendata_eo_tests.c b/test/120_gendata_eo/gendata_eo_tests.c @@ -15,10 +15,10 @@ Pruning table values (from nissy): #define ISIZE 512 #define FULLSIZE (ISIZE + 1024) -char buf[FULLSIZE]; +unsigned char buf[FULLSIZE]; -size_t gendata_coord_dispatch(const char *, void *); -bool readtableinfo(uint64_t, const char *, tableinfo_t *); +size_t gendata_coord_dispatch(const char *, unsigned char *); +bool readtableinfo(uint64_t, const unsigned char *, tableinfo_t *); void run(void) { uint32_t i; diff --git a/test/121_coorddata_dr/coorddata_dr.c b/test/121_coorddata_dr/coorddata_dr.c @@ -5,15 +5,15 @@ #define TGROUP UINT64_C(4278190335) cube_t transform(cube_t, uint8_t); -uint64_t coordinate_dr_coord(cube_t, const void *); -cube_t coordinate_dr_cube(uint64_t, const void *); -uint64_t coordinate_dr_gendata(void *); +uint64_t coordinate_dr_coord(cube_t, const unsigned char *); +cube_t coordinate_dr_cube(uint64_t, const unsigned char *); +uint64_t coordinate_dr_gendata(unsigned char *); void run(void) { bool found; uint64_t t; char str[STRLENMAX]; - void *data; + unsigned char *data; size_t size; cube_t cube; uint64_t coord, coord2; diff --git a/test/122_coorddata_dreo/coorddata_dreo.c b/test/122_coorddata_dreo/coorddata_dreo.c @@ -5,15 +5,15 @@ #define TGROUP UINT64_C(4278190335) cube_t transform(cube_t, uint8_t); -uint64_t coordinate_dreo_coord(cube_t, const void *); -cube_t coordinate_dreo_cube(uint64_t, const void *); -uint64_t coordinate_dreo_gendata(void *); +uint64_t coordinate_dreo_coord(cube_t, const unsigned char *); +cube_t coordinate_dreo_cube(uint64_t, const unsigned char *); +uint64_t coordinate_dreo_gendata(unsigned char *); void run(void) { bool found; uint64_t t; char str[STRLENMAX]; - void *data; + unsigned char *data; size_t size; cube_t cube; uint64_t coord, coord2; diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c @@ -8,7 +8,8 @@ static void run(void) { int64_t size; bool consistent, expected; - char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; + char filename[1024], dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; size = generatetable(solver, &buf, dataid); switch (size) { diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c @@ -6,7 +6,8 @@ char *solver, *filename; static void run(void) { long long int size, result; - char *buf, dataid[NISSY_SIZE_DATAID]; + char dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; FILE *f; size = nissy_solverinfo(solver, dataid); diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c @@ -4,7 +4,7 @@ char *solver; int64_t size = 0; -char *buf; +unsigned char *buf; char *scrambles[] = { /* 12 optimal */ diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c @@ -6,7 +6,7 @@ char *solver; int64_t size = 0, N = 0; -char *buf; +unsigned char *buf; char scrambles[MAX_SCR][MAX_SCR_LEN]; void run(void) { diff --git a/tools/302_solve_multisol/solve_multisol.c b/tools/302_solve_multisol/solve_multisol.c @@ -5,7 +5,7 @@ int nsol; char *solver; int64_t size = 0; -char *buf; +unsigned char *buf; char *scrambles[] = { "U2 D2 F2 B2 L2 R2", diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c @@ -5,8 +5,7 @@ char *solver; int64_t size = 0; -char *buf; - +unsigned char *buf; bool check_one(char *actual, char *expected) { unsigned i; diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h @@ -197,7 +197,7 @@ check_table(uint64_t *exp, tableinfo_t *info) } static bool -check_cocsep(size_t data_size, const void *data) +check_cocsep(size_t data_size, const unsigned char *data) { tableinfo_t info; @@ -219,7 +219,11 @@ unknown_h48(uint8_t h, uint8_t k) } STATIC bool -check_distribution(const char *solver, size_t data_size, const void *data) +check_distribution( + const char *solver, + size_t data_size, + const unsigned char *data +) { const char *str; tableinfo_t info = {0}; diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h @@ -9,7 +9,6 @@ for testing purposes only. #include "../src/solvers/tables_types_macros.h" #include "../src/solvers/tables.h" -size_t gendata_h48_derive(uint8_t, const void *, void *); +size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); -long long int nissy_datainfo(uint64_t, const char *); -long long int nissy_derivedata(const char *, const void *, void *); +long long int nissy_datainfo(uint64_t, const unsigned char *); diff --git a/tools/tool.h b/tools/tool.h @@ -11,12 +11,12 @@ static void log_stderr(const char *, void *); static double timerun(void (*)(void)); -static void writetable(const char *, int64_t, const char *); -static long long int generatetable(const char *, char **, +static void writetable(const unsigned char *, int64_t, const char *); +static long long int generatetable(const char *, unsigned char **, char [static NISSY_SIZE_DATAID]); static long long int derivetable( - const char *, const char *, const char *, char **); -static int getdata(const char *, char **, const char *); + const char *, const char *, const char *, unsigned char **); +static int getdata(const char *, unsigned char **, const char *); static void gendata_run(const char *, uint64_t[static 21]); static void derivedata_run( const char *, const char *, const char *, const char *); @@ -57,7 +57,7 @@ timerun(void (*run)(void)) } static void -writetable(const char *buf, int64_t size, const char *filename) +writetable(const unsigned char *buf, int64_t size, const char *filename) { FILE *f; @@ -74,7 +74,7 @@ writetable(const char *buf, int64_t size, const char *filename) static long long int generatetable( const char *solver, - char **buf, + unsigned char **buf, char dataid[static NISSY_SIZE_DATAID] ) { @@ -105,12 +105,13 @@ derivetable( const char *solver_large, const char *solver_small, const char *filename_large, - char **buf + unsigned char **buf ) { uint8_t h, k; long long int size, gensize; - char *fulltable, dataid[NISSY_SIZE_DATAID]; + char dataid[NISSY_SIZE_DATAID]; + unsigned char *fulltable; if (getdata(solver_large, &fulltable, filename_large) != 0) { printf("Error reading full table.\n"); @@ -149,7 +150,7 @@ derivetable_error_nofree: static int getdata( const char *solver, - char **buf, + unsigned char **buf, const char *filename ) { long long int size, sizeread; @@ -194,7 +195,8 @@ gendata_run( uint64_t expected[static 21] ) { long long int size; - char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; + char filename[1024], dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; size = generatetable(solver, &buf, dataid); sprintf(filename, "tables/%s", dataid); @@ -227,7 +229,7 @@ derivedata_run( ) { long long int size; - char *buf; + unsigned char *buf; buf = NULL; size = derivetable(solver_large, solver_small, filename_large, &buf);