diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-27 00:03:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-27 00:03:19 +0000 |
commit | 5de2204fe84a89604a31253a299ab265dee76934 (patch) | |
tree | 142e5dd065732bf4cc8775f69ce0979230836e51 /llvm/include/Support/MathExtras.h | |
parent | f679703feb9c4702a55f41caec15d5adf997cac9 (diff) | |
download | bcm5719-llvm-5de2204fe84a89604a31253a299ab265dee76934.tar.gz bcm5719-llvm-5de2204fe84a89604a31253a299ab265dee76934.zip |
Create a new #include "Support/..." directory structure to move things
from "llvm/Support/..." that are not llvm dependant.
Move files and fix #includes
llvm-svn: 1400
Diffstat (limited to 'llvm/include/Support/MathExtras.h')
-rw-r--r-- | llvm/include/Support/MathExtras.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/include/Support/MathExtras.h b/llvm/include/Support/MathExtras.h new file mode 100644 index 00000000000..f3dc3de17bb --- /dev/null +++ b/llvm/include/Support/MathExtras.h @@ -0,0 +1,32 @@ +// $Id$ -*-c++-*- +//*************************************************************************** +// File: +// MathExtras.h +// +// Purpose: +// +// History: +// 8/25/01 - Vikram Adve - Created +//**************************************************************************/ + +#ifndef LLVM_SUPPORT_MATH_EXTRAS_H +#define LLVM_SUPPORT_MATH_EXTRAS_H + +#include <sys/types.h> + +inline bool IsPowerOf2 (int64_t C, unsigned& getPow); + +inline +bool IsPowerOf2(int64_t C, unsigned& getPow) +{ + if (C < 0) + C = -C; + bool isBool = C > 0 && (C == (C & ~(C - 1))); + if (isBool) + for (getPow = 0; C > 1; getPow++) + C = C >> 1; + + return isBool; +} + +#endif /*LLVM_SUPPORT_MATH_EXTRAS_H*/ |