refactor(libc): call atomic_signal_fence from _Atomic_signal_fence #10569
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10569"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:21:55Z.
What
Makes
_Atomic_signal_fence_nid_postfixcallstd::atomic_signal_fencefor valid memory orders, as the Microsoft STL body at pinned commitb6f01e438b68ee497f9c08313e49d12bb2f0d8e0does; invalid integer orders are ignored. There is no observable behaviour change. The export is an out-of-line function, so the call boundary is what gives a guest its ordering, and the compiled body is areteither way (reported on the PR from a Windows build withobjdump). The test now calls the export with every order from relaxed through sequentially consistent instead of only sequentially consistent; it passes onmain's body too and is a smoke check, not a regression test for a behaviour. PS5 behavior is not directly verified.Tested
Debian Linux, GCC 12.2.0: compiled
DinkumwareAtomics.cppwithGuestDinkumwareAtomics.cppusing C++20,-O2and pthreads, then ran the focused test successfully. The test invokes every memory order value from relaxed through sequentially consistent.objdumpof the wrapper showed no hardware fence instruction.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpassed. The full project build, Windows, and PS5 hardware were not tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T12:28:37Z.
Review: COMMENTED
Checked against main
87666fc5d6and Microsoft STL b6f01e43 (stl/inc/atomic):_Atomic_signal_fence_nid_postfixas an empty function (DinkumwareAtomics.cpp:146, fromec3fe412db), and I think that body is already correct. A signal fence is only a compiler barrier, and when the guest calls an out-of-line libc.prx export, the call itself is that barrier: the guest's compiler can't move escaping memory accesses across an opaque call. Inside the callee there are no loads or stores forstd::atomic_signal_fenceto order, so I'd expect the new body to compile to the same bareretas main. I didn't compile it to confirm, but your objdump finding no fence instruction is consistent with that.docs/dev/debt/libc.mdalready covers this file in the "Dinkumware atomics" entry under Unknown function info (line 33). The new Functional bullet duplicates it and says the function "orders compiler operations", which the callee can't do by itself. If a note is wanted, one sentence in the existing entry saying_Atomic_signal_fenceis a no-op because the call is the compiler barrier seems more accurate than a separate item.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-10T11:12:04Z.
Review: COMMENTED
Read
66685d4028againstmain.Correctness.
_Atomic_signal_fence_nid_postfixincore/libs/prx/libc/src/DinkumwareAtomics.cppnow callsstd::atomic_signal_fence(static_cast<std::memory_order>(order))whenIsValidOrder(order)holds (0 to 5, which match thestd::memory_orderenumerators). A signal fence is only a compiler barrier, and inside an out-of-line function with no surrounding memory accesses it compiles to nothing, so the export behaves exactly asmain's empty body for every input, valid or not. The PR body says this plainly; the change is correct and harmless.Test. The loop over orders 0 to 5 in
CheckFlagsAndFences(core/libs/tests/GuestDinkumwareAtomics.cpp) passes onmaintoo, as the body states; there is no observable behaviour for a test to pin, so this is a smoke call, not a regression test.Debt. The new
libc.mdentry records no gap: it describes an implementation detail of a no-op whose result is the same as before. Sincedocs/dev/debtis for known gaps, consider dropping it, or reduce it to the one open point (PS5 behaviour not verified) if that is worth tracking at all.Non-blocking.
#include <atomic>is appended after<cstring>, out of the alphabetical order of the other standard headers in that block.Not run here; this is from reading the code.
AI-assisted: yes.
Pull request closed