MCPcopy Create free account
hub / github.com/cameron314/readerwriterqueue / ceilToPow2

Function ceilToPow2

readerwriterqueue.h:654–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652
653
654 AE_FORCEINLINE static size_t ceilToPow2(size_t x)
655 {
656 // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
657 --x;
658 x |= x >> 1;
659 x |= x >> 2;
660 x |= x >> 4;
661 for (size_t i = 1; i < sizeof(size_t); i <<= 1) {
662 x |= x >> (i << 3);
663 }
664 ++x;
665 return x;
666 }
667
668 template<typename U>
669 static AE_FORCEINLINE char* align_for(char* ptr) AE_NO_TSAN

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected