diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:45:30 -0500 |
commit | 9e3c8de30bafe33f35e4b9e82fb49418941f8cb7 (patch) | |
tree | 016c65f8060c49b31d3fd3c064b97ae09279d689 /src/sim/syscall_emul.cc | |
parent | 1031b824b975cec999c37cabc8c05c485a4ae5ca (diff) | |
download | gem5-9e3c8de30bafe33f35e4b9e82fb49418941f8cb7.tar.xz |
MEM: Make port proxies use references rather than pointers
This patch is adding a clearer design intent to all objects that would
not be complete without a port proxy by making the proxies members
rathen than dynamically allocated. In essence, if NULL would not be a
valid value for the proxy, then we avoid using a pointer to make this
clear.
The same approach is used for the methods using these proxies, such as
loadSections, that now use references rather than pointers to better
reflect the fact that NULL would not be an acceptable value (in fact
the code would break and that is how this patch started out).
Overall the concept of "using a reference to express unconditional
composition where a NULL pointer is never valid" could be done on a
much broader scale throughout the code base, but for now it is only
done in the locations affected by the proxies.
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r-- | src/sim/syscall_emul.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index dc8a9a5c8..9e53645f5 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -171,18 +171,18 @@ brkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) // if the address is already there, zero it out else { uint8_t zero = 0; - SETranslatingPortProxy *tp = tc->getMemProxy(); + SETranslatingPortProxy &tp = tc->getMemProxy(); // split non-page aligned accesses Addr next_page = roundUp(gen.addr(), VMPageSize); uint32_t size_needed = next_page - gen.addr(); - tp->memsetBlob(gen.addr(), zero, size_needed); + tp.memsetBlob(gen.addr(), zero, size_needed); if (gen.addr() + VMPageSize > next_page && next_page < new_brk && p->pTable->translate(next_page)) { size_needed = VMPageSize - size_needed; - tp->memsetBlob(next_page, zero, size_needed); + tp.memsetBlob(next_page, zero, size_needed); } } } @@ -358,7 +358,7 @@ readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) return (TheISA::IntReg)-EFAULT; // Adjust path for current working directory @@ -382,7 +382,7 @@ unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) return (TheISA::IntReg)-EFAULT; // Adjust path for current working directory @@ -399,7 +399,7 @@ mkdirFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) return (TheISA::IntReg)-EFAULT; // Adjust path for current working directory @@ -417,12 +417,12 @@ renameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string old_name; int index = 0; - if (!tc->getMemProxy()->tryReadString(old_name, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(old_name, p->getSyscallArg(tc, index))) return -EFAULT; string new_name; - if (!tc->getMemProxy()->tryReadString(new_name, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(new_name, p->getSyscallArg(tc, index))) return -EFAULT; // Adjust path for current working directory @@ -439,7 +439,7 @@ truncateFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; off_t length = p->getSyscallArg(tc, index); @@ -474,7 +474,7 @@ truncate64Func(SyscallDesc *desc, int num, int index = 0; string path; - if (!tc->getMemProxy()->tryReadString(path, process->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) return -EFAULT; int64_t length = process->getSyscallArg(tc, index, 64); @@ -527,7 +527,7 @@ chownFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) string path; int index = 0; - if (!tc->getMemProxy()->tryReadString(path, p->getSyscallArg(tc, index))) + if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index))) return -EFAULT; /* XXX endianess */ |