X-Git-Url: https://git.saurik.com/apple/dyld.git/blobdiff_plain/39a8cd101b922f08058746122efff58c14b57605..8074fd5ce9395d82fc9f7ac611f5ad43378ffc70:/launch-cache/FileAbstraction.hpp diff --git a/launch-cache/FileAbstraction.hpp b/launch-cache/FileAbstraction.hpp index 8d75311..1d73d74 100644 --- a/launch-cache/FileAbstraction.hpp +++ b/launch-cache/FileAbstraction.hpp @@ -127,7 +127,13 @@ public: typedef _E E; static uint64_t getP(const uint_t& from) INLINE { return _E::get32(from); } - static void setP(uint_t& into, uint64_t value) INLINE { _E::set32(into, value); } + static void setP(uint_t& into, uint64_t value) INLINE { _E::set32(into, (uint32_t)value); } + + // Round to a P-size boundary + template + static T round_up(T value) { return (value+3) & ~(T)3; } + template + static T round_down(T value) { return value & ~(T)3; } }; @@ -140,6 +146,12 @@ public: static uint64_t getP(const uint_t& from) INLINE { return _E::get64(from); } static void setP(uint_t& into, uint64_t value) INLINE { _E::set64(into, value); } + + // Round to a P-size boundary + template + static T round_up(T value) { return (value+7) & ~(T)7; } + template + static T round_down(T value) { return value & ~(T)7; } };