MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / ceilToPow2

Function ceilToPow2

app/src/ThirdParty/readerwriterqueue.h:655–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653 ReaderWriterQueue& operator=(const ReaderWriterQueue&) {}
654
655 AE_FORCEINLINE static size_t ceilToPow2(size_t x)
656 {
657 // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
658 --x;
659 x |= x >> 1;
660 x |= x >> 2;
661 x |= x >> 4;
662 for (size_t i = 1; i < sizeof(size_t); i <<= 1)
663 x |= x >> (i << 3);
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