]> git.saurik.com Git - apple/dyld.git/blobdiff - launch-cache/FileAbstraction.hpp
dyld-551.3.tar.gz
[apple/dyld.git] / launch-cache / FileAbstraction.hpp
index 8d75311c16d56e01b400c1dffb10a1759cc1f3f4..1d73d74dea3f5a302833aa40fa7b9a173a8e0a1a 100644 (file)
@@ -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 <typename T>
+    static T round_up(T value) { return (value+3) & ~(T)3; }
+    template <typename T>
+    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 <typename T>
+    static T round_up(T value) { return (value+7) & ~(T)7; }
+    template <typename T>
+    static T round_down(T value) { return value & ~(T)7; }
 };