summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-04-22 13:12:03 -0400
committerNathan Binkert <binkertn@umich.edu>2005-04-22 13:12:03 -0400
commit5a7ee2b4952f8e4fde66a5bb2a50f8afba91b477 (patch)
tree80f020f814829256eb8e0f9991a371778d83bd4b /base
parent535cfaa01e0234e224e588e753419d8777e22d0b (diff)
downloadgem5-5a7ee2b4952f8e4fde66a5bb2a50f8afba91b477.tar.xz
Make code more portable and port to cygwin
arch/alpha/alpha_tru64_process.cc: getdirent isn't implemented by cygwin. panic if this function is executed. (It shouldn't be too much to emulate it using opendir, readdir, etc.) arch/alpha/pseudo_inst.cc: Use lseek once and read instead pread. base/intmath.hh: we want int, long, and long long variations of FloorLog2 instead of int32_t, int64_t. Otherwise, we leave one out. base/socket.cc: Fix define that seems to be for apple sim/serialize.cc: don't use the intXX_t stuff, instead, use the real types so we're sure that we cover all of them. --HG-- extra : convert_revision : 9fccaff583100b06bbaafd95a162c4e19beed59e
Diffstat (limited to 'base')
-rw-r--r--base/intmath.hh38
-rw-r--r--base/socket.cc2
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