X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=base%2Fintmath.hh;h=5ffe2710393c78cd5d746f4e3a60f42f6d19caf0;hb=f5ef4c55331a72839c625c990b544c261e03b914;hp=cb5a34107c1e8ba0e21f2502fd9b8e819f04f3b9;hpb=2f316082e44259feb0bbd8e933d736e37244f3b7;p=gem5.git diff --git a/base/intmath.hh b/base/intmath.hh index cb5a34107..5ffe27103 100644 --- a/base/intmath.hh +++ b/base/intmath.hh @@ -119,6 +119,22 @@ FloorLog2(int64_t 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 inline int CeilLog2(T n)