Skip to content

Commit

Permalink
__bfind got displaced?
Browse files Browse the repository at this point in the history
  • Loading branch information
jbikker committed Dec 6, 2024
1 parent d3d3d42 commit c53303f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions tiny_bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,25 +386,6 @@ typedef bvhvec4 SIMDVEC4;
#define SIMD_SETRVEC(a,b,c,d) bvhvec4( a, b, c, d )
#endif

#if defined BVH_USEAVX || defined BVH_USENEON

static unsigned __bfind( unsigned x ) // https://github.com/mackron/refcode/blob/master/lzcnt.c
{
#if defined(_MSC_VER) && !defined(__clang__)
return 31 - __lzcnt( x );
#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
}

#endif

// error handling
Expand Down Expand Up @@ -858,6 +839,25 @@ ALIGNED(64) static unsigned long long int compactlut[24][2] = { { 0, 0 }, { 0, 0

#endif

#if defined BVH_USEAVX || defined BVH_USENEON

static unsigned __bfind( unsigned x ) // https://github.com/mackron/refcode/blob/master/lzcnt.c
{
#if defined(_MSC_VER) && !defined(__clang__)
return 31 - __lzcnt( x );
#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
}

void* BVH::AlignedAlloc( size_t size )
{
return context.malloc ? context.malloc( size, context.userdata ) : nullptr;
Expand Down

0 comments on commit c53303f

Please sign in to comment.