diff options
Diffstat (limited to 'include/msvc_compat/strings.h')
| -rw-r--r-- | include/msvc_compat/strings.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/msvc_compat/strings.h b/include/msvc_compat/strings.h new file mode 100644 index 0000000..c84975b --- /dev/null +++ b/include/msvc_compat/strings.h @@ -0,0 +1,23 @@ +#ifndef strings_h +#define strings_h + +/* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided + * for both */ +#include <intrin.h> +#pragma intrinsic(_BitScanForward) +static __forceinline int ffsl(long x) +{ + unsigned long i; + + if (_BitScanForward(&i, x)) + return (i + 1); + return (0); +} + +static __forceinline int ffs(int x) +{ + + return (ffsl(x)); +} + +#endif |
