system/core
Revisión | d1db1b05644534ace4d44188328ab71981902c0d (tree) |
---|---|
Tiempo | 2020-03-16 19:40:16 |
Autor | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge tag 'android-8.1.0_r74' into oreo-x86
Android 8.1.0 release 74
@@ -47,7 +47,12 @@ public: | ||
47 | 47 | |
48 | 48 | template<size_t N> |
49 | 49 | static size_t align(void*& buffer) { |
50 | - return align<N>( const_cast<void const*&>(buffer) ); | |
50 | + static_assert(!(N & (N - 1)), "Can only align to a power of 2."); | |
51 | + void* b = buffer; | |
52 | + buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1)); | |
53 | + size_t delta = size_t(uintptr_t(buffer) - uintptr_t(b)); | |
54 | + memset(b, 0, delta); | |
55 | + return delta; | |
51 | 56 | } |
52 | 57 | |
53 | 58 | static void advance(void*& buffer, size_t& size, size_t offset) { |