| 1 | /* |
| 2 | This Software is distributed with the following X11 License, |
| 3 | sometimes also known as MIT license. |
| 4 | |
| 5 | Copyright (c) 2010 Miguel A. Ballicora |
| 6 | |
| 7 | Permission is hereby granted, free of charge, to any person |
| 8 | obtaining a copy of this software and associated documentation |
| 9 | files (the "Software"), to deal in the Software without |
| 10 | restriction, including without limitation the rights to use, |
| 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | copies of the Software, and to permit persons to whom the |
| 13 | Software is furnished to do so, subject to the following |
| 14 | conditions: |
| 15 | |
| 16 | The above copyright notice and this permission notice shall be |
| 17 | included in all copies or substantial portions of the Software. |
| 18 | |
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 26 | OTHER DEALINGS IN THE SOFTWARE. |
| 27 | */ |
| 28 | |
| 29 | #if !defined(H_GTBPROBE) |
| 30 | #define H_GTBPROBEcxx . . $ `gtb-probe.h:30:9`! |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | |
| 38 | #define tb_MAXPATHLENcxx . . $ `gtb-probe.h:38:9`! 1024 |
| 39 | |
| 40 | /*----------------------------------*\ |
| 41 | | CONSTANTS |
| 42 | \*----------------------------------*/ |
| 43 | |
| 44 | enum TB_mask_valuescxx . . $ TB_mask_values# { tb_RESMASKcxx . . $ tb_RESMASK. = 3, tb_INFOMASKcxx . . $ tb_INFOMASK. = 7, tb_PLYSHIFTcxx . . $ tb_PLYSHIFT. = 3 }; |
| 45 | |
| 46 | enum TB_return_valuescxx . . $ TB_return_values# { |
| 47 | tb_DRAWcxx . . $ tb_DRAW. = 0, |
| 48 | tb_WMATEcxx . . $ tb_WMATE. = 1, |
| 49 | tb_BMATEcxx . . $ tb_BMATE. = 2, |
| 50 | tb_FORBIDcxx . . $ tb_FORBID. = 3, |
| 51 | tb_UNKNOWNcxx . . $ tb_UNKNOWN. = 7 |
| 52 | }; |
| 53 | |
| 54 | enum TB_piecescxx . . $ TB_pieces# { |
| 55 | tb_NOPIECEcxx . . $ tb_NOPIECE., tb_PAWNcxx . . $ tb_PAWN., tb_KNIGHTcxx . . $ tb_KNIGHT., tb_BISHOPcxx . . $ tb_BISHOP., tb_ROOKcxx . . $ tb_ROOK., tb_QUEENcxx . . $ tb_QUEEN., tb_KINGcxx . . $ tb_KING. |
| 56 | }; |
| 57 | |
| 58 | enum TB_sidescxx . . $ TB_sides# { |
| 59 | tb_WHITE_TO_MOVEcxx . . $ tb_WHITE_TO_MOVE., tb_BLACK_TO_MOVEcxx . . $ tb_BLACK_TO_MOVE. |
| 60 | }; |
| 61 | |
| 62 | enum TB_squarescxx . . $ TB_squares# { |
| 63 | tb_A1cxx . . $ tb_A1., tb_B1cxx . . $ tb_B1., tb_C1cxx . . $ tb_C1., tb_D1cxx . . $ tb_D1., tb_E1cxx . . $ tb_E1., tb_F1cxx . . $ tb_F1., tb_G1cxx . . $ tb_G1., tb_H1cxx . . $ tb_H1., |
| 64 | tb_A2cxx . . $ tb_A2., tb_B2cxx . . $ tb_B2., tb_C2cxx . . $ tb_C2., tb_D2cxx . . $ tb_D2., tb_E2cxx . . $ tb_E2., tb_F2cxx . . $ tb_F2., tb_G2cxx . . $ tb_G2., tb_H2cxx . . $ tb_H2., |
| 65 | tb_A3cxx . . $ tb_A3., tb_B3cxx . . $ tb_B3., tb_C3cxx . . $ tb_C3., tb_D3cxx . . $ tb_D3., tb_E3cxx . . $ tb_E3., tb_F3cxx . . $ tb_F3., tb_G3cxx . . $ tb_G3., tb_H3cxx . . $ tb_H3., |
| 66 | tb_A4cxx . . $ tb_A4., tb_B4cxx . . $ tb_B4., tb_C4cxx . . $ tb_C4., tb_D4cxx . . $ tb_D4., tb_E4cxx . . $ tb_E4., tb_F4cxx . . $ tb_F4., tb_G4cxx . . $ tb_G4., tb_H4cxx . . $ tb_H4., |
| 67 | tb_A5cxx . . $ tb_A5., tb_B5cxx . . $ tb_B5., tb_C5cxx . . $ tb_C5., tb_D5cxx . . $ tb_D5., tb_E5cxx . . $ tb_E5., tb_F5cxx . . $ tb_F5., tb_G5cxx . . $ tb_G5., tb_H5cxx . . $ tb_H5., |
| 68 | tb_A6cxx . . $ tb_A6., tb_B6cxx . . $ tb_B6., tb_C6cxx . . $ tb_C6., tb_D6cxx . . $ tb_D6., tb_E6cxx . . $ tb_E6., tb_F6cxx . . $ tb_F6., tb_G6cxx . . $ tb_G6., tb_H6cxx . . $ tb_H6., |
| 69 | tb_A7cxx . . $ tb_A7., tb_B7cxx . . $ tb_B7., tb_C7cxx . . $ tb_C7., tb_D7cxx . . $ tb_D7., tb_E7cxx . . $ tb_E7., tb_F7cxx . . $ tb_F7., tb_G7cxx . . $ tb_G7., tb_H7cxx . . $ tb_H7., |
| 70 | tb_A8cxx . . $ tb_A8., tb_B8cxx . . $ tb_B8., tb_C8cxx . . $ tb_C8., tb_D8cxx . . $ tb_D8., tb_E8cxx . . $ tb_E8., tb_F8cxx . . $ tb_F8., tb_G8cxx . . $ tb_G8., tb_H8cxx . . $ tb_H8., |
| 71 | tb_NOSQUAREcxx . . $ tb_NOSQUARE. |
| 72 | }; |
| 73 | |
| 74 | enum TB_castlingcxx . . $ TB_castling# { |
| 75 | tb_NOCASTLEcxx . . $ tb_NOCASTLE. = 0, |
| 76 | tb_WOOcxx . . $ tb_WOO. = 8, |
| 77 | tb_WOOOcxx . . $ tb_WOOO. = 4, |
| 78 | tb_BOOcxx . . $ tb_BOO. = 2, |
| 79 | tb_BOOOcxx . . $ tb_BOOO. = 1 |
| 80 | }; |
| 81 | |
| 82 | enum TB_compression_schemecxx . . $ TB_compression_scheme# { |
| 83 | tb_UNCOMPRESSEDcxx . . $ tb_UNCOMPRESSED., tb_CP1cxx . . $ tb_CP1., tb_CP2cxx . . $ tb_CP2., tb_CP3cxx . . $ tb_CP3., tb_CP4cxx . . $ tb_CP4. |
| 84 | }; |
| 85 | |
| 86 | /*----------------------------------*\ |
| 87 | | FUNCTIONS |
| 88 | \*----------------------------------*/ |
| 89 | |
| 90 | extern char * tb_initcxx . . $ tb_init(4fe2ea5f154cdf07). (int verbosity, int compression_scheme, const char **paths); |
| 91 | |
| 92 | extern char * tb_restartcxx . . $ tb_restart(4fe2ea5f154cdf07).(int verbosity, int compression_scheme, const char **paths); |
| 93 | |
| 94 | extern void tb_donecxx . . $ tb_done(49f6e7a06ebc5aa8). (void); |
| 95 | |
| 96 | extern int /*bool*/ tb_probe_hardcxx . . $ tb_probe_hard(545fa276f31a8a3c). |
| 97 | (unsigned stm, |
| 98 | unsigned epsq, |
| 99 | unsigned castles, |
| 100 | const unsigned *inp_wSQ, |
| 101 | const unsigned *inp_bSQ, |
| 102 | const unsigned char *inp_wPC, |
| 103 | const unsigned char *inp_bPC, |
| 104 | /*@out@*/ unsigned *tbinfo, |
| 105 | /*@out@*/ unsigned *plies); |
| 106 | |
| 107 | extern int /*bool*/ tb_probe_softcxx . . $ tb_probe_soft(545fa276f31a8a3c). |
| 108 | (unsigned stm, |
| 109 | unsigned epsq, |
| 110 | unsigned castles, |
| 111 | const unsigned *inp_wSQ, |
| 112 | const unsigned *inp_bSQ, |
| 113 | const unsigned char *inp_wPC, |
| 114 | const unsigned char *inp_bPC, |
| 115 | /*@out@*/ unsigned *tbinfo, |
| 116 | /*@out@*/ unsigned *plies); |
| 117 | |
| 118 | extern int /*bool*/ tb_probe_WDL_hardcxx . . $ tb_probe_WDL_hard(86eeecdfbc4ee384). |
| 119 | (unsigned stm, |
| 120 | unsigned epsq, |
| 121 | unsigned castles, |
| 122 | const unsigned *inp_wSQ, |
| 123 | const unsigned *inp_bSQ, |
| 124 | const unsigned char *inp_wPC, |
| 125 | const unsigned char *inp_bPC, |
| 126 | /*@out@*/ unsigned *tbinfo); |
| 127 | |
| 128 | extern int /*bool*/ tb_probe_WDL_softcxx . . $ tb_probe_WDL_soft(86eeecdfbc4ee384). |
| 129 | (unsigned stm, |
| 130 | unsigned epsq, |
| 131 | unsigned castles, |
| 132 | const unsigned *inp_wSQ, |
| 133 | const unsigned *inp_bSQ, |
| 134 | const unsigned char *inp_wPC, |
| 135 | const unsigned char *inp_bPC, |
| 136 | /*@out@*/ unsigned *tbinfo); |
| 137 | |
| 138 | extern int /*bool*/ tb_is_initializedcxx . . $ tb_is_initialized(b126dc7c1de90089). (void); |
| 139 | |
| 140 | /* |
| 141 | | tb_availability() returns 0 if no TBs available |
| 142 | | Otherwise, the following bits are turned 'on' if... |
| 143 | | ---------------------------------- |
| 144 | | bit: meaning |
| 145 | | ---------------------------------- |
| 146 | | 0: at least one 3-pc TB is present |
| 147 | | 1: 3-pc TBs are complete |
| 148 | | 2: at least one 4-pc TB is present |
| 149 | | 3: 4-pc TBs are complete |
| 150 | | 4: at least one 5-pc TB is present |
| 151 | | 5: 5-pc TBs are complete |
| 152 | | 6: at least one 6-pc TB is present |
| 153 | | 7: 6-pc TBs are complete |
| 154 | | Example: if 63 is returned, it means all 3-4-5-pc TBs are present |
| 155 | | Bits 6 and 7 will be always off, of course, until 6-piece TBs |
| 156 | | are supported. |
| 157 | */ |
| 158 | |
| 159 | extern unsigned int tb_availabilitycxx . . $ tb_availability(db52760e79bf9054).(void); |
| 160 | |
| 161 | /* |
| 162 | | tb_indexmemory ()returns |
| 163 | | how much memory has been allocated for indexes |
| 164 | */ |
| 165 | |
| 166 | extern size_t tb_indexmemorycxx . . $ tb_indexmemory(f708dce9a8856c70). (void); |
| 167 | |
| 168 | /*----------------------------------*\ |
| 169 | | cache |
| 170 | \*----------------------------------*/ |
| 171 | |
| 172 | extern int /*bool*/ tbcache_initcxx . . $ tbcache_init(4292610292d2867f). (size_t cache_mem, int wdl_fraction); |
| 173 | extern int /*bool*/ tbcache_restartcxx . . $ tbcache_restart(4292610292d2867f). (size_t cache_mem, int wdl_fraction); |
| 174 | extern void tbcache_donecxx . . $ tbcache_done(49f6e7a06ebc5aa8). (void); |
| 175 | extern int /*bool*/ tbcache_is_oncxx . . $ tbcache_is_on(b126dc7c1de90089). (void); |
| 176 | extern void tbcache_flushcxx . . $ tbcache_flush(49f6e7a06ebc5aa8). (void); |
| 177 | |
| 178 | /*----------------------------------*\ |
| 179 | | STATS |
| 180 | \*----------------------------------*/ |
| 181 | |
| 182 | /* |
| 183 | | For maximum portability, some stats are provided |
| 184 | | in two 32 bits integers rather than a single 64 bit number. |
| 185 | | For intance, prob_hard_hits[0] contains the less significant 32 bits |
| 186 | | (0 to 31), and prob_hard_hits[1] the most significant ones (32 to 63). |
| 187 | | The 64-bit number can be recreated like this: |
| 188 | | uint64_t x; |
| 189 | | x = (uint64_t)probe_hard_hits[0]|((uint64_t)probe_hard_hits[1]<<32); |
| 190 | | The user has the responsibility to combine the numbers and use the |
| 191 | | proper 64 bit integers. |
| 192 | */ |
| 193 | |
| 194 | struct TB_STATScxx . . $ TB_STATS# { |
| 195 | long unsigned int wdl_easy_hitscxx . . $ TB_STATS#wdl_easy_hits. [2]; /* hits that were found in own wdl cache */ |
| 196 | long unsigned int wdl_hard_probcxx . . $ TB_STATS#wdl_hard_prob. [2]; /* hard probes to the wdl cache: if fail, they will go to HD */ |
| 197 | long unsigned int wdl_soft_probcxx . . $ TB_STATS#wdl_soft_prob. [2]; /* soft probes to the wdl cache: if fail, they won't go to HD */ |
| 198 | size_t wdl_cachesizecxx . . $ TB_STATS#wdl_cachesize. ; /* size allocated for wdl cache */ |
| 199 | double wdl_occupancycxx . . $ TB_STATS#wdl_occupancy. ; /* % of slots filled in wdl cache */ |
| 200 | |
| 201 | long unsigned int dtm_easy_hitscxx . . $ TB_STATS#dtm_easy_hits. [2]; /* hits that were found in own dtm cache */ |
| 202 | long unsigned int dtm_hard_probcxx . . $ TB_STATS#dtm_hard_prob. [2]; /* hard probes to the dtm cache: if fail, they will go to HD */ |
| 203 | long unsigned int dtm_soft_probcxx . . $ TB_STATS#dtm_soft_prob. [2]; /* soft probes to the dtm cache: if fail, they won't go to HD */ |
| 204 | size_t dtm_cachesizecxx . . $ TB_STATS#dtm_cachesize. ; /* size allocated for dtm cache */ |
| 205 | double dtm_occupancycxx . . $ TB_STATS#dtm_occupancy. ; /* % of slots filled in dtm cache */ |
| 206 | |
| 207 | long unsigned int total_hitscxx . . $ TB_STATS#total_hits. [2]; /* succesful probes */ |
| 208 | long unsigned int memory_hitscxx . . $ TB_STATS#memory_hits. [2]; /* succesful probes to memory */ |
| 209 | long unsigned int drive_hitscxx . . $ TB_STATS#drive_hits. [2]; /* succesful probes to the Hard drive */ |
| 210 | long unsigned int drive_misscxx . . $ TB_STATS#drive_miss. [2]; /* failing probes to the Hard drive */ |
| 211 | long unsigned int bytes_readcxx . . $ TB_STATS#bytes_read. [2]; /* bytes read from Hard drive */ |
| 212 | long unsigned int files_openedcxx . . $ TB_STATS#files_opened. ; /* number of files newly opened */ |
| 213 | double memory_efficiencycxx . . $ TB_STATS#memory_efficiency. ; /* % hits from memory over total hits */ |
| 214 | }; |
| 215 | |
| 216 | extern void tbstats_resetcxx . . $ tbstats_reset(49f6e7a06ebc5aa8). (void); |
| 217 | extern void tbstats_getcxx . . $ tbstats_get(f5411b90d3b076c6). (struct TB_STATScxx . . $ TB_STATS# *stats); |
| 218 | |
| 219 | |
| 220 | /*----------------------------------*\ |
| 221 | | PATH MANAGEMENT |
| 222 | \*----------------------------------*/ |
| 223 | |
| 224 | extern const char ** tbpaths_initcxx . . $ tbpaths_init(5435fb1d25b36c11). (void); |
| 225 | extern const char ** tbpaths_addcxx . . $ tbpaths_add(a255ab5223acb6a2). (const char **ps, const char *newpath); |
| 226 | extern const char ** tbpaths_donecxx . . $ tbpaths_done(54f2ba6f4d2e2b5e). (const char **ps); |
| 227 | |
| 228 | extern const char * tbpaths_getmaincxx . . $ tbpaths_getmain(33a1f659e94feb42). (void); |
| 229 | |
| 230 | /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
| 231 | #ifdef __cplusplus |
| 232 | } |
| 233 | #endif |
| 234 | #endif |