-extern const std::string engine_info(bool to_uci = false);
-extern int cpu_count();
-extern void timed_wait(WaitCondition&, Lock&, int);
-extern void prefetch(char* addr);
+#define stringify2(x) #x
+#define stringify(x) stringify2(x)
+
+namespace Stockfish {
+
+std::string engine_info(bool to_uci = false);
+std::string compiler_info();
+void prefetch(void* addr);
+void start_logger(const std::string& fname);
+void* std_aligned_alloc(size_t alignment, size_t size);
+void std_aligned_free(void* ptr);
+void* aligned_large_pages_alloc(size_t size); // memory aligned by page size, min alignment: 4096 bytes
+void aligned_large_pages_free(void* mem); // nop if mem == nullptr
+
+void dbg_hit_on(bool cond, int slot = 0);
+void dbg_mean_of(int64_t value, int slot = 0);
+void dbg_stdev_of(int64_t value, int slot = 0);
+void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0);
+void dbg_print();
+
+using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds
+static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits");
+inline TimePoint now() {
+ return std::chrono::duration_cast<std::chrono::milliseconds>
+ (std::chrono::steady_clock::now().time_since_epoch()).count();
+}
+
+template<class Entry, int Size>
+struct HashTable {
+ Entry* operator[](Key key) { return &table[(uint32_t)key & (Size - 1)]; }