Merge ktlim@zizzer.eecs.umich.edu:/bk/m5
[gem5.git] / base / intmath.hh
index ca1cce1e01b23fc4d4adb65d734cb8510f8cc34a..5ffe2710393c78cd5d746f4e3a60f42f6d19caf0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2001, 2003 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -109,16 +109,32 @@ inline int
 FloorLog2(int32_t x)
 {
     assert(x > 0);
-    return FloorLog2(x);
+    return FloorLog2((uint32_t)x);
 }
 
 inline int
 FloorLog2(int64_t x)
 {
     assert(x > 0);
-    return FloorLog2(x);
+    return FloorLog2((uint64_t)x);
 }
 
+#if defined(__APPLE__)
+inline int
+FloorLog2(size_t x)
+{
+    assert(x > 0);
+    assert(sizeof(size_t) == 4 || sizeof(size_t) == 8);
+
+    // It's my hope that this is optimized away?
+    if (sizeof(size_t) == 4)
+        return FloorLog2((uint32_t)x);
+     else if (sizeof(size_t) == 8)
+        return FloorLog2((uint64_t)x);
+
+}
+#endif
+
 template <class T>
 inline int
 CeilLog2(T n)
@@ -192,7 +208,7 @@ Hex2Int(char c)
   if (c >= '0' && c <= '9')
     return (c - '0');
 
-  if(c >= 'A' && c <= 'F')
+  if (c >= 'A' && c <= 'F')
     return (c - 'A') + 10;
 
   if (c >= 'a' && c <= 'f')