From dcdb66fe34494e13c3850348caac356f79370a07 Mon Sep 17 00:00:00 2001 From: Jacco Bikker Date: Fri, 6 Dec 2024 08:02:55 +0100 Subject: [PATCH] __bfind patch 2. --- tiny_bvh.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tiny_bvh.h b/tiny_bvh.h index 93de9b6..a1795b3 100644 --- a/tiny_bvh.h +++ b/tiny_bvh.h @@ -395,9 +395,13 @@ static unsigned __bfind( unsigned x ) // https://github.com/mackron/refcode/blob #elif defined(__EMSCRIPTEN__) return 31 - __builtin_clz( x ); #elif defined(__GNUC__) || defined(__clang__) +#ifndef __APPLE__ unsigned r; __asm__ __volatile__( "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc" ); return 31 - r; +#else + return 31 - __builtin_clz( x ); // TODO: unverified. +#endif #endif }