Subversion Repositories Games.Chess Giants

Rev

Rev 108 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 108 Rev 154
Line 8... Line 8...
8
 *   loosely ordered so that the most common functions occur first, to help    *
8
 *   loosely ordered so that the most common functions occur first, to help    *
9
 *   with cache layout when the code is actually loaded.                       *
9
 *   with cache layout when the code is actually loaded.                       *
10
 *                                                                             *
10
 *                                                                             *
11
 *******************************************************************************
11
 *******************************************************************************
12
 */
12
 */
-
 
13
 
-
 
14
#define TB_HAVE_THREADS
-
 
15
#  ifdef TB_HAVE_THREADS
-
 
16
#    ifndef _WIN32 // Pierre-Marie Baty -- fixed include guard
-
 
17
#      define LOCK_T pthread_mutex_t
-
 
18
#      define LOCK_INIT(x) pthread_mutex_init(&(x), NULL)
-
 
19
#      define LOCK(x) pthread_mutex_lock(&(x))
-
 
20
#      define UNLOCK(x) pthread_mutex_unlock(&(x))
-
 
21
#    else
-
 
22
#      define LOCK_T HANDLE
-
 
23
#      define LOCK_INIT(x) do { x = CreateMutex(NULL, FALSE, NULL); } while (0)
-
 
24
#      define LOCK(x) WaitForSingleObject(x, INFINITE)
-
 
25
#      define UNLOCK(x) ReleaseMutex(x)
-
 
26
#    endif
-
 
27
#  else                         /* !TB_HAVE_THREADS */
-
 
28
#    define LOCK_T          int
-
 
29
#    define LOCK_INIT(x)
-
 
30
 /* NOP */
-
 
31
#    define LOCK(x)
-
 
32
 /* NOP */
-
 
33
#    define UNLOCK(x)
-
 
34
 /* NOP */
-
 
35
#  endif
-
 
36
 
-
 
37
 
-
 
38
int __builtin_clzll (unsigned long long x)
-
 
39
{
-
 
40
   // Returns the number of leading 0-bits in x, starting at the most significant bit position.
-
 
41
   // If x is zero, the result is undefined.
-
 
42
   // This uses a binary search (counting down) algorithm from Hacker's Delight.
-
 
43
 
-
 
44
   unsigned long long y;
-
 
45
   int n = 64;
-
 
46
 
-
 
47
   y = x >> 32; if (y != 0) { n = n - 32; x = y; }
-
 
48
   y = x >> 16; if (y != 0) { n = n - 16; x = y; }
-
 
49
   y = x >> 8; if (y != 0) { n = n - 8; x = y; }
-
 
50
   y = x >> 4; if (y != 0) { n = n - 4; x = y; }
-
 
51
   y = x >> 2; if (y != 0) { n = n - 2; x = y; }
-
 
52
   y = x >> 1; if (y != 0) return (n - 2);
-
 
53
 
-
 
54
   return (n - (int) x);
-
 
55
}
-
 
56
 
-
 
57
 
-
 
58
int __builtin_ctzll (unsigned long long x)
-
 
59
{
-
 
60
   // Returns the number of trailing 0-bits in x, starting at the least significant bit position.
-
 
61
   // If x is zero, the result is undefined.
-
 
62
   // This uses a binary search algorithm from Hacker's Delight.
-
 
63
 
-
 
64
   int n = 1;
-
 
65
 
-
 
66
   if ((x & 0x00000000FFFFFFFF) == 0) { n = n + 32; x = x >> 32; }
-
 
67
   if ((x & 0x000000000000FFFF) == 0) { n = n + 16; x = x >> 16; }
-
 
68
   if ((x & 0x00000000000000FF) == 0) { n = n + 8; x = x >> 8; }
-
 
69
   if ((x & 0x000000000000000F) == 0) { n = n + 4; x = x >> 4; }
-
 
70
   if ((x & 0x0000000000000003) == 0) { n = n + 2; x = x >> 2; }
-
 
71
 
-
 
72
   return (n - (x & 1));
-
 
73
}
-
 
74
 
-
 
75
 
-
 
76
int __builtin_popcountll (unsigned long long x)
-
 
77
{
-
 
78
   // counts the number of 1-bits in x
-
 
79
 
-
 
80
   x = (x & 0x5555555555555555ULL) + ((x >> 1) & 0x5555555555555555ULL);
-
 
81
   x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
-
 
82
   x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
-
 
83
   return (int) ((x * 0x0101010101010101ULL) >> 56);
-
 
84
}
-
 
85
 
-
 
86
 
-
 
87
#define __builtin_bswap32 _byteswap_ulong
-
 
88
 
-
 
89
 
13
#include "iterate.c"
90
#include "iterate.c"
14
#include "search.c"
91
#include "search.c"
15
#include "movgen.c"
92
#include "movgen.c"
16
#include "make.c"
93
#include "make.c"
17
#include "unmake.c"
94
#include "unmake.c"
Line 22... Line 99...
22
#include "quiesce.c"
99
#include "quiesce.c"
23
#include "evaluate.c"
100
#include "evaluate.c"
24
#include "hash.c"
101
#include "hash.c"
25
#include "attacks.c"
102
#include "attacks.c"
26
#include "see.c"
103
#include "see.c"
27
#include "boolean.c"
-
 
28
#include "utility.c"
104
#include "utility.c"
29
#include "probe.c"
105
#include "tbprobe.c"
30
#include "book.c"
106
#include "book.c"
31
#include "autotune.c"
107
#include "autotune.c"
32
#include "analyze.c"
108
#include "analyze.c"
33
#include "annotate.c"
109
#include "annotate.c"
34
#include "bench.c"
110
#include "bench.c"