summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-08-22 15:27:59 -0700
committerScott Gasch <[email protected]>2026-08-22 15:27:59 -0700
commitdc0c9dbf405095a6483705b153f4c85c64499d4e (patch)
treed83b20c0095726055327cb2879c0a53a591ff4de /src
parenta99cc7a0289e4106f6bb1954660a3df5c53d470b (diff)
Bug fixes.
Diffstat (limited to 'src')
-rw-r--r--src/GNUmakefile2
-rwxr-xr-xsrc/dynamic.c8
-rwxr-xr-xsrc/hash.c13
-rwxr-xr-xsrc/search.c4
-rw-r--r--src/unix.c26
5 files changed, 33 insertions, 20 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile
index a88b58b..d575cb4 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -119,7 +119,7 @@ PROFILE += -DDUMP_TREE
endif
endif # EVERYTHING
-CFLAGS = -DPROFILE="\"$(PROFILE)\"" $(PROFILE) -Wall
+CFLAGS = -DPROFILE="\"$(PROFILE)\"" $(PROFILE) -Wall -Wno-nan-infinity-disabled
HEADERS = chess.h compiler.h
#
diff --git a/src/dynamic.c b/src/dynamic.c
index 1c1e741..41b8cc1 100755
--- a/src/dynamic.c
+++ b/src/dynamic.c
@@ -223,14 +223,18 @@ Return value:
ASSERT(!IS_CAPTURE_OR_PROMOTION(mv));
ASSERT(mv.uMove);
- if (mv.bvFlags & MOVE_FLAG_ESCAPING_CHECK)
+ if (mv.bvFlags & MOVE_FLAG_ESCAPING_CHECK)
{
if (!IS_SAME_MOVE(mv, ctx->mvKillerEscapes[uPly][0]))
{
ctx->mvKillerEscapes[uPly][1] = ctx->mvKillerEscapes[uPly][0];
ctx->mvKillerEscapes[uPly][0] = mv;
+ if (ctx->mvKillerEscapes[uPly][1].uMove == 0)
+ {
+ ctx->mvKillerEscapes[uPly][1] = ctx->mvNullmoveRefutations[uPly];
+ }
}
- ASSERT(!IS_SAME_MOVE(ctx->mvKillerEscapes[uPly][0],
+ ASSERT(!IS_SAME_MOVE(ctx->mvKillerEscapes[uPly][0],
ctx->mvKillerEscapes[uPly][1]));
}
else
diff --git a/src/hash.c b/src/hash.c
index 4b0cc0a..a29e375 100755
--- a/src/hash.c
+++ b/src/hash.c
@@ -67,9 +67,11 @@ Revision History:
// for other processors, change the constant below.
//
#define CONVERT_SEARCH_DEPTH_TO_HASH_DEPTH(x) \
- ASSERT(IS_VALID_DEPTH(x)); \
- (x) >>= 4; \
- ASSERT(((x) & 0xffffff00) == 0);
+ do { \
+ ASSERT(IS_VALID_DEPTH(x)); \
+ (x) >>= 4; \
+ ASSERT(((x) & 0xffffff00) == 0); \
+ } while (0)
#define HASH_ENTRY_IS_DIRTY(x) \
(((x).bvFlags & 0xF0) != g_cDirty)
@@ -392,7 +394,7 @@ Return value:
// replace the "always replace" 1st entry on the line unless it
// contains mate information and is not stale.
//
- if (((abs(pEntry[1].iValue >= +NMATE)) &&
+ if (((abs(pEntry[1].iValue) >= +NMATE) &&
(abs(iValue) < +NMATE)) &&
(!HASH_ENTRY_IS_DIRTY(pEntry[1])))
{
@@ -405,7 +407,7 @@ Return value:
pEntry[3] = pEntry[1];
}
pStore = &(pEntry[1]);
-
+
end:
ASSERT(pStore != NULL);
return(pStore);
@@ -766,6 +768,7 @@ Return value:
goto end;
}
}
+ pHash++;
}
end:
diff --git a/src/search.c b/src/search.c
index 3b8000c..28f6f3d 100755
--- a/src/search.c
+++ b/src/search.c
@@ -163,6 +163,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
ASSERT(IS_VALID_FLAG(pf->fVerifyNullmove));
memcpy(&pi->sPosition, pos, sizeof(POSITION));
#endif
+ mvBest.uMove = 0;
// Jump directly to Qsearch if remaining depth is low enough.
// This is the only place Qsearch is entered.
@@ -334,7 +335,6 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
// Also clear the avoid null bit in the search flags -- we were
// either told to avoid it or not but there is no need to avoid it
// for the rest of the line...
- mvBest.uMove = 0;
pf->fAvoidNullmove = FALSE;
do
{
@@ -1071,6 +1071,7 @@ QSearchInDangerNoStandPat(IN SEARCHER_THREAD_CONTEXT *ctx,
-iAlpha);
pf->uQsearchDepth--;
UnmakeMove(ctx, mv);
+ if (WE_SHOULD_STOP_SEARCHING) goto end;
if (iScore > iBestScore)
{
@@ -1092,7 +1093,6 @@ QSearchInDangerNoStandPat(IN SEARCHER_THREAD_CONTEXT *ctx,
}
}
}
- if (WE_SHOULD_STOP_SEARCHING) goto end;
}
}
ASSERT(SanityCheckMoves(ctx, x, VERIFY_BEFORE));
diff --git a/src/unix.c b/src/unix.c
index 29ca6c7..99216d0 100644
--- a/src/unix.c
+++ b/src/unix.c
@@ -424,10 +424,11 @@ Return value:
**/
{
- __asm__("rdtsc;"
- :
- :
- : "%eax", "%edx");
+ ULONG uLow, uHigh;
+
+ __asm__ volatile("rdtsc"
+ : "=a" (uLow), "=d" (uHigh));
+ return(((UINT64)uHigh << 32) | (UINT64)uLow);
}
@@ -1068,25 +1069,30 @@ SystemCreateSemaphore(ULONG uValue)
return(u);
}
-FLAG
+FLAG
SystemDeleteSemaphore(ULONG u) {
union semun {
int val;
struct semid_ds *buf;
unsigned short *array;
} value;
+ FLAG fRet = TRUE;
+ memset(&value, 0, sizeof(value));
LOCK_SYSTEM;
- if ((u < MAX_SEM) && (g_rgSemaphores[u] >= 0))
+ if ((u < MAX_SEM) && (g_rgSemaphores[u] >= 0))
{
- if (semctl(g_rgSemaphores[u], 0, IPC_RMID, value) < 0)
+ if (semctl(g_rgSemaphores[u], 0, IPC_RMID, value) < 0)
{
- return(FALSE);
+ fRet = FALSE;
+ }
+ else
+ {
+ g_rgSemaphores[u] = -1;
}
- g_rgSemaphores[u] = -1;
}
UNLOCK_SYSTEM;
- return(TRUE);
+ return(fRet);
}
void