• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

Revisioncb0dfbf14ee08f904dcce47a2b4e06965eb0d88b (tree)
Zeit2019-11-08 09:20:18
AutorSteven Moreland <smoreland@goog...>
CommiterKyriakos Ispoglou

Log Message

FlattenableUtils::align memsets

Bug: 141890807
Test: boot, check data is zero'd
Change-Id: I45aaeac369f4c5cf3eb44f61c233e00f870a5c79
(cherry picked from commit bf824f8fa50d9f7390057278fefb58e83323a644)
(cherry picked from commit e62a9d7669ac85844d4424474f5c88c096f7160b)

Ändern Zusammenfassung

Diff

--- a/libutils/include/utils/Flattenable.h
+++ b/libutils/include/utils/Flattenable.h
@@ -47,7 +47,12 @@ public:
4747
4848 template<size_t N>
4949 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;
5156 }
5257
5358 static void advance(void*& buffer, size_t& size, size_t offset) {