summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2009-01-17 18:56:46 -0500
committerAli Saidi <saidi@eecs.umich.edu>2009-01-17 18:56:46 -0500
commitb4227bd7f697a1f29d25639864f5683d9ddcd41f (patch)
tree1bc2bc16736eea0244a858f70dd30f236b4d3fa6 /src/sim
parent140b4b891ec60496d8aa805fd694d45647ba083c (diff)
downloadgem5-b4227bd7f697a1f29d25639864f5683d9ddcd41f.tar.xz
Fix issue 326: glibc non-deterministic because it reads /proc
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.hh14
-rw-r--r--src/sim/system.cc13
-rw-r--r--src/sim/system.hh6
3 files changed, 30 insertions, 3 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 57403ab27..c334c1e26 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -537,10 +537,18 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str());
- // open the file
- int fd = open(path.c_str(), hostFlags, mode);
+ int fd;
+ if (!path.compare(0, 6, "/proc/") || !path.compare(0, 8, "/system/") ||
+ !path.compare(0, 10, "/platform/") || !path.compare(0, 5, "/sys/")) {
+ // It's a proc/sys entery and requires special handling
+ fd = OS::openSpecialFile(path, process, tc);
+ return (fd == -1) ? -1 : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false);
+ } else {
+ // open the file
+ fd = open(path.c_str(), hostFlags, mode);
+ return (fd == -1) ? -errno : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false);
+ }
- return (fd == -1) ? -errno : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false);
}
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 29b1d1f61..864b0fdc7 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -244,6 +244,19 @@ System::new_page()
fatal("Out of memory, please increase size of physical memory.");
return return_addr;
}
+
+Addr
+System::memSize()
+{
+ return physmem->size();
+}
+
+Addr
+System::freeMemSize()
+{
+ return physmem->size() - (page_ptr << LogVMPageSize);
+}
+
#endif
void
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 9715767b1..bfa5ea8bb 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -139,6 +139,12 @@ class System : public SimObject
return next_PID++;
}
+ /** Amount of physical memory that is still free */
+ Addr freeMemSize();
+
+ /** Amount of physical memory that exists */
+ Addr memSize();
+
#endif // FULL_SYSTEM