Create a new #include "Support/..." directory structure to move things
[oota-llvm.git] / include / llvm / Support / MathExtras.h
1 // $Id$ -*-c++-*-
2 //***************************************************************************
3 // File:
4 //      MathExtras.h
5 // 
6 // Purpose:
7 //      
8 // History:
9 //      8/25/01  -  Vikram Adve  -  Created
10 //**************************************************************************/
11
12 #ifndef LLVM_SUPPORT_MATH_EXTRAS_H
13 #define LLVM_SUPPORT_MATH_EXTRAS_H
14
15 #include <sys/types.h>
16
17 inline bool     IsPowerOf2      (int64_t C, unsigned& getPow);
18
19 inline
20 bool IsPowerOf2(int64_t C, unsigned& getPow)
21 {
22   if (C < 0)
23     C = -C;
24   bool isBool = C > 0 && (C == (C & ~(C - 1)));
25   if (isBool)
26     for (getPow = 0; C > 1; getPow++)
27       C = C >> 1;
28   
29   return isBool;
30 }
31
32 #endif /*LLVM_SUPPORT_MATH_EXTRAS_H*/