[llvm-commits] [llvm] r80339 - /llvm/trunk/include/llvm/Support/MathExtras.h

Daniel Dunbar daniel at zuster.org
Thu Aug 27 22:48:04 PDT 2009


Author: ddunbar
Date: Fri Aug 28 00:48:04 2009
New Revision: 80339

URL: http://llvm.org/viewvc/llvm-project?rev=80339&view=rev
Log:
Add MathExtras.h OffsetToAlignment, like RoundUpToAlignment but returns the
offset to the next aligned integer.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=80339&r1=80338&r2=80339&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Fri Aug 28 00:48:04 2009
@@ -435,6 +435,13 @@
   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".





More information about the llvm-commits mailing list