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

Function ceilToPow2

tests/unittests/unittests.cpp:74–86  ·  view source on GitHub ↗

Extracted from private static method of ReaderWriterQueue

Source from the content-addressed store, hash-verified

72
73/// Extracted from private static method of ReaderWriterQueue
74static size_t ceilToPow2(size_t x)
75{
76 // From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
77 --x;
78 x |= x >> 1;
79 x |= x >> 2;
80 x |= x >> 4;
81 for (size_t i = 1; i < sizeof(size_t); i <<= 1) {
82 x |= x >> (i << 3);
83 }
84 ++x;
85 return x;
86}
87
88
89class ReaderWriterQueueTests : public TestClass<ReaderWriterQueueTests>

Callers 1

max_capacityMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected