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 #ifdef _MSC_VER
7 #  include <intrin.h>
8 #  pragma intrinsic(_BitScanForward)
ffsl(long x)9 static __forceinline int ffsl(long x)
10 {
11 	unsigned long i;
12 
13 	if (_BitScanForward(&i, x))
14 		return (i + 1);
15 	return (0);
16 }
17 
ffs(int x)18 static __forceinline int ffs(int x)
19 {
20 
21 	return (ffsl(x));
22 }
23 
24 #else
25 #  define ffsl(x) __builtin_ffsl(x)
26 #  define ffs(x) __builtin_ffs(x)
27 #endif
28 
29 #endif /* strings_h */
30