Subversion Repositories Games.Chess Giants

Rev

Rev 108 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 pmbaty 1
/* last modified 01/18/09 */
2
/*
3
 *******************************************************************************
4
 *                                                                             *
5
 *   This module is designed for the most efficient compiling, as it includes  *
6
 *   all of the source files into one large wad so that the compiler can see   *
7
 *   all function calls and inline whatever is appropriate.  The includes are  *
8
 *   loosely ordered so that the most common functions occur first, to help    *
9
 *   with cache layout when the code is actually loaded.                       *
10
 *                                                                             *
11
 *******************************************************************************
12
 */
154 pmbaty 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
 
108 pmbaty 90
#include "iterate.c"
33 pmbaty 91
#include "search.c"
92
#include "movgen.c"
93
#include "make.c"
94
#include "unmake.c"
95
#include "thread.c"
96
#include "repeat.c"
97
#include "next.c"
108 pmbaty 98
#include "history.c"
33 pmbaty 99
#include "quiesce.c"
100
#include "evaluate.c"
101
#include "hash.c"
102
#include "attacks.c"
108 pmbaty 103
#include "see.c"
33 pmbaty 104
#include "utility.c"
154 pmbaty 105
#include "tbprobe.c"
33 pmbaty 106
#include "book.c"
108 pmbaty 107
#include "autotune.c"
33 pmbaty 108
#include "analyze.c"
109
#include "annotate.c"
110
#include "bench.c"
111
#include "data.c"
112
#include "drawn.c"
113
#include "edit.c"
114
#include "epd.c"
115
#include "epdglue.c"
116
#include "evtest.c"
117
#include "init.c"
118
#include "input.c"
119
#include "interrupt.c"
120
#include "learn.c"
121
#include "main.c"
122
#include "option.c"
123
#include "output.c"
124
#include "ponder.c"
125
#include "resign.c"
126
#include "root.c"
127
#include "setboard.c"
128
#include "test.c"
129
#include "time.c"
130
#include "validate.c"