Skip to content

Commit

Permalink
Fixing other cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Oct 9, 2024
1 parent 6707d3f commit e5e5074
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 264 deletions.
4 changes: 2 additions & 2 deletions Os/Console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace Os {
//!
//! \return result of placement new, must be equivalent to `aligned_placement_new_memory`
//!
static ConsoleInterface* getDelegate(HandleStorage& aligned_placement_new_memory, const ConsoleInterface* to_copy=nullptr);
static ConsoleInterface* getDelegate(ConsoleHandleStorage& aligned_placement_new_memory, const ConsoleInterface* to_copy=nullptr);
};

class Console : public ConsoleInterface, public Fw::Logger {
Expand Down Expand Up @@ -131,7 +131,7 @@ namespace Os {
// This section is used to store the implementation-defined console handle. To Os::Console and fprime, this type
// is opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store then handle
// in the byte-array here and set `handle` to that address for storage.
alignas(FW_HANDLE_ALIGNMENT) HandleStorage m_handle_storage; // Storage for the delegate
alignas(FW_HANDLE_ALIGNMENT) ConsoleHandleStorage m_handle_storage; // Storage for the delegate
ConsoleInterface &m_delegate; //!< Delegate for the real implementation
};
}
Expand Down
6 changes: 3 additions & 3 deletions Os/Delegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Delegate {
//! \tparam Implementation: implementation class of the delegate (e.g. PosixTask)
//! \param aligned_new_memory: memory to be filled via placement new call
//! \return pointer to implementation result of placement new
template <class Interface, class Implementation, class StorageType=HandleStorage>
template <class Interface, class Implementation, class StorageType>
inline Interface* makeDelegate(StorageType& aligned_new_memory) {
// Ensure prerequisites before performing placement new
static_assert(std::is_base_of<Interface, Implementation>::value, "Implementation must derive from Interface");
Expand Down Expand Up @@ -85,8 +85,8 @@ inline Interface* makeDelegate(StorageType& aligned_new_memory) {
//! \return pointer to implementation result of placement new
//! \param to_copy: pointer to Interface to be copied by copy constructor
//! \return pointer to implementation result of placement new
template <class Interface, class Implementation>
inline Interface* makeDelegate(HandleStorage& aligned_new_memory, const Interface* to_copy) {
template <class Interface, class Implementation, class StorageType>
inline Interface* makeDelegate(StorageType& aligned_new_memory, const Interface* to_copy) {
const Implementation* copy_me = reinterpret_cast<const Implementation*>(to_copy);
// Ensure prerequisites before performing placement new
static_assert(std::is_base_of<Interface, Implementation>::value, "Implementation must derive from Interface");
Expand Down
4 changes: 2 additions & 2 deletions Os/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace Os {
//!
//! \return result of placement new, must be equivalent to `aligned_placement_new_memory`
//!
static FileInterface* getDelegate(HandleStorage& aligned_placement_new_memory, const FileInterface* to_copy=nullptr);
static FileInterface* getDelegate(FileHandleStorage& aligned_placement_new_memory, const FileInterface* to_copy=nullptr);
};


Expand Down Expand Up @@ -503,7 +503,7 @@ namespace Os {
// opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store then handle in
// the byte-array here and set `handle` to that address for storage.
//
alignas(FW_HANDLE_ALIGNMENT) HandleStorage m_handle_storage; //!< Storage for aligned FileHandle data
alignas(FW_HANDLE_ALIGNMENT) FileHandleStorage m_handle_storage; //!< Storage for aligned FileHandle data
FileInterface& m_delegate; //!< Delegate for the real implementation
};
}
Expand Down
6 changes: 3 additions & 3 deletions Os/Mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MutexInterface {
virtual MutexHandle* getHandle() = 0;

//! \brief provide a pointer to a Mutex delegate object
static MutexInterface* getDelegate(HandleStorage& aligned_new_memory);
static MutexInterface* getDelegate(MutexHandleStorage& aligned_new_memory);

virtual Status take() = 0; //!< lock the mutex return status
virtual Status release() = 0; //!< unlock the mutex return status
Expand All @@ -67,8 +67,8 @@ class Mutex final : public MutexInterface {
// opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store then handle in
// the byte-array here and set `handle` to that address for storage.
//
alignas(FW_HANDLE_ALIGNMENT) HandleStorage m_handle_storage; //!< Mutex handle storage
MutexInterface& m_delegate; //!< Delegate for the real implementation
alignas(FW_HANDLE_ALIGNMENT) MutexHandleStorage m_handle_storage; //!< Mutex handle storage
MutexInterface& m_delegate; //!< Delegate for the real implementation
};
//! \brief locks a mutex within the current scope
//!
Expand Down
5 changes: 4 additions & 1 deletion Os/Os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

//! Storage type for OSAL handles
typedef U8 QueueHandleStorage[FW_QUEUE_HANDLE_MAX_SIZE];
typedef U8 HandleStorage[FW_HANDLE_MAX_SIZE];
typedef U8 ConsoleHandleStorage[FW_CONSOLE_HANDLE_MAX_SIZE];
typedef U8 MutexHandleStorage[FW_MUTEX_HANDLE_MAX_SIZE];
typedef U8 FileHandleStorage[FW_FILE_HANDLE_MAX_SIZE];
typedef U8 TaskHandleStorage[FW_TASK_HANDLE_MAX_SIZE];
typedef U8 DirectoryHandleStorage[FW_DIRECTORY_HANDLE_MAX_SIZE];
typedef U8 FileSystemHandleStorage[FW_FILESYSTEM_HANDLE_MAX_SIZE];
typedef U8 ConditionVariableHandleStorage[FW_CONDITION_VARIABLE_HANDLE_MAX_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion Os/Posix/DefaultConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Os/Delegate.hpp"

namespace Os {
ConsoleInterface* ConsoleInterface::getDelegate(HandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
ConsoleInterface* ConsoleInterface::getDelegate(ConsoleHandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
return Os::Delegate::makeDelegate<ConsoleInterface, Os::Posix::Console::PosixConsole>(aligned_new_memory, to_copy);
}
}
2 changes: 1 addition & 1 deletion Os/Posix/DefaultFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Os/Delegate.hpp"

namespace Os {
FileInterface* FileInterface::getDelegate(HandleStorage& aligned_new_memory, const FileInterface* to_copy) {
FileInterface* FileInterface::getDelegate(FileHandleStorage& aligned_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Os::Posix::File::PosixFile>(aligned_new_memory, to_copy);
}
FileSystemInterface* FileSystemInterface::getDelegate(FileSystemHandleStorage& aligned_new_memory) {
Expand Down
2 changes: 1 addition & 1 deletion Os/Posix/DefaultMutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Os {
//! \brief get a delegate for MutexInterface that intercepts calls for Posix
//! \param aligned_new_memory: aligned memory to fill
//! \return: pointer to delegate
MutexInterface *MutexInterface::getDelegate(HandleStorage& aligned_new_memory) {
MutexInterface *MutexInterface::getDelegate(MutexHandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<MutexInterface, Os::Posix::Mutex::PosixMutex>(
aligned_new_memory
);
Expand Down
2 changes: 1 addition & 1 deletion Os/Posix/DefaultTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Os {
return task_status;
}

TaskInterface* TaskInterface::getDelegate(HandleStorage& aligned_new_memory) {
TaskInterface* TaskInterface::getDelegate(TaskHandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<TaskInterface, Os::Posix::Task::PosixTask>(aligned_new_memory);
}

Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/DefaultConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Os/Delegate.hpp"

namespace Os {
ConsoleInterface* ConsoleInterface::getDelegate(HandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
ConsoleInterface* ConsoleInterface::getDelegate(ConsoleHandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
return Os::Delegate::makeDelegate<ConsoleInterface, Os::Stub::Console::StubConsole>(aligned_new_memory, to_copy);
}
}
2 changes: 1 addition & 1 deletion Os/Stub/DefaultFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Os {
//! \param aligned_new_memory: aligned memory to fill
//! \param to_copy: pointer to copy-constructor input
//! \return: pointer to delegate
FileInterface *FileInterface::getDelegate(HandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
FileInterface *FileInterface::getDelegate(FileHandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Os::Stub::File::StubFile>(
aligned_placement_new_memory, to_copy
);
Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/DefaultMutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Os {
//! \param aligned_new_memory: aligned memory to fill
//! \param to_copy: pointer to copy-constructor input
//! \return: pointer to delegate
MutexInterface *MutexInterface::getDelegate(HandleStorage& aligned_new_memory) {
MutexInterface *MutexInterface::getDelegate(MutexHandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<MutexInterface, Os::Stub::Mutex::StubMutex>(
aligned_new_memory
);
Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/DefaultTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Os {
return Os::Task::Status::UNKNOWN_ERROR;
}

TaskInterface* TaskInterface::getDelegate(HandleStorage& aligned_new_memory) {
TaskInterface* TaskInterface::getDelegate(TaskHandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<TaskInterface, Os::Stub::Task::StubTask>(aligned_new_memory);
}

Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/test/DefaultConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Os/Delegate.hpp"

namespace Os {
ConsoleInterface* ConsoleInterface::getDelegate(HandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
ConsoleInterface* ConsoleInterface::getDelegate(ConsoleHandleStorage& aligned_new_memory, const ConsoleInterface* to_copy) {
return Os::Delegate::makeDelegate<ConsoleInterface, Os::Stub::Console::Test::TestConsole>(aligned_new_memory, to_copy);
}
}
2 changes: 1 addition & 1 deletion Os/Stub/test/DefaultFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Os {
//! \param aligned_new_memory: aligned memory to fill
//! \param to_copy: pointer to copy-constructor input
//! \return: pointer to delegate
FileInterface *FileInterface::getDelegate(HandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
FileInterface *FileInterface::getDelegate(FileHandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Os::Stub::File::Test::TestFile>(
aligned_placement_new_memory, to_copy
);
Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/test/DefaultMutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Os {
//! \brief get a delegate for Mutex that intercepts calls for for stub test Mutex usage
//! \param aligned_new_memory: aligned memory to fill
//! \return: pointer to delegate
MutexInterface *MutexInterface::getDelegate(HandleStorage& aligned_placement_new_memory) {
MutexInterface *MutexInterface::getDelegate(MutexHandleStorage& aligned_placement_new_memory) {
return Os::Delegate::makeDelegate<MutexInterface, Os::Stub::Mutex::Test::TestMutex>(
aligned_placement_new_memory
);
Expand Down
2 changes: 1 addition & 1 deletion Os/Stub/test/DefaultTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Os {
return Os::Stub::Task::Test::StaticData::data.delayStatus;
}

TaskInterface* TaskInterface::getDelegate(HandleStorage& aligned_new_memory) {
TaskInterface* TaskInterface::getDelegate(TaskHandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<TaskInterface, Os::Stub::Task::Test::TestTask>(aligned_new_memory);
}

Expand Down
4 changes: 2 additions & 2 deletions Os/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace Os {
//!
//! \return result of placement new, must be equivalent to `aligned_placement_new_memory`
//!
static TaskInterface* getDelegate(HandleStorage& aligned_placement_new_memory);
static TaskInterface* getDelegate(TaskHandleStorage& aligned_placement_new_memory);

// =================
// Implementation functions (instance) to be supplied by the Os::TaskInterface children
Expand Down Expand Up @@ -349,7 +349,7 @@ namespace Os {
// opaque and thus normal allocation cannot be done. Instead, we allow the implementor to store then handle in
// the byte-array here and set `handle` to that address for storage.
//
alignas(FW_HANDLE_ALIGNMENT) HandleStorage m_handle_storage; //!< Storage for aligned FileHandle data
alignas(FW_HANDLE_ALIGNMENT) TaskHandleStorage m_handle_storage; //!< Storage for aligned FileHandle data
TaskInterface& m_delegate; //!< Delegate for the real implementation
};

Expand Down
2 changes: 1 addition & 1 deletion Svc/CmdSequencer/test/ut/CmdSequencerTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ namespace Os {
//! \param aligned_new_memory: aligned memory to fill
//! \param to_copy: pointer to copy-constructor input
//! \return: pointer to delegate
FileInterface *FileInterface::getDelegate(HandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
FileInterface *FileInterface::getDelegate(FileHandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Svc::CmdSequencerTester::Interceptor::PosixFileInterceptor>(
aligned_placement_new_memory, to_copy
);
Expand Down
2 changes: 1 addition & 1 deletion Svc/PrmDb/test/ut/PrmDbImplTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ namespace Os {
//! \param aligned_new_memory: aligned memory to fill
//! \param to_copy: pointer to copy-constructor input
//! \return: pointer to delegate
FileInterface *FileInterface::getDelegate(HandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
FileInterface *FileInterface::getDelegate(FileHandleStorage& aligned_placement_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Svc::PrmDbImplTester::PrmDbTestFile>(
aligned_placement_new_memory, to_copy
);
Expand Down
2 changes: 0 additions & 2 deletions Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/RateLimiter.cpp"
"${CMAKE_CURRENT_LIST_DIR}/TokenBucket.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LockGuard.cpp"
"${CMAKE_CURRENT_LIST_DIR}/CRCChecker.cpp"
)

Expand All @@ -16,7 +15,6 @@ set(MOD_DEPS
register_fprime_module()
set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/main.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/LockGuardTester.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/RateLimiterTester.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TokenBucketTester.cpp"
)
Expand Down
32 changes: 0 additions & 32 deletions Utils/LockGuard.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions Utils/LockGuard.hpp

This file was deleted.

Loading

0 comments on commit e5e5074

Please sign in to comment.