2008-08-31 23:59:13 -06:00
|
|
|
/*
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
|
|
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
2013-02-18 23:54:14 -07:00
|
|
|
Copyright (C) 2008-2013 Marco Costalba, Joona Kiiski, Tord Romstad
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
2008-08-31 23:59:13 -06:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2008-09-06 04:30:07 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
2008-08-31 23:59:13 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-09-06 04:30:07 -06:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(MISC_H_INCLUDED)
|
|
|
|
#define MISC_H_INCLUDED
|
|
|
|
|
2011-10-17 10:49:28 -06:00
|
|
|
#include <fstream>
|
2008-08-31 23:59:13 -06:00
|
|
|
#include <string>
|
2012-03-31 05:15:57 -06:00
|
|
|
#include <vector>
|
2011-11-05 04:19:21 -06:00
|
|
|
|
2009-05-10 05:21:45 -06:00
|
|
|
#include "types.h"
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2011-12-30 04:53:51 -07:00
|
|
|
extern const std::string engine_info(bool to_uci = false);
|
2008-08-31 23:59:13 -06:00
|
|
|
extern int cpu_count();
|
2012-01-23 07:20:53 -07:00
|
|
|
extern void timed_wait(WaitCondition&, Lock&, int);
|
2010-06-19 04:10:54 -06:00
|
|
|
extern void prefetch(char* addr);
|
2012-03-22 15:39:10 -06:00
|
|
|
extern void start_logger(bool b);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-12-14 09:26:05 -07:00
|
|
|
extern void dbg_hit_on(bool b);
|
|
|
|
extern void dbg_hit_on_c(bool c, bool b);
|
|
|
|
extern void dbg_mean_of(int v);
|
2011-12-30 08:14:24 -07:00
|
|
|
extern void dbg_print();
|
2008-10-11 11:25:16 -06:00
|
|
|
|
2012-03-03 01:35:56 -07:00
|
|
|
|
2011-10-17 10:49:28 -06:00
|
|
|
struct Log : public std::ofstream {
|
|
|
|
Log(const std::string& f = "log.txt") : std::ofstream(f.c_str(), std::ios::out | std::ios::app) {}
|
|
|
|
~Log() { if (is_open()) close(); }
|
|
|
|
};
|
|
|
|
|
2012-03-03 01:35:56 -07:00
|
|
|
|
2012-09-04 01:38:51 -06:00
|
|
|
namespace Time {
|
|
|
|
typedef int64_t point;
|
|
|
|
point now();
|
|
|
|
}
|
2012-03-03 01:35:56 -07:00
|
|
|
|
2012-03-31 05:15:57 -06:00
|
|
|
|
|
|
|
template<class Entry, int Size>
|
|
|
|
struct HashTable {
|
2012-08-31 06:21:16 -06:00
|
|
|
HashTable() : e(Size, Entry()) {}
|
2012-03-31 05:15:57 -06:00
|
|
|
Entry* operator[](Key k) { return &e[(uint32_t)k & (Size - 1)]; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Entry> e;
|
|
|
|
};
|
|
|
|
|
2012-08-29 03:25:11 -06:00
|
|
|
|
|
|
|
enum SyncCout { io_lock, io_unlock };
|
|
|
|
std::ostream& operator<<(std::ostream&, SyncCout);
|
|
|
|
|
|
|
|
#define sync_cout std::cout << io_lock
|
|
|
|
#define sync_endl std::endl << io_unlock
|
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
#endif // !defined(MISC_H_INCLUDED)
|