diff options
Diffstat (limited to '')
59 files changed, 564 insertions, 480 deletions
| @@ -33,6 +33,7 @@ tools/results | |||
| 33 | .vscode | 33 | .vscode |
| 34 | *.a | 34 | *.a |
| 35 | *.o | 35 | *.o |
| 36 | *.obj | ||
| 36 | *.so | 37 | *.so |
| 37 | */*.so | 38 | */*.so |
| 38 | *.s | 39 | *.s |
| @@ -39,14 +39,26 @@ is going to configure `nissy` to use at most 3 threads, and build it with | |||
| 39 | 39 | ||
| 40 | ### Windows | 40 | ### Windows |
| 41 | 41 | ||
| 42 | It is possible to build this project on Windows using `build.bat`. The | 42 | It is possible to build this project on Windows using `build.bat`, using |
| 43 | [Clang](https://clang.llvm.org/) compiler must be installed, and the | 43 | either MSVC (default) or [Clang](https://clang.llvm.org/). In either case, |
| 44 | command prompt must be correctly configured to run it. | 44 | the command prompt must be correctly configured to run the compiler from |
| 45 | the command line. | ||
| 45 | 46 | ||
| 46 | We suggest installing Clang via the Visual Studio Installer, selecting | 47 | For Clang, we suggest installing it via the Visual Studio Installer, |
| 47 | the "C++ development" pack, as well as the "clang" and "Windows SDK 11" | 48 | selecting the "C++ development" pack, as well as the "clang" and "Windows |
| 48 | components. It is advised to use "x64 Native Tools Command Prompt for | 49 | SDK 11" components. It is advised to use "x64 Native Tools Command Prompt |
| 49 | VS 2022" instead of a regular command prompt to run the build script. | 50 | for VS 2022" instead of a regular command prompt to run the build script. |
| 51 | |||
| 52 | |||
| 53 | You can specify the compiler to use by setting the | ||
| 54 | `CC` environment variable to either `clang` or `msvc`. For example: | ||
| 55 | |||
| 56 | ``` | ||
| 57 | > SET CC=clang | ||
| 58 | > build.bat test | ||
| 59 | ``` | ||
| 60 | |||
| 61 | Will run all the tests using clang. | ||
| 50 | 62 | ||
| 51 | The `build.bat` script has the same syntax as the `build.sh` script, | 63 | The `build.bat` script has the same syntax as the `build.sh` script, |
| 52 | but not all options are available. For example | 64 | but not all options are available. For example |
| @@ -64,9 +76,20 @@ can be used to build the basic shell, while | |||
| 64 | Builds and runs the unit tests. See `build.bat help` for a list of | 76 | Builds and runs the unit tests. See `build.bat help` for a list of |
| 65 | all available options. | 77 | all available options. |
| 66 | 78 | ||
| 67 | Note: The build script for Windows does not support all the options | 79 | #### Caveats for building on Windows |
| 80 | |||
| 81 | * The build script for Windows does not support all the options | ||
| 68 | available with build.sh. If you want to tune the build options, you'll | 82 | available with build.sh. If you want to tune the build options, you'll |
| 69 | have to manually edit the build script. | 83 | have to manually edit the build script. |
| 84 | * If you are building on an old x86-64 machine that does not support AVX2 | ||
| 85 | instructions, you will have to manually set the architecture to `PORTABLE` | ||
| 86 | with `SET ARCH=PORTABLE`. | ||
| 87 | * Build on Windows on ARM has not been tested at all. | ||
| 88 | * When building with MSVC, the option `/experimental:c11atomics` is used. | ||
| 89 | Despite atomic types being part of the C11 standard for 15 years now, | ||
| 90 | they have only [recently been | ||
| 91 | implemented](https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2), | ||
| 92 | and Microsoft still considers them an experimental feature. Impressive! | ||
| 70 | 93 | ||
| 71 | ## Running tests | 94 | ## Running tests |
| 72 | 95 | ||
| @@ -1,49 +1,96 @@ | |||
| 1 | @echo off | 1 | @echo off |
| 2 | 2 | ||
| 3 | if [%1]==[/d] ( | 3 | SET DEBUG=0 |
| 4 | if "%1"=="/d" ( | ||
| 4 | SET DEBUG=1 | 5 | SET DEBUG=1 |
| 5 | shift | 6 | shift |
| 6 | ) else ( | ||
| 7 | SET DEBUG=0 | ||
| 8 | ) | 7 | ) |
| 8 | if "%1"=="test" (SET DEBUG=1) | ||
| 9 | 9 | ||
| 10 | SET CC=clang | 10 | :: Detect architecture, or use user-specified one |
| 11 | SET CXX=clang++ | 11 | if "%ARCH%"=="" goto :detect_arch |
| 12 | if "%ARCH%"=="PORTABLE" goto :arch_done | ||
| 13 | if "%ARCH%"=="AVX2" goto :arch_done | ||
| 14 | if "%ARCH%"=="NEON" goto :arch_done | ||
| 15 | |||
| 16 | echo Unsupported architecture '%ARCH%' | ||
| 17 | exit /b 1 | ||
| 18 | |||
| 19 | :detect_arch | ||
| 20 | if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( | ||
| 21 | SET ARCH=AVX2 | ||
| 22 | ) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" ( | ||
| 23 | SET ARCH=NEON | ||
| 24 | ) else ( | ||
| 25 | SET ARCH=PORTABLE | ||
| 26 | ) | ||
| 27 | :arch_done | ||
| 28 | |||
| 29 | :: Default value for maximum number of threads | ||
| 12 | SET THREADS=16 | 30 | SET THREADS=16 |
| 13 | SET SANITIZE= | ||
| 14 | 31 | ||
| 15 | SET ARCH=PORTABLE | 32 | :: Detect Python libraries path |
| 16 | clang -march=native -dM -E - < NUL | findstr /C:"__AVX2__" >NUL 2>&1 | 33 | for /f "delims=" %%i in ('python -c "import sys; print(sys.base_prefix)"') do set PYPATH=%%i |
| 17 | if %ERRORLEVEL% EQU 0 ( | 34 | SET PYINCLUDE=%PYPATH%\include |
| 18 | SET ARCH=AVX2 | 35 | SET PYLIBS=%PYPATH%\libs |
| 19 | SET ARCHOPTS=-mavx2 | ||
| 20 | goto :ArchDone | ||
| 21 | ) | ||
| 22 | clang -march=native -dM -E - < NUL | findstr /C:"__ARM_NEON" >NUL 2>&1 | ||
| 23 | if %ERRORLEVEL% EQU 0 ( | ||
| 24 | SET ARCH=NEON | ||
| 25 | goto :ArchDone | ||
| 26 | ) | ||
| 27 | :ArchDone | ||
| 28 | 36 | ||
| 37 | :: Select compiler from possibly user-set %CC% variable | ||
| 38 | :: Currently we only support clang and MSVC | ||
| 39 | if "%CC%"=="" goto :set_msvc | ||
| 40 | if /I "%CC%"=="cl" goto :set_msvc | ||
| 41 | if /I "%CC%"=="msvc" goto :set_msvc | ||
| 42 | if /I "%CC%"=="clang" goto :set_clang | ||
| 29 | 43 | ||
| 30 | SET DFLAGS=-g3 -DDEBUG | 44 | echo Unsupported compiler '%CC%' |
| 31 | SET WARNINGS=-Wno-deprecated-declarations | 45 | exit /b 1 |
| 32 | SET VARIABLES=-DTHREADS=%THREADS% -D%ARCH% | ||
| 33 | SET OFLAGS=-O3 | ||
| 34 | 46 | ||
| 35 | SET CFLAGS=-std=c11 %ARCHOPTS% %WARNINGS% %VARIABLES% | 47 | :set_msvc |
| 48 | SET CC=cl | ||
| 49 | SET CXX=cl | ||
| 36 | 50 | ||
| 37 | SET STACKSIZE=-Wl,-stack:16777216 | 51 | SET DFLAGS=/Zi /DDEBUG |
| 38 | SET LFLAGS=%STACKSIZE% | 52 | SET WARNINGS=/W4 /wd4100 /wd4324 /wd4505 /wd4996 |
| 53 | SET VARIABLES=/DTHREADS=%THREADS% /D%ARCH% | ||
| 54 | SET OFLAGS=/O2 | ||
| 39 | 55 | ||
| 40 | :: Python libraries - change to match your local installation | 56 | if %DEBUG%==1 (SET ODFLAGS=%DFLAGS%) else (SET ODFLAGS=%OFLAGS%) |
| 41 | for /f "delims=" %%i in ('python -c "import sys; print(sys.base_prefix)"') do set PYPATH=%%i | 57 | if "%ARCH%"=="AVX2" (SET ARCHOPTS=/arch:AVX2) else (SET ARCHOPTS=) |
| 42 | ::SET PYPATH=%userprofile%\AppData\Local\Programs\Python\Python313 | ||
| 43 | 58 | ||
| 44 | SET PYINCLUDE=%PYPATH%\include | 59 | SET CFLAGS=/std:c11 /experimental:c11atomics /nologo %ARCHOPTS% %WARNINGS% %VARIABLES% |
| 45 | SET PYLIBS=%PYPATH%\libs | 60 | SET LFLAGS=/F 16777216 |
| 61 | |||
| 62 | SET CC_NISSY=%CC% %CFLAGS% %ODFLAGS% /c src\nissy.c | ||
| 63 | SET CC_SHELL=%CC% %CFLAGS% %ODFALGS% %LFLAGS% nissy.obj shell\shell.c /Fe:run.exe | ||
| 64 | SET CC_PYTHON=%CC% %CFLAGS% %LFLAGS% /I"%PYINCLUDE%" /LD /Fe:python\nissy.pyd python\nissy_module.c nissy.obj /link /LIBPATH:"%PYLIBS%" python3.lib | ||
| 65 | SET CC_TEST=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtest.exe nissy.obj | ||
| 66 | SET CC_TOOL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtool.exe nissy.obj | ||
| 67 | SET CC_CXX=%CXX% /EHsc /nologo %ARCHOPTS% %ODFLAGS% %LFLAGS% /std:c++20 /Fe:runcpp.exe nissy_c.obj cpp\nissy.cpp | ||
| 68 | goto :compiler_done | ||
| 69 | |||
| 70 | :set_clang | ||
| 71 | SET CC=clang | ||
| 72 | SET CXX=clang++ | ||
| 73 | |||
| 74 | SET DFLAGS=-g3 -DDEBUG | ||
| 75 | SET WARNINGS=-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-deprecated-declarations | ||
| 76 | SET VARIABLES=-DTHREADS=%THREADS% -D%ARCH% | ||
| 77 | SET OFLAGS=-O3 | ||
| 78 | |||
| 79 | if %DEBUG%==1 (SET ODFLAGS=%DFLAGS%) else (SET ODFLAGS=%OFLAGS%) | ||
| 80 | if "%ARCH%"=="AVX2" (SET ARCHOPTS=-mavx2) else (SET ARCHOPTS=) | ||
| 81 | |||
| 82 | SET CFLAGS=-std=c11 %ARCHOPTS% %WARNINGS% %VARIABLES% | ||
| 83 | SET LFLAGS=-Wl,-stack:16777216 | ||
| 84 | |||
| 85 | SET CC_NISSY=%CC% %CFLAGS% %ODFLAGS% -c src\nissy.c -o nissy.obj | ||
| 86 | SET CC_SHELL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.obj shell\shell.c -o run.exe | ||
| 87 | SET CC_PYTHON=%CC% %CFLAGS% %LFLAGS% -I%PYINCLUDE% -L%PYLIBS% -shared -lpython3 python\nissy_module.c nissy.obj -o python\nissy.pyd | ||
| 88 | SET CC_TEST=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% -o runtest.exe nissy.obj | ||
| 89 | SET CC_TOOL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% -o runtool.exe nissy.obj | ||
| 90 | SET CC_CXX=%CXX% %ARCHOPTS% %ODFLAGS% %LFLAGS% -std=c++20 -o runcpp.exe nissy_c.obj cpp\nissy.cpp | ||
| 91 | :compiler_done | ||
| 46 | 92 | ||
| 93 | :: Select compilation target from command line argument | ||
| 47 | SET TARGET=%1 | 94 | SET TARGET=%1 |
| 48 | if not defined TARGET SET TARGET=nissy | 95 | if not defined TARGET SET TARGET=nissy |
| 49 | SET EXPR=%2 | 96 | SET EXPR=%2 |
| @@ -53,7 +100,6 @@ for %%a in (nissy python shell test config help clean tool cpp solvetest) do ( | |||
| 53 | exit /b | 100 | exit /b |
| 54 | ) | 101 | ) |
| 55 | ) | 102 | ) |
| 56 | |||
| 57 | echo Target '%TARGET%' unavailable, run 'build help' for info | 103 | echo Target '%TARGET%' unavailable, run 'build help' for info |
| 58 | exit /b 1 | 104 | exit /b 1 |
| 59 | 105 | ||
| @@ -66,7 +112,7 @@ exit /b 1 | |||
| 66 | echo. | 112 | echo. |
| 67 | echo Possible values for TARGET (defaults to 'nissy' if unspecified): | 113 | echo Possible values for TARGET (defaults to 'nissy' if unspecified): |
| 68 | echo. | 114 | echo. |
| 69 | echo nissy Build the nissy.o object file. | 115 | echo nissy Build the nissy.obj object file. |
| 70 | echo python Build the Python module for nissy. | 116 | echo python Build the Python module for nissy. |
| 71 | echo NOTE: Python development headers must be installed in | 117 | echo NOTE: Python development headers must be installed in |
| 72 | echo order to build the Python module. The path of these | 118 | echo order to build the Python module. The path of these |
| @@ -98,32 +144,26 @@ exit /b | |||
| 98 | exit /b | 144 | exit /b |
| 99 | 145 | ||
| 100 | :build_nissy | 146 | :build_nissy |
| 101 | call:odflags | ||
| 102 | @echo on | 147 | @echo on |
| 103 | %CC% %CFLAGS% %ODFLAGS% -c src\nissy.c || exit /b 1 | 148 | %CC_NISSY% || exit /b 1 |
| 104 | @echo off | 149 | @echo off |
| 105 | exit /b | 150 | exit /b |
| 106 | 151 | ||
| 107 | :build_shell | 152 | :build_shell |
| 108 | call:build_nissy || exit /b 1 | 153 | call:build_nissy || exit /b 1 |
| 109 | call:odflags | ||
| 110 | @echo on | 154 | @echo on |
| 111 | %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o shell\shell.c -o run.exe ^ | 155 | %CC_SHELL% || exit /b 1 |
| 112 | || exit /b 1 | ||
| 113 | @echo off | 156 | @echo off |
| 114 | exit /b | 157 | exit /b |
| 115 | 158 | ||
| 116 | :build_python | 159 | :build_python |
| 117 | call:build_nissy || exit /b 1 | 160 | call:build_nissy || exit /b 1 |
| 118 | call:odflags | ||
| 119 | @echo on | 161 | @echo on |
| 120 | %CC% %CFLAGS% %LFLAGS% -I%PYINCLUDE% -L%PYLIBS% -shared -lpython3 ^ | 162 | %CC_PYTHON% || exit /b 1 |
| 121 | python\nissy_module.c nissy.o -o python\nissy.pyd || exit /b 1 | ||
| 122 | @echo off | 163 | @echo off |
| 123 | exit /b | 164 | exit /b |
| 124 | 165 | ||
| 125 | :build_test | 166 | :build_test |
| 126 | SET DEBUG=1 | ||
| 127 | call:build_nissy || exit /b 1 | 167 | call:build_nissy || exit /b 1 |
| 128 | if not defined EXPR ( | 168 | if not defined EXPR ( |
| 129 | SET WILDCARD=* | 169 | SET WILDCARD=* |
| @@ -139,7 +179,7 @@ exit /b | |||
| 139 | 179 | ||
| 140 | :build_clean | 180 | :build_clean |
| 141 | @echo on | 181 | @echo on |
| 142 | del *.o *.so *.a *.ilk *.pdb *.exe | 182 | del *.o *.obj *.so *.a *.ilk *.pdb *.exe |
| 143 | @echo off | 183 | @echo off |
| 144 | exit /b | 184 | exit /b |
| 145 | 185 | ||
| @@ -173,9 +213,11 @@ exit /b | |||
| 173 | exit /b 1 | 213 | exit /b 1 |
| 174 | ) | 214 | ) |
| 175 | call:build_nissy || exit /b 1 | 215 | call:build_nissy || exit /b 1 |
| 216 | copy nissy.obj nissy_c.obj | ||
| 176 | @echo on | 217 | @echo on |
| 177 | %CXX% %ODFLAGS% -std=c++20 -o runcpp.exe cpp\nissy.cpp nissy.o %EXPR% ^ | 218 | %CC_CXX% %EXPR% || exit /b 1 |
| 178 | || exit /b 1 | 219 | del nissy.obj |
| 220 | copy nissy_c.obj nissy.obj | ||
| 179 | runcpp | 221 | runcpp |
| 180 | @echo off | 222 | @echo off |
| 181 | exit /b | 223 | exit /b |
| @@ -189,8 +231,7 @@ exit /b | |||
| 189 | exit /b | 231 | exit /b |
| 190 | 232 | ||
| 191 | :build_single_test | 233 | :build_single_test |
| 192 | call:odflags | 234 | %CC_TEST% %1\*.c || exit /b 1 |
| 193 | %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o %1\*.c -o runtest.exe || exit /b 1 | ||
| 194 | set error=0 | 235 | set error=0 |
| 195 | for %%c in ( %1\*.in ) do ( | 236 | for %%c in ( %1\*.in ) do ( |
| 196 | if %error%==1 exit /b 1 | 237 | if %error%==1 exit /b 1 |
| @@ -213,21 +254,12 @@ exit /b | |||
| 213 | 254 | ||
| 214 | :build_single_tool | 255 | :build_single_tool |
| 215 | @echo on | 256 | @echo on |
| 216 | %CC% %CFLAGS% %ODFLAGS% %LFLAGS% nissy.o tools\%toolname%\*.c ^ | 257 | %CC_TOOL% tools\%toolname%\*.c || exit /b 1 |
| 217 | -o runtool.exe || exit /b 1 | ||
| 218 | @echo off | 258 | @echo off |
| 219 | runtool %3 %4 %5 %6 %7 %8 %9 || exit /b 1 | 259 | runtool %3 %4 %5 %6 %7 %8 %9 || exit /b 1 |
| 220 | @echo. | 260 | @echo. |
| 221 | @echo (On Windows, the output of a tool is not saved to any file.) | 261 | @echo (On Windows, the output of a tool is not saved to any file.) |
| 222 | exit /b | 262 | exit /b |
| 223 | 263 | ||
| 224 | :odflags | ||
| 225 | if %DEBUG%==1 ( | ||
| 226 | SET ODFLAGS=%DFLAGS% | ||
| 227 | ) else ( | ||
| 228 | SET ODFLAGS=%OFLAGS% | ||
| 229 | ) | ||
| 230 | exit /b | ||
| 231 | |||
| 232 | :error | 264 | :error |
| 233 | exit /b 1 \ No newline at end of file | 265 | exit /b 1 \ No newline at end of file |
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 15ce02a..801419e 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -37,11 +37,11 @@ popcount_u32(uint32_t x) | |||
| 37 | STATIC_INLINE int | 37 | STATIC_INLINE int |
| 38 | popcount_u64(uint64_t x) | 38 | popcount_u64(uint64_t x) |
| 39 | { | 39 | { |
| 40 | return _mm_popcnt_u64(x); | 40 | return (int)_mm_popcnt_u64(x); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | STATIC void | 43 | STATIC void |
| 44 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) | 44 | pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) |
| 45 | { | 45 | { |
| 46 | uint8_t aux[32]; | 46 | uint8_t aux[32]; |
| 47 | 47 | ||
| @@ -167,7 +167,7 @@ coord_co(cube_t c) | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | STATIC_INLINE void | 169 | STATIC_INLINE void |
| 170 | copy_co(cube_t cube[static 1], cube_t co) | 170 | copy_co(cube_t cube[NON_NULL], cube_t co) |
| 171 | { | 171 | { |
| 172 | cube_t coclean; | 172 | cube_t coclean; |
| 173 | 173 | ||
| @@ -274,19 +274,19 @@ invcoord_esep(uint64_t esep) | |||
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | STATIC_INLINE void | 276 | STATIC_INLINE void |
| 277 | copy_corners(cube_t dest[static 1], cube_t src) | 277 | copy_corners(cube_t dest[NON_NULL], cube_t src) |
| 278 | { | 278 | { |
| 279 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); | 279 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | STATIC_INLINE void | 282 | STATIC_INLINE void |
| 283 | copy_edges(cube_t dest[static 1], cube_t src) | 283 | copy_edges(cube_t dest[NON_NULL], cube_t src) |
| 284 | { | 284 | { |
| 285 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); | 285 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | STATIC_INLINE void | 288 | STATIC_INLINE void |
| 289 | set_eo(cube_t cube[static 1], uint64_t eo) | 289 | set_eo(cube_t cube[NON_NULL], uint64_t eo) |
| 290 | { | 290 | { |
| 291 | uint64_t eo12, eotop, eobot; | 291 | uint64_t eo12, eotop, eobot; |
| 292 | __m256i veo; | 292 | __m256i veo; |
diff --git a/src/arch/common.h b/src/arch/common.h index 2b95fe3..a7c4a3b 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | STATIC_INLINE int popcount_u32(uint32_t); | 15 | STATIC_INLINE int popcount_u32(uint32_t); |
| 16 | STATIC_INLINE int popcount_u64(uint64_t); | 16 | STATIC_INLINE int popcount_u64(uint64_t); |
| 17 | 17 | ||
| 18 | STATIC void pieces(cube_t [static 1], uint8_t [static 8], uint8_t [static 12]); | 18 | STATIC void pieces(cube_t [NON_NULL], uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 19 | STATIC_INLINE bool equal(cube_t, cube_t); | 19 | STATIC_INLINE bool equal(cube_t, cube_t); |
| 20 | STATIC_INLINE cube_t invertco(cube_t); | 20 | STATIC_INLINE cube_t invertco(cube_t); |
| 21 | STATIC_INLINE cube_t compose_edges(cube_t, cube_t); | 21 | STATIC_INLINE cube_t compose_edges(cube_t, cube_t); |
| @@ -35,12 +35,12 @@ STATIC_INLINE cube_t invcoord_epudsep(uint64_t); | |||
| 35 | 35 | ||
| 36 | STATIC_INLINE bool is_eo_even(cube_t); | 36 | STATIC_INLINE bool is_eo_even(cube_t); |
| 37 | 37 | ||
| 38 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); | 38 | STATIC_INLINE void copy_corners(cube_t [NON_NULL], cube_t); |
| 39 | STATIC_INLINE void copy_co(cube_t [static 1], cube_t); | 39 | STATIC_INLINE void copy_co(cube_t [NON_NULL], cube_t); |
| 40 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); | 40 | STATIC_INLINE void copy_edges(cube_t [NON_NULL], cube_t); |
| 41 | STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); | 41 | STATIC_INLINE void set_eo(cube_t [NON_NULL], uint64_t); |
| 42 | 42 | ||
| 43 | STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[static 12]); | 43 | STATIC_INLINE void invcoord_esep_array(uint64_t, uint64_t, uint8_t[SIZE(12)]); |
| 44 | STATIC_INLINE cube_t invcoord_eoesep(uint64_t); | 44 | STATIC_INLINE cube_t invcoord_eoesep(uint64_t); |
| 45 | STATIC_INLINE uint64_t coord_epudsep_array(const uint8_t [8]); | 45 | STATIC_INLINE uint64_t coord_epudsep_array(const uint8_t [8]); |
| 46 | STATIC_INLINE void invcoord_epudsep_array(uint64_t, uint8_t [8]); | 46 | STATIC_INLINE void invcoord_epudsep_array(uint64_t, uint8_t [8]); |
| @@ -53,7 +53,7 @@ STATIC_INLINE uint64_t coord_epe(cube_t); | |||
| 53 | STATIC_INLINE cube_t invcoord_epe(uint64_t); | 53 | STATIC_INLINE cube_t invcoord_epe(uint64_t); |
| 54 | 54 | ||
| 55 | STATIC_INLINE void | 55 | STATIC_INLINE void |
| 56 | invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[static 12]) | 56 | invcoord_esep_array(uint64_t set1, uint64_t set2, uint8_t mem[SIZE(12)]) |
| 57 | { | 57 | { |
| 58 | uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; | 58 | uint64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; |
| 59 | uint8_t slice[3] = {0}; | 59 | uint8_t slice[3] = {0}; |
diff --git a/src/arch/neon.h b/src/arch/neon.h index 725e589..501b722 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -59,7 +59,7 @@ popcount_u64(uint64_t x) | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | STATIC void | 61 | STATIC void |
| 62 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) | 62 | pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) |
| 63 | { | 63 | { |
| 64 | // First 8 bytes of the corner vector are copied from the c array | 64 | // First 8 bytes of the corner vector are copied from the c array |
| 65 | vst1_u8(c, cube->corner); | 65 | vst1_u8(c, cube->corner); |
| @@ -244,7 +244,7 @@ coord_co(cube_t c) | |||
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | STATIC_INLINE void | 246 | STATIC_INLINE void |
| 247 | copy_co(cube_t cube[static 1], cube_t co) | 247 | copy_co(cube_t cube[NON_NULL], cube_t co) |
| 248 | { | 248 | { |
| 249 | uint8x8_t coclean; | 249 | uint8x8_t coclean; |
| 250 | 250 | ||
| @@ -340,19 +340,19 @@ coord_esep(cube_t c) | |||
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | STATIC_INLINE void | 342 | STATIC_INLINE void |
| 343 | copy_corners(cube_t dst[static 1], cube_t src) | 343 | copy_corners(cube_t dst[NON_NULL], cube_t src) |
| 344 | { | 344 | { |
| 345 | dst->corner = src.corner; | 345 | dst->corner = src.corner; |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | STATIC_INLINE void | 348 | STATIC_INLINE void |
| 349 | copy_edges(cube_t dst[static 1], cube_t src) | 349 | copy_edges(cube_t dst[NON_NULL], cube_t src) |
| 350 | { | 350 | { |
| 351 | dst->edge = src.edge; | 351 | dst->edge = src.edge; |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | STATIC_INLINE void | 354 | STATIC_INLINE void |
| 355 | set_eo(cube_t cube[static 1], uint64_t eo) | 355 | set_eo(cube_t cube[NON_NULL], uint64_t eo) |
| 356 | { | 356 | { |
| 357 | // Temp array to store the NEON vector | 357 | // Temp array to store the NEON vector |
| 358 | uint8_t mem[16]; | 358 | uint8_t mem[16]; |
diff --git a/src/arch/portable.h b/src/arch/portable.h index 162ed1a..f1491f0 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -46,7 +46,7 @@ popcount_u64(uint64_t x) | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | STATIC void | 48 | STATIC void |
| 49 | pieces(cube_t cube[static 1], uint8_t c[static 8], uint8_t e[static 12]) | 49 | pieces(cube_t cube[NON_NULL], uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) |
| 50 | { | 50 | { |
| 51 | memcpy(c, cube->corner, 8); | 51 | memcpy(c, cube->corner, 8); |
| 52 | memcpy(e, cube->edge, 12); | 52 | memcpy(e, cube->edge, 12); |
| @@ -166,7 +166,7 @@ inverse(cube_t cube) | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | STATIC_INLINE void | 168 | STATIC_INLINE void |
| 169 | copy_co(cube_t cube[static 1], cube_t co) | 169 | copy_co(cube_t cube[NON_NULL], cube_t co) |
| 170 | { | 170 | { |
| 171 | uint8_t c; | 171 | uint8_t c; |
| 172 | size_t i; | 172 | size_t i; |
| @@ -291,19 +291,19 @@ invcoord_esep(uint64_t esep) | |||
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | STATIC_INLINE void | 293 | STATIC_INLINE void |
| 294 | copy_corners(cube_t dest[static 1], cube_t src) | 294 | copy_corners(cube_t dest[NON_NULL], cube_t src) |
| 295 | { | 295 | { |
| 296 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); | 296 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | STATIC_INLINE void | 299 | STATIC_INLINE void |
| 300 | copy_edges(cube_t dest[static 1], cube_t src) | 300 | copy_edges(cube_t dest[NON_NULL], cube_t src) |
| 301 | { | 301 | { |
| 302 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); | 302 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | STATIC_INLINE void | 305 | STATIC_INLINE void |
| 306 | set_eo(cube_t cube[static 1], uint64_t eo) | 306 | set_eo(cube_t cube[NON_NULL], uint64_t eo) |
| 307 | { | 307 | { |
| 308 | uint8_t i, sum, flip; | 308 | uint8_t i, sum, flip; |
| 309 | 309 | ||
diff --git a/src/core/cube.h b/src/core/cube.h index 9e79dda..1c21ce1 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | STATIC bool cube_true(cube_t); | 1 | STATIC bool cube_true(cube_t); |
| 2 | 2 | ||
| 3 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 3 | STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 4 | STATIC bool isconsistent(oriented_cube_t); | 4 | STATIC bool isconsistent(oriented_cube_t); |
| 5 | STATIC bool issolvable(oriented_cube_t); | 5 | STATIC bool issolvable(oriented_cube_t); |
| 6 | STATIC bool issolved(oriented_cube_t); | 6 | STATIC bool issolved(oriented_cube_t); |
| @@ -10,7 +10,7 @@ STATIC void getcube_fix(long long *, long long *, | |||
| 10 | STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); | 10 | STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); |
| 11 | 11 | ||
| 12 | STATIC oriented_cube_t readcube(const char *); | 12 | STATIC oriented_cube_t readcube(const char *); |
| 13 | STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); | 13 | STATIC int64_t writecube(oriented_cube_t, size_t n, char *); |
| 14 | STATIC uint8_t readco(const char *); | 14 | STATIC uint8_t readco(const char *); |
| 15 | STATIC uint8_t readcp(const char *); | 15 | STATIC uint8_t readcp(const char *); |
| 16 | STATIC uint8_t readeo(const char *); | 16 | STATIC uint8_t readeo(const char *); |
| @@ -29,7 +29,7 @@ cube_true(cube_t cube) | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | STATIC cube_t | 31 | STATIC cube_t |
| 32 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | 32 | cubefromarray(uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) |
| 33 | { | 33 | { |
| 34 | return STATIC_CUBE( | 34 | return STATIC_CUBE( |
| 35 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], | 35 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], |
| @@ -304,7 +304,7 @@ readcube(const char *buf) | |||
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | STATIC int64_t | 306 | STATIC int64_t |
| 307 | writecube(oriented_cube_t cube, size_t buf_size, char buf[buf_size]) | 307 | writecube(oriented_cube_t cube, size_t buf_size, char *buf) |
| 308 | { | 308 | { |
| 309 | int i; | 309 | int i; |
| 310 | uint8_t corner[8], edge[12]; | 310 | uint8_t corner[8], edge[12]; |
diff --git a/src/core/moves.h b/src/core/moves.h index 6169c6e..9f1f7cc 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -4,15 +4,15 @@ | |||
| 4 | STATIC uint8_t readmove(char); | 4 | STATIC uint8_t readmove(char); |
| 5 | STATIC int64_t readmoves(const char *, | 5 | STATIC int64_t readmoves(const char *, |
| 6 | size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); | 6 | size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); |
| 7 | STATIC int64_t readmoves_struct(const char *, moves_struct_t [static 1]); | 7 | STATIC int64_t readmoves_struct(const char *, moves_struct_t [NON_NULL]); |
| 8 | STATIC int64_t countmoves(const char *); | 8 | STATIC int64_t countmoves(const char *); |
| 9 | STATIC bool moves_struct_equal( | 9 | STATIC bool moves_struct_equal( |
| 10 | const moves_struct_t [static 1], const moves_struct_t [static 1]); | 10 | const moves_struct_t [NON_NULL], const moves_struct_t [NON_NULL]); |
| 11 | STATIC long long comparemoves(const char *, const char *); | 11 | STATIC long long comparemoves(const char *, const char *); |
| 12 | STATIC uint8_t readmodifier(char); | 12 | STATIC uint8_t readmodifier(char); |
| 13 | STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); | 13 | STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); |
| 14 | STATIC int64_t writemoves_struct( | 14 | STATIC int64_t writemoves_struct( |
| 15 | const moves_struct_t [static 1], size_t, char *); | 15 | const moves_struct_t [NON_NULL], size_t, char *); |
| 16 | 16 | ||
| 17 | STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); | 17 | STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); |
| 18 | STATIC bool allowedmoves(size_t, const uint8_t *); | 18 | STATIC bool allowedmoves(size_t, const uint8_t *); |
| @@ -36,9 +36,9 @@ STATIC bool are_lastmoves_singlecw(size_t, const uint8_t*); | |||
| 36 | 36 | ||
| 37 | STATIC int64_t move_variations(const char *, const char *, size_t, char *); | 37 | STATIC int64_t move_variations(const char *, const char *, size_t, char *); |
| 38 | STATIC int64_t move_variations_lastqt( | 38 | STATIC int64_t move_variations_lastqt( |
| 39 | const moves_struct_t [static 1], size_t, char *); | 39 | const moves_struct_t [NON_NULL], size_t, char *); |
| 40 | STATIC int64_t move_variations_unniss( | 40 | STATIC int64_t move_variations_unniss( |
| 41 | const moves_struct_t [static 1], size_t, char *); | 41 | const moves_struct_t [NON_NULL], size_t, char *); |
| 42 | 42 | ||
| 43 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ | 43 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ |
| 44 | RET_ERROR, ARG_ACTION) \ | 44 | RET_ERROR, ARG_ACTION) \ |
| @@ -167,7 +167,7 @@ readmoves( | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | STATIC int64_t | 169 | STATIC int64_t |
| 170 | readmoves_struct(const char *moves, moves_struct_t ret[static 1]) | 170 | readmoves_struct(const char *moves, moves_struct_t ret[NON_NULL]) |
| 171 | { | 171 | { |
| 172 | return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES, | 172 | return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES, |
| 173 | &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); | 173 | &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); |
| @@ -190,8 +190,8 @@ countmoves(const char *buf) | |||
| 190 | 190 | ||
| 191 | STATIC bool | 191 | STATIC bool |
| 192 | moves_struct_equal( | 192 | moves_struct_equal( |
| 193 | const moves_struct_t ms1[static 1], | 193 | const moves_struct_t ms1[NON_NULL], |
| 194 | const moves_struct_t ms2[static 1] | 194 | const moves_struct_t ms2[NON_NULL] |
| 195 | ) | 195 | ) |
| 196 | { | 196 | { |
| 197 | size_t i; | 197 | size_t i; |
| @@ -281,7 +281,7 @@ writemoves_error: | |||
| 281 | 281 | ||
| 282 | STATIC int64_t | 282 | STATIC int64_t |
| 283 | writemoves_struct( | 283 | writemoves_struct( |
| 284 | const moves_struct_t moves[static 1], | 284 | const moves_struct_t moves[NON_NULL], |
| 285 | size_t buf_size, | 285 | size_t buf_size, |
| 286 | char *buf | 286 | char *buf |
| 287 | ) | 287 | ) |
| @@ -612,7 +612,7 @@ move_variations( | |||
| 612 | 612 | ||
| 613 | STATIC int64_t | 613 | STATIC int64_t |
| 614 | move_variations_lastqt( | 614 | move_variations_lastqt( |
| 615 | const moves_struct_t s[static 1], | 615 | const moves_struct_t s[NON_NULL], |
| 616 | size_t result_size, | 616 | size_t result_size, |
| 617 | char *result | 617 | char *result |
| 618 | ) | 618 | ) |
| @@ -623,10 +623,10 @@ move_variations_lastqt( | |||
| 623 | size_t u; | 623 | size_t u; |
| 624 | moves_struct_t ss; | 624 | moves_struct_t ss; |
| 625 | 625 | ||
| 626 | in1 = s->nnormal-1; | 626 | in1 = (uint8_t)(s->nnormal-1); |
| 627 | in2 = s->nnormal-2; | 627 | in2 = (uint8_t)(s->nnormal-2); |
| 628 | ii1 = s->ninverse-1; | 628 | ii1 = (uint8_t)(s->ninverse-1); |
| 629 | ii2 = s->ninverse-2; | 629 | ii2 = (uint8_t)(s->ninverse-2); |
| 630 | 630 | ||
| 631 | n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; | 631 | n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; |
| 632 | n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; | 632 | n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; |
| @@ -686,7 +686,7 @@ lastqt_error: | |||
| 686 | 686 | ||
| 687 | STATIC int64_t | 687 | STATIC int64_t |
| 688 | move_variations_unniss( | 688 | move_variations_unniss( |
| 689 | const moves_struct_t s[static 1], | 689 | const moves_struct_t s[NON_NULL], |
| 690 | size_t result_size, | 690 | size_t result_size, |
| 691 | char *result | 691 | char *result |
| 692 | ) | 692 | ) |
diff --git a/src/core/transform.h b/src/core/transform.h index f19c44f..af4634e 100644 --- a/src/core/transform.h +++ b/src/core/transform.h | |||
| @@ -17,9 +17,9 @@ | |||
| 17 | invertco(compose(compose(TRANS_CUBE_ ## T, c), \ | 17 | invertco(compose(compose(TRANS_CUBE_ ## T, c), \ |
| 18 | TRANS_CUBE_ ## T ## _INVERSE)) | 18 | TRANS_CUBE_ ## T ## _INVERSE)) |
| 19 | 19 | ||
| 20 | STATIC uint8_t readtrans(const char [static NISSY_SIZE_TRANSFORMATION]); | 20 | STATIC uint8_t readtrans(const char [SIZE(NISSY_SIZE_TRANSFORMATION)]); |
| 21 | STATIC uint8_t readrotation(const char [static 2]); | 21 | STATIC uint8_t readrotation(const char [SIZE(2)]); |
| 22 | STATIC void writetrans(uint8_t, char [static NISSY_SIZE_TRANSFORMATION]); | 22 | STATIC void writetrans(uint8_t, char [SIZE(NISSY_SIZE_TRANSFORMATION)]); |
| 23 | 23 | ||
| 24 | STATIC cube_t transform_edges(cube_t, uint8_t); | 24 | STATIC cube_t transform_edges(cube_t, uint8_t); |
| 25 | STATIC cube_t transform_corners(cube_t, uint8_t); | 25 | STATIC cube_t transform_corners(cube_t, uint8_t); |
| @@ -29,7 +29,7 @@ STATIC_INLINE uint8_t inverse_trans(uint8_t); | |||
| 29 | STATIC uint64_t symmetry_mask(cube_t); | 29 | STATIC uint64_t symmetry_mask(cube_t); |
| 30 | 30 | ||
| 31 | STATIC uint8_t | 31 | STATIC uint8_t |
| 32 | readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION]) | 32 | readtrans(const char buf[SIZE(NISSY_SIZE_TRANSFORMATION)]) |
| 33 | { | 33 | { |
| 34 | uint8_t t; | 34 | uint8_t t; |
| 35 | 35 | ||
| @@ -41,7 +41,7 @@ readtrans(const char buf[static NISSY_SIZE_TRANSFORMATION]) | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | STATIC uint8_t | 43 | STATIC uint8_t |
| 44 | readrotation(const char buf[static 2]) | 44 | readrotation(const char buf[SIZE(2)]) |
| 45 | { | 45 | { |
| 46 | char trans_str[NISSY_SIZE_TRANSFORMATION]; | 46 | char trans_str[NISSY_SIZE_TRANSFORMATION]; |
| 47 | 47 | ||
| @@ -53,7 +53,7 @@ readrotation(const char buf[static 2]) | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | STATIC void | 55 | STATIC void |
| 56 | writetrans(uint8_t t, char buf[static NISSY_SIZE_TRANSFORMATION]) | 56 | writetrans(uint8_t t, char buf[SIZE(NISSY_SIZE_TRANSFORMATION)]) |
| 57 | { | 57 | { |
| 58 | if (t >= 48) | 58 | if (t >= 48) |
| 59 | memcpy(buf, "error trans", 11); | 59 | memcpy(buf, "error trans", 11); |
| @@ -407,12 +407,13 @@ inverse_trans(uint8_t t) | |||
| 407 | STATIC uint64_t | 407 | STATIC uint64_t |
| 408 | symmetry_mask(cube_t cube) | 408 | symmetry_mask(cube_t cube) |
| 409 | { | 409 | { |
| 410 | uint64_t t, ret; | 410 | uint64_t ret; |
| 411 | uint8_t t; | ||
| 411 | cube_t transformed; | 412 | cube_t transformed; |
| 412 | 413 | ||
| 413 | for (t = 0, ret = 0; t < NTRANS; t++) { | 414 | for (t = 0, ret = 0; t < NTRANS; t++) { |
| 414 | transformed = transform(cube, t); | 415 | transformed = transform(cube, t); |
| 415 | ret |= ((uint64_t)equal(cube, transformed)) << t; | 416 | ret |= ((uint64_t)equal(cube, transformed)) << (uint64_t)t; |
| 416 | } | 417 | } |
| 417 | 418 | ||
| 418 | return ret; | 419 | return ret; |
diff --git a/src/nissy.c b/src/nissy.c index 594bdc4..0811861 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -12,8 +12,8 @@ | |||
| 12 | #include "core/core.h" | 12 | #include "core/core.h" |
| 13 | #include "solvers/solvers.h" | 13 | #include "solvers/solvers.h" |
| 14 | 14 | ||
| 15 | STATIC long long write_result(oriented_cube_t, char [static NISSY_SIZE_CUBE]); | 15 | STATIC long long write_result(oriented_cube_t, char [SIZE(NISSY_SIZE_CUBE)]); |
| 16 | STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); | 16 | STATIC long long nissy_dataid(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 17 | STATIC long long nissy_gendata_unsafe( | 17 | STATIC long long nissy_gendata_unsafe( |
| 18 | const char *, unsigned long long, unsigned char *); | 18 | const char *, unsigned long long, unsigned char *); |
| 19 | 19 | ||
| @@ -28,7 +28,7 @@ struct { | |||
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | STATIC long long | 30 | STATIC long long |
| 31 | write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) | 31 | write_result(oriented_cube_t cube, char result[SIZE(NISSY_SIZE_CUBE)]) |
| 32 | { | 32 | { |
| 33 | writecube(cube, NISSY_SIZE_CUBE, result); | 33 | writecube(cube, NISSY_SIZE_CUBE, result); |
| 34 | 34 | ||
| @@ -42,8 +42,8 @@ write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) | |||
| 42 | 42 | ||
| 43 | long long | 43 | long long |
| 44 | nissy_inverse( | 44 | nissy_inverse( |
| 45 | const char cube[static NISSY_SIZE_CUBE], | 45 | const char cube[], |
| 46 | char result[static NISSY_SIZE_CUBE] | 46 | char result[] |
| 47 | ) | 47 | ) |
| 48 | { | 48 | { |
| 49 | oriented_cube_t c, res; | 49 | oriented_cube_t c, res; |
| @@ -77,9 +77,9 @@ nissy_inverse_error: | |||
| 77 | 77 | ||
| 78 | long long | 78 | long long |
| 79 | nissy_applymoves( | 79 | nissy_applymoves( |
| 80 | const char cube[static NISSY_SIZE_CUBE], | 80 | const char cube[], |
| 81 | const char *moves, | 81 | const char *moves, |
| 82 | char result[static NISSY_SIZE_CUBE] | 82 | char result[] |
| 83 | ) | 83 | ) |
| 84 | { | 84 | { |
| 85 | oriented_cube_t c, res; | 85 | oriented_cube_t c, res; |
| @@ -116,9 +116,9 @@ nissy_applymoves_error: | |||
| 116 | 116 | ||
| 117 | long long | 117 | long long |
| 118 | nissy_applytrans( | 118 | nissy_applytrans( |
| 119 | const char cube[static NISSY_SIZE_CUBE], | 119 | const char cube[], |
| 120 | const char transformation[static NISSY_SIZE_TRANSFORMATION], | 120 | const char transformation[], |
| 121 | char result[static NISSY_SIZE_CUBE] | 121 | char result[] |
| 122 | ) | 122 | ) |
| 123 | { | 123 | { |
| 124 | oriented_cube_t c, res; | 124 | oriented_cube_t c, res; |
| @@ -181,7 +181,7 @@ nissy_getcube( | |||
| 181 | long long co, | 181 | long long co, |
| 182 | long long orient, | 182 | long long orient, |
| 183 | const char *options, | 183 | const char *options, |
| 184 | char result[static NISSY_SIZE_CUBE] | 184 | char result[] |
| 185 | ) | 185 | ) |
| 186 | { | 186 | { |
| 187 | int i; | 187 | int i; |
| @@ -197,7 +197,7 @@ nissy_getcube( | |||
| 197 | getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); | 197 | getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); |
| 198 | 198 | ||
| 199 | oc.cube = getcube(ep, eo, cp, co); | 199 | oc.cube = getcube(ep, eo, cp, co); |
| 200 | oc.orientation = orient; | 200 | oc.orientation = (uint8_t)orient; |
| 201 | 201 | ||
| 202 | if (!isconsistent(oc)) { | 202 | if (!isconsistent(oc)) { |
| 203 | LOG("[getcube] Error: could not get cube with ep=%lld, " | 203 | LOG("[getcube] Error: could not get cube with ep=%lld, " |
| @@ -210,7 +210,7 @@ nissy_getcube( | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | STATIC long long | 212 | STATIC long long |
| 213 | nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID]) | 213 | nissy_dataid(const char *solver, char dataid[SIZE(NISSY_SIZE_DATAID)]) |
| 214 | { | 214 | { |
| 215 | solver_dispatch_t dispatch; | 215 | solver_dispatch_t dispatch; |
| 216 | 216 | ||
| @@ -226,7 +226,7 @@ nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID]) | |||
| 226 | long long | 226 | long long |
| 227 | nissy_solverinfo( | 227 | nissy_solverinfo( |
| 228 | const char *solver, | 228 | const char *solver, |
| 229 | char dataid[static NISSY_SIZE_DATAID] | 229 | char dataid[] |
| 230 | ) | 230 | ) |
| 231 | { | 231 | { |
| 232 | long long err; | 232 | long long err; |
| @@ -295,7 +295,7 @@ nissy_checkdata( | |||
| 295 | 295 | ||
| 296 | long long | 296 | long long |
| 297 | nissy_solve( | 297 | nissy_solve( |
| 298 | const char cube[static NISSY_SIZE_CUBE], | 298 | const char cube[], |
| 299 | const char *solver, | 299 | const char *solver, |
| 300 | unsigned nissflag, | 300 | unsigned nissflag, |
| 301 | unsigned minmoves, | 301 | unsigned minmoves, |
| @@ -307,7 +307,7 @@ nissy_solve( | |||
| 307 | const unsigned char *data, | 307 | const unsigned char *data, |
| 308 | unsigned sols_size, | 308 | unsigned sols_size, |
| 309 | char *sols, | 309 | char *sols, |
| 310 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 310 | long long stats[], |
| 311 | int (*poll_status)(void *), | 311 | int (*poll_status)(void *), |
| 312 | void *poll_status_data | 312 | void *poll_status_data |
| 313 | ) | 313 | ) |
diff --git a/src/nissy.h b/src/nissy.h index c85072a..c7edf88 100644 --- a/src/nissy.h +++ b/src/nissy.h | |||
| @@ -149,7 +149,9 @@ Compute the inverse of the given cube. | |||
| 149 | 149 | ||
| 150 | Parameters: | 150 | Parameters: |
| 151 | cube - The cube to be inverted. | 151 | cube - The cube to be inverted. |
| 152 | Required size: NISSY_SIZE_CUBE. | ||
| 152 | result - The return parameter for the resulting cube. | 153 | result - The return parameter for the resulting cube. |
| 154 | Required size: NISSY_SIZE_CUBE. | ||
| 153 | 155 | ||
| 154 | Return values: | 156 | Return values: |
| 155 | NISSY_OK - The cube was inverted succesfully. | 157 | NISSY_OK - The cube was inverted succesfully. |
| @@ -161,8 +163,8 @@ Return values: | |||
| 161 | */ | 163 | */ |
| 162 | long long | 164 | long long |
| 163 | nissy_inverse( | 165 | nissy_inverse( |
| 164 | const char cube[static NISSY_SIZE_CUBE], | 166 | const char cube[], /* NISSY_SIZE_CUBE */ |
| 165 | char result[static NISSY_SIZE_CUBE] | 167 | char result[] /* NISSY_SIZE_CUBE */ |
| 166 | ); | 168 | ); |
| 167 | 169 | ||
| 168 | /* | 170 | /* |
| @@ -170,8 +172,10 @@ Apply the given sequence of moves on the given cube. | |||
| 170 | 172 | ||
| 171 | Parameters: | 173 | Parameters: |
| 172 | cube - The cube to move. | 174 | cube - The cube to move. |
| 175 | Required size: NISSY_SIZE_CUBE. | ||
| 173 | moves - The moves to apply to the cube. Must be a NULL-terminated string. | 176 | moves - The moves to apply to the cube. Must be a NULL-terminated string. |
| 174 | result - The return parameter for the resulting cube. | 177 | result - The return parameter for the resulting cube. |
| 178 | Required size: NISSY_SIZE_CUBE. | ||
| 175 | 179 | ||
| 176 | Return values: | 180 | Return values: |
| 177 | NISSY_OK - The moves were applied succesfully. | 181 | NISSY_OK - The moves were applied succesfully. |
| @@ -184,9 +188,9 @@ Return values: | |||
| 184 | */ | 188 | */ |
| 185 | long long | 189 | long long |
| 186 | nissy_applymoves( | 190 | nissy_applymoves( |
| 187 | const char cube[static NISSY_SIZE_CUBE], | 191 | const char cube[], /* NISSY_SIZE_CUBE */ |
| 188 | const char *moves, | 192 | const char *moves, |
| 189 | char result[static NISSY_SIZE_CUBE] | 193 | char result[] /* NISSY_SIZE_CUBE */ |
| 190 | ); | 194 | ); |
| 191 | 195 | ||
| 192 | /* | 196 | /* |
| @@ -194,8 +198,11 @@ Apply the single given transformation to the given cube. | |||
| 194 | 198 | ||
| 195 | Parameters: | 199 | Parameters: |
| 196 | cube - The cube to be transformed. | 200 | cube - The cube to be transformed. |
| 201 | Required size: NISSY_SIZE_CUBE. | ||
| 197 | transformation - The transformation in "(rotation|mirrored) __" format. | 202 | transformation - The transformation in "(rotation|mirrored) __" format. |
| 203 | Required size: NISSY_SIZE_TRANSFORMATION. | ||
| 198 | result - The return parameter for the resulting cube. | 204 | result - The return parameter for the resulting cube. |
| 205 | Required size: NISSY_SIZE_CUBE. | ||
| 199 | 206 | ||
| 200 | Return values: | 207 | Return values: |
| 201 | NISSY_OK - The transformation was performed succesfully. | 208 | NISSY_OK - The transformation was performed succesfully. |
| @@ -206,9 +213,9 @@ Return values: | |||
| 206 | */ | 213 | */ |
| 207 | long long | 214 | long long |
| 208 | nissy_applytrans( | 215 | nissy_applytrans( |
| 209 | const char cube[static NISSY_SIZE_CUBE], | 216 | const char cube[], /* NISSY_SIZE_CUBE */ |
| 210 | const char transformation[static NISSY_SIZE_TRANSFORMATION], | 217 | const char transformation[], /* NISSY_SIZE_TRANSFORMATION */ |
| 211 | char result[static NISSY_SIZE_CUBE] | 218 | char result[] /* NISSY_SIZE_CUBE */ |
| 212 | ); | 219 | ); |
| 213 | 220 | ||
| 214 | /* | 221 | /* |
| @@ -256,6 +263,7 @@ Parameters: | |||
| 256 | orient - The orientation of the cube, 0 <= orient < 24 | 263 | orient - The orientation of the cube, 0 <= orient < 24 |
| 257 | options - Other options. | 264 | options - Other options. |
| 258 | result - The return parameter for the resulting cube. | 265 | result - The return parameter for the resulting cube. |
| 266 | Required size: NISSY_SIZE_CUBE. | ||
| 259 | 267 | ||
| 260 | Return values: | 268 | Return values: |
| 261 | NISSY_OK - The cube was generated succesfully. | 269 | NISSY_OK - The cube was generated succesfully. |
| @@ -270,7 +278,7 @@ nissy_getcube( | |||
| 270 | long long co, | 278 | long long co, |
| 271 | long long orient, | 279 | long long orient, |
| 272 | const char *options, | 280 | const char *options, |
| 273 | char result[static NISSY_SIZE_CUBE] | 281 | char result[] /* NISSY_SIZE_CUBE */ |
| 274 | ); | 282 | ); |
| 275 | 283 | ||
| 276 | /* | 284 | /* |
| @@ -283,6 +291,7 @@ Parameters: | |||
| 283 | solvers may use equivalent data. This identifier can be used | 291 | solvers may use equivalent data. This identifier can be used |
| 284 | e.g. as a filename or database key to save and retrieve the | 292 | e.g. as a filename or database key to save and retrieve the |
| 285 | correct data for each solver, without duplication. | 293 | correct data for each solver, without duplication. |
| 294 | Required size: NISSY_SIZE_DATAID. | ||
| 286 | 295 | ||
| 287 | Return values: | 296 | Return values: |
| 288 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. | 297 | NISSY_ERROR_INVALID_SOLVER - The given solver is not known. |
| @@ -293,7 +302,7 @@ Return values: | |||
| 293 | long long | 302 | long long |
| 294 | nissy_solverinfo( | 303 | nissy_solverinfo( |
| 295 | const char *solver, | 304 | const char *solver, |
| 296 | char dataid[static NISSY_SIZE_DATAID] | 305 | char dataid[] /* NISSY_SIZE_DATAID */ |
| 297 | ); | 306 | ); |
| 298 | 307 | ||
| 299 | /* | 308 | /* |
| @@ -350,6 +359,7 @@ Solve the given cube using the given solver and options. | |||
| 350 | 359 | ||
| 351 | Parameters: | 360 | Parameters: |
| 352 | cube - The cube to solver. | 361 | cube - The cube to solver. |
| 362 | Required size: NISSY_SIZE_CUBE. | ||
| 353 | solver - The name of the solver. See doc/solvers.md for a list. | 363 | solver - The name of the solver. See doc/solvers.md for a list. |
| 354 | nissflag - The flags for NISS (linear, inverse, mixed, or | 364 | nissflag - The flags for NISS (linear, inverse, mixed, or |
| 355 | combinations; see the constants at the top of this file). | 365 | combinations; see the constants at the top of this file). |
| @@ -370,6 +380,7 @@ Parameters: | |||
| 370 | separated by a '\n' (newline) and a '\0' (NULL character) | 380 | separated by a '\n' (newline) and a '\0' (NULL character) |
| 371 | terminates the list. | 381 | terminates the list. |
| 372 | stats - An array to store some statistics about the solve. | 382 | stats - An array to store some statistics about the solve. |
| 383 | Required size: NISSY_SIZE_SOLVE_STATS. | ||
| 373 | poll_status - A callback function that should return the current | 384 | poll_status - A callback function that should return the current |
| 374 | requested status for the solver (e.g. run, stop, pause, | 385 | requested status for the solver (e.g. run, stop, pause, |
| 375 | resume; see the constants at the top of this file). The | 386 | resume; see the constants at the top of this file). The |
| @@ -391,7 +402,7 @@ Return values: | |||
| 391 | */ | 402 | */ |
| 392 | long long | 403 | long long |
| 393 | nissy_solve( | 404 | nissy_solve( |
| 394 | const char cube[static NISSY_SIZE_CUBE], | 405 | const char cube[], /* NISSY_SIZE_CUBE */ |
| 395 | const char *solver, | 406 | const char *solver, |
| 396 | unsigned nissflag, | 407 | unsigned nissflag, |
| 397 | unsigned minmoves, | 408 | unsigned minmoves, |
| @@ -403,7 +414,7 @@ nissy_solve( | |||
| 403 | const unsigned char *data, | 414 | const unsigned char *data, |
| 404 | unsigned sols_size, | 415 | unsigned sols_size, |
| 405 | char *sols, | 416 | char *sols, |
| 406 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 417 | long long stats[], /* NISSY_SIZE_SOLVE_STATS */ |
| 407 | int (*poll_status)(void *), | 418 | int (*poll_status)(void *), |
| 408 | void *poll_status_data | 419 | void *poll_status_data |
| 409 | ); | 420 | ); |
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index d154636..3a62e85 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | STATIC uint64_t coord_coord_generic( | 1 | STATIC uint64_t coord_coord_generic( |
| 2 | const coord_t [static 1], cube_t, const unsigned char *); | 2 | const coord_t [NON_NULL], cube_t, const unsigned char *); |
| 3 | STATIC cube_t coord_cube_generic( | 3 | STATIC cube_t coord_cube_generic( |
| 4 | const coord_t [static 1], uint64_t, const unsigned char *); | 4 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 5 | STATIC bool coord_isnasty_generic( | 5 | STATIC bool coord_isnasty_generic( |
| 6 | const coord_t [static 1], uint64_t, const unsigned char *); | 6 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 7 | STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); | 7 | STATIC size_t coord_gendata_generic(const coord_t [NON_NULL], unsigned char *); |
| 8 | 8 | ||
| 9 | STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); | 9 | STATIC bool solution_lastqt_cw(const solution_moves_t [NON_NULL]); |
| 10 | STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, | 10 | STATIC bool coord_can_switch(const coord_t [NON_NULL], const unsigned char *, |
| 11 | size_t, const uint8_t *); | 11 | size_t, const uint8_t *); |
| 12 | STATIC bool coord_is_solved( | 12 | STATIC bool coord_is_solved( |
| 13 | const coord_t [static 1], uint64_t, const unsigned char *); | 13 | const coord_t [NON_NULL], uint64_t, const unsigned char *); |
| 14 | 14 | ||
| 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); | 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); |
| 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); | 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); |
| @@ -18,7 +18,7 @@ STATIC cube_t coordinate_merge_cpco(cube_t, cube_t); | |||
| 18 | 18 | ||
| 19 | STATIC uint64_t | 19 | STATIC uint64_t |
| 20 | coord_coord_generic( | 20 | coord_coord_generic( |
| 21 | const coord_t coord[static 1], | 21 | const coord_t coord[NON_NULL], |
| 22 | cube_t c, | 22 | cube_t c, |
| 23 | const unsigned char *data | 23 | const unsigned char *data |
| 24 | ) | 24 | ) |
| @@ -36,7 +36,7 @@ coord_coord_generic( | |||
| 36 | 36 | ||
| 37 | STATIC cube_t | 37 | STATIC cube_t |
| 38 | coord_cube_generic( | 38 | coord_cube_generic( |
| 39 | const coord_t coord[static 1], | 39 | const coord_t coord[NON_NULL], |
| 40 | uint64_t i, | 40 | uint64_t i, |
| 41 | const unsigned char *data | 41 | const unsigned char *data |
| 42 | ) | 42 | ) |
| @@ -54,7 +54,7 @@ coord_cube_generic( | |||
| 54 | 54 | ||
| 55 | STATIC bool | 55 | STATIC bool |
| 56 | coord_isnasty_generic( | 56 | coord_isnasty_generic( |
| 57 | const coord_t coord[static 1], | 57 | const coord_t coord[NON_NULL], |
| 58 | uint64_t i, | 58 | uint64_t i, |
| 59 | const unsigned char *data | 59 | const unsigned char *data |
| 60 | ) | 60 | ) |
| @@ -73,11 +73,12 @@ coord_isnasty_generic( | |||
| 73 | 73 | ||
| 74 | STATIC size_t | 74 | STATIC size_t |
| 75 | coord_gendata_generic( | 75 | coord_gendata_generic( |
| 76 | const coord_t coord[static 1], | 76 | const coord_t coord[NON_NULL], |
| 77 | unsigned char *data | 77 | unsigned char *data |
| 78 | ) | 78 | ) |
| 79 | { | 79 | { |
| 80 | uint64_t i, j, n, t, nasty; | 80 | uint64_t i, j, n, nasty; |
| 81 | uint8_t t; | ||
| 81 | unsigned char *datanoinfo; | 82 | unsigned char *datanoinfo; |
| 82 | uint32_t *classttrep, *rep; | 83 | uint32_t *classttrep, *rep; |
| 83 | size_t coord_datasize; | 84 | size_t coord_datasize; |
| @@ -122,16 +123,17 @@ coord_gendata_generic( | |||
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | for (t = 0; t < NTRANS; t++) { | 125 | for (t = 0; t < NTRANS; t++) { |
| 125 | if (!((UINT64_C(1) << t) & coord->trans_mask)) | 126 | if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) |
| 126 | continue; | 127 | continue; |
| 127 | 128 | ||
| 128 | j = coord->sym.coord(transform(c, t)); | 129 | j = coord->sym.coord(transform(c, t)); |
| 129 | classttrep[j] = | 130 | classttrep[j] = (uint32_t)( |
| 130 | (n << COORD_CLASS_SHIFT) | | 131 | (n << COORD_CLASS_SHIFT) | |
| 131 | (nasty << COORD_ISNASTY_SHIFT) | | 132 | (nasty << COORD_ISNASTY_SHIFT) | |
| 132 | (inverse_trans(t) << COORD_TTREP_SHIFT); | 133 | (inverse_trans(t) << COORD_TTREP_SHIFT) |
| 134 | ); | ||
| 133 | } | 135 | } |
| 134 | rep[n++] = i; | 136 | rep[n++] = (uint32_t)i; |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | writetableinfo(&info, coord_datasize, data); | 139 | writetableinfo(&info, coord_datasize, data); |
| @@ -144,21 +146,21 @@ coord_gendata_generic( | |||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | STATIC bool | 148 | STATIC bool |
| 147 | solution_lastqt_cw(const solution_moves_t s[static 1]) | 149 | solution_lastqt_cw(const solution_moves_t s[NON_NULL]) |
| 148 | { | 150 | { |
| 149 | return are_lastmoves_singlecw(s->nmoves, s->moves) && | 151 | return are_lastmoves_singlecw(s->nmoves, s->moves) && |
| 150 | are_lastmoves_singlecw(s->npremoves, s->premoves); | 152 | are_lastmoves_singlecw(s->npremoves, s->premoves); |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | STATIC bool | 155 | STATIC bool |
| 154 | solution_always_valid(const solution_moves_t s[static 1]) | 156 | solution_always_valid(const solution_moves_t s[NON_NULL]) |
| 155 | { | 157 | { |
| 156 | return true; | 158 | return true; |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 159 | STATIC bool | 161 | STATIC bool |
| 160 | coord_can_switch( | 162 | coord_can_switch( |
| 161 | const coord_t coord[static 1], | 163 | const coord_t coord[NON_NULL], |
| 162 | const unsigned char *data, | 164 | const unsigned char *data, |
| 163 | size_t n, | 165 | size_t n, |
| 164 | const uint8_t *moves | 166 | const uint8_t *moves |
| @@ -192,7 +194,7 @@ coord_can_switch( | |||
| 192 | 194 | ||
| 193 | STATIC bool | 195 | STATIC bool |
| 194 | coord_is_solved( | 196 | coord_is_solved( |
| 195 | const coord_t coord[static 1], | 197 | const coord_t coord[NON_NULL], |
| 196 | uint64_t i, | 198 | uint64_t i, |
| 197 | const unsigned char *data | 199 | const unsigned char *data |
| 198 | ) | 200 | ) |
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index cbc8774..edf6ce6 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -1,21 +1,21 @@ | |||
| 1 | STATIC size_t gendata_coord(const coord_t [static 1], unsigned char *); | 1 | STATIC size_t gendata_coord(const coord_t [NON_NULL], unsigned char *); |
| 2 | STATIC size_t gendata_multicoord( | 2 | STATIC size_t gendata_multicoord( |
| 3 | const multicoord_t [static 1], unsigned char *); | 3 | const multicoord_t [NON_NULL], unsigned char *); |
| 4 | STATIC long long gendata_coord_dispatch(const char *, unsigned long long, | 4 | STATIC long long gendata_coord_dispatch(const char *, unsigned long long, |
| 5 | unsigned char *); | 5 | unsigned char *); |
| 6 | STATIC tableinfo_t genptable_coord( | 6 | STATIC tableinfo_t genptable_coord( |
| 7 | const coord_t [static 1], const unsigned char *, unsigned char *); | 7 | const coord_t [NON_NULL], const unsigned char *, unsigned char *); |
| 8 | STATIC uint64_t genptable_coord_init_solved( | 8 | STATIC uint64_t genptable_coord_init_solved( |
| 9 | const coord_t [static 1], const unsigned char *, unsigned char *); | 9 | const coord_t [NON_NULL], const unsigned char *, unsigned char *); |
| 10 | STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); | 10 | STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); |
| 11 | STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1], | 11 | STATIC uint64_t genptable_coord_fillneighbors(const coord_t [NON_NULL], |
| 12 | const unsigned char *, uint64_t, uint8_t, unsigned char *); | 12 | const unsigned char *, uint64_t, uint8_t, unsigned char *); |
| 13 | STATIC uint64_t genptable_coord_fillfromnew(const coord_t [static 1], | 13 | STATIC uint64_t genptable_coord_fillfromnew(const coord_t [NON_NULL], |
| 14 | const unsigned char *, uint64_t, uint8_t, unsigned char *); | 14 | const unsigned char *, uint64_t, uint8_t, unsigned char *); |
| 15 | STATIC uint8_t get_coord_pval( | 15 | STATIC uint8_t get_coord_pval( |
| 16 | const coord_t [static 1], const unsigned char *, uint64_t); | 16 | const coord_t [NON_NULL], const unsigned char *, uint64_t); |
| 17 | STATIC void set_coord_pval( | 17 | STATIC void set_coord_pval( |
| 18 | const coord_t [static 1], unsigned char *, uint64_t, uint8_t); | 18 | const coord_t [NON_NULL], unsigned char *, uint64_t, uint8_t); |
| 19 | 19 | ||
| 20 | STATIC long long | 20 | STATIC long long |
| 21 | gendata_coord_dispatch( | 21 | gendata_coord_dispatch( |
| @@ -40,7 +40,7 @@ gendata_coord_dispatch( | |||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | STATIC size_t | 42 | STATIC size_t |
| 43 | gendata_coord(const coord_t coord[static 1], unsigned char *buf) | 43 | gendata_coord(const coord_t coord[NON_NULL], unsigned char *buf) |
| 44 | { | 44 | { |
| 45 | uint64_t coord_dsize, tablesize, ninfo; | 45 | uint64_t coord_dsize, tablesize, ninfo; |
| 46 | unsigned char *pruningbuf, *coord_data; | 46 | unsigned char *pruningbuf, *coord_data; |
| @@ -96,7 +96,7 @@ gendata_coord_error: | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | STATIC size_t | 98 | STATIC size_t |
| 99 | gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) | 99 | gendata_multicoord(const multicoord_t mcoord[NON_NULL], unsigned char *buf) |
| 100 | { | 100 | { |
| 101 | unsigned char *b; | 101 | unsigned char *b; |
| 102 | size_t i, s, ret; | 102 | size_t i, s, ret; |
| @@ -141,12 +141,13 @@ gendata_multicoord(const multicoord_t mcoord[static 1], unsigned char *buf) | |||
| 141 | 141 | ||
| 142 | STATIC tableinfo_t | 142 | STATIC tableinfo_t |
| 143 | genptable_coord( | 143 | genptable_coord( |
| 144 | const coord_t coord[static 1], | 144 | const coord_t coord[NON_NULL], |
| 145 | const unsigned char *data, | 145 | const unsigned char *data, |
| 146 | unsigned char *table | 146 | unsigned char *table |
| 147 | ) | 147 | ) |
| 148 | { | 148 | { |
| 149 | uint64_t tablesize, i, d, tot, t, nm; | 149 | uint64_t tablesize, i, tot, t, nm; |
| 150 | uint8_t d; | ||
| 150 | tableinfo_t info; | 151 | tableinfo_t info; |
| 151 | 152 | ||
| 152 | tablesize = DIV_ROUND_UP(coord->max, 2); | 153 | tablesize = DIV_ROUND_UP(coord->max, 2); |
| @@ -170,7 +171,7 @@ genptable_coord( | |||
| 170 | 171 | ||
| 171 | tot = info.distribution[0] = | 172 | tot = info.distribution[0] = |
| 172 | genptable_coord_init_solved(coord, data, table); | 173 | genptable_coord_init_solved(coord, data, table); |
| 173 | nm = popcount_u32(coord->moves_mask_gendata); | 174 | nm = popcount_u64(coord->moves_mask_gendata); |
| 174 | for (d = 1; tot < coord->max && d < 15; d++) { | 175 | for (d = 1; tot < coord->max && d < 15; d++) { |
| 175 | t = 0; | 176 | t = 0; |
| 176 | if (switch_to_fromnew(tot, coord->max, nm)) { | 177 | if (switch_to_fromnew(tot, coord->max, nm)) { |
| @@ -204,7 +205,7 @@ genptable_coord( | |||
| 204 | 205 | ||
| 205 | STATIC uint64_t | 206 | STATIC uint64_t |
| 206 | genptable_coord_init_solved( | 207 | genptable_coord_init_solved( |
| 207 | const coord_t coord[static 1], | 208 | const coord_t coord[NON_NULL], |
| 208 | const unsigned char *coord_data, | 209 | const unsigned char *coord_data, |
| 209 | unsigned char *table | 210 | unsigned char *table |
| 210 | ) | 211 | ) |
| @@ -238,7 +239,7 @@ switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm) | |||
| 238 | 239 | ||
| 239 | STATIC uint64_t | 240 | STATIC uint64_t |
| 240 | genptable_coord_fillneighbors( | 241 | genptable_coord_fillneighbors( |
| 241 | const coord_t coord[static 1], | 242 | const coord_t coord[NON_NULL], |
| 242 | const unsigned char *data, | 243 | const unsigned char *data, |
| 243 | uint64_t i, | 244 | uint64_t i, |
| 244 | uint8_t d, | 245 | uint8_t d, |
| @@ -247,20 +248,21 @@ genptable_coord_fillneighbors( | |||
| 247 | { | 248 | { |
| 248 | bool isnasty; | 249 | bool isnasty; |
| 249 | uint8_t m; | 250 | uint8_t m; |
| 250 | uint64_t ii, j, t, tot; | 251 | uint64_t ii, j, tot; |
| 252 | uint8_t t; | ||
| 251 | cube_t c, moved; | 253 | cube_t c, moved; |
| 252 | 254 | ||
| 253 | c = coord->cube(i, data); | 255 | c = coord->cube(i, data); |
| 254 | tot = 0; | 256 | tot = 0; |
| 255 | for (m = 0; m < NMOVES; m++) { | 257 | for (m = 0; m < NMOVES; m++) { |
| 256 | if (!((UINT32_C(1) << (uint32_t)m) & | 258 | if (!((UINT64_C(1) << (uint64_t)m) & |
| 257 | coord->moves_mask_gendata)) | 259 | coord->moves_mask_gendata)) |
| 258 | continue; | 260 | continue; |
| 259 | moved = move(c, m); | 261 | moved = move(c, m); |
| 260 | ii = coord->coord(moved, data); | 262 | ii = coord->coord(moved, data); |
| 261 | isnasty = coord->isnasty(ii, data); | 263 | isnasty = coord->isnasty(ii, data); |
| 262 | for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) { | 264 | for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) { |
| 263 | if (!((UINT64_C(1) << t) & coord->trans_mask)) | 265 | if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) |
| 264 | continue; | 266 | continue; |
| 265 | 267 | ||
| 266 | j = coord->coord(transform(moved, t), data); | 268 | j = coord->coord(transform(moved, t), data); |
| @@ -276,7 +278,7 @@ genptable_coord_fillneighbors( | |||
| 276 | 278 | ||
| 277 | STATIC uint64_t | 279 | STATIC uint64_t |
| 278 | genptable_coord_fillfromnew( | 280 | genptable_coord_fillfromnew( |
| 279 | const coord_t coord[static 1], | 281 | const coord_t coord[NON_NULL], |
| 280 | const unsigned char *data, | 282 | const unsigned char *data, |
| 281 | uint64_t i, | 283 | uint64_t i, |
| 282 | uint8_t d, | 284 | uint8_t d, |
| @@ -285,14 +287,15 @@ genptable_coord_fillfromnew( | |||
| 285 | { | 287 | { |
| 286 | bool found; | 288 | bool found; |
| 287 | uint8_t m; | 289 | uint8_t m; |
| 288 | uint64_t tot, t, ii, j, nsim, sim[NTRANS]; | 290 | uint64_t tot, j, ii, nsim, sim[NTRANS]; |
| 291 | uint8_t t; | ||
| 289 | cube_t c; | 292 | cube_t c; |
| 290 | 293 | ||
| 291 | tot = 0; | 294 | tot = 0; |
| 292 | c = coord->cube(i, data); | 295 | c = coord->cube(i, data); |
| 293 | 296 | ||
| 294 | for (t = 0, nsim = 0; t < NTRANS; t++) { | 297 | for (t = 0, nsim = 0; t < NTRANS; t++) { |
| 295 | if (!((UINT64_C(1) << t) & coord->trans_mask)) | 298 | if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) |
| 296 | continue; | 299 | continue; |
| 297 | 300 | ||
| 298 | ii = coord->coord(transform(c, t), data); | 301 | ii = coord->coord(transform(c, t), data); |
| @@ -305,7 +308,7 @@ genptable_coord_fillfromnew( | |||
| 305 | for (j = 0, found = false; j < nsim && !found; j++) { | 308 | for (j = 0, found = false; j < nsim && !found; j++) { |
| 306 | c = coord->cube(sim[j], data); | 309 | c = coord->cube(sim[j], data); |
| 307 | for (m = 0; m < NMOVES; m++) { | 310 | for (m = 0; m < NMOVES; m++) { |
| 308 | if (!((UINT32_C(1) << (uint32_t)m) & | 311 | if (!((UINT64_C(1) << (uint64_t)m) & |
| 309 | coord->moves_mask_gendata)) | 312 | coord->moves_mask_gendata)) |
| 310 | continue; | 313 | continue; |
| 311 | ii = coord->coord(move(c, m), data); | 314 | ii = coord->coord(move(c, m), data); |
| @@ -331,7 +334,7 @@ genptable_coord_fillfromnew( | |||
| 331 | 334 | ||
| 332 | STATIC uint8_t | 335 | STATIC uint8_t |
| 333 | get_coord_pval( | 336 | get_coord_pval( |
| 334 | const coord_t coord[static 1], | 337 | const coord_t coord[NON_NULL], |
| 335 | const unsigned char *table, | 338 | const unsigned char *table, |
| 336 | uint64_t i | 339 | uint64_t i |
| 337 | ) | 340 | ) |
| @@ -341,7 +344,7 @@ get_coord_pval( | |||
| 341 | 344 | ||
| 342 | STATIC void | 345 | STATIC void |
| 343 | set_coord_pval( | 346 | set_coord_pval( |
| 344 | const coord_t coord[static 1], | 347 | const coord_t coord[NON_NULL], |
| 345 | unsigned char *table, | 348 | unsigned char *table, |
| 346 | uint64_t i, | 349 | uint64_t i, |
| 347 | uint8_t val | 350 | uint8_t val |
diff --git a/src/solvers/coord/htr.h b/src/solvers/coord/htr.h index cfd451b..602625b 100644 --- a/src/solvers/coord/htr.h +++ b/src/solvers/coord/htr.h | |||
| @@ -4,7 +4,7 @@ STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *); | |||
| 4 | STATIC size_t coordinate_htr_gendata(unsigned char *); | 4 | STATIC size_t coordinate_htr_gendata(unsigned char *); |
| 5 | 5 | ||
| 6 | STATIC bool htr_checkmoves(bool *, uint8_t, const uint8_t *); | 6 | STATIC bool htr_checkmoves(bool *, uint8_t, const uint8_t *); |
| 7 | STATIC bool htr_solution_prune(const solution_moves_t [static 1]); | 7 | STATIC bool htr_solution_prune(const solution_moves_t [NON_NULL]); |
| 8 | STATIC bool is_cp_htr(uint64_t, const unsigned char *); | 8 | STATIC bool is_cp_htr(uint64_t, const unsigned char *); |
| 9 | 9 | ||
| 10 | STATIC coord_t coordinate_htr = { | 10 | STATIC coord_t coordinate_htr = { |
| @@ -97,7 +97,7 @@ htr_checkmoves(bool *f, uint8_t n, const uint8_t *moves) | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | STATIC bool | 99 | STATIC bool |
| 100 | htr_solution_prune(const solution_moves_t s[static 1]) | 100 | htr_solution_prune(const solution_moves_t s[NON_NULL]) |
| 101 | { | 101 | { |
| 102 | bool f; | 102 | bool f; |
| 103 | 103 | ||
diff --git a/src/solvers/coord/multisolve.h b/src/solvers/coord/multisolve.h index a45bd6a..efd287d 100644 --- a/src/solvers/coord/multisolve.h +++ b/src/solvers/coord/multisolve.h | |||
| @@ -16,20 +16,20 @@ typedef struct { | |||
| 16 | const unsigned char *ptable[MAX_MULTICOORD_NCOORDS]; | 16 | const unsigned char *ptable[MAX_MULTICOORD_NCOORDS]; |
| 17 | } dfsarg_solve_multicoord_t; | 17 | } dfsarg_solve_multicoord_t; |
| 18 | 18 | ||
| 19 | STATIC int64_t solve_multicoord(oriented_cube_t, multicoord_t [static 1], | 19 | STATIC int64_t solve_multicoord(oriented_cube_t, multicoord_t [NON_NULL], |
| 20 | uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, | 20 | uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, |
| 21 | const unsigned char *, size_t, char *, int (*)(void *), void *); | 21 | const unsigned char *, size_t, char *, int (*)(void *), void *); |
| 22 | STATIC long long solve_multicoord_dispatch(oriented_cube_t, const char *, | 22 | STATIC long long solve_multicoord_dispatch(oriented_cube_t, const char *, |
| 23 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, | 23 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, |
| 24 | unsigned long long, const unsigned char *, unsigned, char *, | 24 | unsigned long long, const unsigned char *, unsigned, char *, |
| 25 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 25 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); |
| 26 | STATIC bool multicoord_solution_admissible( | 26 | STATIC bool multicoord_solution_admissible( |
| 27 | const dfsarg_solve_multicoord_t [static 1]); | 27 | const dfsarg_solve_multicoord_t [NON_NULL]); |
| 28 | STATIC bool multicoord_dfs_stop(const dfsarg_solve_multicoord_t [static 1]); | 28 | STATIC bool multicoord_dfs_stop(const dfsarg_solve_multicoord_t [NON_NULL]); |
| 29 | STATIC int64_t solve_multicoord_dfs(dfsarg_solve_multicoord_t [static 1]); | 29 | STATIC int64_t solve_multicoord_dfs(dfsarg_solve_multicoord_t [NON_NULL]); |
| 30 | 30 | ||
| 31 | STATIC bool | 31 | STATIC bool |
| 32 | multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[static 1]) | 32 | multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[NON_NULL]) |
| 33 | { | 33 | { |
| 34 | uint8_t n, i; | 34 | uint8_t n, i; |
| 35 | const coord_t *c; | 35 | const coord_t *c; |
| @@ -49,7 +49,7 @@ multicoord_solution_admissible(const dfsarg_solve_multicoord_t arg[static 1]) | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | STATIC bool | 51 | STATIC bool |
| 52 | multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[static 1]) | 52 | multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[NON_NULL]) |
| 53 | { | 53 | { |
| 54 | uint8_t pval, i; | 54 | uint8_t pval, i; |
| 55 | uint64_t cval; | 55 | uint64_t cval; |
| @@ -69,11 +69,10 @@ multicoord_dfs_stop(const dfsarg_solve_multicoord_t arg[static 1]) | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | STATIC int64_t | 71 | STATIC int64_t |
| 72 | solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[static 1]) | 72 | solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[NON_NULL]) |
| 73 | { | 73 | { |
| 74 | uint8_t m, l, i; | 74 | uint8_t m, l, i; |
| 75 | uint32_t mm; | 75 | uint64_t mm, coord; |
| 76 | uint64_t coord; | ||
| 77 | int64_t n, ret; | 76 | int64_t n, ret; |
| 78 | const coord_t *c; | 77 | const coord_t *c; |
| 79 | cube_t backup_cube, backup_inverse; | 78 | cube_t backup_cube, backup_inverse; |
| @@ -108,7 +107,7 @@ solve_multicoord_dfs_notsolved: | |||
| 108 | arg->solution_moves->nmoves++; | 107 | arg->solution_moves->nmoves++; |
| 109 | 108 | ||
| 110 | for (m = 0; m < NMOVES; m++) { | 109 | for (m = 0; m < NMOVES; m++) { |
| 111 | if (!(mm & (UINT32_C(1) << (uint32_t)m))) | 110 | if (!(mm & (UINT64_C(1) << (uint64_t)m))) |
| 112 | continue; | 111 | continue; |
| 113 | 112 | ||
| 114 | arg->solution_moves->moves[l] = m; | 113 | arg->solution_moves->moves[l] = m; |
| @@ -141,7 +140,7 @@ solve_multicoord_dispatch( | |||
| 141 | const unsigned char *data, | 140 | const unsigned char *data, |
| 142 | unsigned solutions_size, | 141 | unsigned solutions_size, |
| 143 | char *sols, | 142 | char *sols, |
| 144 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 143 | long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], |
| 145 | int (*poll_status)(void *), | 144 | int (*poll_status)(void *), |
| 146 | void *poll_status_data | 145 | void *poll_status_data |
| 147 | ) | 146 | ) |
| @@ -163,15 +162,16 @@ solve_multicoord_dispatch( | |||
| 163 | return NISSY_ERROR_INVALID_SOLVER; | 162 | return NISSY_ERROR_INVALID_SOLVER; |
| 164 | } | 163 | } |
| 165 | 164 | ||
| 166 | return solve_multicoord(oc, mcoord, trans, minmoves, | 165 | return solve_multicoord(oc, mcoord, trans, (uint8_t)minmoves, |
| 167 | maxmoves, maxsolutions, optimal, threads, data_size, data, | 166 | (uint8_t)maxmoves, (uint8_t)maxsolutions, (uint8_t)optimal, |
| 168 | solutions_size, sols, poll_status, poll_status_data); | 167 | (uint8_t)threads, data_size, data, solutions_size, sols, |
| 168 | poll_status, poll_status_data); | ||
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | STATIC int64_t | 171 | STATIC int64_t |
| 172 | solve_multicoord( | 172 | solve_multicoord( |
| 173 | oriented_cube_t oc, | 173 | oriented_cube_t oc, |
| 174 | multicoord_t mcoord [static 1], | 174 | multicoord_t mcoord [NON_NULL], |
| 175 | uint8_t trans, | 175 | uint8_t trans, |
| 176 | uint8_t minmoves, | 176 | uint8_t minmoves, |
| 177 | uint8_t maxmoves, | 177 | uint8_t maxmoves, |
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index 9ea6d1a..6bb9af2 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -13,20 +13,20 @@ typedef struct { | |||
| 13 | const unsigned char *ptable; | 13 | const unsigned char *ptable; |
| 14 | } dfsarg_solve_coord_t; | 14 | } dfsarg_solve_coord_t; |
| 15 | 15 | ||
| 16 | STATIC int64_t solve_coord(oriented_cube_t, coord_t [static 1], uint8_t, | 16 | STATIC int64_t solve_coord(oriented_cube_t, coord_t [NON_NULL], uint8_t, |
| 17 | uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, | 17 | uint8_t, uint8_t, uint8_t, uint64_t, uint8_t, uint8_t, uint64_t, |
| 18 | const unsigned char *, size_t, char *, int (*)(void *), void *); | 18 | const unsigned char *, size_t, char *, int (*)(void *), void *); |
| 19 | STATIC long long solve_coord_dispatch(oriented_cube_t, const char *, unsigned, | 19 | STATIC long long solve_coord_dispatch(oriented_cube_t, const char *, unsigned, |
| 20 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, | 20 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, |
| 21 | const unsigned char *, unsigned, char *, | 21 | const unsigned char *, unsigned, char *, |
| 22 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 22 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); |
| 23 | STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [static 1]); | 23 | STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [NON_NULL]); |
| 24 | STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [static 1]); | 24 | STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [NON_NULL]); |
| 25 | STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [static 1]); | 25 | STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [NON_NULL]); |
| 26 | STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [static 1]); | 26 | STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [NON_NULL]); |
| 27 | 27 | ||
| 28 | STATIC bool | 28 | STATIC bool |
| 29 | coord_solution_admissible(const dfsarg_solve_coord_t arg[static 1]) | 29 | coord_solution_admissible(const dfsarg_solve_coord_t arg[NON_NULL]) |
| 30 | { | 30 | { |
| 31 | uint8_t n; | 31 | uint8_t n; |
| 32 | 32 | ||
| @@ -39,7 +39,7 @@ coord_solution_admissible(const dfsarg_solve_coord_t arg[static 1]) | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | STATIC bool | 41 | STATIC bool |
| 42 | coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) | 42 | coord_continue_onnormal(const dfsarg_solve_coord_t arg[NON_NULL]) |
| 43 | { | 43 | { |
| 44 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; | 44 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; |
| 45 | uint64_t coord; | 45 | uint64_t coord; |
| @@ -93,7 +93,7 @@ coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | STATIC bool | 95 | STATIC bool |
| 96 | coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) | 96 | coord_continue_oninverse(const dfsarg_solve_coord_t arg[NON_NULL]) |
| 97 | { | 97 | { |
| 98 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; | 98 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; |
| 99 | uint64_t coord; | 99 | uint64_t coord; |
| @@ -147,12 +147,11 @@ coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | STATIC int64_t | 149 | STATIC int64_t |
| 150 | solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | 150 | solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL]) |
| 151 | { | 151 | { |
| 152 | bool lastbackup; | 152 | bool lastbackup; |
| 153 | uint8_t m, l, nnbackup, nibackup, nmoves; | 153 | uint8_t m, l, nnbackup, nibackup, nmoves; |
| 154 | uint32_t mm; | 154 | uint64_t mm, coord; |
| 155 | uint64_t coord; | ||
| 156 | int64_t n, ret; | 155 | int64_t n, ret; |
| 157 | cube_t backup_cube, backup_inverse; | 156 | cube_t backup_cube, backup_inverse; |
| 158 | 157 | ||
| @@ -190,7 +189,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 190 | arg->lastisnormal = true; | 189 | arg->lastisnormal = true; |
| 191 | 190 | ||
| 192 | for (m = 0; m < NMOVES; m++) { | 191 | for (m = 0; m < NMOVES; m++) { |
| 193 | if (!(mm & (UINT32_C(1) << (uint32_t)m))) | 192 | if (!(mm & (UINT64_C(1) << (uint64_t)m))) |
| 194 | continue; | 193 | continue; |
| 195 | 194 | ||
| 196 | arg->solution_moves->moves[l] = m; | 195 | arg->solution_moves->moves[l] = m; |
| @@ -221,7 +220,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 221 | arg->lastisnormal = false; | 220 | arg->lastisnormal = false; |
| 222 | 221 | ||
| 223 | for (m = 0; m < NMOVES; m++) { | 222 | for (m = 0; m < NMOVES; m++) { |
| 224 | if (!(mm & (UINT32_C(1) << (uint32_t)m))) | 223 | if (!(mm & (UINT64_C(1) << (uint64_t)m))) |
| 225 | continue; | 224 | continue; |
| 226 | 225 | ||
| 227 | arg->solution_moves->premoves[l] = m; | 226 | arg->solution_moves->premoves[l] = m; |
| @@ -258,7 +257,7 @@ solve_coord_dispatch( | |||
| 258 | const unsigned char *data, | 257 | const unsigned char *data, |
| 259 | unsigned solutions_size, | 258 | unsigned solutions_size, |
| 260 | char *sols, | 259 | char *sols, |
| 261 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 260 | long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], |
| 262 | int (*poll_status)(void *), | 261 | int (*poll_status)(void *), |
| 263 | void *poll_status_data | 262 | void *poll_status_data |
| 264 | ) | 263 | ) |
| @@ -280,15 +279,16 @@ solve_coord_dispatch( | |||
| 280 | return NISSY_ERROR_INVALID_SOLVER; | 279 | return NISSY_ERROR_INVALID_SOLVER; |
| 281 | } | 280 | } |
| 282 | 281 | ||
| 283 | return solve_coord(oc, coord, trans, nissflag, minmoves, maxmoves, | 282 | return solve_coord(oc, coord, trans, (uint8_t)nissflag, |
| 284 | maxsolutions, optimal, threads, data_size, data, | 283 | (uint8_t)minmoves, (uint8_t)maxmoves, (uint8_t)maxsolutions, |
| 284 | (uint8_t)optimal, (uint8_t)threads, data_size, data, | ||
| 285 | solutions_size, sols, poll_status, poll_status_data); | 285 | solutions_size, sols, poll_status, poll_status_data); |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | STATIC int64_t | 288 | STATIC int64_t |
| 289 | solve_coord( | 289 | solve_coord( |
| 290 | oriented_cube_t oc, | 290 | oriented_cube_t oc, |
| 291 | coord_t coord [static 1], | 291 | coord_t coord [NON_NULL], |
| 292 | uint8_t trans, | 292 | uint8_t trans, |
| 293 | uint8_t nissflag, | 293 | uint8_t nissflag, |
| 294 | uint8_t minmoves, | 294 | uint8_t minmoves, |
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index b75fab8..81db9d4 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -27,8 +27,8 @@ typedef struct { | |||
| 27 | uint64_t moves_mask_gendata; | 27 | uint64_t moves_mask_gendata; |
| 28 | uint64_t moves_mask_solve; | 28 | uint64_t moves_mask_solve; |
| 29 | uint64_t trans_mask; | 29 | uint64_t trans_mask; |
| 30 | bool (*is_admissible)(const solution_moves_t[static 1]); | 30 | bool (*is_admissible)(const solution_moves_t[NON_NULL]); |
| 31 | bool (*solution_prune)(const solution_moves_t[static 1]); | 31 | bool (*solution_prune)(const solution_moves_t[NON_NULL]); |
| 32 | bool (*is_solvable)(cube_t); | 32 | bool (*is_solvable)(cube_t); |
| 33 | /* if is_solved is null, coord == 0 is used */ | 33 | /* if is_solved is null, coord == 0 is used */ |
| 34 | bool (*is_solved)(uint64_t, const unsigned char *); | 34 | bool (*is_solved)(uint64_t, const unsigned char *); |
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index c8a9338..0062587 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h | |||
| @@ -2,7 +2,7 @@ STATIC coord_t *parse_coord(size_t, const char *); | |||
| 2 | STATIC multicoord_t *parse_multicoord(size_t, const char *); | 2 | STATIC multicoord_t *parse_multicoord(size_t, const char *); |
| 3 | STATIC void parse_coord_and_trans( | 3 | STATIC void parse_coord_and_trans( |
| 4 | const char *, coord_t **, multicoord_t **, uint8_t *); | 4 | const char *, coord_t **, multicoord_t **, uint8_t *); |
| 5 | STATIC long long dataid_coord(const char *, char [static NISSY_SIZE_DATAID]); | 5 | STATIC long long dataid_coord(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 6 | 6 | ||
| 7 | STATIC coord_t * | 7 | STATIC coord_t * |
| 8 | parse_coord(size_t n, const char *coord) | 8 | parse_coord(size_t n, const char *coord) |
| @@ -60,7 +60,7 @@ parse_coord_and_trans( | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | STATIC long long | 62 | STATIC long long |
| 63 | dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID]) | 63 | dataid_coord(const char *ca, char dataid[SIZE(NISSY_SIZE_DATAID)]) |
| 64 | { | 64 | { |
| 65 | coord_t *c; | 65 | coord_t *c; |
| 66 | multicoord_t *mc; | 66 | multicoord_t *mc; |
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h index 3184a28..810247f 100644 --- a/src/solvers/dispatch.h +++ b/src/solvers/dispatch.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | typedef struct { | 1 | typedef struct { |
| 2 | const char *solvername; | 2 | const char *solvername; |
| 3 | const char *prefix; | 3 | const char *prefix; |
| 4 | long long (*dataid)(const char *, char [static NISSY_SIZE_DATAID]); | 4 | long long (*dataid)(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 5 | long long (*gendata)( | 5 | long long (*gendata)( |
| 6 | const char *, unsigned long long, unsigned char *); | 6 | const char *, unsigned long long, unsigned char *); |
| 7 | long long (*checkdata)( | 7 | long long (*checkdata)( |
| @@ -9,7 +9,7 @@ typedef struct { | |||
| 9 | long long (*solve)(oriented_cube_t, const char *, unsigned, unsigned, | 9 | long long (*solve)(oriented_cube_t, const char *, unsigned, unsigned, |
| 10 | unsigned, unsigned, unsigned, unsigned, unsigned long long, | 10 | unsigned, unsigned, unsigned, unsigned, unsigned long long, |
| 11 | const unsigned char *, unsigned, char *, | 11 | const unsigned char *, unsigned, char *, |
| 12 | long long [static NISSY_SIZE_SOLVE_STATS], | 12 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], |
| 13 | int (*)(void *), void *); | 13 | int (*)(void *), void *); |
| 14 | } solver_dispatch_t; | 14 | } solver_dispatch_t; |
| 15 | 15 | ||
diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index 78b9b5e..a996e3db 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h | |||
| @@ -12,9 +12,9 @@ typedef struct { | |||
| 12 | 12 | ||
| 13 | STATIC wrapthread_return_t 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 [SIZE(INFO_DISTRIBUTION_LEN)], const tableinfo_t [NON_NULL]); |
| 16 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 16 | STATIC bool distribution_equal(const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], |
| 17 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 17 | const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], uint8_t); |
| 18 | 18 | ||
| 19 | STATIC wrapthread_return_t | 19 | STATIC wrapthread_return_t |
| 20 | getdistribution_runthread(void *arg) | 20 | getdistribution_runthread(void *arg) |
| @@ -39,8 +39,8 @@ getdistribution_runthread(void *arg) | |||
| 39 | STATIC void | 39 | STATIC void |
| 40 | getdistribution( | 40 | getdistribution( |
| 41 | const unsigned char *table, | 41 | const unsigned char *table, |
| 42 | uint64_t distr[static INFO_DISTRIBUTION_LEN], | 42 | uint64_t distr[SIZE(INFO_DISTRIBUTION_LEN)], |
| 43 | const tableinfo_t info[static 1] | 43 | const tableinfo_t info[NON_NULL] |
| 44 | ) { | 44 | ) { |
| 45 | getdistribution_data_t targ[THREADS]; | 45 | getdistribution_data_t targ[THREADS]; |
| 46 | wrapthread_define_var_thread_t(thread[THREADS]); | 46 | wrapthread_define_var_thread_t(thread[THREADS]); |
| @@ -80,8 +80,8 @@ getdistribution( | |||
| 80 | 80 | ||
| 81 | STATIC bool | 81 | STATIC bool |
| 82 | distribution_equal( | 82 | distribution_equal( |
| 83 | const uint64_t expected[static INFO_DISTRIBUTION_LEN], | 83 | const uint64_t expected[SIZE(INFO_DISTRIBUTION_LEN)], |
| 84 | const uint64_t actual[static INFO_DISTRIBUTION_LEN], | 84 | const uint64_t actual[SIZE(INFO_DISTRIBUTION_LEN)], |
| 85 | uint8_t maxvalue | 85 | uint8_t maxvalue |
| 86 | ) | 86 | ) |
| 87 | { | 87 | { |
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h index a7f0087..695efc3 100644 --- a/src/solvers/h48/coordinate.h +++ b/src/solvers/h48/coordinate.h | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | STATIC_INLINE uint64_t coord_h48( | 1 | STATIC_INLINE uint64_t coord_h48( |
| 2 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint8_t); | 2 | 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); | 3 | STATIC_INLINE uint64_t coord_h48_edges(cube_t, uint64_t, uint8_t, uint8_t); |
| 4 | STATIC_INLINE cube_t invcoord_h48( | 4 | STATIC_INLINE cube_t invcoord_h48( |
| 5 | uint64_t, const cube_t [static COCSEP_CLASSES], uint8_t); | 5 | uint64_t, const cube_t [SIZE(COCSEP_CLASSES)], uint8_t); |
| 6 | 6 | ||
| 7 | STATIC_INLINE uint64_t | 7 | STATIC_INLINE uint64_t |
| 8 | coord_h48( | 8 | coord_h48( |
| 9 | cube_t c, | 9 | cube_t c, |
| 10 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], | 10 | const uint32_t cocsepdata[SIZE(COCSEP_TABLESIZE)], |
| 11 | uint8_t h | 11 | uint8_t h |
| 12 | ) | 12 | ) |
| 13 | { | 13 | { |
| @@ -47,7 +47,7 @@ returned cube is a transformed cube of one that gives the correct value. | |||
| 47 | STATIC_INLINE cube_t | 47 | STATIC_INLINE cube_t |
| 48 | invcoord_h48( | 48 | invcoord_h48( |
| 49 | uint64_t i, | 49 | uint64_t i, |
| 50 | const cube_t crep[static COCSEP_CLASSES], | 50 | const cube_t crep[SIZE(COCSEP_CLASSES)], |
| 51 | uint8_t h | 51 | uint8_t h |
| 52 | ) | 52 | ) |
| 53 | { | 53 | { |
diff --git a/src/solvers/h48/distribution_h48.h b/src/solvers/h48/distribution_h48.h index 80c946e..2cb50aa 100644 --- a/src/solvers/h48/distribution_h48.h +++ b/src/solvers/h48/distribution_h48.h | |||
| @@ -6,7 +6,7 @@ to have some duplication than to make these functions needlessly generic. | |||
| 6 | 6 | ||
| 7 | STATIC wrapthread_return_t 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 [SIZE(INFO_DISTRIBUTION_LEN)], const tableinfo_t [NON_NULL]); |
| 10 | 10 | ||
| 11 | STATIC wrapthread_return_t | 11 | STATIC wrapthread_return_t |
| 12 | getdistribution_h48_runthread(void *arg) | 12 | getdistribution_h48_runthread(void *arg) |
| @@ -39,8 +39,8 @@ getdistribution_h48_runthread(void *arg) | |||
| 39 | STATIC void | 39 | STATIC void |
| 40 | getdistribution_h48( | 40 | getdistribution_h48( |
| 41 | const unsigned char *table, | 41 | const unsigned char *table, |
| 42 | uint64_t distr[static INFO_DISTRIBUTION_LEN], | 42 | uint64_t distr[SIZE(INFO_DISTRIBUTION_LEN)], |
| 43 | const tableinfo_t info[static 1] | 43 | const tableinfo_t info[NON_NULL] |
| 44 | ) { | 44 | ) { |
| 45 | getdistribution_data_t targ[THREADS]; | 45 | getdistribution_data_t targ[THREADS]; |
| 46 | wrapthread_define_var_thread_t(thread[THREADS]); | 46 | wrapthread_define_var_thread_t(thread[THREADS]); |
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index db7ac95..f83207b 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); | 1 | STATIC size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); |
| 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [static 1]); | 2 | STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t [NON_NULL]); |
| 3 | 3 | ||
| 4 | STATIC_INLINE bool gendata_cocsep_get_visited( | 4 | STATIC_INLINE bool gendata_cocsep_get_visited( |
| 5 | const uint8_t [static COCSEP_VISITEDSIZE], uint64_t); | 5 | const uint8_t [SIZE(COCSEP_VISITEDSIZE)], uint64_t); |
| 6 | STATIC_INLINE void gendata_cocsep_set_visited( | 6 | STATIC_INLINE void gendata_cocsep_set_visited( |
| 7 | uint8_t [static COCSEP_VISITEDSIZE], uint64_t); | 7 | uint8_t [SIZE(COCSEP_VISITEDSIZE)], uint64_t); |
| 8 | 8 | ||
| 9 | STATIC_INLINE int8_t get_h48_cdata( | 9 | STATIC_INLINE int8_t get_h48_cdata( |
| 10 | cube_t, const uint32_t [static COCSEP_TABLESIZE], uint32_t *); | 10 | cube_t, const uint32_t [SIZE(COCSEP_TABLESIZE)], uint32_t *); |
| 11 | 11 | ||
| 12 | STATIC size_t | 12 | STATIC size_t |
| 13 | gendata_cocsep( | 13 | gendata_cocsep( |
| @@ -79,11 +79,10 @@ gendata_cocsep_return_size: | |||
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | STATIC uint32_t | 81 | STATIC uint32_t |
| 82 | gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) | 82 | gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL]) |
| 83 | { | 83 | { |
| 84 | uint8_t m; | 84 | uint8_t m, t; |
| 85 | uint32_t cc, class, ttrep, depth, olddepth, tinv; | 85 | uint32_t cc, class, ttrep, depth, olddepth, tinv; |
| 86 | uint64_t t; | ||
| 87 | uint64_t i, j; | 86 | uint64_t i, j; |
| 88 | cube_t d; | 87 | cube_t d; |
| 89 | cocsep_dfs_arg_t nextarg; | 88 | cocsep_dfs_arg_t nextarg; |
| @@ -105,7 +104,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) | |||
| 105 | d = transform_corners(arg->cube, t); | 104 | d = transform_corners(arg->cube, t); |
| 106 | j = coord_cocsep(d); | 105 | j = coord_cocsep(d); |
| 107 | if (i == j && arg->selfsim != NULL) | 106 | if (i == j && arg->selfsim != NULL) |
| 108 | arg->selfsim[*arg->n] |= UINT64_C(1) << t; | 107 | arg->selfsim[*arg->n] |= UINT64_C(1) << (uint64_t)t; |
| 109 | if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF)) | 108 | if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF)) |
| 110 | continue; | 109 | continue; |
| 111 | gendata_cocsep_set_visited(arg->visited, j); | 110 | gendata_cocsep_set_visited(arg->visited, j); |
| @@ -135,7 +134,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[static 1]) | |||
| 135 | 134 | ||
| 136 | STATIC_INLINE bool | 135 | STATIC_INLINE bool |
| 137 | gendata_cocsep_get_visited( | 136 | gendata_cocsep_get_visited( |
| 138 | const uint8_t a[static COCSEP_VISITEDSIZE], | 137 | const uint8_t a[SIZE(COCSEP_VISITEDSIZE)], |
| 139 | uint64_t i | 138 | uint64_t i |
| 140 | ) | 139 | ) |
| 141 | { | 140 | { |
| @@ -144,7 +143,7 @@ gendata_cocsep_get_visited( | |||
| 144 | 143 | ||
| 145 | STATIC_INLINE void | 144 | STATIC_INLINE void |
| 146 | gendata_cocsep_set_visited( | 145 | gendata_cocsep_set_visited( |
| 147 | uint8_t a[static COCSEP_VISITEDSIZE], | 146 | uint8_t a[SIZE(COCSEP_VISITEDSIZE)], |
| 148 | uint64_t i | 147 | uint64_t i |
| 149 | ) | 148 | ) |
| 150 | { | 149 | { |
| @@ -154,7 +153,7 @@ gendata_cocsep_set_visited( | |||
| 154 | STATIC_INLINE int8_t | 153 | STATIC_INLINE int8_t |
| 155 | get_h48_cdata( | 154 | get_h48_cdata( |
| 156 | cube_t cube, | 155 | cube_t cube, |
| 157 | const uint32_t cocsepdata[static COCSEP_TABLESIZE], | 156 | const uint32_t cocsepdata[SIZE(COCSEP_TABLESIZE)], |
| 158 | uint32_t *cdata | 157 | uint32_t *cdata |
| 159 | ) | 158 | ) |
| 160 | { | 159 | { |
diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index e9a2794..81bbd43 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h | |||
| @@ -1,25 +1,25 @@ | |||
| 1 | STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [static ESEP_MAX]); | 1 | STATIC uint64_t coord_eoesep_sym(cube_t, const uint32_t [SIZE(ESEP_MAX)]); |
| 2 | STATIC size_t gendata_esep_classes( | 2 | STATIC size_t gendata_esep_classes( |
| 3 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 3 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); |
| 4 | STATIC size_t gendata_eoesep(unsigned char *, uint8_t); | 4 | STATIC size_t gendata_eoesep(unsigned char *, uint8_t); |
| 5 | STATIC uint32_t gendata_eoesep_bfs(uint8_t, uint8_t [static EOESEP_BUF], | 5 | STATIC uint32_t gendata_eoesep_bfs(uint8_t, uint8_t [SIZE(EOESEP_BUF)], |
| 6 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 6 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); |
| 7 | STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [static EOESEP_BUF], | 7 | STATIC uint32_t gendata_eoesep_fromnew(uint8_t, uint8_t [SIZE(EOESEP_BUF)], |
| 8 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 8 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); |
| 9 | STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [static EOESEP_BUF], | 9 | STATIC uint32_t gendata_eoesep_fromdone(uint8_t, uint8_t [SIZE(EOESEP_BUF)], |
| 10 | uint32_t [static ESEP_MAX], uint16_t [static ESEP_CLASSES]); | 10 | uint32_t [SIZE(ESEP_MAX)], uint16_t [SIZE(ESEP_CLASSES)]); |
| 11 | STATIC uint32_t gendata_eoesep_marksim(uint64_t, uint8_t, | 11 | STATIC uint32_t gendata_eoesep_marksim(uint64_t, uint8_t, |
| 12 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); | 12 | uint8_t [SIZE(EOESEP_BUF)], uint32_t [SIZE(ESEP_MAX)]); |
| 13 | STATIC bool gendata_eoesep_next(cube_t, uint8_t, | 13 | STATIC bool gendata_eoesep_next(cube_t, uint8_t, |
| 14 | uint8_t [static EOESEP_BUF], uint32_t [static ESEP_MAX]); | 14 | uint8_t [SIZE(EOESEP_BUF)], uint32_t [SIZE(ESEP_MAX)]); |
| 15 | STATIC uint8_t get_eoesep_pval( | 15 | STATIC uint8_t get_eoesep_pval( |
| 16 | const uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t); | 16 | const uint8_t [SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t); |
| 17 | STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); | 17 | STATIC uint8_t get_eoesep_pval_cube(const unsigned char *, cube_t); |
| 18 | STATIC void set_eoesep_pval( | 18 | STATIC void set_eoesep_pval( |
| 19 | uint8_t [static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], uint64_t, uint8_t); | 19 | uint8_t [SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], uint64_t, uint8_t); |
| 20 | 20 | ||
| 21 | STATIC uint64_t | 21 | STATIC uint64_t |
| 22 | coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) | 22 | coord_eoesep_sym(cube_t c, const uint32_t esep_classes[SIZE(ESEP_MAX)]) |
| 23 | { | 23 | { |
| 24 | uint8_t ttrep; | 24 | uint8_t ttrep; |
| 25 | uint32_t edata, class; | 25 | uint32_t edata, class; |
| @@ -36,8 +36,8 @@ coord_eoesep_sym(cube_t c, const uint32_t esep_classes[static ESEP_MAX]) | |||
| 36 | 36 | ||
| 37 | STATIC size_t | 37 | STATIC size_t |
| 38 | gendata_esep_classes( | 38 | gendata_esep_classes( |
| 39 | uint32_t esep_classes[static ESEP_MAX], | 39 | uint32_t esep_classes[SIZE(ESEP_MAX)], |
| 40 | uint16_t rep[static ESEP_CLASSES] | 40 | uint16_t rep[SIZE(ESEP_CLASSES)] |
| 41 | ) | 41 | ) |
| 42 | { | 42 | { |
| 43 | bool visited[ESEP_MAX]; | 43 | bool visited[ESEP_MAX]; |
| @@ -59,7 +59,7 @@ gendata_esep_classes( | |||
| 59 | esep_classes[j] = cl | ti; | 59 | esep_classes[j] = cl | ti; |
| 60 | visited[j] = true; | 60 | visited[j] = true; |
| 61 | } | 61 | } |
| 62 | rep[class] = i; | 62 | rep[class] = (uint16_t)i; |
| 63 | class++; | 63 | class++; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| @@ -121,8 +121,8 @@ STATIC uint32_t | |||
| 121 | gendata_eoesep_bfs( | 121 | gendata_eoesep_bfs( |
| 122 | uint8_t d, | 122 | uint8_t d, |
| 123 | uint8_t buf8[EOESEP_BUF], | 123 | uint8_t buf8[EOESEP_BUF], |
| 124 | uint32_t esep_classes[static ESEP_MAX], | 124 | uint32_t esep_classes[SIZE(ESEP_MAX)], |
| 125 | uint16_t rep[static ESEP_CLASSES] | 125 | uint16_t rep[SIZE(ESEP_CLASSES)] |
| 126 | ) | 126 | ) |
| 127 | { | 127 | { |
| 128 | if (d < 9) | 128 | if (d < 9) |
| @@ -135,12 +135,13 @@ STATIC uint32_t | |||
| 135 | gendata_eoesep_fromdone( | 135 | gendata_eoesep_fromdone( |
| 136 | uint8_t d, | 136 | uint8_t d, |
| 137 | uint8_t buf8[EOESEP_BUF], | 137 | uint8_t buf8[EOESEP_BUF], |
| 138 | uint32_t esep_classes[static ESEP_MAX], | 138 | uint32_t esep_classes[SIZE(ESEP_MAX)], |
| 139 | uint16_t rep[static ESEP_CLASSES] | 139 | uint16_t rep[SIZE(ESEP_CLASSES)] |
| 140 | ) | 140 | ) |
| 141 | { | 141 | { |
| 142 | uint8_t pval; | 142 | uint8_t pval; |
| 143 | uint64_t i, esep, eo, coord, done; | 143 | uint32_t done; |
| 144 | uint64_t i, esep, eo, coord; | ||
| 144 | 145 | ||
| 145 | done = 0; | 146 | done = 0; |
| 146 | for (i = 0; i < ESEP_CLASSES; i++) { | 147 | for (i = 0; i < ESEP_CLASSES; i++) { |
| @@ -164,12 +165,13 @@ STATIC uint32_t | |||
| 164 | gendata_eoesep_fromnew( | 165 | gendata_eoesep_fromnew( |
| 165 | uint8_t d, | 166 | uint8_t d, |
| 166 | uint8_t buf8[EOESEP_BUF], | 167 | uint8_t buf8[EOESEP_BUF], |
| 167 | uint32_t esep_classes[static ESEP_MAX], | 168 | uint32_t esep_classes[SIZE(ESEP_MAX)], |
| 168 | uint16_t rep[static ESEP_CLASSES] | 169 | uint16_t rep[SIZE(ESEP_CLASSES)] |
| 169 | ) | 170 | ) |
| 170 | { | 171 | { |
| 171 | uint8_t pval; | 172 | uint8_t pval; |
| 172 | uint64_t i, esep, eo, coord, done; | 173 | uint32_t done; |
| 174 | uint64_t i, esep, eo, coord; | ||
| 173 | cube_t c; | 175 | cube_t c; |
| 174 | 176 | ||
| 175 | done = 0; | 177 | done = 0; |
| @@ -196,8 +198,8 @@ STATIC uint32_t | |||
| 196 | gendata_eoesep_marksim( | 198 | gendata_eoesep_marksim( |
| 197 | uint64_t i, | 199 | uint64_t i, |
| 198 | uint8_t d, | 200 | uint8_t d, |
| 199 | uint8_t buf8[static EOESEP_BUF], | 201 | uint8_t buf8[SIZE(EOESEP_BUF)], |
| 200 | uint32_t esep_classes[static ESEP_MAX] | 202 | uint32_t esep_classes[SIZE(ESEP_MAX)] |
| 201 | ) | 203 | ) |
| 202 | { | 204 | { |
| 203 | uint8_t t, m, pval; | 205 | uint8_t t, m, pval; |
| @@ -227,8 +229,8 @@ STATIC bool | |||
| 227 | gendata_eoesep_next( | 229 | gendata_eoesep_next( |
| 228 | cube_t c, | 230 | cube_t c, |
| 229 | uint8_t d, | 231 | uint8_t d, |
| 230 | uint8_t buf8[static EOESEP_BUF], | 232 | uint8_t buf8[SIZE(EOESEP_BUF)], |
| 231 | uint32_t esep_classes[static ESEP_MAX] | 233 | uint32_t esep_classes[SIZE(ESEP_MAX)] |
| 232 | ) | 234 | ) |
| 233 | { | 235 | { |
| 234 | uint8_t m, t, pval; | 236 | uint8_t m, t, pval; |
| @@ -251,7 +253,7 @@ gendata_eoesep_next( | |||
| 251 | 253 | ||
| 252 | STATIC uint8_t | 254 | STATIC uint8_t |
| 253 | get_eoesep_pval( | 255 | get_eoesep_pval( |
| 254 | const uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | 256 | const uint8_t table[SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], |
| 255 | uint64_t i | 257 | uint64_t i |
| 256 | ) | 258 | ) |
| 257 | { | 259 | { |
| @@ -270,7 +272,7 @@ get_eoesep_pval_cube(const unsigned char *data, cube_t c) | |||
| 270 | 272 | ||
| 271 | STATIC void | 273 | STATIC void |
| 272 | set_eoesep_pval( | 274 | set_eoesep_pval( |
| 273 | uint8_t table[static DIV_ROUND_UP(EOESEP_TABLESIZE, 2)], | 275 | uint8_t table[SIZE(DIV_ROUND_UP(EOESEP_TABLESIZE, 2))], |
| 274 | uint64_t i, | 276 | uint64_t i, |
| 275 | uint8_t val | 277 | uint8_t val |
| 276 | ) | 278 | ) |
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index b37bcfb..53b1fad 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | STATIC long long gendata_h48_dispatch( | 1 | STATIC long long gendata_h48_dispatch( |
| 2 | const char *, unsigned long long, unsigned char *); | 2 | const char *, unsigned long long, unsigned char *); |
| 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); | 3 | STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); |
| 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); | 4 | STATIC int64_t gendata_h48(gendata_h48_arg_t [NON_NULL]); |
| 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); | 5 | STATIC void gendata_h48_maintable(gendata_h48_arg_t [NON_NULL]); |
| 6 | STATIC wrapthread_return_t 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 [NON_NULL]); |
| 9 | STATIC_INLINE bool gendata_h48_dfs_stop( | 9 | STATIC_INLINE bool gendata_h48_dfs_stop( |
| 10 | cube_t, int8_t, h48_dfs_arg_t [static 1]); | 10 | cube_t, int8_t, h48_dfs_arg_t [NON_NULL]); |
| 11 | STATIC void gendata_h48_dfs(h48_dfs_arg_t [static 1]); | 11 | STATIC void gendata_h48_dfs(h48_dfs_arg_t [NON_NULL]); |
| 12 | STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [static 1]); | 12 | STATIC tableinfo_t makeinfo_h48(gendata_h48_arg_t [NON_NULL]); |
| 13 | 13 | ||
| 14 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); | 14 | STATIC const uint32_t *get_cocsepdata_constptr(const unsigned char *); |
| 15 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); | 15 | STATIC const unsigned char *get_h48data_constptr(const unsigned char *); |
| @@ -19,7 +19,7 @@ STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t); | |||
| 19 | STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); | 19 | STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); |
| 20 | STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); | 20 | STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); |
| 21 | STATIC_INLINE uint8_t get_h48_pval_and_min( | 21 | STATIC_INLINE uint8_t get_h48_pval_and_min( |
| 22 | const unsigned char *, uint64_t, uint8_t [static 1]); | 22 | const unsigned char *, uint64_t, uint8_t [NON_NULL]); |
| 23 | 23 | ||
| 24 | STATIC long long | 24 | STATIC long long |
| 25 | gendata_h48_dispatch( | 25 | gendata_h48_dispatch( |
| @@ -43,7 +43,7 @@ gendata_h48_dispatch( | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | STATIC uint64_t | 45 | STATIC uint64_t |
| 46 | gendata_h48short(gendata_h48short_arg_t arg[static 1]) | 46 | gendata_h48short(gendata_h48short_arg_t arg[NON_NULL]) |
| 47 | { | 47 | { |
| 48 | uint8_t i, m; | 48 | uint8_t i, m; |
| 49 | uint64_t coord; | 49 | uint64_t coord; |
| @@ -77,7 +77,7 @@ gendata_h48short(gendata_h48short_arg_t arg[static 1]) | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | STATIC int64_t | 79 | STATIC int64_t |
| 80 | gendata_h48(gendata_h48_arg_t arg[static 1]) | 80 | gendata_h48(gendata_h48_arg_t arg[NON_NULL]) |
| 81 | { | 81 | { |
| 82 | uint64_t size, cocsepsize, h48size, eoesepsize; | 82 | uint64_t size, cocsepsize, h48size, eoesepsize; |
| 83 | long long r; | 83 | long long r; |
| @@ -149,7 +149,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | STATIC void | 151 | STATIC void |
| 152 | gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) | 152 | gendata_h48_maintable(gendata_h48_arg_t arg[NON_NULL]) |
| 153 | { | 153 | { |
| 154 | /* | 154 | /* |
| 155 | * A good base value for the h48 tables have few positions with value | 155 | * A good base value for the h48 tables have few positions with value |
| @@ -264,7 +264,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) | |||
| 264 | velocity = count; | 264 | velocity = count; |
| 265 | 265 | ||
| 266 | /* We plan to log 10 times */ | 266 | /* We plan to log 10 times */ |
| 267 | sleeptime = (100*(nshort-velocity)) / velocity; | 267 | sleeptime = (int)((100*(nshort-velocity)) / velocity); |
| 268 | 268 | ||
| 269 | done = count; | 269 | done = count; |
| 270 | while (nshort - done > (velocity * sleeptime) / 1000) { | 270 | while (nshort - done > (velocity * sleeptime) / 1000) { |
| @@ -320,7 +320,7 @@ gendata_h48_runthread(void *arg) | |||
| 320 | mutex = H48_LINE(coord) % CHUNKS; | 320 | mutex = H48_LINE(coord) % CHUNKS; |
| 321 | wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); | 321 | wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); |
| 322 | set_h48_pval(dfsarg->table, coordext, 0); | 322 | set_h48_pval(dfsarg->table, coordext, 0); |
| 323 | set_h48_pvalmin(dfsarg->table, coordmin, kv.val); | 323 | set_h48_pvalmin(dfsarg->table, coordmin, (uint8_t)kv.val); |
| 324 | wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); | 324 | wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); |
| 325 | } else { | 325 | } else { |
| 326 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); | 326 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); |
| @@ -332,7 +332,7 @@ gendata_h48_runthread(void *arg) | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | STATIC void | 334 | STATIC void |
| 335 | gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) | 335 | gendata_h48_dfs(h48_dfs_arg_t arg[NON_NULL]) |
| 336 | { | 336 | { |
| 337 | int8_t d; | 337 | int8_t d; |
| 338 | uint8_t m[4]; | 338 | uint8_t m[4]; |
| @@ -411,7 +411,7 @@ gendata_h48_dfs(h48_dfs_arg_t arg[static 1]) | |||
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | STATIC_INLINE void | 413 | STATIC_INLINE void |
| 414 | gendata_h48_mark(gendata_h48_mark_t arg[static 1]) | 414 | gendata_h48_mark(gendata_h48_mark_t arg[NON_NULL]) |
| 415 | { | 415 | { |
| 416 | uint8_t oldval, newval, v; | 416 | uint8_t oldval, newval, v; |
| 417 | uint64_t coord, coordext, coordmin; | 417 | uint64_t coord, coordext, coordmin; |
| @@ -435,7 +435,7 @@ gendata_h48_mark(gendata_h48_mark_t arg[static 1]) | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | STATIC_INLINE bool | 437 | STATIC_INLINE bool |
| 438 | gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) | 438 | gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[NON_NULL]) |
| 439 | { | 439 | { |
| 440 | uint64_t val; | 440 | uint64_t val; |
| 441 | uint64_t coord, coordext; | 441 | uint64_t coord, coordext; |
| @@ -463,7 +463,7 @@ gendata_h48_dfs_stop(cube_t cube, int8_t d, h48_dfs_arg_t arg[static 1]) | |||
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | STATIC tableinfo_t | 465 | STATIC tableinfo_t |
| 466 | makeinfo_h48(gendata_h48_arg_t arg[static 1]) | 466 | makeinfo_h48(gendata_h48_arg_t arg[NON_NULL]) |
| 467 | { | 467 | { |
| 468 | tableinfo_t info; | 468 | tableinfo_t info; |
| 469 | 469 | ||
| @@ -533,7 +533,7 @@ STATIC_INLINE uint8_t | |||
| 533 | get_h48_pval_and_min( | 533 | get_h48_pval_and_min( |
| 534 | const unsigned char *table, | 534 | const unsigned char *table, |
| 535 | uint64_t coord_noext, | 535 | uint64_t coord_noext, |
| 536 | uint8_t pval_min[static 1] | 536 | uint8_t pval_min[NON_NULL] |
| 537 | ) | 537 | ) |
| 538 | { | 538 | { |
| 539 | uint64_t iext, imin; | 539 | uint64_t iext, imin; |
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index b603ee3..c9cfb06 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | STATIC void h48map_create(h48map_t [static 1], uint64_t, uint64_t); | 1 | STATIC void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 2 | STATIC void h48map_clear(h48map_t [static 1]); | 2 | STATIC void h48map_clear(h48map_t [NON_NULL]); |
| 3 | STATIC void h48map_destroy(h48map_t [static 1]); | 3 | STATIC void h48map_destroy(h48map_t [NON_NULL]); |
| 4 | STATIC uint64_t h48map_lookup(h48map_t [static 1], uint64_t); | 4 | STATIC uint64_t h48map_lookup(h48map_t [NON_NULL], uint64_t); |
| 5 | STATIC void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); | 5 | STATIC void h48map_insertmin(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 6 | STATIC uint64_t h48map_value(h48map_t [static 1], uint64_t); | 6 | STATIC uint64_t h48map_value(h48map_t [NON_NULL], uint64_t); |
| 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); | 7 | STATIC kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]); |
| 8 | 8 | ||
| 9 | STATIC void | 9 | STATIC void |
| 10 | h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) | 10 | h48map_create(h48map_t map[NON_NULL], uint64_t capacity, uint64_t randomizer) |
| 11 | { | 11 | { |
| 12 | map->capacity = capacity; | 12 | map->capacity = capacity; |
| 13 | map->randomizer = randomizer; | 13 | map->randomizer = randomizer; |
| @@ -17,20 +17,20 @@ h48map_create(h48map_t map[static 1], uint64_t capacity, uint64_t randomizer) | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | STATIC void | 19 | STATIC void |
| 20 | h48map_clear(h48map_t map[static 1]) | 20 | h48map_clear(h48map_t map[NON_NULL]) |
| 21 | { | 21 | { |
| 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); | 22 | memset(map->table, 0xFF, map->capacity * sizeof(uint64_t)); |
| 23 | map->n = 0; | 23 | map->n = 0; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | STATIC void | 26 | STATIC void |
| 27 | h48map_destroy(h48map_t map[static 1]) | 27 | h48map_destroy(h48map_t map[NON_NULL]) |
| 28 | { | 28 | { |
| 29 | free(map->table); | 29 | free(map->table); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | STATIC_INLINE uint64_t | 32 | STATIC_INLINE uint64_t |
| 33 | h48map_lookup(h48map_t map[static 1], uint64_t x) | 33 | h48map_lookup(h48map_t map[NON_NULL], uint64_t x) |
| 34 | { | 34 | { |
| 35 | uint64_t hash, i; | 35 | uint64_t hash, i; |
| 36 | 36 | ||
| @@ -44,7 +44,7 @@ h48map_lookup(h48map_t map[static 1], uint64_t x) | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | STATIC_INLINE void | 46 | STATIC_INLINE void |
| 47 | h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) | 47 | h48map_insertmin(h48map_t map[NON_NULL], uint64_t key, uint64_t val) |
| 48 | { | 48 | { |
| 49 | uint64_t i, oldval, min; | 49 | uint64_t i, oldval, min; |
| 50 | 50 | ||
| @@ -57,13 +57,13 @@ h48map_insertmin(h48map_t map[static 1], uint64_t key, uint64_t val) | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | STATIC_INLINE uint64_t | 59 | STATIC_INLINE uint64_t |
| 60 | h48map_value(h48map_t map[static 1], uint64_t key) | 60 | h48map_value(h48map_t map[NON_NULL], uint64_t key) |
| 61 | { | 61 | { |
| 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; | 62 | return map->table[h48map_lookup(map, key)] >> MAP_KEYSHIFT; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | STATIC kvpair_t | 65 | STATIC kvpair_t |
| 66 | h48map_nextkvpair(h48map_t map[static 1], uint64_t p[static 1]) | 66 | h48map_nextkvpair(h48map_t map[NON_NULL], uint64_t p[NON_NULL]) |
| 67 | { | 67 | { |
| 68 | kvpair_t kv; | 68 | kvpair_t kv; |
| 69 | uint64_t pair; | 69 | uint64_t pair; |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 4fd0aea..ebc5208 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -64,27 +64,27 @@ typedef struct { | |||
| 64 | STATIC long long solve_h48_dispatch(oriented_cube_t, const char *, unsigned, | 64 | STATIC long long solve_h48_dispatch(oriented_cube_t, const char *, unsigned, |
| 65 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, | 65 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, |
| 66 | const unsigned char *, unsigned, char *, | 66 | const unsigned char *, unsigned, char *, |
| 67 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 67 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); |
| 68 | STATIC_INLINE void h48_prune_pipeline(dfsarg_solve_h48_t [static 1], | 68 | STATIC_INLINE void h48_prune_pipeline(dfsarg_solve_h48_t [NON_NULL], |
| 69 | h48_prune_t [static NMOVES], uint8_t, bool); | 69 | h48_prune_t [SIZE(NMOVES)], uint8_t, bool); |
| 70 | STATIC_INLINE uint8_t h48_prune_lookup( | 70 | STATIC_INLINE uint8_t h48_prune_lookup( |
| 71 | uint64_t, cube_t, dfsarg_solve_h48_t [static 1]); | 71 | uint64_t, cube_t, dfsarg_solve_h48_t [NON_NULL]); |
| 72 | STATIC_INLINE uint8_t h48_prune_lookup_nocoord( | 72 | STATIC_INLINE uint8_t h48_prune_lookup_nocoord( |
| 73 | cube_t, dfsarg_solve_h48_t [static 1]); | 73 | cube_t, dfsarg_solve_h48_t [NON_NULL]); |
| 74 | STATIC_INLINE void h48_prune_restore_normal(const h48_prune_t [static 1], | 74 | STATIC_INLINE void h48_prune_restore_normal(const h48_prune_t [NON_NULL], |
| 75 | dfsarg_solve_h48_t [static 1], uint8_t); | 75 | dfsarg_solve_h48_t [NON_NULL], uint8_t); |
| 76 | STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [static 1], | 76 | STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [NON_NULL], |
| 77 | dfsarg_solve_h48_t [static 1], uint8_t); | 77 | dfsarg_solve_h48_t [NON_NULL], uint8_t); |
| 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 [NON_NULL], dfsarg_solve_h48_maketasks_t [NON_NULL], |
| 80 | solve_h48_task_t [static H48_STARTING_CUBES], int [static 1]); | 80 | solve_h48_task_t [SIZE(H48_STARTING_CUBES)], int [NON_NULL]); |
| 81 | STATIC wrapthread_return_t 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 [NON_NULL]); |
| 83 | STATIC void solve_h48_log_solutions(solution_list_t [static 1], size_t); | 83 | STATIC void solve_h48_log_solutions(solution_list_t [NON_NULL], size_t); |
| 84 | STATIC int solve_h48_compare_tasks(const void *, const void *); | 84 | STATIC int solve_h48_compare_tasks(const void *, const void *); |
| 85 | STATIC int64_t solve_h48(oriented_cube_t, uint8_t, uint8_t, uint64_t, uint8_t, | 85 | STATIC int64_t solve_h48(oriented_cube_t, uint8_t, uint8_t, uint64_t, uint8_t, |
| 86 | uint8_t, uint64_t, const unsigned char *, size_t, char *, | 86 | uint8_t, uint64_t, const unsigned char *, size_t, char *, |
| 87 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 87 | long long [SIZE(NISSY_SIZE_SOLVE_STATS)], int (*)(void *), void *); |
| 88 | 88 | ||
| 89 | STATIC long long solve_h48_dispatch( | 89 | STATIC long long solve_h48_dispatch( |
| 90 | oriented_cube_t oc, | 90 | oriented_cube_t oc, |
| @@ -99,7 +99,7 @@ STATIC long long solve_h48_dispatch( | |||
| 99 | const unsigned char *data, | 99 | const unsigned char *data, |
| 100 | unsigned sols_size, | 100 | unsigned sols_size, |
| 101 | char *sols, | 101 | char *sols, |
| 102 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 102 | long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], |
| 103 | int (*poll_status)(void *), | 103 | int (*poll_status)(void *), |
| 104 | void *poll_status_data | 104 | void *poll_status_data |
| 105 | ) | 105 | ) |
| @@ -111,7 +111,8 @@ STATIC long long solve_h48_dispatch( | |||
| 111 | if (err != NISSY_OK) | 111 | if (err != NISSY_OK) |
| 112 | return err; | 112 | return err; |
| 113 | 113 | ||
| 114 | return solve_h48(oc, minmoves, maxmoves, maxsols, optimal, threads, | 114 | return solve_h48(oc, (uint8_t)minmoves, (uint8_t)maxmoves, |
| 115 | (uint8_t)maxsols, (uint8_t)optimal, (uint8_t)threads, | ||
| 115 | data_size, data, sols_size, sols, stats, | 116 | data_size, data, sols_size, sols, stats, |
| 116 | poll_status, poll_status_data); | 117 | poll_status, poll_status_data); |
| 117 | } | 118 | } |
| @@ -120,7 +121,7 @@ STATIC_INLINE uint8_t | |||
| 120 | h48_prune_lookup( | 121 | h48_prune_lookup( |
| 121 | uint64_t coord, | 122 | uint64_t coord, |
| 122 | cube_t cube, | 123 | cube_t cube, |
| 123 | dfsarg_solve_h48_t arg[static 1] | 124 | dfsarg_solve_h48_t arg[NON_NULL] |
| 124 | ) | 125 | ) |
| 125 | { | 126 | { |
| 126 | uint8_t p, pmin, pe; | 127 | uint8_t p, pmin, pe; |
| @@ -139,7 +140,7 @@ h48_prune_lookup( | |||
| 139 | STATIC_INLINE uint8_t | 140 | STATIC_INLINE uint8_t |
| 140 | h48_prune_lookup_nocoord( | 141 | h48_prune_lookup_nocoord( |
| 141 | cube_t cube, | 142 | cube_t cube, |
| 142 | dfsarg_solve_h48_t arg[static 1] | 143 | dfsarg_solve_h48_t arg[NON_NULL] |
| 143 | ) | 144 | ) |
| 144 | { | 145 | { |
| 145 | uint32_t cdata; | 146 | uint32_t cdata; |
| @@ -152,8 +153,8 @@ h48_prune_lookup_nocoord( | |||
| 152 | 153 | ||
| 153 | STATIC_INLINE void | 154 | STATIC_INLINE void |
| 154 | h48_prune_pipeline( | 155 | h48_prune_pipeline( |
| 155 | dfsarg_solve_h48_t arg[static 1], | 156 | dfsarg_solve_h48_t arg[NON_NULL], |
| 156 | h48_prune_t prune[static NMOVES], | 157 | h48_prune_t prune[SIZE(NMOVES)], |
| 157 | uint8_t target, | 158 | uint8_t target, |
| 158 | bool normal | 159 | bool normal |
| 159 | ) | 160 | ) |
| @@ -252,8 +253,8 @@ h48_prune_pipeline( | |||
| 252 | 253 | ||
| 253 | STATIC_INLINE void | 254 | STATIC_INLINE void |
| 254 | h48_prune_restore_normal( | 255 | h48_prune_restore_normal( |
| 255 | const h48_prune_t prune[static 1], | 256 | const h48_prune_t prune[NON_NULL], |
| 256 | dfsarg_solve_h48_t arg[static 1], | 257 | dfsarg_solve_h48_t arg[NON_NULL], |
| 257 | uint8_t target | 258 | uint8_t target |
| 258 | ) | 259 | ) |
| 259 | { | 260 | { |
| @@ -276,8 +277,8 @@ h48_prune_restore_normal( | |||
| 276 | 277 | ||
| 277 | STATIC_INLINE void | 278 | STATIC_INLINE void |
| 278 | h48_prune_restore_inverse( | 279 | h48_prune_restore_inverse( |
| 279 | const h48_prune_t prune[static 1], | 280 | const h48_prune_t prune[NON_NULL], |
| 280 | dfsarg_solve_h48_t arg[static 1], | 281 | dfsarg_solve_h48_t arg[NON_NULL], |
| 281 | uint8_t target | 282 | uint8_t target |
| 282 | ) | 283 | ) |
| 283 | { | 284 | { |
| @@ -299,7 +300,7 @@ h48_prune_restore_inverse( | |||
| 299 | } | 300 | } |
| 300 | 301 | ||
| 301 | STATIC int64_t | 302 | STATIC int64_t |
| 302 | solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | 303 | solve_h48_dfs(dfsarg_solve_h48_t arg[NON_NULL]) |
| 303 | { | 304 | { |
| 304 | int64_t ret, n; | 305 | int64_t ret, n; |
| 305 | uint8_t m, nm, nn, ni, target; | 306 | uint8_t m, nm, nn, ni, target; |
| @@ -343,7 +344,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 343 | backup_inverse = arg->inverse; | 344 | backup_inverse = arg->inverse; |
| 344 | 345 | ||
| 345 | ret = 0; | 346 | ret = 0; |
| 346 | if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { | 347 | if (popcount_u64(mm_normal) <= popcount_u64(mm_inverse)) { |
| 347 | h48_prune_pipeline(arg, prune, target, true); | 348 | h48_prune_pipeline(arg, prune, target, true); |
| 348 | arg->solution_moves->nmoves++; | 349 | arg->solution_moves->nmoves++; |
| 349 | for (m = 0; m < NMOVES; m++) { | 350 | for (m = 0; m < NMOVES; m++) { |
| @@ -450,14 +451,13 @@ solve_h48_runthread_end: | |||
| 450 | 451 | ||
| 451 | STATIC int64_t | 452 | STATIC int64_t |
| 452 | solve_h48_maketasks( | 453 | solve_h48_maketasks( |
| 453 | dfsarg_solve_h48_t solve_arg[static 1], | 454 | dfsarg_solve_h48_t solve_arg[NON_NULL], |
| 454 | dfsarg_solve_h48_maketasks_t mtarg[static 1], | 455 | dfsarg_solve_h48_maketasks_t mtarg[NON_NULL], |
| 455 | solve_h48_task_t tasks[static H48_STARTING_CUBES], | 456 | solve_h48_task_t tasks[SIZE(H48_STARTING_CUBES)], |
| 456 | int ntasks[static 1] | 457 | int ntasks[NON_NULL] |
| 457 | ) | 458 | ) |
| 458 | { | 459 | { |
| 459 | int r; | 460 | int64_t r, appret; |
| 460 | int64_t appret; | ||
| 461 | uint8_t m, t; | 461 | uint8_t m, t; |
| 462 | uint64_t mm; | 462 | uint64_t mm; |
| 463 | cube_t backup_cube; | 463 | cube_t backup_cube; |
| @@ -524,7 +524,7 @@ solve_h48_maketasks( | |||
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | STATIC void | 526 | STATIC void |
| 527 | solve_h48_log_solutions(solution_list_t s[static 1], size_t e) | 527 | solve_h48_log_solutions(solution_list_t s[NON_NULL], size_t e) |
| 528 | { | 528 | { |
| 529 | size_t i; | 529 | size_t i; |
| 530 | char b; | 530 | char b; |
| @@ -561,7 +561,7 @@ solve_h48( | |||
| 561 | const unsigned char *data, | 561 | const unsigned char *data, |
| 562 | size_t solutions_size, | 562 | size_t solutions_size, |
| 563 | char *solutions, | 563 | char *solutions, |
| 564 | long long stats[static NISSY_SIZE_SOLVE_STATS], | 564 | long long stats[SIZE(NISSY_SIZE_SOLVE_STATS)], |
| 565 | int (*poll_status)(void *), | 565 | int (*poll_status)(void *), |
| 566 | void *poll_status_data | 566 | void *poll_status_data |
| 567 | ) | 567 | ) |
diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h index 27fb2e5..6d91108 100644 --- a/src/solvers/h48/utils.h +++ b/src/solvers/h48/utils.h | |||
| @@ -4,11 +4,11 @@ | |||
| 4 | #define H48_HMAX UINT8_C(7) | 4 | #define H48_HMAX UINT8_C(7) |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | long long parse_h48h(const char *, uint8_t [static 1]); | 7 | long long parse_h48h(const char *, uint8_t [NON_NULL]); |
| 8 | STATIC long long dataid_h48(const char *, char [static NISSY_SIZE_DATAID]); | 8 | STATIC long long dataid_h48(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 9 | 9 | ||
| 10 | long long | 10 | long long |
| 11 | parse_h48h(const char *buf, uint8_t h[static 1]) | 11 | parse_h48h(const char *buf, uint8_t h[NON_NULL]) |
| 12 | { | 12 | { |
| 13 | char format_error_msg[100]; | 13 | char format_error_msg[100]; |
| 14 | sprintf(format_error_msg, "[H48] Error parsing H48 solver: must be in " | 14 | sprintf(format_error_msg, "[H48] Error parsing H48 solver: must be in " |
| @@ -29,7 +29,7 @@ parse_h48h(const char *buf, uint8_t h[static 1]) | |||
| 29 | goto parse_h48h_error; | 29 | goto parse_h48h_error; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | *h = atoi(buf); | 32 | *h = (uint8_t)atoi(buf); |
| 33 | if (*h > H48_HMAX) { | 33 | if (*h > H48_HMAX) { |
| 34 | LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " | 34 | LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " |
| 35 | "at most %" PRIu8 ")\n", *h, H48_HMAX); | 35 | "at most %" PRIu8 ")\n", *h, H48_HMAX); |
| @@ -51,7 +51,7 @@ parse_h48h_error: | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | STATIC long long | 53 | STATIC long long |
| 54 | dataid_h48(const char *str, char buf[static NISSY_SIZE_DATAID]) | 54 | dataid_h48(const char *str, char buf[SIZE(NISSY_SIZE_DATAID)]) |
| 55 | { | 55 | { |
| 56 | uint8_t h; | 56 | uint8_t h; |
| 57 | long long err; | 57 | long long err; |
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 8817348..b7a848b 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -1,39 +1,39 @@ | |||
| 1 | STATIC void solution_moves_reset(solution_moves_t [static 1]); | 1 | STATIC void solution_moves_reset(solution_moves_t [NON_NULL]); |
| 2 | STATIC void solution_moves_transform(solution_moves_t [static 1], size_t, | 2 | STATIC void solution_moves_transform(solution_moves_t [NON_NULL], size_t, |
| 3 | uint8_t); | 3 | uint8_t); |
| 4 | STATIC void solution_moves_reorient(solution_moves_t [static 1], uint8_t); | 4 | STATIC void solution_moves_reorient(solution_moves_t [NON_NULL], uint8_t); |
| 5 | STATIC bool solution_list_init(solution_list_t [static 1], size_t, char *); | 5 | STATIC bool solution_list_init(solution_list_t [NON_NULL], size_t, char *); |
| 6 | STATIC bool solution_moves_equal( | 6 | STATIC bool solution_moves_equal( |
| 7 | const solution_moves_t [static 1], const solution_moves_t [static 1]); | 7 | const solution_moves_t [NON_NULL], const solution_moves_t [NON_NULL]); |
| 8 | STATIC bool last_solution_is_duplicate(const solution_list_t [static 1]); | 8 | STATIC bool last_solution_is_duplicate(const solution_list_t [NON_NULL]); |
| 9 | STATIC bool appendchar(solution_list_t [static 1], char); | 9 | STATIC bool appendchar(solution_list_t [NON_NULL], char); |
| 10 | STATIC bool appendnormal( | 10 | STATIC bool appendnormal( |
| 11 | const solution_moves_t [static 1], solution_list_t [static 1]); | 11 | const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); |
| 12 | STATIC bool appendinverse( | 12 | STATIC bool appendinverse( |
| 13 | const solution_moves_t [static 1], solution_list_t [static 1]); | 13 | const solution_moves_t [NON_NULL], solution_list_t [NON_NULL]); |
| 14 | STATIC void appendsolution_dfs(const solution_moves_t [static 1], size_t, | 14 | STATIC void appendsolution_dfs(const solution_moves_t [NON_NULL], size_t, |
| 15 | const uint64_t *, size_t, uint8_t *, const solution_settings_t [static 1], | 15 | const uint64_t *, size_t, uint8_t *, const solution_settings_t [NON_NULL], |
| 16 | solution_list_t [static 1], | 16 | solution_list_t [NON_NULL], |
| 17 | solution_moves_t [static NTRANS * SOLUTION_MAXLEN], int64_t [static 1]); | 17 | solution_moves_t [SIZE(NTRANS * SOLUTION_MAXLEN)], int64_t [NON_NULL]); |
| 18 | STATIC int64_t appendsolution(const solution_moves_t [static 1], | 18 | STATIC int64_t appendsolution(const solution_moves_t [NON_NULL], |
| 19 | size_t, const uint64_t *, const solution_settings_t [static 1], | 19 | size_t, const uint64_t *, const solution_settings_t [NON_NULL], |
| 20 | solution_list_t [static 1]); | 20 | solution_list_t [NON_NULL]); |
| 21 | STATIC bool solutions_done(const solution_list_t [static 1], | 21 | STATIC bool solutions_done(const solution_list_t [NON_NULL], |
| 22 | const solution_settings_t [static 1], int8_t depth); | 22 | const solution_settings_t [NON_NULL], int8_t depth); |
| 23 | 23 | ||
| 24 | STATIC void | 24 | STATIC void |
| 25 | solution_moves_reset(solution_moves_t sol[static 1]) | 25 | solution_moves_reset(solution_moves_t sol[NON_NULL]) |
| 26 | { | 26 | { |
| 27 | sol->nmoves = 0; | 27 | sol->nmoves = 0; |
| 28 | sol->npremoves = 0; | 28 | sol->npremoves = 0; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | STATIC void | 31 | STATIC void |
| 32 | solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) | 32 | solution_moves_transform(solution_moves_t moves[NON_NULL], size_t z, uint8_t t) |
| 33 | { | 33 | { |
| 34 | uint8_t i; | 34 | uint8_t i; |
| 35 | 35 | ||
| 36 | for (i = z; i < moves->nmoves; i++) | 36 | for (i = (uint8_t)z; i < moves->nmoves; i++) |
| 37 | moves->moves[i] = transform_move(moves->moves[i], t); | 37 | moves->moves[i] = transform_move(moves->moves[i], t); |
| 38 | 38 | ||
| 39 | for (i = 0; i < moves->npremoves; i++) | 39 | for (i = 0; i < moves->npremoves; i++) |
| @@ -41,7 +41,7 @@ solution_moves_transform(solution_moves_t moves[static 1], size_t z, uint8_t t) | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | STATIC void | 43 | STATIC void |
| 44 | solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) | 44 | solution_moves_reorient(solution_moves_t moves[NON_NULL], uint8_t or) |
| 45 | { | 45 | { |
| 46 | uint8_t i; | 46 | uint8_t i; |
| 47 | 47 | ||
| @@ -55,7 +55,7 @@ solution_moves_reorient(solution_moves_t moves[static 1], uint8_t or) | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | STATIC bool | 57 | STATIC bool |
| 58 | solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) | 58 | solution_list_init(solution_list_t sols[NON_NULL], size_t n, char *buf) |
| 59 | { | 59 | { |
| 60 | if (n == 0) | 60 | if (n == 0) |
| 61 | return false; | 61 | return false; |
| @@ -72,8 +72,8 @@ solution_list_init(solution_list_t sols[static 1], size_t n, char *buf) | |||
| 72 | 72 | ||
| 73 | STATIC bool | 73 | STATIC bool |
| 74 | solution_moves_equal( | 74 | solution_moves_equal( |
| 75 | const solution_moves_t a[static 1], | 75 | const solution_moves_t a[NON_NULL], |
| 76 | const solution_moves_t b[static 1] | 76 | const solution_moves_t b[NON_NULL] |
| 77 | ) | 77 | ) |
| 78 | { | 78 | { |
| 79 | uint8_t i; | 79 | uint8_t i; |
| @@ -93,7 +93,7 @@ solution_moves_equal( | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | STATIC bool | 95 | STATIC bool |
| 96 | last_solution_is_duplicate(const solution_list_t l[static 1]) | 96 | last_solution_is_duplicate(const solution_list_t l[NON_NULL]) |
| 97 | { | 97 | { |
| 98 | size_t i, j; | 98 | size_t i, j; |
| 99 | 99 | ||
| @@ -119,7 +119,7 @@ last_solution_is_duplicate(const solution_list_t l[static 1]) | |||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | STATIC bool | 121 | STATIC bool |
| 122 | appendchar(solution_list_t solutions[static 1], char c) | 122 | appendchar(solution_list_t solutions[NON_NULL], char c) |
| 123 | { | 123 | { |
| 124 | if (solutions->size <= solutions->used) | 124 | if (solutions->size <= solutions->used) |
| 125 | return false; | 125 | return false; |
| @@ -131,8 +131,8 @@ appendchar(solution_list_t solutions[static 1], char c) | |||
| 131 | 131 | ||
| 132 | STATIC bool | 132 | STATIC bool |
| 133 | appendnormal( | 133 | appendnormal( |
| 134 | const solution_moves_t moves[static 1], | 134 | const solution_moves_t moves[NON_NULL], |
| 135 | solution_list_t list[static 1] | 135 | solution_list_t list[NON_NULL] |
| 136 | ) | 136 | ) |
| 137 | { | 137 | { |
| 138 | int64_t strl; | 138 | int64_t strl; |
| @@ -150,8 +150,8 @@ appendnormal( | |||
| 150 | 150 | ||
| 151 | STATIC bool | 151 | STATIC bool |
| 152 | appendinverse( | 152 | appendinverse( |
| 153 | const solution_moves_t moves[static 1], | 153 | const solution_moves_t moves[NON_NULL], |
| 154 | solution_list_t list[static 1] | 154 | solution_list_t list[NON_NULL] |
| 155 | ) | 155 | ) |
| 156 | { | 156 | { |
| 157 | int64_t strl; | 157 | int64_t strl; |
| @@ -172,15 +172,15 @@ appendinverse( | |||
| 172 | 172 | ||
| 173 | STATIC void | 173 | STATIC void |
| 174 | appendsolution_dfs( | 174 | appendsolution_dfs( |
| 175 | const solution_moves_t moves[static 1], | 175 | const solution_moves_t moves[NON_NULL], |
| 176 | size_t ntmask, | 176 | size_t ntmask, |
| 177 | const uint64_t *tmask, | 177 | const uint64_t *tmask, |
| 178 | size_t itm, | 178 | size_t itm, |
| 179 | uint8_t *tt, | 179 | uint8_t *tt, |
| 180 | const solution_settings_t settings[static 1], | 180 | const solution_settings_t settings[NON_NULL], |
| 181 | solution_list_t list[static 1], | 181 | solution_list_t list[NON_NULL], |
| 182 | solution_moves_t tsol[static NTRANS * SOLUTION_MAXLEN], | 182 | solution_moves_t tsol[SIZE(NTRANS * SOLUTION_MAXLEN)], |
| 183 | int64_t r[static 1] | 183 | int64_t r[NON_NULL] |
| 184 | ) | 184 | ) |
| 185 | { | 185 | { |
| 186 | /* | 186 | /* |
| @@ -276,11 +276,11 @@ appendsolution_dfs_error_buffer: | |||
| 276 | 276 | ||
| 277 | STATIC int64_t | 277 | STATIC int64_t |
| 278 | appendsolution( | 278 | appendsolution( |
| 279 | const solution_moves_t moves[static 1], | 279 | const solution_moves_t moves[NON_NULL], |
| 280 | size_t ntmask, | 280 | size_t ntmask, |
| 281 | const uint64_t *tmask, | 281 | const uint64_t *tmask, |
| 282 | const solution_settings_t settings[static 1], | 282 | const solution_settings_t settings[NON_NULL], |
| 283 | solution_list_t list[static 1] | 283 | solution_list_t list[NON_NULL] |
| 284 | ) | 284 | ) |
| 285 | { | 285 | { |
| 286 | int64_t r; | 286 | int64_t r; |
| @@ -329,8 +329,8 @@ appendsolution_error_solution_length: | |||
| 329 | 329 | ||
| 330 | STATIC bool | 330 | STATIC bool |
| 331 | solutions_done( | 331 | solutions_done( |
| 332 | const solution_list_t list[static 1], | 332 | const solution_list_t list[NON_NULL], |
| 333 | const solution_settings_t settings[static 1], | 333 | const solution_settings_t settings[NON_NULL], |
| 334 | int8_t depth | 334 | int8_t depth |
| 335 | ) | 335 | ) |
| 336 | { | 336 | { |
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index b7a1079..3db1d1e 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | STATIC uint64_t read_unaligned_u64( | 1 | STATIC uint64_t read_unaligned_u64( |
| 2 | const unsigned char [static sizeof(uint64_t)]); | 2 | const unsigned char [SIZE(sizeof(uint64_t))]); |
| 3 | STATIC void write_unaligned_u64( | 3 | STATIC void write_unaligned_u64( |
| 4 | unsigned char [static sizeof(uint64_t)], uint64_t); | 4 | unsigned char [SIZE(sizeof(uint64_t))], uint64_t); |
| 5 | STATIC int64_t readtableinfo( | 5 | STATIC int64_t readtableinfo( |
| 6 | size_t, const unsigned char *, tableinfo_t [static 1]); | 6 | size_t, const unsigned char *, tableinfo_t [NON_NULL]); |
| 7 | STATIC int64_t readtableinfo_n( | 7 | STATIC int64_t readtableinfo_n( |
| 8 | size_t, const unsigned char *, uint8_t, tableinfo_t [static 1]); | 8 | size_t, const unsigned char *, uint8_t, tableinfo_t [NON_NULL]); |
| 9 | STATIC int64_t writetableinfo( | 9 | STATIC int64_t writetableinfo( |
| 10 | const tableinfo_t [static 1], size_t, unsigned char *); | 10 | const tableinfo_t [NON_NULL], size_t, unsigned char *); |
| 11 | STATIC void append_name(tableinfo_t [static 1], const char *); | 11 | STATIC void append_name(tableinfo_t [NON_NULL], const char *); |
| 12 | 12 | ||
| 13 | STATIC uint64_t | 13 | STATIC uint64_t |
| 14 | read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) | 14 | read_unaligned_u64(const unsigned char buf[SIZE(sizeof(uint64_t))]) |
| 15 | { | 15 | { |
| 16 | uint64_t ret; | 16 | uint64_t ret; |
| 17 | 17 | ||
| @@ -21,7 +21,7 @@ read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | STATIC void | 23 | STATIC void |
| 24 | write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) | 24 | write_unaligned_u64(unsigned char buf[SIZE(sizeof(uint64_t))], uint64_t x) |
| 25 | { | 25 | { |
| 26 | memcpy(buf, &x, sizeof(uint64_t)); | 26 | memcpy(buf, &x, sizeof(uint64_t)); |
| 27 | } | 27 | } |
| @@ -30,7 +30,7 @@ STATIC int64_t | |||
| 30 | readtableinfo( | 30 | readtableinfo( |
| 31 | size_t buf_size, | 31 | size_t buf_size, |
| 32 | const unsigned char *buf, | 32 | const unsigned char *buf, |
| 33 | tableinfo_t info[static 1] | 33 | tableinfo_t info[NON_NULL] |
| 34 | ) | 34 | ) |
| 35 | { | 35 | { |
| 36 | size_t i; | 36 | size_t i; |
| @@ -75,7 +75,7 @@ readtableinfo_n( | |||
| 75 | size_t buf_size, | 75 | size_t buf_size, |
| 76 | const unsigned char *buf, | 76 | const unsigned char *buf, |
| 77 | uint8_t n, | 77 | uint8_t n, |
| 78 | tableinfo_t info[static 1] | 78 | tableinfo_t info[NON_NULL] |
| 79 | ) | 79 | ) |
| 80 | { | 80 | { |
| 81 | int64_t ret; | 81 | int64_t ret; |
| @@ -89,7 +89,7 @@ readtableinfo_n( | |||
| 89 | 89 | ||
| 90 | STATIC int64_t | 90 | STATIC int64_t |
| 91 | writetableinfo( | 91 | writetableinfo( |
| 92 | const tableinfo_t info[static 1], | 92 | const tableinfo_t info[NON_NULL], |
| 93 | size_t data_size, | 93 | size_t data_size, |
| 94 | unsigned char *buf | 94 | unsigned char *buf |
| 95 | ) | 95 | ) |
| @@ -138,9 +138,9 @@ writetableinfo( | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | STATIC void | 140 | STATIC void |
| 141 | append_name(tableinfo_t info[static 1], const char *str) | 141 | append_name(tableinfo_t info[NON_NULL], const char *str) |
| 142 | { | 142 | { |
| 143 | int i, j; | 143 | size_t i, j; |
| 144 | 144 | ||
| 145 | for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) | 145 | for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) |
| 146 | info->solver[j] = str[i]; | 146 | info->solver[j] = str[i]; |
diff --git a/src/utils/compilers.h b/src/utils/compilers.h index a7d6df5..1b175bb 100644 --- a/src/utils/compilers.h +++ b/src/utils/compilers.h | |||
| @@ -1,13 +1,24 @@ | |||
| 1 | #if defined(__GNUC__) | 1 | #if defined(__GNUC__) |
| 2 | 2 | ||
| 3 | #define unused __attribute__((unused)) | 3 | #define UNUSED __attribute__((unused)) |
| 4 | #define SIZE(x) static (x) | ||
| 5 | #define NON_NULL SIZE(1) | ||
| 4 | 6 | ||
| 5 | #elif defined(__clang__) | 7 | #elif defined(__clang__) |
| 6 | 8 | ||
| 7 | #define unused __attribute__((unused)) | 9 | #define UNUSED __attribute__((unused)) |
| 10 | #define SIZE(x) static (x) | ||
| 11 | #define NON_NULL SIZE(1) | ||
| 8 | 12 | ||
| 9 | #else | 13 | #else |
| 10 | 14 | ||
| 11 | #define unused | 15 | /* |
| 16 | For example MSVC, which is not fully C11 compliant (e.g. it does not support | ||
| 17 | a[static N] notation for array parameters). | ||
| 18 | */ | ||
| 19 | |||
| 20 | #define UNUSED | ||
| 21 | #define SIZE(x) | ||
| 22 | #define NON_NULL | ||
| 12 | 23 | ||
| 13 | #endif | 24 | #endif |
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h index d737ff2..08d42a3 100644 --- a/src/utils/dbg_log.h +++ b/src/utils/dbg_log.h | |||
| @@ -7,8 +7,7 @@ void write_wrapper(void (*)(const char *, void *), const char *, ...); | |||
| 7 | void | 7 | void |
| 8 | write_wrapper(void (*write)(const char *, void *), const char *str, ...) | 8 | write_wrapper(void (*write)(const char *, void *), const char *str, ...) |
| 9 | { | 9 | { |
| 10 | static const size_t len = 1000; | 10 | char message[1000]; |
| 11 | char message[len]; | ||
| 12 | va_list args; | 11 | va_list args; |
| 13 | 12 | ||
| 14 | va_start(args, str); | 13 | va_start(args, str); |
diff --git a/src/utils/math.h b/src/utils/math.h index f2176b6..0c56861 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -73,10 +73,10 @@ indextoperm(uint64_t p, size_t n, uint8_t *r) | |||
| 73 | 73 | ||
| 74 | /* Find k-th unused number */ | 74 | /* Find k-th unused number */ |
| 75 | for (j = 0, c = 0; c <= k; j++) | 75 | for (j = 0, c = 0; c <= k; j++) |
| 76 | c += 1 - ((used & (1<<j)) >> j); | 76 | c += UINT64_C(1) - ((used & (UINT64_C(1)<<j)) >> j); |
| 77 | 77 | ||
| 78 | r[i] = j-1; | 78 | r[i] = (uint8_t)(j-1); |
| 79 | used |= 1 << (j-1); | 79 | used |= UINT64_C(1) << (j-1); |
| 80 | p %= factorial[n-i-1]; | 80 | p %= factorial[n-i-1]; |
| 81 | } | 81 | } |
| 82 | 82 | ||
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index 4ac72a6..9578293 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h | |||
| @@ -61,8 +61,8 @@ | |||
| 61 | #define wrapthread_return_t int | 61 | #define wrapthread_return_t int |
| 62 | #define wrapthread_return_val 0 | 62 | #define wrapthread_return_val 0 |
| 63 | 63 | ||
| 64 | #define wrapthread_define_var_thread_t(x) unused char x | 64 | #define wrapthread_define_var_thread_t(x) UNUSED char x |
| 65 | #define wrapthread_define_var_mutex_t(x) unused char x | 65 | #define wrapthread_define_var_mutex_t(x) UNUSED char x |
| 66 | #define wrapthread_define_struct_thread_t(x) char x | 66 | #define wrapthread_define_struct_thread_t(x) char x |
| 67 | #define wrapthread_define_struct_mutex_t(x) char x | 67 | #define wrapthread_define_struct_mutex_t(x) char x |
| 68 | 68 | ||
diff --git a/test/001_pieces/pieces_tests.c b/test/001_pieces/pieces_tests.c index f46a143..7937fb1 100644 --- a/test/001_pieces/pieces_tests.c +++ b/test/001_pieces/pieces_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 3 | void pieces(cube_t *, uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | int i; | 6 | int i; |
diff --git a/test/010_math_permtoindex/permtoindex_tests.c b/test/010_math_permtoindex/permtoindex_tests.c index f246ef3..2a7ecf3 100644 --- a/test/010_math_permtoindex/permtoindex_tests.c +++ b/test/010_math_permtoindex/permtoindex_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | uint64_t permtoindex(size_t n, const uint8_t [n]); | 3 | uint64_t permtoindex(size_t n, const uint8_t *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| @@ -11,7 +11,7 @@ void run(void) { | |||
| 11 | n = atoll(str); | 11 | n = atoll(str); |
| 12 | for (i = 0; i < n; i++) { | 12 | for (i = 0; i < n; i++) { |
| 13 | fgets(str, STRLENMAX, stdin); | 13 | fgets(str, STRLENMAX, stdin); |
| 14 | a[i] = atoi(str); | 14 | a[i] = (uint8_t)atoi(str); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | p = permtoindex(n, a); | 17 | p = permtoindex(n, a); |
diff --git a/test/011_math_indextoperm/indextoperm_tests.c b/test/011_math_indextoperm/indextoperm_tests.c index e83cbad..1464d7b 100644 --- a/test/011_math_indextoperm/indextoperm_tests.c +++ b/test/011_math_indextoperm/indextoperm_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void indextoperm(uint64_t, size_t n, uint8_t [n]); | 3 | void indextoperm(uint64_t, size_t n, uint8_t *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/012_math_permsign/permsign_tests.c b/test/012_math_permsign/permsign_tests.c index 5b4daa3..f5a52d0 100644 --- a/test/012_math_permsign/permsign_tests.c +++ b/test/012_math_permsign/permsign_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int permsign(size_t n, const uint8_t [n]); | 3 | int permsign(size_t n, const uint8_t *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| @@ -13,7 +13,7 @@ void run(void) { | |||
| 13 | 13 | ||
| 14 | for (i = 0; i < n; i++) { | 14 | for (i = 0; i < n; i++) { |
| 15 | fgets(str, STRLENMAX, stdin); | 15 | fgets(str, STRLENMAX, stdin); |
| 16 | a[i] = atoi(str); | 16 | a[i] = (uint8_t)atoi(str); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | p = permsign(n, a); | 19 | p = permsign(n, a); |
diff --git a/test/013_math_digitstosumzero/digitstosumzero_tests.c b/test/013_math_digitstosumzero/digitstosumzero_tests.c index 5c93083..8df1848 100644 --- a/test/013_math_digitstosumzero/digitstosumzero_tests.c +++ b/test/013_math_digitstosumzero/digitstosumzero_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | uint64_t digitstosumzero(size_t n, uint8_t [n], uint8_t); | 3 | uint64_t digitstosumzero(size_t n, uint8_t *, uint8_t); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| @@ -11,10 +11,10 @@ void run(void) { | |||
| 11 | fgets(str, STRLENMAX, stdin); | 11 | fgets(str, STRLENMAX, stdin); |
| 12 | n = atoi(str); | 12 | n = atoi(str); |
| 13 | fgets(str, STRLENMAX, stdin); | 13 | fgets(str, STRLENMAX, stdin); |
| 14 | b = atoi(str); | 14 | b = (uint8_t)atoi(str); |
| 15 | for (i = 0; i < n; i++) { | 15 | for (i = 0; i < n; i++) { |
| 16 | fgets(str, STRLENMAX, stdin); | 16 | fgets(str, STRLENMAX, stdin); |
| 17 | a[i] = atoi(str); | 17 | a[i] = (uint8_t)atoi(str); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | p = digitstosumzero(n, a, b); | 20 | p = digitstosumzero(n, a, b); |
diff --git a/test/014_math_sumzerotodigits/sumzerotodigits.c b/test/014_math_sumzerotodigits/sumzerotodigits.c index e8d2814..256ca5a 100644 --- a/test/014_math_sumzerotodigits/sumzerotodigits.c +++ b/test/014_math_sumzerotodigits/sumzerotodigits.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void sumzerotodigits(uint64_t, size_t n, uint8_t, uint8_t [n]); | 3 | void sumzerotodigits(uint64_t, size_t n, uint8_t, uint8_t *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| @@ -8,9 +8,9 @@ void run(void) { | |||
| 8 | uint64_t d; | 8 | uint64_t d; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | n = atoi(str); | 11 | n = (uint8_t)atoi(str); |
| 12 | fgets(str, STRLENMAX, stdin); | 12 | fgets(str, STRLENMAX, stdin); |
| 13 | b = atoi(str); | 13 | b = (uint8_t)atoi(str); |
| 14 | fgets(str, STRLENMAX, stdin); | 14 | fgets(str, STRLENMAX, stdin); |
| 15 | d = atoll(str); | 15 | d = atoll(str); |
| 16 | 16 | ||
diff --git a/test/033_inverse_move/inverse_move_tests.c b/test/033_inverse_move/inverse_move_tests.c index 5453f83..86bf741 100644 --- a/test/033_inverse_move/inverse_move_tests.c +++ b/test/033_inverse_move/inverse_move_tests.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | extern char *movestr[]; | 3 | extern char *movestr[]; |
| 4 | 4 | ||
| 5 | int64_t readmoves(const char *, size_t n, size_t m, | 5 | int64_t readmoves(const char *, size_t n, size_t m, |
| 6 | size_t *, size_t *, uint8_t [n], uint8_t [m]); | 6 | size_t *, size_t *, uint8_t *, uint8_t *); |
| 7 | uint8_t inverse_move(uint8_t); | 7 | uint8_t inverse_move(uint8_t); |
| 8 | 8 | ||
| 9 | void run(void) { | 9 | void run(void) { |
diff --git a/test/061_inverse_trans/inverse_trans_tests.c b/test/061_inverse_trans/inverse_trans_tests.c index bad39fa..bb2a271 100644 --- a/test/061_inverse_trans/inverse_trans_tests.c +++ b/test/061_inverse_trans/inverse_trans_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]); | 3 | uint8_t readtrans(char [SIZE(NISSY_SIZE_TRANSFORMATION)]); |
| 4 | uint8_t inverse_trans(uint8_t); | 4 | uint8_t inverse_trans(uint8_t); |
| 5 | oriented_cube_t applymoves(oriented_cube_t, char *); | 5 | oriented_cube_t applymoves(oriented_cube_t, char *); |
| 6 | oriented_cube_t applytrans(oriented_cube_t, char *); | 6 | oriented_cube_t applytrans(oriented_cube_t, char *); |
diff --git a/test/062_transform_move/transform_move_tests.c b/test/062_transform_move/transform_move_tests.c index 218c6a1..a9beb60 100644 --- a/test/062_transform_move/transform_move_tests.c +++ b/test/062_transform_move/transform_move_tests.c | |||
| @@ -5,10 +5,10 @@ | |||
| 5 | cube_t applytrans(cube_t, const char *); | 5 | cube_t applytrans(cube_t, const char *); |
| 6 | uint8_t transform_move(uint8_t, uint8_t); | 6 | uint8_t transform_move(uint8_t, uint8_t); |
| 7 | int64_t readmoves(const char *, size_t n, size_t m, | 7 | int64_t readmoves(const char *, size_t n, size_t m, |
| 8 | size_t *, size_t *, uint8_t [n], uint8_t [m]); | 8 | size_t *, size_t *, uint8_t *, uint8_t *); |
| 9 | oriented_cube_t move_extended(oriented_cube_t, uint8_t); | 9 | oriented_cube_t move_extended(oriented_cube_t, uint8_t); |
| 10 | oriented_cube_t applymoves(oriented_cube_t, const char *); | 10 | oriented_cube_t applymoves(oriented_cube_t, const char *); |
| 11 | uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); | 11 | uint8_t readtrans(const char[SIZE(NISSY_SIZE_TRANSFORMATION)]); |
| 12 | 12 | ||
| 13 | void run(void) { | 13 | void run(void) { |
| 14 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; | 14 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; |
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index a0ad3fe..0ce22e0 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | uint64_t coord_eo(cube_t); | 3 | uint64_t coord_eo(cube_t); |
| 4 | void set_eo(cube_t *, uint64_t); | 4 | void set_eo(cube_t *, uint64_t); |
| 5 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 5 | void pieces(cube_t *, uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 6 | 6 | ||
| 7 | void run(void) { | 7 | void run(void) { |
| 8 | char str[STRLENMAX]; | 8 | char str[STRLENMAX]; |
diff --git a/test/076_copy_co/copy_co_tests.c b/test/076_copy_co/copy_co_tests.c index 3ca109b..4127022 100644 --- a/test/076_copy_co/copy_co_tests.c +++ b/test/076_copy_co/copy_co_tests.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | void copy_co(cube_t *, cube_t); | 3 | void copy_co(cube_t *, cube_t); |
| 4 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 4 | void pieces(cube_t *, uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 5 | 5 | ||
| 6 | void run(void) { | 6 | void run(void) { |
| 7 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
diff --git a/test/090_allowedmoves/allowedmoves_tests.c b/test/090_allowedmoves/allowedmoves_tests.c index aa6bda7..cff8303 100644 --- a/test/090_allowedmoves/allowedmoves_tests.c +++ b/test/090_allowedmoves/allowedmoves_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | bool allowedmoves(size_t n, const uint8_t [n]); | 3 | bool allowedmoves(size_t n, const uint8_t *); |
| 4 | 4 | ||
| 5 | static char *moves[] = { | 5 | static char *moves[] = { |
| 6 | "U", "U2", "U'", | 6 | "U", "U2", "U'", |
| @@ -13,8 +13,8 @@ static char *moves[] = { | |||
| 13 | 13 | ||
| 14 | void run(void) { | 14 | void run(void) { |
| 15 | char movestr[STRLENMAX]; | 15 | char movestr[STRLENMAX]; |
| 16 | uint8_t m[100]; | 16 | uint8_t j, m[100]; |
| 17 | int n, i, j; | 17 | int n, i; |
| 18 | 18 | ||
| 19 | fgets(movestr, STRLENMAX, stdin); | 19 | fgets(movestr, STRLENMAX, stdin); |
| 20 | n = atoi(movestr); | 20 | n = atoi(movestr); |
diff --git a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c index c5c1bb5..936dac3 100644 --- a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c +++ b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c | |||
| @@ -6,9 +6,9 @@ uint64_t coord_cocsep(cube_t); | |||
| 6 | size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); | 6 | size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); |
| 7 | 7 | ||
| 8 | void run(void) { | 8 | void run(void) { |
| 9 | uint8_t t; | 9 | uint8_t t, tt; |
| 10 | unsigned char buf[2000000]; | 10 | unsigned char buf[2000000]; |
| 11 | uint32_t *cocsepdata, tt; | 11 | uint32_t *cocsepdata; |
| 12 | uint64_t i, selfsim[COCSEP_CLASSES]; | 12 | uint64_t i, selfsim[COCSEP_CLASSES]; |
| 13 | uint64_t j, k, l; | 13 | uint64_t j, k, l; |
| 14 | cube_t rep[COCSEP_CLASSES], c, d; | 14 | cube_t rep[COCSEP_CLASSES], c, d; |
diff --git a/test/115_gendata_eoesep/gendata_eoesep_tests.c b/test/115_gendata_eoesep/gendata_eoesep_tests.c index 7ed9778..76de323 100644 --- a/test/115_gendata_eoesep/gendata_eoesep_tests.c +++ b/test/115_gendata_eoesep/gendata_eoesep_tests.c | |||
| @@ -25,7 +25,7 @@ The test does not generate the full table. For reference, these are the values: | |||
| 25 | 25 | ||
| 26 | unsigned char buf[FULLSIZE]; | 26 | unsigned char buf[FULLSIZE]; |
| 27 | 27 | ||
| 28 | size_t gendata_eoesep(unsigned char [static FULLSIZE], uint8_t); | 28 | size_t gendata_eoesep(unsigned char [SIZE(FULLSIZE)], uint8_t); |
| 29 | int64_t readtableinfo(size_t, const unsigned char *, tableinfo_t *); | 29 | int64_t readtableinfo(size_t, const unsigned char *, tableinfo_t *); |
| 30 | 30 | ||
| 31 | void run(void) { | 31 | void run(void) { |
diff --git a/test/121_h48map/h48map_tests.c b/test/121_h48map/h48map_tests.c index 927b157..e06c395 100644 --- a/test/121_h48map/h48map_tests.c +++ b/test/121_h48map/h48map_tests.c | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | #define MAXPOS 1000 | 3 | #define MAXPOS 1000 |
| 4 | 4 | ||
| 5 | void h48map_create(h48map_t [static 1], uint64_t, uint64_t); | 5 | void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 6 | void h48map_destroy(h48map_t [static 1]); | 6 | void h48map_destroy(h48map_t [NON_NULL]); |
| 7 | void h48map_insertmin(h48map_t [static 1], uint64_t, uint64_t); | 7 | void h48map_insertmin(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 8 | uint64_t h48map_value(h48map_t [static 1], uint64_t); | 8 | uint64_t h48map_value(h48map_t [NON_NULL], uint64_t); |
| 9 | kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); | 9 | kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]); |
| 10 | 10 | ||
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| 12 | 12 | ||
diff --git a/test/122_gendata_h48short/gendata_h48short_tests.c b/test/122_gendata_h48short/gendata_h48short_tests.c index 0de9408..0996f8c 100644 --- a/test/122_gendata_h48short/gendata_h48short_tests.c +++ b/test/122_gendata_h48short/gendata_h48short_tests.c | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | #define MAXPOS 200 | 3 | #define MAXPOS 200 |
| 4 | 4 | ||
| 5 | void h48map_create(h48map_t [static 1], uint64_t, uint64_t); | 5 | void h48map_create(h48map_t [NON_NULL], uint64_t, uint64_t); |
| 6 | void h48map_destroy(h48map_t [static 1]); | 6 | void h48map_destroy(h48map_t [NON_NULL]); |
| 7 | kvpair_t h48map_nextkvpair(h48map_t [static 1], uint64_t [static 1]); | 7 | kvpair_t h48map_nextkvpair(h48map_t [NON_NULL], uint64_t [NON_NULL]); |
| 8 | size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); | 8 | size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); |
| 9 | uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); | 9 | uint64_t gendata_h48short(gendata_h48short_arg_t [NON_NULL]); |
| 10 | 10 | ||
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| 12 | 12 | ||
| @@ -34,7 +34,7 @@ void run(void) { | |||
| 34 | 34 | ||
| 35 | capacity = readl(); | 35 | capacity = readl(); |
| 36 | randomizer = readl(); | 36 | randomizer = readl(); |
| 37 | arg.maxdepth = readl(); | 37 | arg.maxdepth = (uint8_t)readl(); |
| 38 | arg.crep = crep; | 38 | arg.crep = crep; |
| 39 | arg.selfsim = selfsim; | 39 | arg.selfsim = selfsim; |
| 40 | arg.map = ↦ | 40 | arg.map = ↦ |
diff --git a/test/131_coorddata_dr/coorddata_dr.c b/test/131_coorddata_dr/coorddata_dr.c index d8ac94a..d262fe3 100644 --- a/test/131_coorddata_dr/coorddata_dr.c +++ b/test/131_coorddata_dr/coorddata_dr.c | |||
| @@ -11,7 +11,7 @@ size_t coordinate_dr_gendata(unsigned char *); | |||
| 11 | 11 | ||
| 12 | void run(void) { | 12 | void run(void) { |
| 13 | bool found; | 13 | bool found; |
| 14 | uint64_t t; | 14 | uint8_t t; |
| 15 | char str[STRLENMAX]; | 15 | char str[STRLENMAX]; |
| 16 | unsigned char *data; | 16 | unsigned char *data; |
| 17 | size_t size; | 17 | size_t size; |
| @@ -33,8 +33,8 @@ void run(void) { | |||
| 33 | goto cleanup; | 33 | goto cleanup; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | for (t = 0, found = false; t < 48; t++) { | 36 | for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { |
| 37 | if (!((UINT64_C(1) << t) & TGROUP)) | 37 | if (!((UINT64_C(1) << (uint8_t)t) & TGROUP)) |
| 38 | continue; | 38 | continue; |
| 39 | 39 | ||
| 40 | coord2 = coordinate_dr_coord(transform(cube, t), data); | 40 | coord2 = coordinate_dr_coord(transform(cube, t), data); |
diff --git a/test/132_coorddata_dreo/coorddata_dreo.c b/test/132_coorddata_dreo/coorddata_dreo.c index 2b99b7f..50294ff 100644 --- a/test/132_coorddata_dreo/coorddata_dreo.c +++ b/test/132_coorddata_dreo/coorddata_dreo.c | |||
| @@ -11,7 +11,7 @@ size_t coordinate_dreo_gendata(unsigned char *); | |||
| 11 | 11 | ||
| 12 | void run(void) { | 12 | void run(void) { |
| 13 | bool found; | 13 | bool found; |
| 14 | uint64_t t; | 14 | uint8_t t; |
| 15 | char str[STRLENMAX]; | 15 | char str[STRLENMAX]; |
| 16 | unsigned char *data; | 16 | unsigned char *data; |
| 17 | size_t size; | 17 | size_t size; |
| @@ -33,8 +33,8 @@ void run(void) { | |||
| 33 | goto cleanup; | 33 | goto cleanup; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | for (t = 0, found = false; t < 48; t++) { | 36 | for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { |
| 37 | if (!((UINT64_C(1) << t) & TGROUP)) | 37 | if (!((UINT64_C(1) << (uint64_t)t) & TGROUP)) |
| 38 | continue; | 38 | continue; |
| 39 | 39 | ||
| 40 | coord2 = coordinate_dreo_coord(transform(cube, t), data); | 40 | coord2 = coordinate_dreo_coord(transform(cube, t), data); |
diff --git a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c index 11ae9f7..7d19361 100644 --- a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c +++ b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c | |||
| @@ -10,7 +10,7 @@ size_t coordinate_drfinnoe_gendata(unsigned char *); | |||
| 10 | 10 | ||
| 11 | void run(void) { | 11 | void run(void) { |
| 12 | bool found; | 12 | bool found; |
| 13 | uint64_t t; | 13 | uint8_t t; |
| 14 | char str[STRLENMAX]; | 14 | char str[STRLENMAX]; |
| 15 | unsigned char *data; | 15 | unsigned char *data; |
| 16 | size_t size; | 16 | size_t size; |
| @@ -32,8 +32,8 @@ void run(void) { | |||
| 32 | goto cleanup; | 32 | goto cleanup; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | for (t = 0, found = false; t < 48; t++) { | 35 | for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { |
| 36 | if (!((UINT64_C(1) << t) & TGROUP)) | 36 | if (!((UINT64_C(1) << (uint64_t)t) & TGROUP)) |
| 37 | continue; | 37 | continue; |
| 38 | 38 | ||
| 39 | coord2 = coordinate_drfinnoe_coord(transform(cube, t), data); | 39 | coord2 = coordinate_drfinnoe_coord(transform(cube, t), data); |
diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index f9620ab..3f4fb15 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c | |||
| @@ -16,12 +16,12 @@ See below for the output format. | |||
| 16 | 16 | ||
| 17 | uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); | 17 | uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); |
| 18 | int64_t readmoves(const char *, size_t n, size_t m, | 18 | int64_t readmoves(const char *, size_t n, size_t m, |
| 19 | size_t *, size_t *, uint8_t [n], uint8_t [m]); | 19 | size_t *, size_t *, uint8_t *, uint8_t *); |
| 20 | void solution_moves_reset(solution_moves_t [static 1]); | 20 | void solution_moves_reset(solution_moves_t [NON_NULL]); |
| 21 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); | 21 | bool solution_list_init(solution_list_t [NON_NULL], size_t n, char *); |
| 22 | int64_t appendsolution(const solution_moves_t [static 1], | 22 | int64_t appendsolution(const solution_moves_t [NON_NULL], |
| 23 | size_t, const uint64_t *, const solution_settings_t [static 1], | 23 | size_t, const uint64_t *, const solution_settings_t [NON_NULL], |
| 24 | solution_list_t [static 1]); | 24 | solution_list_t [NON_NULL]); |
| 25 | 25 | ||
| 26 | void run(void) { | 26 | void run(void) { |
| 27 | int i, j, nnt, ntrans; | 27 | int i, j, nnt, ntrans; |
| @@ -39,7 +39,7 @@ void run(void) { | |||
| 39 | .unniss = false, | 39 | .unniss = false, |
| 40 | .maxmoves = 20, | 40 | .maxmoves = 20, |
| 41 | .maxsolutions = 100, | 41 | .maxsolutions = 100, |
| 42 | .optimal = -1, | 42 | .optimal = 0, |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | fgets(str, STRLENMAX, stdin); | 45 | fgets(str, STRLENMAX, stdin); |
| @@ -48,8 +48,8 @@ void run(void) { | |||
| 48 | printf("Test error reading moves\n"); | 48 | printf("Test error reading moves\n"); |
| 49 | return; | 49 | return; |
| 50 | } | 50 | } |
| 51 | moves.nmoves = nm; | 51 | moves.nmoves = (uint8_t)nm; |
| 52 | moves.npremoves = np; | 52 | moves.npremoves = (uint8_t)np; |
| 53 | fgets(str, STRLENMAX, stdin); | 53 | fgets(str, STRLENMAX, stdin); |
| 54 | settings.unniss = (bool)atoi(str); | 54 | settings.unniss = (bool)atoi(str); |
| 55 | 55 | ||
| @@ -64,7 +64,7 @@ void run(void) { | |||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | fgets(str, STRLENMAX, stdin); | 66 | fgets(str, STRLENMAX, stdin); |
| 67 | settings.orientation = atoi(str); | 67 | settings.orientation = (uint8_t)atoi(str); |
| 68 | 68 | ||
| 69 | appendsolution(&moves, nnt, tmask, &settings, &list); | 69 | appendsolution(&moves, nnt, tmask, &settings, &list); |
| 70 | 70 | ||
diff --git a/test/test.h b/test/test.h index 60e340f..b8c5922 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | 9 | ||
| 10 | #include "../src/utils/compilers.h" | ||
| 10 | #include "../src/utils/wrapthread.h" | 11 | #include "../src/utils/wrapthread.h" |
| 11 | #include "../src/nissy.h" | 12 | #include "../src/nissy.h" |
| 12 | #include "../src/arch/arch.h" | 13 | #include "../src/arch/arch.h" |
| @@ -27,7 +28,7 @@ bool isconsistent(oriented_cube_t); | |||
| 27 | bool issolvable(oriented_cube_t); | 28 | bool issolvable(oriented_cube_t); |
| 28 | bool issolved(oriented_cube_t); | 29 | bool issolved(oriented_cube_t); |
| 29 | oriented_cube_t readcube(char *); | 30 | oriented_cube_t readcube(char *); |
| 30 | int64_t writecube(oriented_cube_t, size_t n, char [n]); | 31 | int64_t writecube(oriented_cube_t, size_t n, char *); |
| 31 | 32 | ||
| 32 | /* Test function to be implemented by all tests */ | 33 | /* Test function to be implemented by all tests */ |
| 33 | void run(void); | 34 | void run(void); |
diff --git a/tools/420_solvetest_h48_symmetric/solvetest.c b/tools/420_solvetest_h48_symmetric/solvetest.c index 245b7fe..45345eb 100644 --- a/tools/420_solvetest_h48_symmetric/solvetest.c +++ b/tools/420_solvetest_h48_symmetric/solvetest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #define SOLVER "h48h3k2" | 1 | #define SOLVER "h48h3" |
| 2 | #define NISSFLAG NISSY_NISSFLAG_NORMAL | 2 | #define NISSFLAG NISSY_NISSFLAG_NORMAL |
| 3 | #define MINMOVES 0 | 3 | #define MINMOVES 0 |
| 4 | #define MAXMOVES 20 | 4 | #define MAXMOVES 20 |
diff --git a/tools/solvetest.h b/tools/solvetest.h index 75f7aab..8c93d21 100644 --- a/tools/solvetest.h +++ b/tools/solvetest.h | |||
| @@ -13,7 +13,7 @@ bool check_one( | |||
| 13 | const char *aname, | 13 | const char *aname, |
| 14 | const char *bstr, | 14 | const char *bstr, |
| 15 | const char *bname, | 15 | const char *bname, |
| 16 | bool exp[static MAXSOLUTIONS] | 16 | bool *exp |
| 17 | ) { | 17 | ) { |
| 18 | size_t i, j, nn, lb; | 18 | size_t i, j, nn, lb; |
| 19 | char b[MAX_SOLUTION_LEN]; | 19 | char b[MAX_SOLUTION_LEN]; |
| @@ -130,7 +130,7 @@ int main(int argc, char **argv) { | |||
| 130 | printf("Using user-specified solver %s\n", solver); | 130 | printf("Using user-specified solver %s\n", solver); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | srand(time(NULL)); | 133 | srand((unsigned)time(NULL)); |
| 134 | nissy_setlogger(log_stderr, NULL); | 134 | nissy_setlogger(log_stderr, NULL); |
| 135 | 135 | ||
| 136 | size = nissy_solverinfo(solver, dataid); | 136 | size = nissy_solverinfo(solver, dataid); |
diff --git a/tools/tool.h b/tools/tool.h index 96e7f27..582e2ce 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -18,10 +18,9 @@ | |||
| 18 | static void log_stderr(const char *, void *); | 18 | static void log_stderr(const char *, void *); |
| 19 | static double timerun(void (*)(void)); | 19 | static double timerun(void (*)(void)); |
| 20 | static void writetable(const unsigned char *, int64_t, const char *); | 20 | static void writetable(const unsigned char *, int64_t, const char *); |
| 21 | static long long int generatetable(const char *, unsigned char **, | 21 | static long long int generatetable(const char *, unsigned char **, char *); |
| 22 | char [static NISSY_SIZE_DATAID]); | ||
| 23 | static int getdata(const char *, unsigned char **, const char *); | 22 | static int getdata(const char *, unsigned char **, const char *); |
| 24 | static void gendata_run(const char *, uint64_t[static 21]); | 23 | static void gendata_run(const char *, uint64_t *); |
| 25 | 24 | ||
| 26 | static void | 25 | static void |
| 27 | log_stderr(const char *str, void *unused) | 26 | log_stderr(const char *str, void *unused) |
| @@ -113,7 +112,7 @@ static long long int | |||
| 113 | generatetable( | 112 | generatetable( |
| 114 | const char *solver, | 113 | const char *solver, |
| 115 | unsigned char **buf, | 114 | unsigned char **buf, |
| 116 | char dataid[static NISSY_SIZE_DATAID] | 115 | char *dataid |
| 117 | ) | 116 | ) |
| 118 | { | 117 | { |
| 119 | long long int size, gensize; | 118 | long long int size, gensize; |
| @@ -183,7 +182,7 @@ getdata_error_nofree: | |||
| 183 | static void | 182 | static void |
| 184 | gendata_run( | 183 | gendata_run( |
| 185 | const char *solver, | 184 | const char *solver, |
| 186 | uint64_t expected[static 21] | 185 | uint64_t *expected |
| 187 | ) { | 186 | ) { |
| 188 | long long int size; | 187 | long long int size; |
| 189 | char filename[1024], dataid[NISSY_SIZE_DATAID]; | 188 | char filename[1024], dataid[NISSY_SIZE_DATAID]; |
