changeset cafae9abd4e4 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=cafae9abd4e4
description:
        style: change Process function calls to use camelCase

        The Process class methods were using an improper style and this 
subsequently
        bled into the system call code.  The following regular expressions 
should be
        helpful if someone transitions private system call patches on top of 
these
        changesets:

        s/alloc_fd/allocFD/
        s/sim_fd(/simFD(/
        s/sim_fd_obj/getFDEntry/
        s/fix_file_offsets/fixFileOffsets/
        s/find_file_offsets/findFileOffsets/

diffstat:

 src/kern/tru64/tru64.hh |   2 +-
 src/sim/process.cc      |  52 +++++++++++++++++++++++++-----------------------
 src/sim/process.hh      |  18 ++++++++--------
 src/sim/syscall_emul.cc |  32 +++++++++++++++---------------
 src/sim/syscall_emul.hh |  16 +++++++-------
 5 files changed, 61 insertions(+), 59 deletions(-)

diffs (truncated from 466 to 300 lines):

diff -r 42d846318962 -r cafae9abd4e4 src/kern/tru64/tru64.hh
--- a/src/kern/tru64/tru64.hh   Fri Jul 24 12:25:23 2015 -0700
+++ b/src/kern/tru64/tru64.hh   Fri Jul 24 12:25:23 2015 -0700
@@ -438,7 +438,7 @@
         panic("getdirent not implemented on cygwin!");
 #else
         int index = 0;
-        int fd = process->sim_fd(process->getSyscallArg(tc, index));
+        int fd = process->getSimFD(process->getSyscallArg(tc, index));
         Addr tgt_buf = process->getSyscallArg(tc, index);
         int tgt_nbytes = process->getSyscallArg(tc, index);
         Addr tgt_basep = process->getSyscallArg(tc, index);
diff -r 42d846318962 -r cafae9abd4e4 src/sim/process.cc
--- a/src/sim/process.cc        Fri Jul 24 12:25:23 2015 -0700
+++ b/src/sim/process.cc        Fri Jul 24 12:25:23 2015 -0700
@@ -95,6 +95,7 @@
 int num_processes = 0;
 
 template<class IntType>
+
 AuxVector<IntType>::AuxVector(IntType type, IntType val)
 {
     a_type = TheISA::htog(type);
@@ -153,7 +154,7 @@
 
     // Search through the input options and set fd if match is found;
     // otherwise, open an input file and seek to location.
-    FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
     if ((it = imap.find(params->input)) != imap.end())
         sim_fd = it->second;
     else
@@ -162,7 +163,7 @@
 
     // Search through the output/error options and set fd if match is found;
     // otherwise, open an output file and seek to location.
-    FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
     if ((it = oemap.find(params->output)) != oemap.end())
         sim_fd = it->second;
     else
@@ -170,7 +171,7 @@
     fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
                     0664, false);
 
-    FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
     if (params->output == params->errout)
         // Reuse the same file descriptor if these match.
         sim_fd = fde_stdout->fd;
@@ -199,7 +200,7 @@
 }
 
 void
-Process::inheritFdArray(Process *p)
+Process::inheritFDArray(Process *p)
 {
     fd_array = p->fd_array;
 }
@@ -233,19 +234,19 @@
 DrainState
 Process::drain()
 {
-    find_file_offsets();
+    findFileOffsets();
     return DrainState::Drained;
 }
 
 int
-Process::alloc_fd(int sim_fd, const string& filename, int flags, int mode,
-                  bool pipe)
+Process::allocFD(int sim_fd, const string& filename, int flags, int mode,
+                 bool pipe)
 {
     if (sim_fd == -1)
         return -1;
 
     for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
-        FDEntry *fde = get_fd_entry(free_fd);
+        FDEntry *fde = getFDEntry(free_fd);
         if (fde->isFree()) {
             fde->set(sim_fd, filename, flags, mode, pipe);
             return free_fd;
@@ -256,30 +257,30 @@
 }
 
 void
-Process::reset_fd_entry(int tgt_fd)
+Process::resetFDEntry(int tgt_fd)
 {
-    FDEntry *fde = get_fd_entry(tgt_fd);
+    FDEntry *fde = getFDEntry(tgt_fd);
     assert(fde->fd > -1);
 
     fde->reset();
 }
 
 int
-Process::sim_fd(int tgt_fd)
+Process::getSimFD(int tgt_fd)
 {
-    FDEntry *entry = get_fd_entry(tgt_fd);
+    FDEntry *entry = getFDEntry(tgt_fd);
     return entry ? entry->fd : -1;
 }
 
 FDEntry *
-Process::get_fd_entry(int tgt_fd)
+Process::getFDEntry(int tgt_fd)
 {
     assert(0 <= tgt_fd && tgt_fd < fd_array->size());
     return &(*fd_array)[tgt_fd];
 }
 
 int
-Process::tgt_fd(int sim_fd)
+Process::getTgtFD(int sim_fd)
 {
     for (int index = 0; index < fd_array->size(); index++)
         if ((*fd_array)[index].fd == sim_fd)
@@ -321,7 +322,7 @@
 }
 
 void
-Process::fix_file_offsets()
+Process::fixFileOffsets()
 {
     auto seek = [] (FDEntry *fde)
     {
@@ -333,7 +334,7 @@
 
     // Search through the input options and set fd if match is found;
     // otherwise, open an input file and seek to location.
-    FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
     if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
         fde_stdin->fd = it->second;
     } else {
@@ -343,7 +344,7 @@
 
     // Search through the output/error options and set fd if match is found;
     // otherwise, open an output file and seek to location.
-    FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
     if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
         fde_stdout->fd = it->second;
     } else {
@@ -351,7 +352,7 @@
         seek(fde_stdout);
     }
 
-    FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
     if (fde_stdout->filename == fde_stderr->filename) {
         // Reuse the same file descriptor if these match.
         fde_stderr->fd = fde_stdout->fd;
@@ -363,7 +364,7 @@
     }
 
     for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
-        FDEntry *fde = get_fd_entry(tgt_fd);
+        FDEntry *fde = getFDEntry(tgt_fd);
         if (fde->fd == -1)
             continue;
 
@@ -378,8 +379,9 @@
 
             fde->fd = fds[0];
 
-            FDEntry *fde_write = get_fd_entry(fde->readPipeSource);
-            assert(fde_write->filename == "PIPE-WRITE");
+            FDEntry *fde_write = getFDEntry(fde->readPipeSource);
+            assert(
+                    fde_write->filename == "PIPE-WRITE");
             fde_write->fd = fds[1];
         } else {
             fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
@@ -389,7 +391,7 @@
 }
 
 void
-Process::find_file_offsets()
+Process::findFileOffsets()
 {
     for (auto& fde : *fd_array) {
         if (fde.fd != -1)
@@ -400,7 +402,7 @@
 void
 Process::setReadPipeSource(int read_pipe_fd, int source_fd)
 {
-    FDEntry *fde = get_fd_entry(read_pipe_fd);
+    FDEntry *fde = getFDEntry(read_pipe_fd);
     assert(source_fd >= -1);
     fde->readPipeSource = source_fd;
 }
@@ -439,10 +441,10 @@
     UNSERIALIZE_SCALAR(nxm_end);
     pTable->unserialize(cp);
     for (int x = 0; x < fd_array->size(); x++) {
-        FDEntry *fde = get_fd_entry(x);
+        FDEntry *fde = getFDEntry(x);
         fde->unserializeSection(cp, csprintf("FDEntry%d", x));
     }
-    fix_file_offsets();
+    fixFileOffsets();
     UNSERIALIZE_OPT_SCALAR(M5_pid);
     // The above returns a bool so that you could do something if you don't
     // find the param in the checkpoint if you wanted to, like set a default
diff -r 42d846318962 -r cafae9abd4e4 src/sim/process.hh
--- a/src/sim/process.hh        Fri Jul 24 12:25:23 2015 -0700
+++ b/src/sim/process.hh        Fri Jul 24 12:25:23 2015 -0700
@@ -153,7 +153,7 @@
 
   public:
     // inherit file descriptor map from another process (necessary for clone)
-    void inheritFdArray(Process *p);
+    void inheritFDArray(Process *p);
 
     // override of virtual SimObject method: register statistics
     virtual void regStats();
@@ -172,30 +172,30 @@
     virtual const char *progName() const { return "<unknown>"; }
 
     // generate new target fd for sim_fd
-    int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode,
-                 bool pipe);
+    int allocFD(int sim_fd, const std::string& filename, int flags, int mode,
+                bool pipe);
 
     // disassociate target fd with simulator fd and cleanup subsidiary fields
-    void reset_fd_entry(int tgt_fd);
+    void resetFDEntry(int tgt_fd);
 
     // look up simulator fd for given target fd
-    int sim_fd(int tgt_fd);
+    int getSimFD(int tgt_fd);
 
     // look up fd entry for a given target fd
-    FDEntry *get_fd_entry(int tgt_fd);
+    FDEntry *getFDEntry(int tgt_fd);
 
     // look up target fd for given host fd
     // Assumes a 1:1 mapping between target file descriptor and host file
     // descriptor. Given the current API, this must be true given that it's
     // not possible to map multiple target file descriptors to the same host
     // file descriptor
-    int tgt_fd(int sim_fd);
+    int getTgtFD(int sim_fd);
 
     // fix all offsets for currently open files and save them
-    void fix_file_offsets();
+    void fixFileOffsets();
 
     // find all offsets for currently open files and save them
-    void find_file_offsets();
+    void findFileOffsets();
 
     // set the source of this read pipe for a checkpoint resume
     void setReadPipeSource(int read_pipe_fd, int source_fd);
diff -r 42d846318962 -r cafae9abd4e4 src/sim/syscall_emul.cc
--- a/src/sim/syscall_emul.cc   Fri Jul 24 12:25:23 2015 -0700
+++ b/src/sim/syscall_emul.cc   Fri Jul 24 12:25:23 2015 -0700
@@ -212,7 +212,7 @@
     int index = 0;
     int tgt_fd = p->getSyscallArg(tc, index);
 
-    int sim_fd = p->sim_fd(tgt_fd);
+    int sim_fd = p->getSimFD(tgt_fd);
     if (sim_fd < 0)
         return -EBADF;
 
@@ -220,7 +220,7 @@
     if (sim_fd > 2)
         status = close(sim_fd);
     if (status >= 0)
-        p->reset_fd_entry(tgt_fd);
+        p->resetFDEntry(tgt_fd);
     return status;
 }
 
@@ -234,7 +234,7 @@
     int nbytes = p->getSyscallArg(tc, index);
     BufferArg bufArg(bufPtr, nbytes);
 
-    int sim_fd = p->sim_fd(tgt_fd);
+    int sim_fd = p->getSimFD(tgt_fd);
     if (sim_fd < 0)
         return -EBADF;
 
@@ -255,7 +255,7 @@
     int nbytes = p->getSyscallArg(tc, index);
     BufferArg bufArg(bufPtr, nbytes);
 
-    int sim_fd = p->sim_fd(tgt_fd);
+    int sim_fd = p->getSimFD(tgt_fd);
     if (sim_fd < 0)
         return -EBADF;
 
@@ -277,7 +277,7 @@
     uint64_t offs = p->getSyscallArg(tc, index);
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to