summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2006-02-12 11:38:26 -0500
committerGabe Black <gblack@eecs.umich.edu>2006-02-12 11:38:26 -0500
commit94590a4dba6712ae61bfed260d7933b58b78c449 (patch)
treecbde4c0a95ab6e064649ec9ffd474a43fdd9b24e /sim
parentb0700182662df6050c5baf46ea6bae2835b55a78 (diff)
parent79613686f0f6a8725e88e935a7c9ff4ede4cfc2b (diff)
downloadgem5-94590a4dba6712ae61bfed260d7933b58b78c449.tar.xz
Merge zizzer.eecs.umich.edu:/z/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/z/m5/Bitkeeper/multiarch --HG-- extra : convert_revision : 427b5c957f91e66271444acebc01e1a861790363
Diffstat (limited to 'sim')
-rw-r--r--sim/byteswap.hh19
-rw-r--r--sim/syscall_emul.hh43
2 files changed, 37 insertions, 25 deletions
diff --git a/sim/byteswap.hh b/sim/byteswap.hh
index 12d63b6b6..6a98a987f 100644
--- a/sim/byteswap.hh
+++ b/sim/byteswap.hh
@@ -75,15 +75,16 @@ swap_byte16(uint16_t x)
//This lets the compiler figure out how to call the swap_byte functions above
//for different data types.
-static inline uint64_t swap_byte(uint64_t x) {return swap_byte64(x);} \
-static inline int64_t swap_byte(int64_t x) {return swap_byte64((uint64_t)x);} \
-static inline uint32_t swap_byte(uint32_t x) {return swap_byte32(x);} \
-static inline int32_t swap_byte(int32_t x) {return swap_byte32((uint32_t)x);} \
-static inline uint16_t swap_byte(uint16_t x) {return swap_byte32(x);} \
-static inline int16_t swap_byte(int16_t x) {return swap_byte16((uint16_t)x);} \
-static inline uint8_t swap_byte(uint8_t x) {return x;} \
-static inline int8_t swap_byte(int8_t x) {return x;} \
-static inline double swap_byte(double x) {return swap_byte64((uint64_t)x);} \
+static inline uint64_t swap_byte(uint64_t x) {return swap_byte64(x);}
+static inline int64_t swap_byte(int64_t x) {return swap_byte64((uint64_t)x);}
+static inline uint32_t swap_byte(uint32_t x) {return swap_byte32(x);}
+static inline int32_t swap_byte(int32_t x) {return swap_byte32((uint32_t)x);}
+static inline int32_t swap_byte(long x) {return swap_byte32((long)x);}
+static inline uint16_t swap_byte(uint16_t x) {return swap_byte32(x);}
+static inline int16_t swap_byte(int16_t x) {return swap_byte16((uint16_t)x);}
+static inline uint8_t swap_byte(uint8_t x) {return x;}
+static inline int8_t swap_byte(int8_t x) {return x;}
+static inline double swap_byte(double x) {return swap_byte64((uint64_t)x);}
static inline float swap_byte(float x) {return swap_byte32((uint32_t)x);}
//The conversion functions with fixed endianness on both ends don't need to
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index 185ada2c5..f55709575 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -29,6 +29,9 @@
#ifndef __SIM_SYSCALL_EMUL_HH__
#define __SIM_SYSCALL_EMUL_HH__
+#define BSD_HOST (defined(__APPLE__) || defined(__OpenBSD__) || \
+ defined(__FreeBSD__))
+
///
/// @file syscall_emul.hh
///
@@ -441,8 +444,13 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process,
return -EBADF;
}
- struct stat64 hostBuf;
+#if BSD_HOST
+ struct stat hostBuf;
+ int result = fstat(process->sim_fd(fd), &hostBuf);
+#else
+ struct stat64 hostBuf;
int result = fstat64(process->sim_fd(fd), &hostBuf);
+#endif
if (result < 0)
return errno;
@@ -486,8 +494,13 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process,
if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
return -EFAULT;
+#if BSD_HOST
+ struct stat hostBuf;
+ int result = lstat(path.c_str(), &hostBuf);
+#else
struct stat64 hostBuf;
int result = lstat64(path.c_str(), &hostBuf);
+#endif
if (result < 0)
return -errno;
@@ -517,7 +530,6 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process,
return -errno;
OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf);
-
return 0;
}
@@ -653,22 +665,22 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
template <class OS>
SyscallReturn
getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
- ExecContext *xc)
+ ExecContext *xc)
{
unsigned resource = xc->getSyscallArg(0);
TypedBufferArg<typename OS::rlimit> rlp(xc->getSyscallArg(1));
switch (resource) {
- case OS::RLIMIT_STACK:
- // max stack size in bytes: make up a number (2MB for now)
- rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024;
- break;
-
- default:
- std::cerr << "getrlimitFunc: unimplemented resource " << resource
- << std::endl;
- abort();
- break;
+ case OS::TGT_RLIMIT_STACK:
+ // max stack size in bytes: make up a number (2MB for now)
+ rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024;
+ break;
+
+ default:
+ std::cerr << "getrlimitFunc: unimplemented resource " << resource
+ << std::endl;
+ abort();
+ break;
}
rlp.copyOut(xc->mem);
@@ -679,7 +691,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
template <class OS>
SyscallReturn
gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process,
- ExecContext *xc)
+ ExecContext *xc)
{
TypedBufferArg<typename OS::timeval> tp(xc->getSyscallArg(0));
@@ -719,7 +731,6 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process,
return 0;
}
-
/// Target getrusage() function.
template <class OS>
SyscallReturn
@@ -729,7 +740,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
int who = xc->getSyscallArg(0); // THREAD, SELF, or CHILDREN
TypedBufferArg<typename OS::rusage> rup(xc->getSyscallArg(1));
- if (who != OS::RUSAGE_SELF) {
+ if (who != OS::TGT_RUSAGE_SELF) {
// don't really handle THREAD or CHILDREN, but just warn and
// plow ahead
warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.",