diff options
author | Kevin Lim <ktlim@umich.edu> | 2005-05-02 14:16:33 -0400 |
---|---|---|
committer | Kevin Lim <ktlim@umich.edu> | 2005-05-02 14:16:33 -0400 |
commit | 6191d3e4443b5337232a238a3a0dd5d11249e223 (patch) | |
tree | 4adb8d7c510a8b123b285e0cd0cb2d74f093a108 /base | |
parent | e2ad9e68160659712f017a2aa24cc2acc29cd7f0 (diff) | |
parent | 950ce813c436cd5a70ed44794f0508799c09ed3a (diff) | |
download | gem5-6191d3e4443b5337232a238a3a0dd5d11249e223.tar.xz |
Merge ktlim@zizzer.eecs.umich.edu:/bk/m5
into zamp.eecs.umich.edu:/z/ktlim2/m5
--HG--
extra : convert_revision : ac0788599c365b2d7fe0870f0fea4b62c3b3ef22
Diffstat (limited to 'base')
-rw-r--r-- | base/intmath.hh | 38 | ||||
-rw-r--r-- | base/socket.cc | 2 |
2 files changed, 33 insertions, 7 deletions
diff --git a/base/intmath.hh b/base/intmath.hh index 5ffe27103..0cf48b41b 100644 --- a/base/intmath.hh +++ b/base/intmath.hh @@ -73,7 +73,7 @@ IsPowerOf2(T n) } inline int -FloorLog2(uint32_t x) +FloorLog2(unsigned x) { assert(x > 0); @@ -89,7 +89,26 @@ FloorLog2(uint32_t x) } inline int -FloorLog2(uint64_t x) +FloorLog2(unsigned long x) +{ + assert(x > 0); + + int y = 0; + +#if defined(__LP64__) + if (x & ULL(0xffffffff00000000)) { y += 32; x >>= 32; } +#endif + if (x & 0xffff0000) { y += 16; x >>= 16; } + if (x & 0x0000ff00) { y += 8; x >>= 8; } + if (x & 0x000000f0) { y += 4; x >>= 4; } + if (x & 0x0000000c) { y += 2; x >>= 2; } + if (x & 0x00000002) { y += 1; } + + return y; +} + +inline int +FloorLog2(unsigned long long x) { assert(x > 0); @@ -106,17 +125,24 @@ FloorLog2(uint64_t x) } inline int -FloorLog2(int32_t x) +FloorLog2(int x) +{ + assert(x > 0); + return FloorLog2((unsigned)x); +} + +inline int +FloorLog2(long x) { assert(x > 0); - return FloorLog2((uint32_t)x); + return FloorLog2((unsigned long)x); } inline int -FloorLog2(int64_t x) +FloorLog2(long long x) { assert(x > 0); - return FloorLog2((uint64_t)x); + return FloorLog2((unsigned long long)x); } #if defined(__APPLE__) diff --git a/base/socket.cc b/base/socket.cc index ee87dc057..c2e9e70e0 100644 --- a/base/socket.cc +++ b/base/socket.cc @@ -93,7 +93,7 @@ ListenSocket::listen(int port, bool reuse) return true; } -#if !defined(__OpenBSD__) && !defined(linux) +#if defined(__APPLE__) typedef int socklen_t; #endif |