MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / mi_rotl

Function mi_rotl

system/lib/mimalloc/include/mimalloc/bits.h:309–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309static inline size_t mi_rotl(size_t x, size_t r) {
310 #if (mi_has_builtin(rotateleft64) && MI_SIZE_BITS==64)
311 return mi_builtin(rotateleft64)(x,r);
312 #elif (mi_has_builtin(rotateleft32) && MI_SIZE_BITS==32)
313 return mi_builtin(rotateleft32)(x,r);
314 #elif defined(_MSC_VER) && (MI_ARCH_X64 || MI_ARCH_ARM64)
315 return _rotl64(x, (int)r);
316 #elif defined(_MSC_VER) && (MI_ARCH_X86 || MI_ARCH_ARM32)
317 return _lrotl(x, (int)r);
318 #else
319 // The term `(-rshift)&(BITS-1)` is written instead of `BITS - rshift` to
320 // avoid UB when `rshift==0`. See <https://blog.regehr.org/archives/1063>
321 const unsigned int rshift = (unsigned int)(r) & (MI_SIZE_BITS-1);
322 return ((x << rshift) | (x >> ((-rshift) & (MI_SIZE_BITS-1))));
323 #endif
324}
325
326static inline uint32_t mi_rotl32(uint32_t x, uint32_t r) {
327 #if mi_has_builtin(rotateleft32)

Callers 1

mi_ptr_encodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected