Skip to content

Commit

Permalink
Fix Cfish for android
Browse files Browse the repository at this point in the history
  • Loading branch information
syzygy1 committed Apr 8, 2018
1 parent fc941c6 commit aae652f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/benchmark.c
Expand Up @@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define _GNU_SOURCE
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
12 changes: 6 additions & 6 deletions src/bitbase.c
Expand Up @@ -39,7 +39,7 @@ static uint32_t KPKBitbase[MAX_INDEX / 32];
// bit 13-14: white pawn file (from FILE_A to FILE_D)
// bit 15-17: white pawn RANK_7 - rank
// (from RANK_7 - RANK_7 to RANK_7 - RANK_2)
static unsigned index(unsigned us, Square bksq, Square wksq, Square psq)
static unsigned bb_index(unsigned us, Square bksq, Square wksq, Square psq)
{
return wksq | (bksq << 6) | (us << 12) | (file_of(psq) << 13) | ((RANK_7 - rank_of(psq)) << 15);
}
Expand All @@ -50,7 +50,7 @@ unsigned bitbases_probe(Square wksq, Square wpsq, Square bksq, unsigned us)
{
assert(file_of(wpsq) <= FILE_D);

unsigned idx = index(us, bksq, wksq, wpsq);
unsigned idx = bb_index(us, bksq, wksq, wpsq);
return KPKBitbase[idx / 32] & (1 << (idx & 0x1F));
}

Expand Down Expand Up @@ -109,17 +109,17 @@ static uint8_t classify(uint8_t *db, unsigned idx)
Bitboard b = PseudoAttacks[KING][ksq[us]];

while (b)
r |= us == WHITE ? db[index(them, ksq[them] , pop_lsb(&b), psq)]
: db[index(them, pop_lsb(&b), ksq[them] , psq)];
r |= us == WHITE ? db[bb_index(them, ksq[them] , pop_lsb(&b), psq)]
: db[bb_index(them, pop_lsb(&b), ksq[them] , psq)];

if (us == WHITE) {
if (rank_of(psq) < RANK_7) // Single push
r |= db[index(them, ksq[them], ksq[us], psq + NORTH)];
r |= db[bb_index(them, ksq[them], ksq[us], psq + NORTH)];

if ( rank_of(psq) == RANK_2 // Double push
&& psq + NORTH != ksq[us]
&& psq + NORTH != ksq[them])
r |= db[index(them, ksq[them], ksq[us], psq + NORTH + NORTH)];
r |= db[bb_index(them, ksq[them], ksq[us], psq + NORTH + NORTH)];
}

return db[idx] = r & good ? good : r & RES_UNKNOWN ? RES_UNKNOWN : bad;
Expand Down
2 changes: 0 additions & 2 deletions src/misc.c
Expand Up @@ -115,7 +115,6 @@ uint64_t prng_sparse_rand(PRNG *rng)
return r1 & r2 & r3;
}

#ifdef __WIN32__
ssize_t getline(char **lineptr, size_t *n, FILE *stream)
{
if (*n == 0)
Expand All @@ -132,7 +131,6 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream)
(*lineptr)[i] = 0;
return i;
}
#endif

#ifdef __WIN32__
typedef SIZE_T (WINAPI *GLPM)(void);
Expand Down
4 changes: 3 additions & 1 deletion src/misc.h
Expand Up @@ -28,6 +28,7 @@
#endif
#include <stdatomic.h>
#include <sys/time.h>
#include <unistd.h>

#include "types.h"

Expand Down Expand Up @@ -76,14 +77,15 @@ extern pthread_mutex_t io_mutex;
#define IO_LOCK pthread_mutex_lock(&io_mutex)
#define IO_UNLOCK pthread_mutex_unlock(&io_mutex)
#else
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
extern HANDLE io_mutex;
#define IO_LOCK WaitForSingleObject(io_mutex, INFINITE)
#define IO_UNLOCK ReleaseMutex(io_mutex)
int large_pages_supported(void);
extern size_t large_page_minimum;
#endif

ssize_t getline(char **lineptr, size_t *n, FILE *stream);

struct PRNG
{
uint64_t s;
Expand Down
3 changes: 1 addition & 2 deletions src/numa.c
@@ -1,7 +1,5 @@
#ifdef NUMA

#define _GNU_SOURCE

#ifndef __WIN32__
#include <numa.h>
#else
Expand All @@ -10,6 +8,7 @@
#endif
#include <stdio.h>

#include "misc.h"
#include "settings.h"
#include "types.h"

Expand Down
1 change: 1 addition & 0 deletions src/tt.c
Expand Up @@ -19,6 +19,7 @@
*/

#define _GNU_SOURCE

#include <inttypes.h>
#include <stdio.h>
#include <string.h> // For std::memset
Expand Down
1 change: 0 additions & 1 deletion src/uci.c
Expand Up @@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <ctype.h>
Expand Down
2 changes: 0 additions & 2 deletions src/ucioption.c
Expand Up @@ -18,8 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define _GNU_SOURCE

#include <assert.h>
#include <ctype.h>
#include <stdio.h>
Expand Down

0 comments on commit aae652f

Please sign in to comment.