| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title Os/Posix/DefaultCountingSemaphore.cpp | ||
| 3 | // \brief sets default Os::CountingSemaphore Posix implementation via linker | ||
| 4 | // ====================================================================== | ||
| 5 | #include "Os/Delegate.hpp" | ||
| 6 | #include "Os/Posix/CountingSemaphore.hpp" | ||
| 7 | |||
| 8 | namespace Os { | ||
| 9 | |||
| 10 | ✗ | CountingSemaphoreInterface* CountingSemaphoreInterface::getDelegate(CountingSemaphoreHandleStorage& aligned_new_memory, | |
| 11 | U32 initial_count) { | ||
| 12 | static_assert(std::is_base_of<CountingSemaphoreInterface, Os::Posix::Semaphore::PosixCountingSemaphore>::value, | ||
| 13 | "Implementation must derive from CountingSemaphoreInterface"); | ||
| 14 | static_assert(sizeof(Os::Posix::Semaphore::PosixCountingSemaphore) <= sizeof(CountingSemaphoreHandleStorage), | ||
| 15 | "Handle size not large enough"); | ||
| 16 | static_assert((FW_HANDLE_ALIGNMENT % alignof(Os::Posix::Semaphore::PosixCountingSemaphore)) == 0, | ||
| 17 | "Handle alignment invalid"); | ||
| 18 | ✗ | auto* ptr = new (aligned_new_memory) Os::Posix::Semaphore::PosixCountingSemaphore(initial_count); | |
| 19 | ✗ | FW_ASSERT(ptr != nullptr); | |
| 20 | ✗ | return ptr; | |
| 21 | } | ||
| 22 | } // namespace Os | ||
| 23 |