Skip to content

Commit

Permalink
Dup to fcntl (#3047)
Browse files Browse the repository at this point in the history
* Adding restrict_platform support for FPRIME_HAS_XYZ flags

* fcntl here is the equivalent of dup. Using fcntl because it's supported in VxWorks too

* Undoing regression

---------

Co-authored-by: Michael D Starch <Michael.D.Starch@jpl.nasa.gov>
Co-authored-by: M Starch <LeStarch@googlemail.com>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent b8a259f commit b40097e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
8 changes: 2 additions & 6 deletions Os/Posix/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,17 @@ static_assert(std::numeric_limits<FwSignedSizeType>::min() <= std::numeric_limit
"Minimum value of FwSizeType larger than the minimum value of ssize_t. Configure a larger type.");

//!\brief default copy constructor
#ifndef TGT_OS_TYPE_VXWORKS
PosixFile::PosixFile(const PosixFile& other) {
// Must properly duplicate the file handle
this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor);
this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0);
}
#endif

#ifndef TGT_OS_TYPE_VXWORKS
PosixFile& PosixFile::operator=(const PosixFile& other) {
if (this != &other) {
this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor);
this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0);
}
return *this;
}
#endif

PosixFile::Status PosixFile::open(const char* filepath,
PosixFile::Mode requested_mode,
Expand Down
18 changes: 2 additions & 16 deletions Os/Posix/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ class PosixFile : public FileInterface {
PosixFile() = default;

//! \brief copy constructor
#ifdef TGT_OS_TYPE_VXWORKS
// Adding this pound-if-define code to allow building VxWorks for POSIX.
// Better than the alternative of copying this entire file to the VxWorks repo
// and removing this line.
PosixFile(const PosixFile& other) = delete;
#else
PosixFile(const PosixFile& other);
#endif

//! \brief assignment operator that copies the internal representation
#ifdef TGT_OS_TYPE_VXWORKS
// Adding this pound-if-define code to allow building VxWorks for POSIX.
// Better than the alternative of copying this entire file to the VxWorks repo
// and removing this line.
PosixFile& operator=(const PosixFile& other) = delete;
#else

//! \brief assignment operator that copies the internal representation
PosixFile& operator=(const PosixFile& other);
#endif

//! \brief destructor
//!
Expand Down

0 comments on commit b40097e

Please sign in to comment.