Repository navigation
Os: compile-time alias option for File, FileSystem, Directory, Console, CountingSemaphore, Cpu, and Memory (rebase of #5955) - #6318
Conversation
… Mutex, & ConditionVariable
This reverts commit 5f495b261c3c7cc69dd075db45c2df270ce371a3, reversing changes made to ae321743ed113ab34cc48a2abcd17b97581acf6c. Undoes the merge commit because fprime devel commit c103965 is breaking our build
… revert The Aug 19 "Revert Merge branch devel into multi-os-alias" undid a devel merge because fpp 3.3.0a17 broke the build. That issue was fixed upstream by 1fadfda (bump to stable fpp 3.3.0), and both commits are already in devel's history, but the revert's content was never re-integrated. This commit fixes that (modifies about 170 non-Os files).
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Fw/DataStructures |
97.51 | -0.45 | 97.14 | +0.00 | 81.93 | -0.73 |
Os/Generic |
90.18 | -0.10 | 89.13 | +0.00 | 75.10 | -0.19 |
Os |
20.14 | +0.27 | 22.95 | +0.37 | 17.49 | +0.03 |
Os/Posix |
71.08 | +0.44 | 87.50 | +0.00 | 51.11 | +0.44 |
Svc/DpCatalog |
89.44 | +1.50 | 98.00 | +0.13 | 82.44 | +1.92 |
Svc/FprimeDeframer |
100.00 | +1.85 | 100.00 | +0.00 | 100.00 | +4.08 |
New modules
| Module | Line | Function | Branch |
|---|---|---|---|
Fw/Prm |
0.00 | 0.00 | 0.00 |
Modules without UTs
CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/Ports/DataTypes, Drv/PosixUartDriver, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Obj, Fw/Port, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, Svc/Ccsds/Utils, Svc/FatalHandler, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComCcsdsSdls, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Subtopologies/FileHandlingCfdp, Svc/Subtopologies/FileHandlingCfdp/FileHandlingCfdpConfig, TestDeploymentsProject/Ref/DpDemo, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestConfigDeployment, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestDuplicateDirective, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestLinkDepends, cmake/test/data/TestDeployment/TestRelative, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
Resolves conflicts in Os/FileSystem.cpp (copyFile truncation fix nasa#6083 carried into FileSystemInterface.cpp), Os/docs/sdd.md and default/config/CMakeLists.txt; folds the seven config/OsDelegate<Service>.hpp headers into the consolidated config/OsSelection.hpp (nasa#6049); adds the Os/ConsoleInterface.cpp referenced by Os/CMakeLists.txt. Co-authored-by: M Starch <LeStarch@googlemail.com>
- DelegateFile::open(path, mode, overwrite): drop the re-applied FileNameStringSize bound so length-validated callers (Fw::String paths up to capacity) keep the devel behaviour - PosixFile::operator=: copy the FileInterface base (m_mode) like the copy constructor does - DelegateConsole: un-hide ConsoleInterface::writeMessage(const Fw::ConstStringBase&) - Docs: complete 10-service OsSelection.hpp override example, point the TIP at FileInterface.hpp, correct the SDD static-wrapper sentence, note the override must define every alias/macro, document the FW_FILE_HANDLE_MAX_SIZE sizing Co-authored-by: M Starch <LeStarch@googlemail.com>
- PosixDirectory, PosixConsole, StubConsole: un-hide the base read()/writeMessage() string overloads (matches StubDirectory/DelegateDirectory/DelegateConsole) - DelegateConsole: move the using-declaration out of the writeMessage Doxygen block - DelegateFile.cpp: drop the now-unused StringUtils include; DelegateFileSystem: drop the unused friend declaration - Aggregator headers: correct the "included only by <Service>Interface.hpp" comment - FileInterface.hpp: document that the 3-argument open() is the implementation hook and applies no length bound (use a length overload for unterminated buffers) - OsSelection.hpp / SDD: spell out the extra obligations of a direct alias (singleton init()/getSingleton(), File CRC methods and open/closed guards; Console statics are not on the interface) Co-authored-by: M Starch <LeStarch@googlemail.com>
- Aggregator headers: state that config/OsSelection.hpp is included via Os/<Service>Interface.hpp - Posix/Stub Console, Posix Directory: place the using-declarations ahead of the Doxygen blocks - FileInterface.hpp: the 4-argument open() validates and delegates to the 3-argument hook Co-authored-by: M Starch <LeStarch@googlemail.com>
…or pointer-handle implementations - Os/<Service>.hpp aggregators fall back to the link-time Delegate<Service> when a project config/OsSelection.hpp predates the new selection and defines neither the alias nor OS_<SERVICE>_HEADER (fixes the Vorago CI build, whose override selects only RawTime/Mutex/ ConditionVariable) - FW_FILE_HANDLE_MAX_SIZE 16 -> 24: FileInterface::m_mode pushes pointer-handle File implementations (Zephyr) past the previous budget (fixes the Zephyr CI static_assert) Co-authored-by: M Starch <LeStarch@googlemail.com>
4d6c813 to
4ed2684
Compare
Co-authored-by: M Starch <LeStarch@googlemail.com>
Os/test/utsuites exercise every service through the default delegate aliases; no new behaviour was added)Os/docs/sdd.md,docs/how-to/integrate/implement-osal.md,default/config/OsSelection.hppcomments)Change Description
Continuation of #5955 (@bevinduckett's branch, all of her commits preserved;
develmerged in by the autobot and review follow-ups added on top — same merge-based flow the original branch used). It extends the compile-time alias mechanism introduced forOs::RawTime(#5617) andOs::Mutex/Os::ConditionVariable(#5936) to the remaining simple OSAL services: File, FileSystem, Directory, Console, CountingSemaphore, Cpu and Memory.For each service, formulaically:
Os/<Service>.hppbecomes a thin aggregator: includesOs/<Service>Interface.hpp, then#include OS_<SERVICE>_HEADER.Os/Delegate<Service>.{hpp,cpp}(link-time delegate, unchanged behaviour) and remains the default viausing <Service> = Delegate<Service>;.open(...)overloads,read(Fw::StringBase&), static singleton wrappers, etc.) move onto<Service>Interfaceso a direct alias inherits them.OS_*_HEADERmacros live in the consolidateddefault/config/OsSelection.hpp(Os: consolidate selection config headers into config/OsSelection.hpp #6049); the per-serviceconfig/OsDelegate<Service>.hppheaders from the original PR were dropped during the rebase.Compatibility: a project
config/OsSelection.hppwritten before this PR (e.g. fprime-vorago's, which selects only RawTime/Mutex/ConditionVariable) defines neither the new aliases nor theOS_*_HEADERmacros; each new aggregator falls back to the link-time delegate in that case instead of#error-ing, so existing overrides keep building.FW_FILE_HANDLE_MAX_SIZEis bumped 16 → 24 becauseFileInterface::m_modepushes pointer-handle implementations (fprime-zephyr) past the old budget.Rebase adaptations beyond the original PR: upstream's
FileSystem::copyFiletruncation fix (#6083) is carried intoFileSystemInterface.cpp; the missingOs/ConsoleInterface.cppreferenced byOs/CMakeLists.txtwas added;FW_DIRECTORY_HANDLE_MAX_SIZEis bumped 16 → 32 with a sizing comment (the open-state flag moved ontoDirectoryInterface, originally part of #5955).Migration note for projects that override
PlatformCfg.fpp:FW_DIRECTORY_HANDLE_MAX_SIZEmust be ≥ 24 (default now 32) andFW_FILE_HANDLE_MAX_SIZE≥ 24 for pointer-handleFileimplementations (default now 24); the open state formerly held by theOs::File/Os::Directorywrappers now lives on the interface classes and is counted inside the handle budget. Companionpr-6318branches on fprime-vorago-reference and fprime-zephyr-reference carry that bump for CI.Rationale
Projects targeting bare-metal / small-RAM platforms (see #5249) can alias
Os::Fileetc. directly to their implementation and avoid the delegate indirection and handle storage, while every existing build keeps the link-time delegate behaviour by default.Testing/Review Recommendations
CI is green with companion branches
pr-6318on fprime-community/fprime-vorago-reference and fprime-community/fprime-zephyr-reference (handle-size bumps; the Vorago one also pins Os/Baremetal/File: copy the FileInterface base in the copy constructor and operator= fprime-community/fprime-baremetal#60, a one-lineFileInterface(other)copy-constructor fix). Merge those alongside this PR.fprime-util build,fprime-util build --ut+ctest(133/133 pass),TestDeploymentsProject/Refbuild andRef/test/intpytest suite against the GDS all pass on the rebased head; FileManager/PrmDb file operations exercised manually through the GDS.The change is large but repetitive; reviewing one service end-to-end (e.g.
Os/File.hpp→Os/FileInterface.hpp→Os/DelegateFile.hpp/.cpp→OsSelection.hpp) and then diffing the pattern across the others is the quickest route.Behavioural note for reviewers: the virtual 3-argument
open(path, mode, overwrite)is now both a public overload and the implementation hook; it applies no length bound (documented onFileInterface.hpp). Thelength/Fw::ConstStringBaseoverloads validate as before.An iterative local multi-agent review (security, correctness, supply-chain, design, operational-consequences, F´ C++ design, stale-documentation, architecture, test-quality, maintainability lenses) was run across three iterations; all must-fix findings were resolved. Residual acknowledged items are listed under Future Work.
Future Work
Os::Filealias need not re-implementcalculateCrc/incrementalCrc/finalizeCrc.static_assert(std::is_base_of<...>)in the aggregator headers to enforce the "MUST derive from the interface" rule at compile time.File::openso the public 3-argument overload could regain a path bound.Consolebackend; in-tree tests cover only the default delegate aliases.Contributor Checklist
AI Usage (see policy)
AI (Devin, operated by @LeStarch) merged
develinto #5955's branch, resolved the conflicts, adapted the PR to the consolidatedconfig/OsSelection.hpp, fixed the build, ran the unit/integration/manual tests, and ran a local-only multi-agent review loop whose findings were triaged and fixed with minimal, repeated edits only. Original design and implementation by @bevinduckett.AGENTS.md).IAMAI