eygilbert / egdb_intl

Functions to access the kingsrow international draughts endgame database
Boost Software License 1.0
4 stars 3 forks source link

function _BitScanForward64() for Linux ? #5

Open tissatussa opened 1 month ago

tissatussa commented 1 month ago

in the code of some chess engine i find the part below. it contains the function _BitScanForward64 which seems Windows specific .. i'm on Linux though, so i would like to use alternative code .. i found your #1 and that may hold an answer. Can you help ?

#include <intrin.h>

inline int lsb(const unsigned long long b)
{
  unsigned long idx;
  _BitScanForward64(&idx, b);
  return static_cast<int>(idx);
}

btw. the <intrin.h> seems Windows specific also .. i tried to replace it by <x86intrin.h> but the problem remains.

rhalbersma commented 1 month ago

@tissatussa see the file egdb/platform.h for a Windows and Linux wrapper for this function: https://github.com/eygilbert/egdb_intl/blob/eacf10797e8f6c81d618caa7af1eba05df139ac7/egdb/platform.h#L373 https://github.com/eygilbert/egdb_intl/blob/eacf10797e8f6c81d618caa7af1eba05df139ac7/egdb/platform.h#L435

tissatussa commented 1 month ago

thanks, it looks like a solution, but i get this error :

error: too many arguments to function ‘int bit_scan_forward64(uint64_t)’

indeed the original function has two parameters, yours has one !?