diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-09-17 21:58:25 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-09-17 22:25:03 +0200 |
| commit | 446f56c8752071ba64c7ec22968b2417c9465c8e (patch) | |
| tree | fa3d07dae927d563fb67723f9e8a625cd1258eae | |
| parent | 2f9d00075b0d236ecd8431761bb045e6aa088001 (diff) | |
| parent | 1f7e8e937d0e71e7eb3b5deab38b34d0a0159d88 (diff) | |
| download | nissy-core-446f56c8752071ba64c7ec22968b2417c9465c8e.tar.gz nissy-core-446f56c8752071ba64c7ec22968b2417c9465c8e.zip | |
Merge branch 'master' into twostep-solver
61 files changed, 340 insertions, 6 deletions
diff --git a/src/arch/arch.h b/src/arch/arch.h index aa4a5c5..c4efbd5 100644 --- a/src/arch/arch.h +++ b/src/arch/arch.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef ARCH_ARCH_H | ||
| 2 | #define ARCH_ARCH_H | ||
| 3 | |||
| 1 | #if defined(AVX2) | 4 | #if defined(AVX2) |
| 2 | 5 | ||
| 3 | #include <immintrin.h> | 6 | #include <immintrin.h> |
| @@ -36,3 +39,5 @@ typedef struct { | |||
| 36 | #endif | 39 | #endif |
| 37 | 40 | ||
| 38 | #endif | 41 | #endif |
| 42 | |||
| 43 | #endif /* ARCH_ARCH_H */ | ||
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 801419e..5b9ecc7 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef ARCH_AVX2_H | ||
| 2 | #define ARCH_AVX2_H | ||
| 3 | |||
| 1 | #define CO2_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) | 4 | #define CO2_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) |
| 2 | #define COCW_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) | 5 | #define COCW_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) |
| 3 | #define CP_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707)) | 6 | #define CP_AVX2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707)) |
| @@ -478,3 +481,5 @@ invcoord_epudsep(uint64_t i) | |||
| 478 | 481 | ||
| 479 | return _mm256_or_si256(elow, cube); | 482 | return _mm256_or_si256(elow, cube); |
| 480 | } | 483 | } |
| 484 | |||
| 485 | #endif /* ARCH_AVX2_H */ | ||
diff --git a/src/arch/common.h b/src/arch/common.h index a7c4a3b..973263f 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef ARCH_COMMON_H | ||
| 2 | #define ARCH_COMMON_H | ||
| 3 | |||
| 1 | #define EOSHIFT UINT8_C(4) | 4 | #define EOSHIFT UINT8_C(4) |
| 2 | #define COSHIFT UINT8_C(5) | 5 | #define COSHIFT UINT8_C(5) |
| 3 | 6 | ||
| @@ -126,3 +129,5 @@ invcoord_epudsep_array(uint64_t c, uint8_t ret[8]) | |||
| 126 | k -= is; | 129 | k -= is; |
| 127 | } | 130 | } |
| 128 | } | 131 | } |
| 132 | |||
| 133 | #endif /* ARCH_COMMON_H */ | ||
diff --git a/src/arch/neon.h b/src/arch/neon.h index 501b722..faf3b8f 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef ARCH_NEON_H | ||
| 2 | #define ARCH_NEON_H | ||
| 3 | |||
| 1 | #define CO2_NEON vdup_n_u8(0x60) | 4 | #define CO2_NEON vdup_n_u8(0x60) |
| 2 | #define COCW_NEON vdup_n_u8(0x20) | 5 | #define COCW_NEON vdup_n_u8(0x20) |
| 3 | #define EO_NEON vdupq_n_u8(0x10) | 6 | #define EO_NEON vdupq_n_u8(0x10) |
| @@ -557,3 +560,5 @@ invcoord_epudsep(uint64_t i) | |||
| 557 | .edge = vcombine_u8(vld1_u8(e), vld1_u8(SOLVED_H)) | 560 | .edge = vcombine_u8(vld1_u8(e), vld1_u8(SOLVED_H)) |
| 558 | }; | 561 | }; |
| 559 | } | 562 | } |
| 563 | |||
| 564 | #endif /* ARCH_NEON_H */ | ||
diff --git a/src/arch/portable.h b/src/arch/portable.h index f1491f0..18fb6b8 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef ARCH_PORTABLE_H | ||
| 2 | #define ARCH_PORTABLE_H | ||
| 3 | |||
| 1 | #define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ | 4 | #define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ |
| 2 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ | 5 | e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ |
| 3 | ((cube_t) { \ | 6 | ((cube_t) { \ |
| @@ -407,3 +410,5 @@ invcoord_epudsep(uint64_t c) | |||
| 407 | invcoord_epudsep_array(c, ret.edge); | 410 | invcoord_epudsep_array(c, ret.edge); |
| 408 | return ret; | 411 | return ret; |
| 409 | } | 412 | } |
| 413 | |||
| 414 | #endif /* ARCH_PORTABLE_H */ | ||
diff --git a/src/core/constants.h b/src/core/constants.h index 076a483..7e51f67 100644 --- a/src/core/constants.h +++ b/src/core/constants.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_CONSTANTS_H | ||
| 2 | #define CORE_CONSTANTS_H | ||
| 3 | |||
| 1 | #define ZERO_ORIENTED_CUBE ((oriented_cube_t) {0}) | 4 | #define ZERO_ORIENTED_CUBE ((oriented_cube_t) {0}) |
| 2 | #define SOLVED_ORIENTED_CUBE \ | 5 | #define SOLVED_ORIENTED_CUBE \ |
| 3 | ((oriented_cube_t) { .cube = SOLVED_CUBE, .orientation = 0 }) | 6 | ((oriented_cube_t) { .cube = SOLVED_CUBE, .orientation = 0 }) |
| @@ -913,3 +916,5 @@ STATIC uint8_t basic_to_rotation[] = { | |||
| 913 | [MOVE_B2] = MOVE_z2, | 916 | [MOVE_B2] = MOVE_z2, |
| 914 | [MOVE_B3] = MOVE_z, | 917 | [MOVE_B3] = MOVE_z, |
| 915 | }; | 918 | }; |
| 919 | |||
| 920 | #endif /* CORE_CONSTANTS_H */ | ||
diff --git a/src/core/core.h b/src/core/core.h index 5e0faaa..d1c0ec1 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | #ifndef CORE_CORE_H | ||
| 2 | #define CORE_CORE_H | ||
| 3 | |||
| 1 | #include "core_types.h" | 4 | #include "core_types.h" |
| 2 | #include "constants.h" | 5 | #include "constants.h" |
| 3 | #include "cube.h" | 6 | #include "cube.h" |
| 4 | #include "moves.h" | 7 | #include "moves.h" |
| 5 | #include "transform.h" | 8 | #include "transform.h" |
| 6 | #include "oriented_cube.h" | 9 | #include "oriented_cube.h" |
| 10 | |||
| 11 | #endif /* CORE_CORE_H */ | ||
diff --git a/src/core/core_types.h b/src/core/core_types.h index 53cc95e..6f69a8b 100644 --- a/src/core/core_types.h +++ b/src/core/core_types.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_CORE_TYPES_H | ||
| 2 | #define CORE_CORE_TYPES_H | ||
| 3 | |||
| 1 | typedef struct { | 4 | typedef struct { |
| 2 | cube_t cube; | 5 | cube_t cube; |
| 3 | uint8_t orientation; | 6 | uint8_t orientation; |
| @@ -9,3 +12,5 @@ typedef struct { | |||
| 9 | uint8_t normal[NISSY_SIZE_MOVES]; | 12 | uint8_t normal[NISSY_SIZE_MOVES]; |
| 10 | uint8_t inverse[NISSY_SIZE_MOVES]; | 13 | uint8_t inverse[NISSY_SIZE_MOVES]; |
| 11 | } moves_struct_t; | 14 | } moves_struct_t; |
| 15 | |||
| 16 | #endif /* CORE_CORE_TYPES_H */ | ||
diff --git a/src/core/cube.h b/src/core/cube.h index 1c21ce1..1dc6b61 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_CUBE_H | ||
| 2 | #define CORE_CUBE_H | ||
| 3 | |||
| 1 | STATIC bool cube_true(cube_t); | 4 | STATIC bool cube_true(cube_t); |
| 2 | 5 | ||
| 3 | STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); | 6 | STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| @@ -369,3 +372,5 @@ cornertob32(uint8_t corner) | |||
| 369 | 372 | ||
| 370 | return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); | 373 | return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); |
| 371 | } | 374 | } |
| 375 | |||
| 376 | #endif /* CORE_CUBE_H */ | ||
diff --git a/src/core/moves.h b/src/core/moves.h index 9f1f7cc..19314de 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_MOVES_H | ||
| 2 | #define CORE_MOVES_H | ||
| 3 | |||
| 1 | #define MOVE(M, c) compose(c, MOVE_CUBE_ ## M) | 4 | #define MOVE(M, c) compose(c, MOVE_CUBE_ ## M) |
| 2 | #define PREMOVE(M, c) compose(MOVE_CUBE_ ## M, c) | 5 | #define PREMOVE(M, c) compose(MOVE_CUBE_ ## M, c) |
| 3 | 6 | ||
| @@ -719,3 +722,5 @@ unniss_error: | |||
| 719 | LOG("[variations] Error writing result.\n"); | 722 | LOG("[variations] Error writing result.\n"); |
| 720 | return NISSY_ERROR_BUFFER_SIZE; | 723 | return NISSY_ERROR_BUFFER_SIZE; |
| 721 | } | 724 | } |
| 725 | |||
| 726 | #endif /* CORE_MOVES_H */ | ||
diff --git a/src/core/oriented_cube.h b/src/core/oriented_cube.h index 5449204..cc08736 100644 --- a/src/core/oriented_cube.h +++ b/src/core/oriented_cube.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_ORIENTED_CUBE_H | ||
| 2 | #define CORE_ORIENTED_CUBE_H | ||
| 3 | |||
| 1 | STATIC oriented_cube_t solvedcube(void); | 4 | STATIC oriented_cube_t solvedcube(void); |
| 2 | 5 | ||
| 3 | STATIC oriented_cube_t move_extended(oriented_cube_t, uint8_t); | 6 | STATIC oriented_cube_t move_extended(oriented_cube_t, uint8_t); |
| @@ -75,3 +78,5 @@ applymoves(oriented_cube_t cube, const char *buf) | |||
| 75 | cinv.cube = inverse(cinv.cube); | 78 | cinv.cube = inverse(cinv.cube); |
| 76 | return compose_oriented(cinv, c); | 79 | return compose_oriented(cinv, c); |
| 77 | } | 80 | } |
| 81 | |||
| 82 | #endif /* CORE_ORIENTED_CUBE_H */ | ||
diff --git a/src/core/transform.h b/src/core/transform.h index af4634e..1c896e0 100644 --- a/src/core/transform.h +++ b/src/core/transform.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef CORE_TRANSFORM_H | ||
| 2 | #define CORE_TRANSFORM_H | ||
| 3 | |||
| 1 | #define TRANS_EDGES_ROTATION(T, c) \ | 4 | #define TRANS_EDGES_ROTATION(T, c) \ |
| 2 | compose_edges(compose_edges(TRANS_CUBE_ ## T, c), \ | 5 | compose_edges(compose_edges(TRANS_CUBE_ ## T, c), \ |
| 3 | TRANS_CUBE_ ## T ## _INVERSE) | 6 | TRANS_CUBE_ ## T ## _INVERSE) |
| @@ -418,3 +421,5 @@ symmetry_mask(cube_t cube) | |||
| 418 | 421 | ||
| 419 | return ret; | 422 | return ret; |
| 420 | } | 423 | } |
| 424 | |||
| 425 | #endif /* CORE_TRANSFORM_H */ | ||
diff --git a/src/solvers/coord/checkdata.h b/src/solvers/coord/checkdata.h index 51265a8..a5d5316 100644 --- a/src/solvers/coord/checkdata.h +++ b/src/solvers/coord/checkdata.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_CHECKDATA_H | ||
| 2 | #define SOLVERS_COORD_CHECKDATA_H | ||
| 3 | |||
| 1 | STATIC long long checkdata_coord_dispatch( | 4 | STATIC long long checkdata_coord_dispatch( |
| 2 | const char *, unsigned long long, const unsigned char *); | 5 | const char *, unsigned long long, const unsigned char *); |
| 3 | STATIC long long checkdata_coord( | 6 | STATIC long long checkdata_coord( |
| @@ -120,3 +123,5 @@ checkdata_multicoord( | |||
| 120 | 123 | ||
| 121 | return NISSY_OK; | 124 | return NISSY_OK; |
| 122 | } | 125 | } |
| 126 | |||
| 127 | #endif /* SOLVERS_COORD_CHECKDATA_H */ | ||
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index 3a62e85..8e6db20 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_COMMON_H | ||
| 2 | #define SOLVERS_COORD_COMMON_H | ||
| 3 | |||
| 1 | STATIC uint64_t coord_coord_generic( | 4 | STATIC uint64_t coord_coord_generic( |
| 2 | const coord_t [NON_NULL], cube_t, const unsigned char *); | 5 | const coord_t [NON_NULL], cube_t, const unsigned char *); |
| 3 | STATIC cube_t coord_cube_generic( | 6 | STATIC cube_t coord_cube_generic( |
| @@ -229,3 +232,5 @@ coordinate_merge_cpco(cube_t cp, cube_t co) | |||
| 229 | 232 | ||
| 230 | return merged; | 233 | return merged; |
| 231 | } | 234 | } |
| 235 | |||
| 236 | #endif /* SOLVERS_COORD_COMMON_H */ | ||
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index 98f4d05..6c4cc1b 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_COORD_H | ||
| 2 | #define SOLVERS_COORD_COORD_H | ||
| 3 | |||
| 1 | #include "types_macros.h" | 4 | #include "types_macros.h" |
| 2 | #include "common.h" | 5 | #include "common.h" |
| 3 | #include "eo.h" | 6 | #include "eo.h" |
| @@ -16,3 +19,5 @@ | |||
| 16 | #include "checkdata.h" | 19 | #include "checkdata.h" |
| 17 | #include "solve.h" | 20 | #include "solve.h" |
| 18 | #include "multisolve.h" | 21 | #include "multisolve.h" |
| 22 | |||
| 23 | #endif /* SOLVERS_COORD_COORD_H */ | ||
diff --git a/src/solvers/coord/corners.h b/src/solvers/coord/corners.h index cc0d9a5..6dd60b5 100644 --- a/src/solvers/coord/corners.h +++ b/src/solvers/coord/corners.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_CORNERS_H | ||
| 2 | #define SOLVERS_COORD_CORNERS_H | ||
| 3 | |||
| 1 | #define CLASSES_CP_48 984 | 4 | #define CLASSES_CP_48 984 |
| 2 | 5 | ||
| 3 | STATIC uint64_t coordinate_corners_coord(const cube_t, const unsigned char *); | 6 | STATIC uint64_t coordinate_corners_coord(const cube_t, const unsigned char *); |
| @@ -70,3 +73,5 @@ coordinate_corners_gendata(unsigned char *data) | |||
| 70 | { | 73 | { |
| 71 | return coord_gendata_generic(&coordinate_corners, data); | 74 | return coord_gendata_generic(&coordinate_corners, data); |
| 72 | } | 75 | } |
| 76 | |||
| 77 | #endif /* SOLVERS_COORD_CORNERS_H */ | ||
diff --git a/src/solvers/coord/cornersx.h b/src/solvers/coord/cornersx.h index 788db8d..f4b564f 100644 --- a/src/solvers/coord/cornersx.h +++ b/src/solvers/coord/cornersx.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_CORNERSX_H | ||
| 2 | #define SOLVERS_COORD_CORNERSX_H | ||
| 3 | |||
| 1 | STATIC bool is_cornersx_solved(uint64_t, const unsigned char *); | 4 | STATIC bool is_cornersx_solved(uint64_t, const unsigned char *); |
| 2 | 5 | ||
| 3 | STATIC coord_t coordinate_cornersx = { | 6 | STATIC coord_t coordinate_cornersx = { |
| @@ -74,3 +77,5 @@ is_cornersx_solved(uint64_t coord, const unsigned char *data) | |||
| 74 | 77 | ||
| 75 | return false; | 78 | return false; |
| 76 | } | 79 | } |
| 80 | |||
| 81 | #endif /* SOLVERS_COORD_CORNERSX_H */ | ||
diff --git a/src/solvers/coord/cpepe.h b/src/solvers/coord/cpepe.h index 7035400..1ad80dd 100644 --- a/src/solvers/coord/cpepe.h +++ b/src/solvers/coord/cpepe.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_CPEPE_H | ||
| 2 | #define SOLVERS_COORD_CPEPE_H | ||
| 3 | |||
| 1 | STATIC uint64_t coordinate_cpepe_coord(const cube_t, const unsigned char *); | 4 | STATIC uint64_t coordinate_cpepe_coord(const cube_t, const unsigned char *); |
| 2 | STATIC cube_t coordinate_cpepe_cube(uint64_t, const unsigned char *); | 5 | STATIC cube_t coordinate_cpepe_cube(uint64_t, const unsigned char *); |
| 3 | STATIC bool coordinate_cpepe_isnasty(uint64_t, const unsigned char *); | 6 | STATIC bool coordinate_cpepe_isnasty(uint64_t, const unsigned char *); |
| @@ -71,3 +74,5 @@ coordinate_cpepe_gendata(unsigned char *data) | |||
| 71 | { | 74 | { |
| 72 | return coord_gendata_generic(&coordinate_cpepe, data); | 75 | return coord_gendata_generic(&coordinate_cpepe, data); |
| 73 | } | 76 | } |
| 77 | |||
| 78 | #endif /* SOLVERS_COORD_CPEPE_H */ | ||
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h index 8100910..c5c73c2 100644 --- a/src/solvers/coord/dr.h +++ b/src/solvers/coord/dr.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_DR_H | ||
| 2 | #define SOLVERS_COORD_DR_H | ||
| 3 | |||
| 1 | #define DREOESEP_CLASSES UINT64_C(64430) | 4 | #define DREOESEP_CLASSES UINT64_C(64430) |
| 2 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) | 5 | #define DREOESEP_MAX (POW_2_11 * COMB_12_4) |
| 3 | 6 | ||
| @@ -117,3 +120,5 @@ is_eoco_solvable(cube_t cube) { | |||
| 117 | 120 | ||
| 118 | return cocount % 3 == 0 && eocount % 2 == 0; | 121 | return cocount % 3 == 0 && eocount % 2 == 0; |
| 119 | } | 122 | } |
| 123 | |||
| 124 | #endif /* SOLVERS_COORD_DR_H */ | ||
diff --git a/src/solvers/coord/dreo.h b/src/solvers/coord/dreo.h index c5cacac..a201ae6 100644 --- a/src/solvers/coord/dreo.h +++ b/src/solvers/coord/dreo.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_DREO_H | ||
| 2 | #define SOLVERS_COORD_DREO_H | ||
| 3 | |||
| 1 | #define DRESEP_CLASSES 81 | 4 | #define DRESEP_CLASSES 81 |
| 2 | 5 | ||
| 3 | STATIC uint64_t coord_dresep_nosym(cube_t); | 6 | STATIC uint64_t coord_dresep_nosym(cube_t); |
| @@ -101,3 +104,5 @@ is_dreo_solvable(cube_t cube) { | |||
| 101 | 104 | ||
| 102 | return cocount % 3 == 0; | 105 | return cocount % 3 == 0; |
| 103 | } | 106 | } |
| 107 | |||
| 108 | #endif /* SOLVERS_COORD_DREO_H */ | ||
diff --git a/src/solvers/coord/drfin.h b/src/solvers/coord/drfin.h index 569419b..ec645a2 100644 --- a/src/solvers/coord/drfin.h +++ b/src/solvers/coord/drfin.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_DRFIN_H | ||
| 2 | #define SOLVERS_COORD_DRFIN_H | ||
| 3 | |||
| 1 | STATIC bool is_drfin_solvable(cube_t); | 4 | STATIC bool is_drfin_solvable(cube_t); |
| 2 | 5 | ||
| 3 | STATIC multicoord_t multicoordinate_drfin = { | 6 | STATIC multicoord_t multicoordinate_drfin = { |
| @@ -15,3 +18,5 @@ is_drfin_solvable(cube_t cube) | |||
| 15 | coord_co(cube) == 0 && | 18 | coord_co(cube) == 0 && |
| 16 | issolvable((oriented_cube_t){.cube = cube, .orientation = 0}); | 19 | issolvable((oriented_cube_t){.cube = cube, .orientation = 0}); |
| 17 | } | 20 | } |
| 21 | |||
| 22 | #endif /* SOLVERS_COORD_DRFIN_H */ | ||
diff --git a/src/solvers/coord/drfinnoe.h b/src/solvers/coord/drfinnoe.h index 63f4edf..5ffffc3 100644 --- a/src/solvers/coord/drfinnoe.h +++ b/src/solvers/coord/drfinnoe.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_DRFINNOE_H | ||
| 2 | #define SOLVERS_COORD_DRFINNOE_H | ||
| 3 | |||
| 1 | /* | 4 | /* |
| 2 | TODO | 5 | TODO |
| 3 | 6 | ||
| @@ -96,3 +99,5 @@ is_drfinnoe_solvable(cube_t cube) { | |||
| 96 | coord_eo(transform_edges(cube, TRANS_URr)) == 0 && | 99 | coord_eo(transform_edges(cube, TRANS_URr)) == 0 && |
| 97 | coord_co(cube) == 0; | 100 | coord_co(cube) == 0; |
| 98 | } | 101 | } |
| 102 | |||
| 103 | #endif /* SOLVERS_COORD_DRFINNOE_H */ | ||
diff --git a/src/solvers/coord/drslice.h b/src/solvers/coord/drslice.h index 42699f8..87bf87e 100644 --- a/src/solvers/coord/drslice.h +++ b/src/solvers/coord/drslice.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_DRSLICE_H | ||
| 2 | #define SOLVERS_COORD_DRSLICE_H | ||
| 3 | |||
| 1 | /* | 4 | /* |
| 2 | The DRSLICE coordinate is almost identical to DRFINNOE, but it allows for | 5 | The DRSLICE coordinate is almost identical to DRFINNOE, but it allows for |
| 3 | the centers of the E layer to be off by a rotation. For this reason we reuse | 6 | the centers of the E layer to be off by a rotation. For this reason we reuse |
| @@ -95,3 +98,5 @@ is_drslice_solved(uint64_t i, const unsigned char *data) | |||
| 95 | /* Pre-computed coordinates of U D' (= U' D up to trans) and U2 D2 */ | 98 | /* Pre-computed coordinates of U D' (= U' D up to trans) and U2 D2 */ |
| 96 | return i == 0 || i == 109779816 || i == 68468527; | 99 | return i == 0 || i == 109779816 || i == 68468527; |
| 97 | } | 100 | } |
| 101 | |||
| 102 | #endif /* SOLVERS_COORD_DRSLICE_H */ | ||
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h index 42196af..a5a0e85 100644 --- a/src/solvers/coord/eo.h +++ b/src/solvers/coord/eo.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_EO_H | ||
| 2 | #define SOLVERS_COORD_EO_H | ||
| 3 | |||
| 1 | STATIC uint64_t coordinate_eo_coord(cube_t, const unsigned char *); | 4 | STATIC uint64_t coordinate_eo_coord(cube_t, const unsigned char *); |
| 2 | STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *); | 5 | STATIC cube_t coordinate_eo_cube(uint64_t, const unsigned char *); |
| 3 | STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *); | 6 | STATIC bool coordinate_eo_isnasty(uint64_t, const unsigned char *); |
| @@ -57,3 +60,5 @@ coordinate_eo_gendata(unsigned char *data) | |||
| 57 | { | 60 | { |
| 58 | return 0; | 61 | return 0; |
| 59 | } | 62 | } |
| 63 | |||
| 64 | #endif /* SOLVERS_COORD_EO_H */ | ||
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index 81ab842..a48263c 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_GENDATA_H | ||
| 2 | #define SOLVERS_COORD_GENDATA_H | ||
| 3 | |||
| 1 | STATIC size_t gendata_coord(const coord_t [NON_NULL], unsigned char *); | 4 | STATIC size_t gendata_coord(const coord_t [NON_NULL], unsigned char *); |
| 2 | STATIC size_t gendata_multicoord( | 5 | STATIC size_t gendata_multicoord( |
| 3 | const multicoord_t [NON_NULL], unsigned char *); | 6 | const multicoord_t [NON_NULL], unsigned char *); |
| @@ -362,3 +365,5 @@ set_coord_pval( | |||
| 362 | table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) | 365 | table[COORD_INDEX(i)] = (table[COORD_INDEX(i)] & (~COORD_MASK(i))) |
| 363 | | (val << COORD_SHIFT(i)); | 366 | | (val << COORD_SHIFT(i)); |
| 364 | } | 367 | } |
| 368 | |||
| 369 | #endif /* SOLVERS_COORD_GENDATA_H */ | ||
diff --git a/src/solvers/coord/htr.h b/src/solvers/coord/htr.h index 602625b..d6fc311 100644 --- a/src/solvers/coord/htr.h +++ b/src/solvers/coord/htr.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_HTR_H | ||
| 2 | #define SOLVERS_COORD_HTR_H | ||
| 3 | |||
| 1 | STATIC uint64_t coordinate_htr_coord(cube_t, const unsigned char *); | 4 | STATIC uint64_t coordinate_htr_coord(cube_t, const unsigned char *); |
| 2 | STATIC cube_t coordinate_htr_cube(uint64_t, const unsigned char *); | 5 | STATIC cube_t coordinate_htr_cube(uint64_t, const unsigned char *); |
| 3 | STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *); | 6 | STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *); |
| @@ -123,3 +126,5 @@ is_cp_htr(uint64_t i, const unsigned char *data) | |||
| 123 | 126 | ||
| 124 | return e == 0 && is_cp16_htr_table[c / 8] & (UINT8_C(1) << (c % 8)); | 127 | return e == 0 && is_cp16_htr_table[c / 8] & (UINT8_C(1) << (c % 8)); |
| 125 | } | 128 | } |
| 129 | |||
| 130 | #endif /* SOLVERS_COORD_HTR_H */ | ||
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index 6856c13..71f7920 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_LIST_H | ||
| 2 | #define SOLVERS_COORD_LIST_H | ||
| 3 | |||
| 1 | coord_t *all_coordinates[] = { | 4 | coord_t *all_coordinates[] = { |
| 2 | &coordinate_eo, | 5 | &coordinate_eo, |
| 3 | &coordinate_dr, | 6 | &coordinate_dr, |
| @@ -15,3 +18,5 @@ multicoord_t *all_multicoordinates[] = { | |||
| 15 | &multicoordinate_drfin, | 18 | &multicoordinate_drfin, |
| 16 | NULL | 19 | NULL |
| 17 | }; | 20 | }; |
| 21 | |||
| 22 | #endif /* SOLVERS_COORD_LIST_H */ | ||
diff --git a/src/solvers/coord/multisolve.h b/src/solvers/coord/multisolve.h index efd287d..4990a39 100644 --- a/src/solvers/coord/multisolve.h +++ b/src/solvers/coord/multisolve.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_MULTISOLVE_H | ||
| 2 | #define SOLVERS_COORD_MULTISOLVE_H | ||
| 3 | |||
| 1 | /* | 4 | /* |
| 2 | For now the only multicoordinate is DRFIN, and this solver reflects this. | 5 | For now the only multicoordinate is DRFIN, and this solver reflects this. |
| 3 | For example, NISS is not available. | 6 | For example, NISS is not available. |
| @@ -297,3 +300,5 @@ solve_multicoord_error_unsolvable: | |||
| 297 | LOG("[%s solve] Error: cube not ready\n", mcoord->name); | 300 | LOG("[%s solve] Error: cube not ready\n", mcoord->name); |
| 298 | return NISSY_ERROR_UNSOLVABLE_CUBE; | 301 | return NISSY_ERROR_UNSOLVABLE_CUBE; |
| 299 | } | 302 | } |
| 303 | |||
| 304 | #endif /* SOLVERS_COORD_MULTISOLVE_H */ | ||
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index 6bb9af2..9a0c63c 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_SOLVE_H | ||
| 2 | #define SOLVERS_COORD_SOLVE_H | ||
| 3 | |||
| 1 | typedef struct { | 4 | typedef struct { |
| 2 | cube_t cube; | 5 | cube_t cube; |
| 3 | cube_t inverse; | 6 | cube_t inverse; |
| @@ -400,3 +403,5 @@ solve_coord_error_unsolvable: | |||
| 400 | LOG("[%s solve] Error: cube not ready\n", coord->name); | 403 | LOG("[%s solve] Error: cube not ready\n", coord->name); |
| 401 | return NISSY_ERROR_UNSOLVABLE_CUBE; | 404 | return NISSY_ERROR_UNSOLVABLE_CUBE; |
| 402 | } | 405 | } |
| 406 | |||
| 407 | #endif /* SOLVERS_COORD_SOLVE_H */ | ||
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index 81db9d4..b042788 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_COORD_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define COORD_INDEX(i) ((i)/2) | 4 | #define COORD_INDEX(i) ((i)/2) |
| 2 | #define COORD_SHIFT(i) (UINT8_C(4) * (uint8_t)((i) % 2)) | 5 | #define COORD_SHIFT(i) (UINT8_C(4) * (uint8_t)((i) % 2)) |
| 3 | #define COORD_MASK(i) (UINT8_C(0xF) << COORD_SHIFT(i)) | 6 | #define COORD_MASK(i) (UINT8_C(0xF) << COORD_SHIFT(i)) |
| @@ -53,3 +56,5 @@ typedef struct { | |||
| 53 | uint64_t moves_mask; | 56 | uint64_t moves_mask; |
| 54 | bool (*is_solvable)(cube_t); | 57 | bool (*is_solvable)(cube_t); |
| 55 | } multicoord_t; | 58 | } multicoord_t; |
| 59 | |||
| 60 | #endif /* SOLVERS_COORD_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index 0062587..232d6f8 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_COORD_UTILS_H | ||
| 2 | #define SOLVERS_COORD_UTILS_H | ||
| 3 | |||
| 1 | STATIC coord_t *parse_coord(size_t, const char *); | 4 | STATIC coord_t *parse_coord(size_t, const char *); |
| 2 | STATIC multicoord_t *parse_multicoord(size_t, const char *); | 5 | STATIC multicoord_t *parse_multicoord(size_t, const char *); |
| 3 | STATIC void parse_coord_and_trans( | 6 | STATIC void parse_coord_and_trans( |
| @@ -80,3 +83,5 @@ dataid_coord(const char *ca, char dataid[SIZE(NISSY_SIZE_DATAID)]) | |||
| 80 | LOG("Error: cannot parse coordinate from '%s'\n", ca); | 83 | LOG("Error: cannot parse coordinate from '%s'\n", ca); |
| 81 | return NISSY_ERROR_INVALID_SOLVER; | 84 | return NISSY_ERROR_INVALID_SOLVER; |
| 82 | } | 85 | } |
| 86 | |||
| 87 | #endif /* SOLVERS_COORD_UTILS_H */ | ||
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h index f6d2bee..89a0771 100644 --- a/src/solvers/dispatch.h +++ b/src/solvers/dispatch.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_DISPATCH_H | ||
| 2 | #define SOLVERS_DISPATCH_H | ||
| 3 | |||
| 1 | typedef struct { | 4 | typedef struct { |
| 2 | const char *solvername; | 5 | const char *solvername; |
| 3 | const char *prefix; | 6 | const char *prefix; |
| @@ -100,3 +103,5 @@ match_solver(const char *name) | |||
| 100 | 103 | ||
| 101 | return solver_dispatchers[i]; | 104 | return solver_dispatchers[i]; |
| 102 | } | 105 | } |
| 106 | |||
| 107 | #endif /* SOLVERS_DISPATCH_H */ | ||
diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index a996e3db..1ed7453 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_DISTRIBUTION_H | ||
| 2 | #define SOLVERS_DISTRIBUTION_H | ||
| 3 | |||
| 1 | #define ENTRIES_PER_BYTE(k) (UINT64_C(8) / (uint64_t)(k)) | 4 | #define ENTRIES_PER_BYTE(k) (UINT64_C(8) / (uint64_t)(k)) |
| 2 | #define TABLE_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % ENTRIES_PER_BYTE(k))) | 5 | #define TABLE_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % ENTRIES_PER_BYTE(k))) |
| 3 | #define TABLE_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << TABLE_SHIFT(i, k)) | 6 | #define TABLE_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << TABLE_SHIFT(i, k)) |
| @@ -99,3 +102,5 @@ distribution_equal( | |||
| 99 | 102 | ||
| 100 | return wrong == 0; | 103 | return wrong == 0; |
| 101 | } | 104 | } |
| 105 | |||
| 106 | #endif /* SOLVERS_DISTRIBUTION_H */ | ||
diff --git a/src/solvers/h48/checkdata.h b/src/solvers/h48/checkdata.h index 948ac67..e2fa38c 100644 --- a/src/solvers/h48/checkdata.h +++ b/src/solvers/h48/checkdata.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_CHECKDATA_H | ||
| 2 | #define SOLVERS_H48_CHECKDATA_H | ||
| 3 | |||
| 1 | STATIC long long checkdata_h48( | 4 | STATIC long long checkdata_h48( |
| 2 | const char *, unsigned long long, const unsigned char *); | 5 | const char *, unsigned long long, const unsigned char *); |
| 3 | 6 | ||
| @@ -194,3 +197,5 @@ checkdata_h48( | |||
| 194 | 197 | ||
| 195 | return NISSY_OK; | 198 | return NISSY_OK; |
| 196 | } | 199 | } |
| 200 | |||
| 201 | #endif /* SOLVERS_H48_CHECKDATA_H */ | ||
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index 695efc3..acbb9c0 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_COORDINATE_H | ||
| 2 | #define SOLVERS_H48_COORDINATE_H | ||
| 3 | |||
| 1 | STATIC_INLINE uint64_t coord_h48( | 4 | STATIC_INLINE uint64_t coord_h48( |
| 2 | cube_t, const uint32_t [SIZE(COCSEP_TABLESIZE)], uint8_t); | 5 | cube_t, const uint32_t [SIZE(COCSEP_TABLESIZE)], uint8_t); |
| 3 | STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); | 6 | STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); |
| @@ -68,3 +71,5 @@ invcoord_h48( | |||
| 68 | 71 | ||
| 69 | return ret; | 72 | return ret; |
| 70 | } | 73 | } |
| 74 | |||
| 75 | #endif /* SOLVERS_H48_COORDINATE_H */ | ||
diff --git a/src/solvers/h48/coordinate_types_macros.h b/src/solvers/h48/coordinate_types_macros.h index cf24e47..6ddd3e8 100644 --- a/src/solvers/h48/coordinate_types_macros.h +++ b/src/solvers/h48/coordinate_types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_COORDINATE_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_H48_COORDINATE_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (uint64_t)(h)) | 4 | #define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (uint64_t)(h)) |
| 2 | 5 | ||
| 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) | 6 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) |
| @@ -5,3 +8,5 @@ | |||
| 5 | #define ECLASS(x) COCLASS(x) | 8 | #define ECLASS(x) COCLASS(x) |
| 6 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) | 9 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) |
| 7 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) | 10 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) |
| 11 | |||
| 12 | #endif /* SOLVERS_H48_COORDINATE_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/h48/distribution_h48.h b/src/solvers/h48/distribution_h48.h index 2cb50aa..b7f3811 100644 --- a/src/solvers/h48/distribution_h48.h +++ b/src/solvers/h48/distribution_h48.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_DISTRIBUTION_H48_H | ||
| 2 | #define SOLVERS_H48_DISTRIBUTION_H48_H | ||
| 3 | |||
| 1 | /* | 4 | /* |
| 2 | This file is very similar to ../distibution.h, but some adaptations are | 5 | This file is very similar to ../distibution.h, but some adaptations are |
| 3 | needed for H48 because of the intertwined fallback table, and it is easier | 6 | needed for H48 because of the intertwined fallback table, and it is easier |
| @@ -74,3 +77,5 @@ getdistribution_h48( | |||
| 74 | c = H48_LINE_EXT(H48_COORDMAX(info->h48h)) % H48_LINE_ALLCOORDS; | 77 | c = H48_LINE_EXT(H48_COORDMAX(info->h48h)) % H48_LINE_ALLCOORDS; |
| 75 | distr[3] -= H48_LINE_COORDS - c; | 78 | distr[3] -= H48_LINE_COORDS - c; |
| 76 | } | 79 | } |
| 80 | |||
| 81 | #endif /* SOLVERS_H48_DISTRIBUTION_H48_H */ | ||
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index f83207b..1cea52e 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_GENDATA_COCSEP_H | ||
| 2 | #define SOLVERS_H48_GENDATA_COCSEP_H | ||
| 3 | |||
| 1 | STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); | 4 | STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); |
| 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [NON_NULL]); | 5 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [NON_NULL]); |
| 3 | 6 | ||
| @@ -164,3 +167,5 @@ get_h48_cdata( | |||
| 164 | 167 | ||
| 165 | return CBOUND(*cdata); | 168 | return CBOUND(*cdata); |
| 166 | } | 169 | } |
| 170 | |||
| 171 | #endif /* SOLVERS_H48_GENDATA_COCSEP_H */ | ||
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index 81bbd43..55097c9 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_GENDATA_EOESEP_H | ||
| 2 | #define SOLVERS_H48_GENDATA_EOESEP_H | ||
| 3 | |||
| 1 | STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [SIZE(ESEP_MAX)]); | 4 | STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [SIZE(ESEP_MAX)]); |
| 2 | STATIC size_t gendata_esep_classes( | 5 | STATIC size_t gendata_esep_classes( |
| 3 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); | 6 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); |
| @@ -280,3 +283,5 @@ set_eoesep_pval( | |||
| 280 | table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i))) | 283 | table[EOESEP_INDEX(i)] = (table[EOESEP_INDEX(i)] & (~EOESEP_MASK(i))) |
| 281 | | (val << EOESEP_SHIFT(i)); | 284 | | (val << EOESEP_SHIFT(i)); |
| 282 | } | 285 | } |
| 286 | |||
| 287 | #endif /* SOLVERS_H48_GENDATA_EOESEP_H */ | ||
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 53b1fad..0b85e49 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_GENDATA_H48_H | ||
| 2 | #define SOLVERS_H48_GENDATA_H48_H | ||
| 3 | |||
| 1 | STATIC long long gendata_h48_dispatch( | 4 | STATIC long long gendata_h48_dispatch( |
| 2 | const char *, unsigned long long, unsigned char *); | 5 | const char *, unsigned long long, unsigned char *); |
| 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); | 6 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); |
| @@ -547,3 +550,5 @@ get_h48_pval_and_min( | |||
| 547 | *pval_min = tmin >> UINT8_C(4); | 550 | *pval_min = tmin >> UINT8_C(4); |
| 548 | return (t & H48_MASK(iext)) >> H48_SHIFT(iext); | 551 | return (t & H48_MASK(iext)) >> H48_SHIFT(iext); |
| 549 | } | 552 | } |
| 553 | |||
| 554 | #endif /* SOLVERS_H48_GENDATA_H48_H */ | ||
diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h index 9bce2c9..e81acc5 100644 --- a/src/solvers/h48/gendata_types_macros.h +++ b/src/solvers/h48/gendata_types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_GENDATA_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_H48_GENDATA_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define COCSEP_CLASSES ((size_t)3393) | 4 | #define COCSEP_CLASSES ((size_t)3393) |
| 2 | #define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7) | 5 | #define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7) |
| 3 | #define COCSEP_VISITEDSIZE DIV_ROUND_UP(COCSEP_TABLESIZE, (size_t)8) | 6 | #define COCSEP_VISITEDSIZE DIV_ROUND_UP(COCSEP_TABLESIZE, (size_t)8) |
| @@ -116,3 +119,5 @@ typedef struct { | |||
| 116 | wrapthread_atomic unsigned char *table_atomic; | 119 | wrapthread_atomic unsigned char *table_atomic; |
| 117 | wrapthread_define_struct_mutex_t(**table_mutex); | 120 | wrapthread_define_struct_mutex_t(**table_mutex); |
| 118 | } gendata_h48_mark_t; | 121 | } gendata_h48_mark_t; |
| 122 | |||
| 123 | #endif /* SOLVERS_H48_GENDATA_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/h48/h48.h b/src/solvers/h48/h48.h index f7ba8b7..e05fc2b 100644 --- a/src/solvers/h48/h48.h +++ b/src/solvers/h48/h48.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_H48_H | ||
| 2 | #define SOLVERS_H48_H48_H | ||
| 3 | |||
| 1 | #include "utils.h" | 4 | #include "utils.h" |
| 2 | #include "coordinate_types_macros.h" | 5 | #include "coordinate_types_macros.h" |
| 3 | #include "map_types_macros.h" | 6 | #include "map_types_macros.h" |
| @@ -10,3 +13,5 @@ | |||
| 10 | #include "gendata_h48.h" | 13 | #include "gendata_h48.h" |
| 11 | #include "checkdata.h" | 14 | #include "checkdata.h" |
| 12 | #include "solve.h" | 15 | #include "solve.h" |
| 16 | |||
| 17 | #endif /* SOLVERS_H48_H48_H */ | ||
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index c9cfb06..75b5236 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_MAP_H | ||
| 2 | #define SOLVERS_H48_MAP_H | ||
| 3 | |||
| 1 | STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); | 4 | STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 2 | STATIC void h48map_clear(h48map_t [NON_NULL]); | 5 | STATIC void h48map_clear(h48map_t [NON_NULL]); |
| 3 | STATIC void h48map_destroy(h48map_t [NON_NULL]); | 6 | STATIC void h48map_destroy(h48map_t [NON_NULL]); |
| @@ -82,3 +85,5 @@ h48map_nextkvpair(h48map_t map[NON_NULL], uint64_t p[NON_NULL]) | |||
| 82 | 85 | ||
| 83 | return kv; | 86 | return kv; |
| 84 | } | 87 | } |
| 88 | |||
| 89 | #endif /* SOLVERS_H48_MAP_H */ | ||
diff --git a/src/solvers/h48/map_types_macros.h b/src/solvers/h48/map_types_macros.h index b77c68a..a4e3c75 100644 --- a/src/solvers/h48/map_types_macros.h +++ b/src/solvers/h48/map_types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_MAP_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_H48_MAP_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF) | 4 | #define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF) |
| 2 | #define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF) | 5 | #define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF) |
| 3 | #define MAP_KEYSHIFT UINT64_C(40) | 6 | #define MAP_KEYSHIFT UINT64_C(40) |
| @@ -14,3 +17,5 @@ typedef struct { | |||
| 14 | uint64_t key; | 17 | uint64_t key; |
| 15 | uint64_t val; | 18 | uint64_t val; |
| 16 | } kvpair_t; | 19 | } kvpair_t; |
| 20 | |||
| 21 | #endif /* SOLVERS_H48_MAP_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index ebc5208..36fefa1 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_SOLVE_H | ||
| 2 | #define SOLVERS_H48_SOLVE_H | ||
| 3 | |||
| 1 | #define H48_STARTING_MOVES 4 | 4 | #define H48_STARTING_MOVES 4 |
| 2 | #define H48_STARTING_CUBES 43254 | 5 | #define H48_STARTING_CUBES 43254 |
| 3 | #define H48_SORT_TASKS_MIN_DEPTH 16 | 6 | #define H48_SORT_TASKS_MIN_DEPTH 16 |
| @@ -758,3 +761,5 @@ solve_h48_error_data: | |||
| 758 | solve_h48_error_solutions_buffer: | 761 | solve_h48_error_solutions_buffer: |
| 759 | return NISSY_ERROR_BUFFER_SIZE; | 762 | return NISSY_ERROR_BUFFER_SIZE; |
| 760 | } | 763 | } |
| 764 | |||
| 765 | #endif /* SOLVERS_H48_SOLVE_H */ | ||
diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h index 6d91108..81c6451 100644 --- a/src/solvers/h48/utils.h +++ b/src/solvers/h48/utils.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_H48_UTILS_H | ||
| 2 | #define SOLVERS_H48_UTILS_H | ||
| 3 | |||
| 1 | #if SIZE_MAX == UINT64_MAX | 4 | #if SIZE_MAX == UINT64_MAX |
| 2 | #define H48_HMAX UINT8_C(11) | 5 | #define H48_HMAX UINT8_C(11) |
| 3 | #else | 6 | #else |
| @@ -63,3 +66,5 @@ dataid_h48(const char *str, char buf[SIZE(NISSY_SIZE_DATAID)]) | |||
| 63 | sprintf(buf, "h48h%" PRIu8, h); | 66 | sprintf(buf, "h48h%" PRIu8, h); |
| 64 | return NISSY_OK; | 67 | return NISSY_OK; |
| 65 | } | 68 | } |
| 69 | |||
| 70 | #endif /* SOLVERS_H48_UTILS_H */ | ||
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index b7a848b..f9bed75 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_SOLUTIONS_H | ||
| 2 | #define SOLVERS_SOLUTIONS_H | ||
| 3 | |||
| 1 | STATIC void solution_moves_reset(solution_moves_t [NON_NULL]); | 4 | STATIC void solution_moves_reset(solution_moves_t [NON_NULL]); |
| 2 | STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t, | 5 | STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t, |
| 3 | uint8_t); | 6 | uint8_t); |
| @@ -338,3 +341,5 @@ solutions_done( | |||
| 338 | depth > list->shortest_sol + settings->optimal || | 341 | depth > list->shortest_sol + settings->optimal || |
| 339 | list->nsols >= settings->maxsolutions; | 342 | list->nsols >= settings->maxsolutions; |
| 340 | } | 343 | } |
| 344 | |||
| 345 | #endif /* SOLVERS_SOLUTIONS_H */ | ||
diff --git a/src/solvers/solutions_types_macros.h b/src/solvers/solutions_types_macros.h index cecd140..6cde681 100644 --- a/src/solvers/solutions_types_macros.h +++ b/src/solvers/solutions_types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_SOLUTIONS_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_SOLUTIONS_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define SOLUTION_MAXLEN 25 | 4 | #define SOLUTION_MAXLEN 25 |
| 2 | 5 | ||
| 3 | typedef struct { | 6 | typedef struct { |
| @@ -22,3 +25,5 @@ typedef struct { | |||
| 22 | size_t used; | 25 | size_t used; |
| 23 | char *buf; | 26 | char *buf; |
| 24 | } solution_list_t; | 27 | } solution_list_t; |
| 28 | |||
| 29 | #endif /* SOLVERS_SOLUTIONS_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/solvers.h b/src/solvers/solvers.h index f9f2287..fab6e27 100644 --- a/src/solvers/solvers.h +++ b/src/solvers/solvers.h | |||
| @@ -1,9 +1,14 @@ | |||
| 1 | #ifndef SOLVERS_SOLVERS_H | ||
| 2 | #define SOLVERS_SOLVERS_H | ||
| 3 | |||
| 1 | #include "solutions_types_macros.h" | 4 | #include "solutions_types_macros.h" |
| 2 | #include "solutions.h" | 5 | #include "solutions.h" |
| 3 | #include "tables_types_macros.h" | 6 | #include "tables_types_macros.h" |
| 4 | #include "tables.h" | 7 | #include "tables.h" |
| 5 | #include "distribution.h" | 8 | #include "distribution.h" |
| 6 | /*#include "coord/coord.h"*/ | 9 | #include "coord/coord.h" |
| 7 | #include "twostep/twostep.h" | 10 | #include "twostep/twostep.h" |
| 8 | #include "h48/h48.h" | 11 | #include "h48/h48.h" |
| 9 | #include "dispatch.h" | 12 | #include "dispatch.h" |
| 13 | |||
| 14 | #endif /* SOLVERS_SOLVERS_H */ | ||
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index 3db1d1e..f850793 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_TABLES_H | ||
| 2 | #define SOLVERS_TABLES_H | ||
| 3 | |||
| 1 | STATIC uint64_t read_unaligned_u64( | 4 | STATIC uint64_t read_unaligned_u64( |
| 2 | const unsigned char [SIZE(sizeof(uint64_t))]); | 5 | const unsigned char [SIZE(sizeof(uint64_t))]); |
| 3 | STATIC void write_unaligned_u64( | 6 | STATIC void write_unaligned_u64( |
| @@ -147,3 +150,5 @@ append_name(tableinfo_t info[NON_NULL], const char *str) | |||
| 147 | 150 | ||
| 148 | info->solver[j] = '\0'; | 151 | info->solver[j] = '\0'; |
| 149 | } | 152 | } |
| 153 | |||
| 154 | #endif /* SOLVERS_TABLES_H */ | ||
diff --git a/src/solvers/tables_types_macros.h b/src/solvers/tables_types_macros.h index b2809b7..8ae18d3 100644 --- a/src/solvers/tables_types_macros.h +++ b/src/solvers/tables_types_macros.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef SOLVERS_TABLES_TYPES_MACROS_H | ||
| 2 | #define SOLVERS_TABLES_TYPES_MACROS_H | ||
| 3 | |||
| 1 | #define OFFSET(B, K) (((unsigned char *)B) + K) | 4 | #define OFFSET(B, K) (((unsigned char *)B) + K) |
| 2 | 5 | ||
| 3 | #define INFOSIZE INT64_C(512) | 6 | #define INFOSIZE INT64_C(512) |
| @@ -37,3 +40,5 @@ typedef struct { | |||
| 37 | uint8_t base; | 40 | uint8_t base; |
| 38 | uint8_t maxvalue; | 41 | uint8_t maxvalue; |
| 39 | } tableinfo_t; | 42 | } tableinfo_t; |
| 43 | |||
| 44 | #endif /* SOLVERS_TABLES_TYPES_MACROS_H */ | ||
diff --git a/src/solvers/twostep/twostep.h b/src/solvers/twostep/twostep.h index 8947a50..e5b00f6 100644 --- a/src/solvers/twostep/twostep.h +++ b/src/solvers/twostep/twostep.h | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | #ifndef SRC_SOLVERS_TWOSTEP_TWOSTEP_H | ||
| 2 | #define SRC_SOLVERS_TWOSTEP_TWOSTEP_H | ||
| 3 | |||
| 1 | #include "../coord/coord.h" | 4 | #include "../coord/coord.h" |
| 2 | 5 | ||
| 6 | STATIC size_t twostep_size_1(void); | ||
| 7 | STATIC size_t twostep_size_2(void); | ||
| 3 | STATIC long long dataid_twostep(const char *, char [SIZE(NISSY_SIZE_DATAID)]); | 8 | STATIC long long dataid_twostep(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 4 | STATIC long long gendata_twostep( | 9 | STATIC long long gendata_twostep( |
| 5 | const char *, unsigned long long, unsigned char *); | 10 | const char *, unsigned long long, unsigned char *); |
| @@ -10,6 +15,23 @@ STATIC long long solve_twostep(oriented_cube_t, const char *, unsigned, | |||
| 10 | const unsigned char *, unsigned, char *, | 15 | const unsigned char *, unsigned, char *, |
| 11 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); | 16 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); |
| 12 | 17 | ||
| 18 | STATIC size_t | ||
| 19 | twostep_size_1(void) | ||
| 20 | { | ||
| 21 | size_t s; | ||
| 22 | |||
| 23 | s = gendata_coord(&coordinate_dr, NULL); | ||
| 24 | s = (size_t)8 * DIV_ROUND_UP(s, 8); /* Preserve 8-byte alignment */ | ||
| 25 | |||
| 26 | return s; | ||
| 27 | } | ||
| 28 | |||
| 29 | STATIC size_t | ||
| 30 | twostep_size_2(void) | ||
| 31 | { | ||
| 32 | return gendata_multicoord(&multicoordinate_drfin, NULL); | ||
| 33 | } | ||
| 34 | |||
| 13 | STATIC long long | 35 | STATIC long long |
| 14 | dataid_twostep(const char *s, char dataid[SIZE(NISSY_SIZE_DATAID)]) | 36 | dataid_twostep(const char *s, char dataid[SIZE(NISSY_SIZE_DATAID)]) |
| 15 | { | 37 | { |
| @@ -26,9 +48,8 @@ gendata_twostep( | |||
| 26 | { | 48 | { |
| 27 | size_t r, s1, s2; | 49 | size_t r, s1, s2; |
| 28 | 50 | ||
| 29 | s1 = gendata_coord(&coordinate_dr, NULL); | 51 | s1 = twostep_size_1(); |
| 30 | s1 = DIV_ROUND_UP(s1, 8); /* Preserve 8-byte alignment */ | 52 | s2 = twostep_size_2(); |
| 31 | s2 = gendata_multicoord(&multicoordinate_drfin, NULL); | ||
| 32 | 53 | ||
| 33 | if (buf == NULL) | 54 | if (buf == NULL) |
| 34 | goto gendata_twostep_return_size; | 55 | goto gendata_twostep_return_size; |
| @@ -41,7 +62,7 @@ gendata_twostep( | |||
| 41 | return NISSY_ERROR_UNKNOWN; | 62 | return NISSY_ERROR_UNKNOWN; |
| 42 | 63 | ||
| 43 | r = gendata_multicoord(&multicoordinate_drfin, buf + s1); | 64 | r = gendata_multicoord(&multicoordinate_drfin, buf + s1); |
| 44 | if (r != NISSY_OK) | 65 | if (r == 0) |
| 45 | return NISSY_ERROR_UNKNOWN; | 66 | return NISSY_ERROR_UNKNOWN; |
| 46 | 67 | ||
| 47 | gendata_twostep_return_size: | 68 | gendata_twostep_return_size: |
| @@ -63,7 +84,8 @@ checkdata_twostep( | |||
| 63 | if (r != NISSY_OK) | 84 | if (r != NISSY_OK) |
| 64 | return r; | 85 | return r; |
| 65 | 86 | ||
| 66 | r = checkdata_multicoord(&multicoordinate_drfin, bufsize, buf); | 87 | r = checkdata_multicoord( |
| 88 | &multicoordinate_drfin, bufsize, buf + twostep_size_1()); | ||
| 67 | if (r != NISSY_OK) | 89 | if (r != NISSY_OK) |
| 68 | return r; | 90 | return r; |
| 69 | 91 | ||
| @@ -91,3 +113,5 @@ solve_twostep( | |||
| 91 | { | 113 | { |
| 92 | //TODO | 114 | //TODO |
| 93 | } | 115 | } |
| 116 | |||
| 117 | #endif /* SRC_SOLVERS_TWOSTEP_TWOSTEP_H */ | ||
diff --git a/src/utils/compilers.h b/src/utils/compilers.h index 1b175bb..a2ae3ba 100644 --- a/src/utils/compilers.h +++ b/src/utils/compilers.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_COMPILERS_H | ||
| 2 | #define UTILS_COMPILERS_H | ||
| 3 | |||
| 1 | #if defined(__GNUC__) | 4 | #if defined(__GNUC__) |
| 2 | 5 | ||
| 3 | #define UNUSED __attribute__((unused)) | 6 | #define UNUSED __attribute__((unused)) |
| @@ -22,3 +25,5 @@ a[static N] notation for array parameters). | |||
| 22 | #define NON_NULL | 25 | #define NON_NULL |
| 23 | 26 | ||
| 24 | #endif | 27 | #endif |
| 28 | |||
| 29 | #endif /* UTILS_COMPILERS_H */ | ||
diff --git a/src/utils/constants.h b/src/utils/constants.h index 3eed27d..3d0f6e3 100644 --- a/src/utils/constants.h +++ b/src/utils/constants.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_CONSTANTS_H | ||
| 2 | #define UTILS_CONSTANTS_H | ||
| 3 | |||
| 1 | #define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i)) | 4 | #define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i)) |
| 2 | 5 | ||
| 3 | #define FACTORIAL_MAX UINT64_C(12) | 6 | #define FACTORIAL_MAX UINT64_C(12) |
| @@ -42,3 +45,5 @@ STATIC uint64_t binomial[12][12] = { | |||
| 42 | {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0}, | 45 | {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0}, |
| 43 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, | 46 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, |
| 44 | }; | 47 | }; |
| 48 | |||
| 49 | #endif /* UTILS_CONSTANTS_H */ | ||
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h index 08d42a3..f22260a 100644 --- a/src/utils/dbg_log.h +++ b/src/utils/dbg_log.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_DBG_LOG_H | ||
| 2 | #define UTILS_DBG_LOG_H | ||
| 3 | |||
| 1 | #include <stdio.h> | 4 | #include <stdio.h> |
| 2 | 5 | ||
| 3 | void (*nissy_log)(const char *, void *); | 6 | void (*nissy_log)(const char *, void *); |
| @@ -31,3 +34,5 @@ write_wrapper(void (*write)(const char *, void *), const char *str, ...) | |||
| 31 | #define DBG_WARN(condition, ...) | 34 | #define DBG_WARN(condition, ...) |
| 32 | #define DBG_ASSERT(condition, ...) | 35 | #define DBG_ASSERT(condition, ...) |
| 33 | #endif | 36 | #endif |
| 37 | |||
| 38 | #endif /* UTILS_DBG_LOG_H */ | ||
diff --git a/src/utils/math.h b/src/utils/math.h index 0c56861..66ddaed 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_MATH_H | ||
| 2 | #define UTILS_MATH_H | ||
| 3 | |||
| 1 | #define SWAP(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) | 4 | #define SWAP(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) |
| 2 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) | 5 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) |
| 3 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) | 6 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) |
| @@ -146,3 +149,5 @@ intpow(double b, uint64_t e) | |||
| 146 | 149 | ||
| 147 | return e % 2 == 0 ? r * r : b * r * r; | 150 | return e % 2 == 0 ? r * r : b * r * r; |
| 148 | } | 151 | } |
| 152 | |||
| 153 | #endif /* UTILS_MATH_H */ | ||
diff --git a/src/utils/prefetch.h b/src/utils/prefetch.h index a2c41ef..30e364e 100644 --- a/src/utils/prefetch.h +++ b/src/utils/prefetch.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_PREFETCH_H | ||
| 2 | #define UTILS_PREFETCH_H | ||
| 3 | |||
| 1 | #if defined(__GNUC__) || defined(__clang__) | 4 | #if defined(__GNUC__) || defined(__clang__) |
| 2 | #define prefetch(a, i) __builtin_prefetch(a+i, 0, 0) | 5 | #define prefetch(a, i) __builtin_prefetch(a+i, 0, 0) |
| 3 | #elif defined(AVX2) | 6 | #elif defined(AVX2) |
| @@ -5,3 +8,5 @@ | |||
| 5 | #else | 8 | #else |
| 6 | #define prefetch(a, i) (void)i | 9 | #define prefetch(a, i) (void)i |
| 7 | #endif | 10 | #endif |
| 11 | |||
| 12 | #endif /* UTILS_PREFETCH_H */ | ||
diff --git a/src/utils/sleep.h b/src/utils/sleep.h index 7c0a84d..28bb807 100644 --- a/src/utils/sleep.h +++ b/src/utils/sleep.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_SLEEP_H | ||
| 2 | #define UTILS_SLEEP_H | ||
| 3 | |||
| 1 | #define BASE_SLEEP_TIME 500 | 4 | #define BASE_SLEEP_TIME 500 |
| 2 | 5 | ||
| 3 | STATIC void msleep(int); | 6 | STATIC void msleep(int); |
| @@ -50,3 +53,5 @@ msleep(int milliseconds) | |||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | #endif | 55 | #endif |
| 56 | |||
| 57 | #endif /* UTILS_SLEEP_H */ | ||
diff --git a/src/utils/utils.h b/src/utils/utils.h index e322f20..e320105 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_UTILS_H | ||
| 2 | #define UTILS_UTILS_H | ||
| 3 | |||
| 1 | #include "compilers.h" | 4 | #include "compilers.h" |
| 2 | #include "dbg_log.h" | 5 | #include "dbg_log.h" |
| 3 | #include "constants.h" | 6 | #include "constants.h" |
| @@ -5,3 +8,5 @@ | |||
| 5 | #include "sleep.h" | 8 | #include "sleep.h" |
| 6 | #include "wrapthread.h" | 9 | #include "wrapthread.h" |
| 7 | #include "prefetch.h" | 10 | #include "prefetch.h" |
| 11 | |||
| 12 | #endif /* UTILS_UTILS_H */ | ||
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index 9578293..e88eb58 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_WRAPTHREAD_H | ||
| 2 | #define UTILS_WRAPTHREAD_H | ||
| 3 | |||
| 1 | #if THREADS == 1 | 4 | #if THREADS == 1 |
| 2 | #define WRAPTHREAD_NOTHREADS 1 | 5 | #define WRAPTHREAD_NOTHREADS 1 |
| 3 | #elif defined(__unix__) | 6 | #elif defined(__unix__) |
| @@ -75,3 +78,5 @@ | |||
| 75 | #define wrapthread_mutex_unlock(a) | 78 | #define wrapthread_mutex_unlock(a) |
| 76 | 79 | ||
| 77 | #endif | 80 | #endif |
| 81 | |||
| 82 | #endif /* UTILS_WRAPTHREAD_H */ | ||
diff --git a/utils/add_include_guard.sh b/utils/add_include_guard.sh new file mode 100755 index 0000000..7ca10db --- /dev/null +++ b/utils/add_include_guard.sh | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | if [ -z "$1" ]; then | ||
| 4 | echo "Usage: $0 [file]" | ||
| 5 | exit 1 | ||
| 6 | fi | ||
| 7 | |||
| 8 | guard="$(echo "$1" | sed 's/^\.\///' | tr 'a-z/.' 'A-Z__')" | ||
| 9 | |||
| 10 | new_file="$1.adding_include_guard" | ||
| 11 | printf '#ifndef %s\n#define %s\n\n' "$guard" "$guard" > "$new_file" | ||
| 12 | cat "$1" >> "$new_file" | ||
| 13 | printf '\n#endif /* %s */\n' "$guard" >> "$new_file" | ||
| 14 | |||
| 15 | mv "$new_file" "$1" | ||
