Fix the Windows x86 MSVC build
Fixes: https://github.com/quickjs-ng/quickjs/issues/430
This commit is contained in:
parent
c98d445b63
commit
a008f1c098
2 changed files with 14 additions and 1 deletions
7
cutils.h
7
cutils.h
|
@ -203,9 +203,16 @@ static inline int clz32(unsigned int a)
|
||||||
static inline int clz64(uint64_t a)
|
static inline int clz64(uint64_t a)
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
#if INTPTR_MAX == INT64_MAX
|
||||||
unsigned long index;
|
unsigned long index;
|
||||||
_BitScanReverse64(&index, a);
|
_BitScanReverse64(&index, a);
|
||||||
return 63 - index;
|
return 63 - index;
|
||||||
|
#else
|
||||||
|
if (a >> 32)
|
||||||
|
return clz32((unsigned)(a >> 32));
|
||||||
|
else
|
||||||
|
return clz32((unsigned)a) + 32;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
return __builtin_clzll(a);
|
return __builtin_clzll(a);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,14 +94,20 @@ static inline int clz32(unsigned int a)
|
||||||
static inline int clz64(uint64_t a)
|
static inline int clz64(uint64_t a)
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
#if INTPTR_MAX == INT64_MAX
|
||||||
unsigned long index;
|
unsigned long index;
|
||||||
_BitScanReverse64(&index, a);
|
_BitScanReverse64(&index, a);
|
||||||
return 63 - index;
|
return 63 - index;
|
||||||
|
#else
|
||||||
|
if (a >> 32)
|
||||||
|
return clz32((unsigned)(a >> 32));
|
||||||
|
else
|
||||||
|
return clz32((unsigned)a) + 32;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
return __builtin_clzll(a);
|
return __builtin_clzll(a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// prototypes for final functions
|
// prototypes for final functions
|
||||||
extern char const digits36[36];
|
extern char const digits36[36];
|
||||||
size_t u32toa(char buf[minimum_length(11)], uint32_t n);
|
size_t u32toa(char buf[minimum_length(11)], uint32_t n);
|
||||||
|
|
Loading…
Reference in a new issue