aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-28 05:48:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-28 05:48:04 +0000
commiteccf22528f8b4c21cdbd2f620cbe39dbb38ea6e1 (patch)
tree8d78e94829aa443ddc928b970a248a5157b3566b /include
parentca7943226e1d58f4f3ae936f93aa03c2a72289ae (diff)
downloadexternal_llvm-eccf22528f8b4c21cdbd2f620cbe39dbb38ea6e1.zip
external_llvm-eccf22528f8b4c21cdbd2f620cbe39dbb38ea6e1.tar.gz
external_llvm-eccf22528f8b4c21cdbd2f620cbe39dbb38ea6e1.tar.bz2
Add MathExtras.h OffsetToAlignment, like RoundUpToAlignment but returns the
offset to the next aligned integer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/MathExtras.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 7ba5d86..6fa618e 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -435,6 +435,13 @@ inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
return ((Value + Align - 1) / Align) * Align;
}
+/// OffsetToAlignment - Return the offset to the next integer (mod 2**64) that
+/// is greater than or equal to \arg Value and is a multiple of \arg
+/// Align. Align must be non-zero.
+inline uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align) {
+ return RoundUpToAlignment(Value, Align) - Value;
+}
+
/// abs64 - absolute value of a 64-bit int. Not all environments support
/// "abs" on whatever their name for the 64-bit int type is. The absolute
/// value of the largest negative number is undefined, as with "abs".