Home | History | Annotate | Download | only in msvc_compat
      1 #ifndef strings_h
      2 #define strings_h
      3 
      4 /* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided
      5  * for both */
      6 #include <intrin.h>
      7 #pragma intrinsic(_BitScanForward)
      8 static __forceinline int ffsl(long x)
      9 {
     10 	unsigned long i;
     11 
     12 	if (_BitScanForward(&i, x))
     13 		return (i + 1);
     14 	return (0);
     15 }
     16 
     17 static __forceinline int ffs(int x)
     18 {
     19 
     20 	return (ffsl(x));
     21 }
     22 
     23 #endif
     24