diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-08-17 17:27:31 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-08-17 17:27:31 -0700 |
| commit | df51fe36f190ab8831549d7f8854372fa142f8b3 (patch) | |
| tree | 0697495ad032611a3824bb3050208f8397be4ebe /src/rt/rust_shape.cpp | |
| parent | 49397b5af6cf72487c404b6be27394720cc46cce (diff) | |
| download | rust-df51fe36f190ab8831549d7f8854372fa142f8b3.tar.gz rust-df51fe36f190ab8831549d7f8854372fa142f8b3.zip | |
Revert "rt: Use obstacks in lieu of dynamically-sized frames"
This reverts commit cc5fcfce89312042e52401eb883160ebf289235f.
Diffstat (limited to 'src/rt/rust_shape.cpp')
| -rw-r--r-- | src/rt/rust_shape.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index e5b96e7e91f..c23d3aaa858 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -64,6 +64,18 @@ const uint8_t CMP_LT = 1u; const uint8_t CMP_LE = 2u; +// Utility functions + +// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power +// of two. +template<typename T> +static inline T +align_to(T size, size_t alignment) { + assert(alignment); + T x = (T)(((uintptr_t)size + alignment - 1) & ~(alignment - 1)); + return x; +} + // Utility classes struct size_align { @@ -173,18 +185,11 @@ public: } }; -} // end namespace shape - - -inline shape::ptr_pair -align_to(const shape::ptr_pair &pair, size_t n) { - return shape::ptr_pair::make(align_to(pair.fst, n), - align_to(pair.snd, n)); +inline ptr_pair +align_to(const ptr_pair &pair, size_t n) { + return ptr_pair::make(align_to(pair.fst, n), align_to(pair.snd, n)); } - -namespace shape { - // NB: This function does not align. template<typename T> inline data_pair<T> |
