about summary refs log tree commit diff
path: root/src/rt/jemalloc/include/msvc_compat/strings.h
blob: 1ca24fa0f9ee6e98a5224b20942a82d6e72c1c4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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