Skip to content

Commit ce8a72d

Browse files
author
Giuseppe Cannella
committed
fix js compile
1 parent 2f00b68 commit ce8a72d

24 files changed

+93
-78
lines changed

src/Hash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mutex Hash::mutexConstructor;
2525
volatile bool Hash::generated = false;
2626

2727
Hash::Hash() {
28-
std::lock_guard<std::mutex> lock(mutexConstructor);
28+
std::lock_guard <std::mutex> lock(mutexConstructor);
2929
if (generated) {
3030
return;
3131
}

src/IterativeDeeping.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ IterativeDeeping::IterativeDeeping() : maxDepth(MAX_PLY), running(false), openBo
2626
void IterativeDeeping::setMaxDepth(const int d) {
2727
maxDepth = min(d, _board::MAX_PLY);
2828
}
29-
29+
#ifndef JS_MODE
3030
bool IterativeDeeping::getGtbAvailable() const {
3131
return searchManager.getGtbAvailable();
3232
}
33-
33+
#endif
3434
IterativeDeeping::~IterativeDeeping() {
3535
}
3636

src/IterativeDeeping.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class IterativeDeeping: public Thread<IterativeDeeping> {
4444
void endRun() { };
4545

4646
bool getPonderEnabled() const;
47-
47+
#ifndef JS_MODE
4848
bool getGtbAvailable() const;
49-
49+
#endif
5050
bool getUseBook() const;
5151

5252
void setUseBook(const bool b);

src/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ gnuprof:
150150
gprof $(PA)$(EXE)
151151

152152
cinnamon-js:
153-
em++ -std=c++11 -DJS_MODE -DDLOG_LEVEL=_FATAL util/Bitboard.cpp -fsigned-char ChessBoard.cpp Eval.cpp Hash.cpp IterativeDeeping.cpp js/main.cpp OpenBook.cpp Search.cpp SearchManager.cpp perft/Perft.cpp util/String.cpp util/IniFile.cpp util/Timer.cpp perft/PerftThread.cpp -s EXPORTED_FUNCTIONS="['_main','_perft','_command','_isvalid']" -s NO_EXIT_RUNTIME=1 -o cinnamon.js -O3 --memory-init-file 0
153+
emcc -std=c++11 -w -DJS_MODE -DDLOG_LEVEL=_FATAL util/Bitboard.cpp -fsigned-char ChessBoard.cpp Eval.cpp Hash.cpp IterativeDeeping.cpp GenMoves.cpp js/main.cpp \
154+
db/OpenBook.cpp Search.cpp SearchManager.cpp perft/Perft.cpp util/String.cpp util/IniFile.cpp util/Timer.cpp perft/PerftThread.cpp \
155+
-s WASM=0 -s EXPORTED_FUNCTIONS="['_main','_perft','_command','_isvalid']" -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s NO_EXIT_RUNTIME=1 -o cinnamon.js -O3 --memory-init-file 0
154156

155157
cinnamon-drmemory:
156158
$(MAKE) LIBS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive lib/$(OS)/32/libgtb.a" CFLAGS="-pthread -std=c++11 -DHAS_BSF -DHAS_POPCNT -g -fsigned-char -fno-inline -fno-omit-frame-pointer -m32 " drmemory

src/Search.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void Search::clone(const Search *s) {
8888
memcpy(chessboard, s->chessboard, sizeof(_Tchessboard));
8989
}
9090

91+
#ifndef JS_MODE
9192
void Search::printDtmGtb() {
9293
int side = getSide();
9394
u64 friends = side == WHITE ? getBitmap<WHITE>() : getBitmap<BLACK>();
@@ -127,6 +128,7 @@ void Search::printDtmGtb() {
127128
decListId();
128129

129130
}
131+
#endif
130132

131133
void Search::setNullMove(bool b) {
132134
nullSearch = !b;
@@ -373,6 +375,7 @@ string Search::probeRootTB() {
373375
const auto tot = bitCount(getBitmap<WHITE>() | getBitmap<BLACK>());
374376
const int side = getSide();
375377
string best = "";
378+
#ifndef JS_MODE
376379
if (gtb && gtb->isInstalledPieces(tot)) {
377380
u64 friends = side == WHITE ? getBitmap<WHITE>() : getBitmap<BLACK>();
378381
u64 enemies = side == BLACK ? getBitmap<WHITE>() : getBitmap<BLACK>();
@@ -429,7 +432,7 @@ string Search::probeRootTB() {
429432
return best;
430433

431434
}
432-
435+
#endif
433436
//kpk -> try draw
434437
if (tot == 3 && chessboard[side] == 0 && chessboard[side ^ 1]) {
435438

src/Search.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class Search: public Eval, public Thread<Search>, public Hash {
7373
void run();
7474

7575
void endRun();
76-
76+
#ifndef JS_MODE
7777
void printDtmGtb();
78-
78+
#endif
7979
GTB &getGtb() const;
8080

8181
void setMainPly(int);

src/SearchManager.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SearchManager::SearchManager() {
2929
IniFile iniFile("cinnamon.ini");
3030

3131
while (true) {
32-
pair<string, string> *parameters = iniFile.get();
32+
pair <string, string> *parameters = iniFile.get();
3333
if (!parameters) {
3434
break;
3535
}
@@ -265,7 +265,7 @@ void SearchManager::unsetSearchMoves() {
265265
}
266266
}
267267

268-
void SearchManager::setSearchMoves(vector<string> &searchMov) {
268+
void SearchManager::setSearchMoves(vector <string> &searchMov) {
269269
_Tmove move;
270270
vector<int> searchMoves;
271271
for (std::vector<string>::iterator it = searchMov.begin(); it != searchMov.end(); ++it) {
@@ -336,9 +336,6 @@ void SearchManager::setSide(bool i) {
336336
}
337337
}
338338

339-
bool SearchManager::getGtbAvailable() const {
340-
return getThread(0).getGtbAvailable();
341-
}
342339

343340
int SearchManager::getMoveFromSan(String string, _Tmove *ptr) {
344341
#ifdef DEBUG_MODE
@@ -350,10 +347,31 @@ int SearchManager::getMoveFromSan(String string, _Tmove *ptr) {
350347
return getThread(0).getMoveFromSan(string, ptr);
351348
}
352349

350+
351+
#ifndef JS_MODE
352+
353+
bool SearchManager::getGtbAvailable() const {
354+
return getThread(0).getGtbAvailable();
355+
}
356+
357+
353358
GTB &SearchManager::getGtb() const {
354359
return getThread(0).getGtb();
355360
}
356361

362+
363+
void SearchManager::deleteGtb() {
364+
for (Search *s:getPool()) {
365+
s->deleteGtb();
366+
}
367+
}
368+
369+
GTB &SearchManager::createGtb() {
370+
GTB &gtb = GTB::getInstance();
371+
setGtb(gtb);
372+
return gtb;
373+
}
374+
357375
void SearchManager::printDtmGtb() {
358376
getThread(0).printDtmGtb();
359377
}
@@ -363,7 +381,7 @@ void SearchManager::setGtb(GTB &tablebase) {
363381
s->setGtb(tablebase);
364382
}
365383
}
366-
384+
#endif
367385
void SearchManager::pushStackMove() {
368386
for (Search *s:getPool()) {
369387
s->pushStackMove();
@@ -382,11 +400,6 @@ void SearchManager::setRepetitionMapCount(int i) {
382400
}
383401
}
384402

385-
void SearchManager::deleteGtb() {
386-
for (Search *s:getPool()) {
387-
s->deleteGtb();
388-
}
389-
}
390403

391404
bool SearchManager::setNthread(int nthread) {
392405
if (!ThreadPool::setNthread(nthread))return false;
@@ -406,11 +419,7 @@ bool SearchManager::setParameter(String param, int value) {
406419
}
407420

408421

409-
GTB &SearchManager::createGtb() {
410-
GTB &gtb = GTB::getInstance();
411-
setGtb(gtb);
412-
return gtb;
413-
}
422+
414423

415424

416425

src/SearchManager.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class SearchManager: public Singleton<SearchManager>, public ThreadPool<Search>
3737

3838
~SearchManager();
3939

40-
GTB &getGtb() const;
41-
42-
GTB &createGtb();
43-
4440
int loadFen(string fen = "");
4541

4642
int getPieceAt(int side, u64 i);
@@ -83,7 +79,7 @@ class SearchManager: public Singleton<SearchManager>, public ThreadPool<Search>
8379

8480
void setMaxTimeMillsec(int i);
8581
void unsetSearchMoves();
86-
void setSearchMoves(vector<string> &searchmoves);
82+
void setSearchMoves(vector <string> &searchmoves);
8783
void setPonder(bool i);
8884

8985
int getSide();
@@ -102,14 +98,19 @@ class SearchManager: public Singleton<SearchManager>, public ThreadPool<Search>
10298

10399
void setSide(bool i);
104100

105-
bool getGtbAvailable() const;
106101

107102
int getMoveFromSan(String string, _Tmove *ptr);
103+
#ifndef JS_MODE
104+
bool getGtbAvailable() const;
105+
106+
GTB &getGtb() const;
107+
108+
GTB &createGtb();
108109

109110
void printDtmGtb();
110111

111112
void setGtb(GTB &tablebase);
112-
113+
#endif
113114
void pushStackMove();
114115

115116
void init();

src/Uci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void Uci::listner(IterativeDeeping *it) {
345345
searchManager.setMaxTimeMillsec(0x7FFFFFFF);
346346
forceTime = true;
347347
} else if (token == "searchmoves") {
348-
vector<string> searchmoves;
348+
vector <string> searchmoves;
349349
while (!uip.eof()) {
350350
uip >> token;
351351
searchmoves.push_back(token);

src/WrapperCinnamon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "WrapperCinnamon.h"
2121

22-
vector<string> WrapperCinnamon::getSuccessorsFen(const string &fen, const int depth) {
22+
vector <string> WrapperCinnamon::getSuccessorsFen(const string &fen, const int depth) {
2323
PerftThread a;
2424
return a.getSuccessorsFen(fen, depth);
2525
}

0 commit comments

Comments
 (0)