From 002062ae934c1fae3e56157e8e7e6451b552ada5 Mon Sep 17 00:00:00 2001 From: homoSapiensSapiens Date: Tue, 23 Jul 2013 16:31:57 +0300 Subject: [PATCH 1/1] Use #ifndef instead of #if !defined And #ifdef instead of #if defined This is more standard form (see for example iostream file). No functional change. Signed-off-by: Marco Costalba --- src/bitboard.cpp | 4 ++-- src/bitboard.h | 8 ++++---- src/bitcount.h | 6 +++--- src/book.h | 4 ++-- src/endgame.h | 4 ++-- src/evaluate.h | 4 ++-- src/material.h | 4 ++-- src/misc.cpp | 8 ++++---- src/misc.h | 4 ++-- src/movegen.h | 4 ++-- src/movepick.h | 4 ++-- src/notation.h | 4 ++-- src/pawns.h | 4 ++-- src/platform.h | 10 +++++----- src/position.h | 4 ++-- src/psqtab.h | 4 ++-- src/rkiss.h | 4 ++-- src/search.h | 4 ++-- src/thread.h | 4 ++-- src/timeman.h | 4 ++-- src/tt.h | 4 ++-- src/types.h | 10 +++++----- src/ucioption.h | 4 ++-- 23 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 3f855c57..39da1976 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -83,7 +83,7 @@ namespace { /// lsb()/msb() finds the least/most significant bit in a nonzero bitboard. /// pop_lsb() finds and clears the least significant bit in a nonzero bitboard. -#if !defined(USE_BSFQ) +#ifndef USE_BSFQ Square lsb(Bitboard b) { return BSFTable[bsf_index(b)]; } @@ -122,7 +122,7 @@ Square msb(Bitboard b) { return (Square)(result + MS1BTable[b32]); } -#endif // !defined(USE_BSFQ) +#endif // ifndef USE_BSFQ /// Bitboards::print() prints a bitboard in an easily readable format to the diff --git a/src/bitboard.h b/src/bitboard.h index eec8342f..d15d8838 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#if !defined(BITBOARD_H_INCLUDED) +#ifndef BITBOARD_H_INCLUDED #define BITBOARD_H_INCLUDED #include "types.h" @@ -258,7 +258,7 @@ inline Bitboard attacks_bb(Square s, Bitboard occ) { /// lsb()/msb() finds the least/most significant bit in a nonzero bitboard. /// pop_lsb() finds and clears the least significant bit in a nonzero bitboard. -#if defined(USE_BSFQ) +#ifdef BSFQ # if defined(_MSC_VER) && !defined(__INTEL_COMPILER) @@ -311,7 +311,7 @@ FORCE_INLINE Square pop_lsb(Bitboard* b) { return s; } -#else // if !defined(USE_BSFQ) +#else // if defined(USE_BSFQ) extern Square msb(Bitboard b); extern Square lsb(Bitboard b); @@ -319,4 +319,4 @@ extern Square pop_lsb(Bitboard* b); #endif -#endif // !defined(BITBOARD_H_INCLUDED) +#endif // #ifndef BITBOARD_H_INCLUDED diff --git a/src/bitcount.h b/src/bitcount.h index 2300bc96..ad8df94a 100644 --- a/src/bitcount.h +++ b/src/bitcount.h @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#if !defined(BITCOUNT_H_INCLUDED) +#ifndef BITCOUNT_H_INCLUDED #define BITCOUNT_H_INCLUDED #include @@ -81,7 +81,7 @@ inline int popcount(Bitboard b) { template<> inline int popcount(Bitboard b) { -#if !defined(USE_POPCNT) +#ifndef USE_POPCNT assert(false); return b != 0; // Avoid 'b not used' warning @@ -102,4 +102,4 @@ inline int popcount(Bitboard b) { #endif } -#endif // !defined(BITCOUNT_H_INCLUDED) +#endif // #ifndef BITCOUNT_H_INCLUDED diff --git a/src/book.h b/src/book.h index ed446636..4ce74f47 100644 --- a/src/book.h +++ b/src/book.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(BOOK_H_INCLUDED) +#ifndef BOOK_H_INCLUDED #define BOOK_H_INCLUDED #include @@ -42,4 +42,4 @@ private: std::string fileName; }; -#endif // !defined(BOOK_H_INCLUDED) +#endif // #ifndef BOOK_H_INCLUDED diff --git a/src/endgame.h b/src/endgame.h index b560c798..7f3ce6fb 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(ENDGAME_H_INCLUDED) +#ifndef ENDGAME_H_INCLUDED #define ENDGAME_H_INCLUDED #include @@ -119,4 +119,4 @@ public: { return eg = map(eg).count(key) ? map(eg)[key] : NULL; } }; -#endif // !defined(ENDGAME_H_INCLUDED) +#endif // #ifndef ENDGAME_H_INCLUDED diff --git a/src/evaluate.h b/src/evaluate.h index 8eb39642..2234a4a0 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(EVALUATE_H_INCLUDED) +#ifndef EVALUATE_H_INCLUDED #define EVALUATE_H_INCLUDED #include "types.h" @@ -32,4 +32,4 @@ extern std::string trace(const Position& pos); } -#endif // !defined(EVALUATE_H_INCLUDED) +#endif // #ifndef EVALUATE_H_INCLUDED diff --git a/src/material.h b/src/material.h index 96fd3f8f..cbf6e555 100644 --- a/src/material.h +++ b/src/material.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(MATERIAL_H_INCLUDED) +#ifndef MATERIAL_H_INCLUDED #define MATERIAL_H_INCLUDED #include "endgame.h" @@ -74,4 +74,4 @@ inline ScaleFactor Entry::scale_factor(const Position& pos, Color c) const { } -#endif // !defined(MATERIAL_H_INCLUDED) +#endif // #ifndef MATERIAL_H_INCLUDED diff --git a/src/misc.cpp b/src/misc.cpp index 16ae0a6b..0ca56571 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -24,7 +24,7 @@ #include "misc.h" #include "thread.h" -#if defined(__hpux) +#ifdef __hpux # include #endif @@ -173,7 +173,7 @@ void start_logger(bool b) { Logger::start(b); } int cpu_count() { -#if defined(_WIN32) +#ifdef _WIN32 SYSTEM_INFO s; GetSystemInfo(&s); return s.dwNumberOfProcessors; @@ -199,7 +199,7 @@ int cpu_count() { void timed_wait(WaitCondition& sleepCond, Lock& sleepLock, int msec) { -#if defined(_WIN32) +#ifdef _WIN32 int tm = msec; #else timespec ts, *tm = &ts; @@ -216,7 +216,7 @@ void timed_wait(WaitCondition& sleepCond, Lock& sleepLock, int msec) { /// prefetch() preloads the given address in L1/L2 cache. This is a non /// blocking function and do not stalls the CPU waiting for data to be /// loaded from memory, that can be quite slow. -#if defined(NO_PREFETCH) +#ifdef NO_PREFETCH void prefetch(char*) {} diff --git a/src/misc.h b/src/misc.h index c09d2c6b..ea1e55f1 100644 --- a/src/misc.h +++ b/src/misc.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(MISC_H_INCLUDED) +#ifndef MISC_H_INCLUDED #define MISC_H_INCLUDED #include @@ -66,4 +66,4 @@ std::ostream& operator<<(std::ostream&, SyncCout); #define sync_cout std::cout << io_lock #define sync_endl std::endl << io_unlock -#endif // !defined(MISC_H_INCLUDED) +#endif // #ifndef MISC_H_INCLUDED diff --git a/src/movegen.h b/src/movegen.h index 71e9ca03..2a4cda90 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(MOVEGEN_H_INCLUDED) +#ifndef MOVEGEN_H_INCLUDED #define MOVEGEN_H_INCLUDED #include "types.h" @@ -55,4 +55,4 @@ private: ExtMove *cur, *last; }; -#endif // !defined(MOVEGEN_H_INCLUDED) +#endif // #ifndef MOVEGEN_H_INCLUDED diff --git a/src/movepick.h b/src/movepick.h index 572025f2..c444615f 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined MOVEPICK_H_INCLUDED +#ifndef MOVEPICK_H_INCLUDED #define MOVEPICK_H_INCLUDED #include // For std::max @@ -107,4 +107,4 @@ private: ExtMove moves[MAX_MOVES]; }; -#endif // !defined(MOVEPICK_H_INCLUDED) +#endif // #ifndef MOVEPICK_H_INCLUDED diff --git a/src/notation.h b/src/notation.h index d757bd40..3ede2607 100644 --- a/src/notation.h +++ b/src/notation.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(NOTATION_H_INCLUDED) +#ifndef NOTATION_H_INCLUDED #define NOTATION_H_INCLUDED #include @@ -32,4 +32,4 @@ const std::string move_to_uci(Move m, bool chess960); const std::string move_to_san(Position& pos, Move m); std::string pretty_pv(Position& pos, int depth, Value score, int64_t msecs, Move pv[]); -#endif // !defined(NOTATION_H_INCLUDED) +#endif // #ifndef NOTATION_H_INCLUDED diff --git a/src/pawns.h b/src/pawns.h index 307da51c..7292606b 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(PAWNS_H_INCLUDED) +#ifndef PAWNS_H_INCLUDED #define PAWNS_H_INCLUDED #include "misc.h" @@ -75,4 +75,4 @@ Entry* probe(const Position& pos, Table& entries); } -#endif // !defined(PAWNS_H_INCLUDED) +#endif // #ifndef PAWNS_H_INCLUDED diff --git a/src/platform.h b/src/platform.h index 334a0eec..e4b4d2ce 100644 --- a/src/platform.h +++ b/src/platform.h @@ -17,10 +17,10 @@ along with this program. If not, see . */ -#if !defined(PLATFORM_H_INCLUDED) +#ifndef PLATFORM_H_INCLUDED #define PLATFORM_H_INCLUDED -#if defined(_MSC_VER) +#ifdef _MSC_VER // Disable some silly and noisy warning from MSVC compiler #pragma warning(disable: 4127) // Conditional expression is constant @@ -43,7 +43,7 @@ typedef unsigned __int64 uint64_t; # include // Used by sysconf(_SC_NPROCESSORS_ONLN) #endif -#if !defined(_WIN32) // Linux - Unix +#ifndef _WIN32 // Linux - Unix # include typedef timeval sys_time_t; @@ -77,7 +77,7 @@ typedef _timeb sys_time_t; inline void system_time(sys_time_t* t) { _ftime(t); } inline int64_t time_to_msec(const sys_time_t& t) { return t.time * 1000LL + t.millitm; } -#if !defined(NOMINMAX) +#ifndef NOMINMAX # define NOMINMAX // disable macros min() and max() #endif @@ -110,4 +110,4 @@ inline DWORD* dwWin9xKludge() { static DWORD dw; return &dw; } #endif -#endif // !defined(PLATFORM_H_INCLUDED) +#endif // #ifndef PLATFORM_H_INCLUDED diff --git a/src/position.h b/src/position.h index 5a4c594d..51231392 100644 --- a/src/position.h +++ b/src/position.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(POSITION_H_INCLUDED) +#ifndef POSITION_H_INCLUDED #define POSITION_H_INCLUDED #include @@ -414,4 +414,4 @@ inline Thread* Position::this_thread() const { return thisThread; } -#endif // !defined(POSITION_H_INCLUDED) +#endif // #ifndef POSITION_H_INCLUDED diff --git a/src/psqtab.h b/src/psqtab.h index 2dc29b61..f45442da 100644 --- a/src/psqtab.h +++ b/src/psqtab.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(PSQTAB_H_INCLUDED) +#ifndef PSQTAB_H_INCLUDED #define PSQTAB_H_INCLUDED #include "types.h" @@ -95,4 +95,4 @@ static const Score PSQT[][SQUARE_NB] = { #undef S -#endif // !defined(PSQTAB_H_INCLUDED) +#endif // #ifndef PSQTAB_H_INCLUDED diff --git a/src/rkiss.h b/src/rkiss.h index 86f0599b..9564253b 100644 --- a/src/rkiss.h +++ b/src/rkiss.h @@ -22,7 +22,7 @@ (at your option) any later version. */ -#if !defined(RKISS_H_INCLUDED) +#ifndef RKISS_H_INCLUDED #define RKISS_H_INCLUDED #include "types.h" @@ -71,4 +71,4 @@ public: template T rand() { return T(rand64()); } }; -#endif // !defined(RKISS_H_INCLUDED) +#endif // #ifndef RKISS_H_INCLUDED diff --git a/src/search.h b/src/search.h index 37ea9fea..e2a13606 100644 --- a/src/search.h +++ b/src/search.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(SEARCH_H_INCLUDED) +#ifndef SEARCH_H_INCLUDED #define SEARCH_H_INCLUDED #include @@ -109,4 +109,4 @@ extern void think(); } // namespace Search -#endif // !defined(SEARCH_H_INCLUDED) +#endif // #ifndef SEARCH_H_INCLUDED diff --git a/src/thread.h b/src/thread.h index 46c40d9b..4ad08465 100644 --- a/src/thread.h +++ b/src/thread.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(THREAD_H_INCLUDED) +#ifndef THREAD_H_INCLUDED #define THREAD_H_INCLUDED #include @@ -165,4 +165,4 @@ struct ThreadPool : public std::vector { extern ThreadPool Threads; -#endif // !defined(THREAD_H_INCLUDED) +#endif // #ifndef THREAD_H_INCLUDED diff --git a/src/timeman.h b/src/timeman.h index 484513bb..e12b0007 100644 --- a/src/timeman.h +++ b/src/timeman.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(TIMEMAN_H_INCLUDED) +#ifndef TIMEMAN_H_INCLUDED #define TIMEMAN_H_INCLUDED /// The TimeManager class computes the optimal time to think depending on the @@ -36,4 +36,4 @@ private: int unstablePVExtraTime; }; -#endif // !defined(TIMEMAN_H_INCLUDED) +#endif // #ifndef TIMEMAN_H_INCLUDED diff --git a/src/tt.h b/src/tt.h index aee530b0..3113751a 100644 --- a/src/tt.h +++ b/src/tt.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(TT_H_INCLUDED) +#ifndef TT_H_INCLUDED #define TT_H_INCLUDED #include "misc.h" @@ -115,4 +115,4 @@ inline void TranspositionTable::refresh(const TTEntry* tte) const { const_cast(tte)->set_generation(generation); } -#endif // !defined(TT_H_INCLUDED) +#endif // #ifndef TT_H_INCLUDED diff --git a/src/types.h b/src/types.h index 51c05b2f..d27f390a 100644 --- a/src/types.h +++ b/src/types.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(TYPES_H_INCLUDED) +#ifndef TYPES_H_INCLUDED #define TYPES_H_INCLUDED /// For Linux and OSX configuration is done automatically using Makefile. To get @@ -65,7 +65,7 @@ # define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(CACHE_LINE_SIZE))) #endif -#if defined(_MSC_VER) +#ifdef _MSC_VER # define FORCE_INLINE __forceinline #elif defined(__GNUC__) # define FORCE_INLINE inline __attribute__((always_inline)) @@ -73,13 +73,13 @@ # define FORCE_INLINE inline #endif -#if defined(USE_POPCNT) +#ifdef USE_POPCNT const bool HasPopCnt = true; #else const bool HasPopCnt = false; #endif -#if defined(IS_64BIT) +#ifdef IS_64BIT const bool Is64Bit = true; #else const bool Is64Bit = false; @@ -440,4 +440,4 @@ inline const std::string square_to_string(Square s) { return ch; } -#endif // !defined(TYPES_H_INCLUDED) +#endif // #ifndef TYPES_H_INCLUDED diff --git a/src/ucioption.h b/src/ucioption.h index feafe36a..efdfce66 100644 --- a/src/ucioption.h +++ b/src/ucioption.h @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#if !defined(UCIOPTION_H_INCLUDED) +#ifndef UCIOPTION_H_INCLUDED #define UCIOPTION_H_INCLUDED #include @@ -66,4 +66,4 @@ void loop(const std::string&); extern UCI::OptionsMap Options; -#endif // !defined(UCIOPTION_H_INCLUDED) +#endif // #ifndef UCIOPTION_H_INCLUDED -- 2.39.2