summaryrefslogtreecommitdiff
path: root/base/intmath.hh
diff options
context:
space:
mode:
Diffstat (limited to 'base/intmath.hh')
-rw-r--r--base/intmath.hh18
1 files changed, 17 insertions, 1 deletions
diff --git a/base/intmath.hh b/base/intmath.hh
index 77f63fe8d..821514668 100644
--- a/base/intmath.hh
+++ b/base/intmath.hh
@@ -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
@@ -119,6 +119,22 @@ FloorLog2(int64_t x)
return FloorLog2((uint64_t)x);
}
+#if defined(__APPLE__)
+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)