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)
33 #define BSWAP32(v) __builtin_bswap32(v)
34 #define BSWAP64(v) __builtin_bswap64(v)
36 #define BSWAP32(v) _byteswap_ulong(v)
37 #define BSWAP64(v) _byteswap_uint64(v)
40 #define WDLSUFFIX ".rtbw"
41 #define DTZSUFFIX ".rtbz"
42 #define WDLDIR "RTBWDIR"
43 #define DTZDIR "RTBZDIR"
46 typedef unsigned long long uint64;
47 typedef unsigned int uint32;
48 typedef unsigned char ubyte;
49 typedef unsigned short ushort;
51 const ubyte WDL_MAGIC[4] = { 0x71, 0xe8, 0x23, 0x5d };
52 const ubyte DTZ_MAGIC[4] = { 0xd7, 0x66, 0x0c, 0xa5 };
58 typedef uint64 base_t;
70 base_t base[1]; // C++ complains about base[]...
83 __attribute__((__may_alias__))
87 struct TBEntry_piece {
96 struct PairsData *precomp[2];
97 int factor[2][TBPIECES];
98 ubyte pieces[2][TBPIECES];
99 ubyte norm[2][TBPIECES];
102 struct TBEntry_pawn {
112 struct PairsData *precomp[2];
113 int factor[2][TBPIECES];
114 ubyte pieces[2][TBPIECES];
115 ubyte norm[2][TBPIECES];
119 struct DTZEntry_piece {
128 struct PairsData *precomp;
129 int factor[TBPIECES];
130 ubyte pieces[TBPIECES];
131 ubyte norm[TBPIECES];
132 ubyte flags; // accurate, mapped, side
137 struct DTZEntry_pawn {
147 struct PairsData *precomp;
148 int factor[TBPIECES];
149 ubyte pieces[TBPIECES];
150 ubyte norm[TBPIECES];
153 ushort map_idx[4][4];
162 struct DTZTableEntry {
165 struct TBEntry *entry;