Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
154 | pmbaty | 1 | /* |
2 | Copyright (c) 2011-2015 Ronald de Man |
||
3 | */ |
||
4 | |||
5 | #ifndef TBCORE_H |
||
6 | # define TBCORE_H |
||
7 | |||
8 | # ifndef _WIN32 // Pierre-Marie Baty -- fixed include guard |
||
9 | # include <pthread.h> |
||
10 | # define SEP_CHAR ':' |
||
11 | # define FD int |
||
12 | # define FD_ERR -1 |
||
13 | # else |
||
14 | # include <windows.h> |
||
15 | # define SEP_CHAR ';' |
||
16 | # define FD HANDLE |
||
17 | # define FD_ERR INVALID_HANDLE_VALUE |
||
18 | # endif |
||
19 | |||
20 | # define WDLSUFFIX ".rtbw" |
||
21 | # define DTZSUFFIX ".rtbz" |
||
22 | # define WDLDIR "RTBWDIR" |
||
23 | # define DTZDIR "RTBZDIR" |
||
24 | # define TBPIECES 6 |
||
25 | |||
26 | # define WDL_MAGIC 0x5d23e871 |
||
27 | # define DTZ_MAGIC 0xa50c66d7 |
||
28 | |||
29 | # define TBHASHBITS 10 |
||
30 | |||
31 | typedef unsigned long long uint64; |
||
32 | typedef unsigned int uint32; |
||
33 | typedef unsigned char ubyte; |
||
34 | typedef unsigned short ushort; |
||
35 | |||
36 | struct TBHashEntry; |
||
37 | |||
38 | # ifdef DECOMP64 |
||
39 | typedef uint64 base_t; |
||
40 | # else |
||
41 | typedef uint32 base_t; |
||
42 | # endif |
||
43 | |||
44 | struct PairsData { |
||
45 | char *indextable; |
||
46 | ushort *sizetable; |
||
47 | ubyte *data; |
||
48 | ushort *offset; |
||
49 | ubyte *symlen; |
||
50 | ubyte *sympat; |
||
51 | int blocksize; |
||
52 | int idxbits; |
||
53 | int min_len; |
||
54 | base_t base[1]; // C++ complains about base[]... |
||
55 | }; |
||
56 | |||
57 | struct TBEntry { |
||
58 | char *data; |
||
59 | uint64 key; |
||
60 | uint64 mapping; |
||
61 | ubyte ready; |
||
62 | ubyte num; |
||
63 | ubyte symmetric; |
||
64 | ubyte has_pawns; |
||
65 | } |
||
66 | #ifndef _WIN32 // Pierre-Marie Baty -- MSVC doesn't like that |
||
67 | __attribute__ ((__may_alias__)) |
||
68 | #endif // _WIN32 |
||
69 | ; |
||
70 | |||
71 | struct TBEntry_piece { |
||
72 | char *data; |
||
73 | uint64 key; |
||
74 | uint64 mapping; |
||
75 | ubyte ready; |
||
76 | ubyte num; |
||
77 | ubyte symmetric; |
||
78 | ubyte has_pawns; |
||
79 | ubyte enc_type; |
||
80 | struct PairsData *precomp[2]; |
||
81 | int factor[2][TBPIECES]; |
||
82 | ubyte pieces[2][TBPIECES]; |
||
83 | ubyte norm[2][TBPIECES]; |
||
84 | }; |
||
85 | |||
86 | struct TBEntry_pawn { |
||
87 | char *data; |
||
88 | uint64 key; |
||
89 | uint64 mapping; |
||
90 | ubyte ready; |
||
91 | ubyte num; |
||
92 | ubyte symmetric; |
||
93 | ubyte has_pawns; |
||
94 | ubyte pawns[2]; |
||
95 | struct { |
||
96 | struct PairsData *precomp[2]; |
||
97 | int factor[2][TBPIECES]; |
||
98 | ubyte pieces[2][TBPIECES]; |
||
99 | ubyte norm[2][TBPIECES]; |
||
100 | } file[4]; |
||
101 | }; |
||
102 | |||
103 | struct DTZEntry_piece { |
||
104 | char *data; |
||
105 | uint64 key; |
||
106 | uint64 mapping; |
||
107 | ubyte ready; |
||
108 | ubyte num; |
||
109 | ubyte symmetric; |
||
110 | ubyte has_pawns; |
||
111 | ubyte enc_type; |
||
112 | struct PairsData *precomp; |
||
113 | int factor[TBPIECES]; |
||
114 | ubyte pieces[TBPIECES]; |
||
115 | ubyte norm[TBPIECES]; |
||
116 | ubyte flags; // accurate, mapped, side |
||
117 | ushort map_idx[4]; |
||
118 | ubyte *map; |
||
119 | }; |
||
120 | |||
121 | struct DTZEntry_pawn { |
||
122 | char *data; |
||
123 | uint64 key; |
||
124 | uint64 mapping; |
||
125 | ubyte ready; |
||
126 | ubyte num; |
||
127 | ubyte symmetric; |
||
128 | ubyte has_pawns; |
||
129 | ubyte pawns[2]; |
||
130 | struct { |
||
131 | struct PairsData *precomp; |
||
132 | int factor[TBPIECES]; |
||
133 | ubyte pieces[TBPIECES]; |
||
134 | ubyte norm[TBPIECES]; |
||
135 | } file[4]; |
||
136 | ubyte flags[4]; |
||
137 | ushort map_idx[4][4]; |
||
138 | ubyte *map; |
||
139 | }; |
||
140 | |||
141 | struct TBHashEntry { |
||
142 | uint64 key; |
||
143 | struct TBEntry *ptr; |
||
144 | }; |
||
145 | |||
146 | struct DTZTableEntry { |
||
147 | uint64 key1; |
||
148 | uint64 key2; |
||
149 | struct TBEntry *entry; |
||
150 | }; |
||
151 | |||
152 | #endif |