Explorar o código

Implement SDL_MostSignificantBitIndex32 using MSVC intrinsics

Cameron Gutman %!s(int64=5) %!d(string=hai) anos
pai
achega
91a831e2d0
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      include/SDL_bits.h

+ 6 - 0
include/SDL_bits.h

@@ -73,6 +73,12 @@ SDL_MostSignificantBitIndex32(Uint32 x)
         return -1;
     }
     return 31 - _SDL_clz_watcom(x);
+#elif defined(_MSC_VER)
+    unsigned long index;
+    if (_BitScanReverse(&index, x)) {
+        return index;
+    }
+    return -1;
 #else
     /* Based off of Bit Twiddling Hacks by Sean Eron Anderson
      * <seander@cs.stanford.edu>, released in the public domain.