diff options
| -rw-r--r-- | src/solvers/distribution.h | 6 | ||||
| -rw-r--r-- | src/solvers/h48/distribution_h48.h | 6 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 6 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 6 | ||||
| -rw-r--r-- | src/utils/wrapthread.h | 13 |
5 files changed, 23 insertions, 14 deletions
diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index 7adc964..78b9b5e 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h | |||
| @@ -10,13 +10,13 @@ typedef struct { | |||
| 10 | const unsigned char *table; | 10 | const unsigned char *table; |
| 11 | } getdistribution_data_t; | 11 | } getdistribution_data_t; |
| 12 | 12 | ||
| 13 | STATIC void *getdistribution_runthread(void *); | 13 | STATIC wrapthread_return_t getdistribution_runthread(void *); |
| 14 | STATIC void getdistribution(const unsigned char *, | 14 | STATIC void getdistribution(const unsigned char *, |
| 15 | uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); | 15 | uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); |
| 16 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 16 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], |
| 17 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 17 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 18 | 18 | ||
| 19 | STATIC void * | 19 | STATIC wrapthread_return_t |
| 20 | getdistribution_runthread(void *arg) | 20 | getdistribution_runthread(void *arg) |
| 21 | { | 21 | { |
| 22 | getdistribution_data_t *data = (getdistribution_data_t *)arg; | 22 | getdistribution_data_t *data = (getdistribution_data_t *)arg; |
| @@ -33,7 +33,7 @@ getdistribution_runthread(void *arg) | |||
| 33 | for (j = 0; j < ENTRIES_PER_BYTE(k); j++) | 33 | for (j = 0; j < ENTRIES_PER_BYTE(k); j++) |
| 34 | data->distr[(table[i] & (m << (j*k))) >> (j*k)]++; | 34 | data->distr[(table[i] & (m << (j*k))) >> (j*k)]++; |
| 35 | 35 | ||
| 36 | return NULL; | 36 | return wrapthread_return_val; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | STATIC void | 39 | STATIC void |
diff --git a/src/solvers/h48/distribution_h48.h b/src/solvers/h48/distribution_h48.h index 6d50ae5..80c946e 100644 --- a/src/solvers/h48/distribution_h48.h +++ b/src/solvers/h48/distribution_h48.h | |||
| @@ -4,11 +4,11 @@ needed for H48 because of the intertwined fallback table, and it is easier | |||
| 4 | to have some duplication than to make these functions needlessly generic. | 4 | to have some duplication than to make these functions needlessly generic. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | STATIC void *getdistribution_h48_runthread(void *); | 7 | STATIC wrapthread_return_t getdistribution_h48_runthread(void *); |
| 8 | STATIC void getdistribution_h48(const unsigned char *, | 8 | STATIC void getdistribution_h48(const unsigned char *, |
| 9 | uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); | 9 | uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); |
| 10 | 10 | ||
| 11 | STATIC void * | 11 | STATIC wrapthread_return_t |
| 12 | getdistribution_h48_runthread(void *arg) | 12 | getdistribution_h48_runthread(void *arg) |
| 13 | { | 13 | { |
| 14 | getdistribution_data_t *data = (getdistribution_data_t *)arg; | 14 | getdistribution_data_t *data = (getdistribution_data_t *)arg; |
| @@ -33,7 +33,7 @@ getdistribution_h48_runthread(void *arg) | |||
| 33 | data->distr[(t & (m << (3*k))) >> (3*k)]--; | 33 | data->distr[(t & (m << (3*k))) >> (3*k)]--; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | return NULL; | 36 | return wrapthread_return_val; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | STATIC void | 39 | STATIC void |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index a5bb331..b37bcfb 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -3,7 +3,7 @@ STATIC long long gendata_h48_dispatch( | |||
| 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); | 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); |
| 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); | 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); |
| 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); | 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); |
| 6 | STATIC void *gendata_h48_runthread(void *); | 6 | STATIC wrapthread_return_t gendata_h48_runthread(void *); |
| 7 | 7 | ||
| 8 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); | 8 | STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); |
| 9 | STATIC_INLINE bool gendata_h48_dfs_stop( | 9 | STATIC_INLINE bool gendata_h48_dfs_stop( |
| @@ -291,7 +291,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) | |||
| 291 | writetableinfo(&arg->info, bufsize, (unsigned char *)arg->h48buf); | 291 | writetableinfo(&arg->info, bufsize, (unsigned char *)arg->h48buf); |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | STATIC void * | 294 | STATIC wrapthread_return_t |
| 295 | gendata_h48_runthread(void *arg) | 295 | gendata_h48_runthread(void *arg) |
| 296 | { | 296 | { |
| 297 | uint64_t coord, coordext, coordmin; | 297 | uint64_t coord, coordext, coordmin; |
| @@ -328,7 +328,7 @@ gendata_h48_runthread(void *arg) | |||
| 328 | } | 328 | } |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | return NULL; | 331 | return wrapthread_return_val; |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | STATIC void | 334 | STATIC void |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 19aaf79..4fd0aea 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -78,7 +78,7 @@ STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [static 1], | |||
| 78 | STATIC int64_t solve_h48_maketasks( | 78 | STATIC int64_t solve_h48_maketasks( |
| 79 | dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1], | 79 | dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1], |
| 80 | solve_h48_task_t [static H48_STARTING_CUBES], int [static 1]); | 80 | solve_h48_task_t [static H48_STARTING_CUBES], int [static 1]); |
| 81 | STATIC void *solve_h48_runthread(void *); | 81 | STATIC wrapthread_return_t solve_h48_runthread(void *); |
| 82 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); | 82 | STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); |
| 83 | STATIC void solve_h48_log_solutions(solution_list_t [static 1], size_t); | 83 | STATIC void solve_h48_log_solutions(solution_list_t [static 1], size_t); |
| 84 | STATIC int solve_h48_compare_tasks(const void *, const void *); | 84 | STATIC int solve_h48_compare_tasks(const void *, const void *); |
| @@ -383,7 +383,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 383 | return ret; | 383 | return ret; |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | STATIC void * | 386 | STATIC wrapthread_return_t |
| 387 | solve_h48_runthread(void *arg) | 387 | solve_h48_runthread(void *arg) |
| 388 | { | 388 | { |
| 389 | int i, j; | 389 | int i, j; |
| @@ -445,7 +445,7 @@ solve_h48_runthread(void *arg) | |||
| 445 | 445 | ||
| 446 | solve_h48_runthread_end: | 446 | solve_h48_runthread_end: |
| 447 | dfsarg->thread_done = true; | 447 | dfsarg->thread_done = true; |
| 448 | return NULL; | 448 | return wrapthread_return_val; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | STATIC int64_t | 451 | STATIC int64_t |
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index d5de155..fe9d175 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | #define wrapthread_atomic | 3 | #define wrapthread_atomic |
| 4 | 4 | ||
| 5 | #define wrapthread_return_t int | ||
| 6 | #define wrapthread_return_val 0 | ||
| 7 | |||
| 5 | #define wrapthread_define_var_thread_t(x) unused char x | 8 | #define wrapthread_define_var_thread_t(x) unused char x |
| 6 | #define wrapthread_define_var_mutex_t(x) unused char x | 9 | #define wrapthread_define_var_mutex_t(x) unused char x |
| 7 | #define wrapthread_define_struct_thread_t(x) char x | 10 | #define wrapthread_define_struct_thread_t(x) char x |
| @@ -15,12 +18,15 @@ | |||
| 15 | #define wrapthread_mutex_lock(a) | 18 | #define wrapthread_mutex_lock(a) |
| 16 | #define wrapthread_mutex_unlock(a) | 19 | #define wrapthread_mutex_unlock(a) |
| 17 | 20 | ||
| 18 | #elif defined(_WIN32) | 21 | #elif defined(__unix__) |
| 19 | 22 | ||
| 20 | #include <threads.h> | 23 | #include <threads.h> |
| 21 | 24 | ||
| 22 | #define wrapthread_atomic _Atomic | 25 | #define wrapthread_atomic _Atomic |
| 23 | 26 | ||
| 27 | #define wrapthread_return_t int | ||
| 28 | #define wrapthread_return_val 0 | ||
| 29 | |||
| 24 | #define wrapthread_define_var_thread_t(x) thrd_t x | 30 | #define wrapthread_define_var_thread_t(x) thrd_t x |
| 25 | #define wrapthread_define_var_mutex_t(x) mtx_t x | 31 | #define wrapthread_define_var_mutex_t(x) mtx_t x |
| 26 | #define wrapthread_define_struct_thread_t(x) thrd_t x | 32 | #define wrapthread_define_struct_thread_t(x) thrd_t x |
| @@ -28,7 +34,7 @@ | |||
| 28 | 34 | ||
| 29 | #define wrapthread_define_if_threads(T, x) T x | 35 | #define wrapthread_define_if_threads(T, x) T x |
| 30 | 36 | ||
| 31 | #define wrapthread_create(a, f, arg) thrd_create(a, (int(*)(void *))f, arg) | 37 | #define wrapthread_create(a, f, arg) thrd_create(a, f, arg) |
| 32 | #define wrapthread_join(a) thrd_join(a, NULL) | 38 | #define wrapthread_join(a) thrd_join(a, NULL) |
| 33 | #define wrapthread_mutex_init(a) mtx_init(a, mtx_plain) | 39 | #define wrapthread_mutex_init(a) mtx_init(a, mtx_plain) |
| 34 | #define wrapthread_mutex_lock(a) mtx_lock(a) | 40 | #define wrapthread_mutex_lock(a) mtx_lock(a) |
| @@ -40,6 +46,9 @@ | |||
| 40 | 46 | ||
| 41 | #define wrapthread_atomic _Atomic | 47 | #define wrapthread_atomic _Atomic |
| 42 | 48 | ||
| 49 | #define wrapthread_return_t void * | ||
| 50 | #define wrapthread_return_val NULL | ||
| 51 | |||
| 43 | #define wrapthread_define_var_thread_t(x) pthread_t x | 52 | #define wrapthread_define_var_thread_t(x) pthread_t x |
| 44 | #define wrapthread_define_var_mutex_t(x) pthread_mutex_t x | 53 | #define wrapthread_define_var_mutex_t(x) pthread_mutex_t x |
| 45 | #define wrapthread_define_struct_thread_t(x) pthread_t x | 54 | #define wrapthread_define_struct_thread_t(x) pthread_t x |
