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))
26 #define BSWAP32(v) __builtin_bswap32(v)
27 #define BSWAP64(v) __builtin_bswap64(v)
30 #define LOCK_INIT(x) do { x = CreateMutex(NULL, FALSE, NULL); } while (0)
31 #define LOCK(x) WaitForSingleObject(x, INFINITE)
32 #define UNLOCK(x) ReleaseMutex(x)
34 #define BSWAP32(v) _byteswap_ulong(v)
35 #define BSWAP64(v) _byteswap_uint64(v)
38 #define WDLSUFFIX ".rtbw"
39 #define DTZSUFFIX ".rtbz"
40 #define WDLDIR "RTBWDIR"
41 #define DTZDIR "RTBZDIR"
44 typedef unsigned long long uint64;
45 typedef unsigned int uint32;
46 typedef unsigned char ubyte;
47 typedef unsigned short ushort;
49 const ubyte WDL_MAGIC[4] = { 0x71, 0xe8, 0x23, 0x5d };
50 const ubyte DTZ_MAGIC[4] = { 0xd7, 0x66, 0x0c, 0xa5 };
56 typedef uint64 base_t;
68 base_t base[1]; // C++ complains about base[]...
81 __attribute__((__may_alias__))
85 struct TBEntry_piece {
94 struct PairsData *precomp[2];
95 int factor[2][TBPIECES];
96 ubyte pieces[2][TBPIECES];
97 ubyte norm[2][TBPIECES];
100 struct TBEntry_pawn {
110 struct PairsData *precomp[2];
111 int factor[2][TBPIECES];
112 ubyte pieces[2][TBPIECES];
113 ubyte norm[2][TBPIECES];
117 struct DTZEntry_piece {
126 struct PairsData *precomp;
127 int factor[TBPIECES];
128 ubyte pieces[TBPIECES];
129 ubyte norm[TBPIECES];
130 ubyte flags; // accurate, mapped, side
135 struct DTZEntry_pawn {
145 struct PairsData *precomp;
146 int factor[TBPIECES];
147 ubyte pieces[TBPIECES];
148 ubyte norm[TBPIECES];
151 ushort map_idx[4][4];
160 struct DTZTableEntry {
163 struct TBEntry *entry;