maxdeg wrote: ↑Mon Jul 06, 2020 2:24 pm

Mac version please !

Somebody !

Max you can find some here

https://github.com/MichaelB7/Cfish/tree/master/src
Bonth clang and gcc - gcc are the fastest for me - clang is the most compatible with other users. Strangely, the Popcnt version is now fastest on my bmi2 CPU mac. I also updated the source in type.h so that they can compile on the macOS if one was having issues before. Sorry that the diff in Github showed everything a being changed - not sure what happened there.

I had to add size_t and long to the max, min and clamp functions to compile on macOS -:

#define MAX(T) INLINE T max_##T(T a, T b) { return a > b ? a : b; }

MAX(int)

MAX(uint64_t)

MAX(unsigned)

MAX(int64_t)

MAX(uint8_t)

MAX(double)

MAX(size_t)

MAX(long)

#undef MAX

#define MIN(T) INLINE T min_##T(T a, T b) { return a < b ? a : b; }

MIN(int)

MIN(uint64_t)

MIN(unsigned)

MIN(int64_t)

MIN(uint8_t)

MIN(double)

MIN(size_t)

MIN(long)

#undef MIN

#define CLAMP(T) INLINE T clamp_##T(T a, T b, T c) { return a < b ? b : a > c ? c : a; }

CLAMP(int)

CLAMP(uint64_t)

CLAMP(unsigned)

CLAMP(int64_t)

CLAMP(uint8_t)

CLAMP(double)

CLAMP(size_t)

CLAMP(long)

#undef CLAMP

#define max(a,b) _Generic((a), \

int: max_int, \

uint64_t: max_uint64_t, \

unsigned: max_unsigned, \

int64_t: max_int64_t, \

uint8_t: max_uint8_t, \

double: max_double, \

size_t: max_size_t, \

long: max_long \

) (a,b)

#define min(a,b) _Generic((a), \

int: min_int, \

uint64_t: min_uint64_t, \

unsigned: min_unsigned, \

int64_t: min_int64_t, \

uint8_t: min_uint8_t, \

double: min_double, \

size_t: min_size_t, \

long: min_long \

) (a,b)

#define clamp(a,b,c) _Generic((a), \

int: clamp_int, \

uint64_t: clamp_uint64_t, \

unsigned: clamp_unsigned, \

int64_t: clamp_int64_t, \

uint8_t: clamp_uint8_t, \

double: clamp_double, \

size_t: clamp_size_t, \

long: clamp_long \

) (a,b,c)