strings.h 370 B

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