| 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 |