Added Virtual File System support
This commit is contained in:
parent
363c4f19cb
commit
01f4ad7f62
18 changed files with 4582 additions and 64 deletions
24
bits.h
24
bits.h
|
|
@ -3,6 +3,7 @@
|
|||
#include "collatypes.h"
|
||||
|
||||
uint32 bitsCtz(uint32 v);
|
||||
uint32 bitsNextPow2(uint32 v);
|
||||
|
||||
// == INLINE IMPLEMENTATION ==============================================================
|
||||
|
||||
|
|
@ -13,6 +14,9 @@ uint32 bitsCtz(uint32 v);
|
|||
#elif COLLA_GCC || COLLA_CLANG || COLLA_EMC
|
||||
#define BITS_WIN 0
|
||||
#define BITS_LIN 1
|
||||
#elif COLLA_TCC
|
||||
#define BITS_WIN 0
|
||||
#define BITS_LIN 0
|
||||
#else
|
||||
#error "bits header not supported on this compiler"
|
||||
#endif
|
||||
|
|
@ -24,11 +28,27 @@ inline uint32 bitsCtz(uint32 v) {
|
|||
return v ? __builtin_ctz(v) : 0;
|
||||
#elif BITS_WIN
|
||||
uint32 trailing = 0;
|
||||
return _BitScanForward((unsigned long *)&trailing, v) ? trailing : 0;
|
||||
return _BitScanForward((unsigned long *)&trailing, v) ? trailing : 32;
|
||||
#else
|
||||
return 0;
|
||||
if (v == 0) return 0;
|
||||
for (uint32 i = 0; i < 32; ++i) {
|
||||
if (v & (1 << i)) return i;
|
||||
}
|
||||
return 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint32 bitsNextPow2(uint32 v) {
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
#undef BITS_WIN
|
||||
#undef BITS_LIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue