2 Copyright (c) 2011-2013 Ronald de Man
17 #define FD_ERR INVALID_HANDLE_VALUE
21 #define LOCK_T pthread_mutex_t
22 #define LOCK_INIT(x) pthread_mutex_init(&(x), NULL)
23 #define LOCK(x) pthread_mutex_lock(&(x))
24 #define UNLOCK(x) pthread_mutex_unlock(&(x))
27 #define LOCK_INIT(x) do { x = CreateMutex(NULL, FALSE, NULL); } while (0)
28 #define LOCK(x) WaitForSingleObject(x, INFINITE)
29 #define UNLOCK(x) ReleaseMutex(x)
32 #define WDLSUFFIX ".rtbw"
33 #define DTZSUFFIX ".rtbz"
34 #define WDLDIR "RTBWDIR"
35 #define DTZDIR "RTBZDIR"
38 typedef unsigned long long uint64;
39 typedef unsigned int uint32;
40 typedef unsigned char ubyte;
41 typedef unsigned short ushort;
43 const ubyte WDL_MAGIC[4] = { 0x71, 0xe8, 0x23, 0x5d };
44 const ubyte DTZ_MAGIC[4] = { 0xd7, 0x66, 0x0c, 0xa5 };
50 typedef uint64 base_t;
62 base_t base[1]; // C++ complains about base[]...
73 } __attribute__((__may_alias__));
75 struct TBEntry_piece {
84 struct PairsData *precomp[2];
85 int factor[2][TBPIECES];
86 ubyte pieces[2][TBPIECES];
87 ubyte norm[2][TBPIECES];
100 struct PairsData *precomp[2];
101 int factor[2][TBPIECES];
102 ubyte pieces[2][TBPIECES];
103 ubyte norm[2][TBPIECES];
107 struct DTZEntry_piece {
116 struct PairsData *precomp;
117 int factor[TBPIECES];
118 ubyte pieces[TBPIECES];
119 ubyte norm[TBPIECES];
120 ubyte flags; // accurate, mapped, side
125 struct DTZEntry_pawn {
135 struct PairsData *precomp;
136 int factor[TBPIECES];
137 ubyte pieces[TBPIECES];
138 ubyte norm[TBPIECES];
141 ushort map_idx[4][4];
150 struct DTZTableEntry {
153 struct TBEntry *entry;