From aa56ed4dc50255869e72b9399c671c21d88e88d4 Mon Sep 17 00:00:00 2001 From: Brandon Potter Date: Wed, 18 Apr 2018 14:42:31 -0400 Subject: syscall_emul: style changes and FDArray refactor Some members were defined as public when they should have been privately declared so these were moved to the appropriate spot. The operator[] had inline specified for for an in-class definition which is redundant since inline definitions are always implicitly inline. Private members had the leading underscore applied to them to denote that they're private (consistent with style guide). Changed static const defined class variable into a constexpr with brace-list initialization. Change-Id: If3054416b57827d1542e9ebab428d67d0e767723 Reviewed-on: https://gem5-review.googlesource.com/12110 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/sim/fd_array.hh | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/sim/fd_array.hh') diff --git a/src/sim/fd_array.hh b/src/sim/fd_array.hh index 70a7f47da..ac6c07f95 100644 --- a/src/sim/fd_array.hh +++ b/src/sim/fd_array.hh @@ -44,9 +44,6 @@ class FDArray { - private: - static const int NUM_FDS = 1024; - public: /** * Initialize the file descriptor array and set the standard file @@ -59,10 +56,6 @@ class FDArray FDArray(std::string const& input, std::string const& output, std::string const& errout); - std::string _input; - std::string _output; - std::string _errout; - /** * Figure out the file offsets for all currently open files and save them * the offsets during the calls to drain by the owning process. @@ -75,17 +68,30 @@ class FDArray */ void restoreFileOffsets(); + /** + * Put the pointer specified by fdep into the _fdArray entry indexed + * by tgt_fd. + * @param tgt_fd Use target file descriptors to index the array. + * @param fdep Incoming pointer used to set the entry pointed to by tgt_fd. + */ + void setFDEntry(int tgt_fd, std::shared_ptr fdep); + /** * Treat this object like a normal array in using the subscript operator * to pull entries out of it. * @param tgt_fd Use target file descriptors to index the array. */ - inline std::shared_ptr + std::shared_ptr operator[](int tgt_fd) { return getFDEntry(tgt_fd); } + /** + * Return the size of the _fdArray field + */ + int getSize() const { return _fdArray.size(); } + /** * Step through the file descriptor array and find the first available * entry which is denoted as being free by being a 'nullptr'. That file @@ -98,19 +104,6 @@ class FDArray */ int allocFD(std::shared_ptr fdp); - /** - * Return the size of the _fdArray field - */ - int getSize() const { return _fdArray.size(); } - - /** - * Put the pointer specified by fdep into the _fdArray entry indexed - * by tgt_fd. - * @param tgt_fd Use target file descriptors to index the array. - * @param fdep Incoming pointer used to set the entry pointed to by tgt_fd. - */ - void setFDEntry(int tgt_fd, std::shared_ptr fdep); - /** * Try to close the host file descriptor. If successful, set the * specified file descriptor entry object pointer to nullptr. @@ -141,7 +134,17 @@ class FDArray * Hold pointers to the file descriptor entries. The array size is * statically defined by the operating system. */ - std::array, NUM_FDS> _fdArray; + static constexpr size_t _numFDs {1024}; + std::array, _numFDs> _fdArray; + + /** + * Hold param strings passed from the Process class which indicate + * the filename for each of the corresponding files or some keyword + * indicating the use of standard file descriptors. + */ + std::string _input; + std::string _output; + std::string _errout; /** * Hold strings which represent the default values which are checked @@ -149,8 +152,8 @@ class FDArray * provided doesn't hit against these maps, then a file is opened on the * host instead of using the host's standard file descriptors. */ - std::map imap; - std::map oemap; + std::map _imap; + std::map _oemap; }; #endif // __FD_ARRAY_HH__ -- cgit v1.2.3