]> git.sesse.net Git - stockfish/blob - src/types.h
1f1eb0671160b17b4739ac047f8648050548d54e
[stockfish] / src / types.h
1 /*
2   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3   Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
4   Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
5
6   Stockfish is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   Stockfish is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #if !defined(TYPES_H_INCLUDED)
22 #define TYPES_H_INCLUDED
23
24 #if !defined(_MSC_VER)
25
26 #include <inttypes.h>
27
28 #else
29
30 typedef __int8 int8_t;
31 typedef unsigned __int8 uint8_t;
32 typedef __int16 int16;
33 typedef unsigned __int16 uint16_t;
34 typedef __int32 int32_t;
35 typedef unsigned __int32 uint32_t;
36 typedef __int64 int64_t;
37 typedef unsigned __int64 uint64_t;
38
39 typedef __int16 int16_t;
40 typedef __int64 int64_t;
41
42 #endif // !defined(_MSC_VER)
43
44 // Hash keys
45 typedef uint64_t Key;
46
47 // Bitboard type
48 typedef uint64_t Bitboard;
49
50
51 ////
52 //// Configuration
53 ////
54
55 //// For Linux configuration is done using Makefile. To get started type "make help".
56 ////
57 //// For windows you need to set the right compiler switches manually:
58 ////
59 //// -DNDEBUG       | Disable debugging mode. Use always.
60 ////
61 //// -DIS_64BIT     | Compile in 64-bit mode. Use on 64-bit systems.
62 ////
63 //// -DBIGENDIAN    | Should not be used on Windows
64 ////
65 //// -DUSE_PREFETCH | Use prefetch asm-instruction. Gives a small speed up,
66 ////                | but executable won't work on some very old machines.
67 ////
68 //// -DUSE_BSFQ     | Use bsfq asm-instruction. Works only in 64-bit mode.
69 ////                | Works with ICC and GCC, not with MSVC. Gives a small speed up.
70 ////
71 //// -DUSE_POPCNT   | Add runtime support for use of popcnt asm-instruction.
72 ////                | Works only in 64-bit mode. For compiling requires hardware
73 ////                | with popcnt support. Around 4% speed-up.
74
75
76 // Cache line alignment specification
77 #if defined(_MSC_VER) || defined(__INTEL_COMPILER)
78 #define CACHE_LINE_ALIGNMENT __declspec(align(64))
79 #else
80 #define CACHE_LINE_ALIGNMENT  __attribute__ ((aligned(64)))
81 #endif
82
83 // Define a __cpuid() function for gcc compilers, for Intel and MSVC
84 // is already available as an intrinsic.
85 #if defined(_MSC_VER)
86 #include <intrin.h>
87 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
88 inline void __cpuid(int CPUInfo[4], int InfoType)
89 {
90   int* eax = CPUInfo + 0;
91   int* ebx = CPUInfo + 1;
92   int* ecx = CPUInfo + 2;
93   int* edx = CPUInfo + 3;
94
95   *eax = InfoType;
96   *ecx = 0;
97   __asm__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
98                   : "0" (*eax), "2" (*ecx));
99 }
100 #else
101 inline void __cpuid(int CPUInfo[4], int)
102 {
103    CPUInfo[0] = CPUInfo[1] = CPUInfo[2] = CPUInfo[3] = 0;
104 }
105 #endif
106
107 #endif // !defined(TYPES_H_INCLUDED)