genrand_int32();
}
-Application::~Application() {
-
- exit_threads();
- quit_eval();
-}
-
void Application::initialize() {
// A static Application object is allocated
static Application singleton;
}
+void Application::free_resources() {
+
+ // Warning, following functions reference global objects that
+ // must be still alive when free_resources() is called.
+ exit_threads();
+ quit_eval();
+}
+
void Application::exit_with_failure() {
- exit(EXIT_FAILURE); // d'tor will be called automatically
+ exit(EXIT_FAILURE);
}
Application();
Application(const Application&);
- ~Application();
public:
static void initialize();
+ static void free_resources();
static void exit_with_failure();
};
// Middle-game specific evaluation terms
if (phase > PHASE_ENDGAME)
{
- // Pawn storms in positions with opposite castling.
+ // Pawn storms in positions with opposite castling
if ( square_file(pos.king_square(WHITE)) >= FILE_E
&& square_file(pos.king_square(BLACK)) <= FILE_D)
CALLGRIND_START_INSTRUMENTATION;
#endif
- // Process command line arguments if any
- if (argc > 1)
+ if (argc <= 1)
+ {
+ // Print copyright notice
+ cout << engine_name()
+ << " by Tord Romstad, Marco Costalba, Joona Kiiski" << endl;
+
+ if (CpuHasPOPCNT)
+ cout << "Good! CPU has hardware POPCNT." << endl;
+
+ // Enter UCI mode
+ uci_main_loop();
+ }
+ else // Process command line arguments
{
if (string(argv[1]) != "bench" || argc < 4 || argc > 8)
cout << "Usage: stockfish bench <hash size> <threads> "
else
{
string time = argc > 4 ? argv[4] : "60";
- string fen = argc > 5 ? argv[5] : "default";
- string lim = argc > 6 ? argv[6] : "time";
- string tim = argc > 7 ? argv[7] : "";
+ string fen = argc > 5 ? argv[5] : "default";
+ string lim = argc > 6 ? argv[6] : "time";
+ string tim = argc > 7 ? argv[7] : "";
benchmark(string(argv[2]) + " " + string(argv[3]) + " " + time + " " + fen + " " + lim + " " + tim);
}
- return 0;
}
- // Print copyright notice
- cout << engine_name()
- << ". By Tord Romstad, Marco Costalba, Joona Kiiski." << endl;
-
- if (CpuHasPOPCNT)
- cout << "Good! CPU has hardware POPCNT. We will use it." << endl;
-
- // Enter UCI mode
- uci_main_loop();
+ Application::free_resources();
return 0;
}