fix(libc): format %p as FreeBSD does on Windows #3393

Merged
LeandroLP23 merged 2 commits from upstream-pr/3393 into main 2026-10-11 09:58:03 +00:00
LeandroLP23 commented 2026-10-11 09:40:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T09:40:54Z.


Carrying @husseinkad's fix for #3111 (they can't open PRs yet). The change is theirs: 37a1b95a and f5991134 cherry-picked onto main without conflicts, authorship kept.

What

On Windows the printf family formats %p with the host's rules, a zero-padded 16-digit value without 0x. It now follows FreeBSD (0x plus the hex digits, flags, width and precision as FreeBSD's vfprintf applies them) in both the narrow and the wide formatters; Linux keeps glibc's %p, recorded in TechnicalDebt. Details, including the 2.8 million-call comparison against FreeBSD's algorithm, in #3111.

Tested

Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, on main f8d8ae52: guest_formatting and guest_wide_formatting pass 3/3 and fail with main's formatting code; ctest -E agc_ 445/445 apart from one guest_ampr_markers run that hit a guest arena overlap in the parallel run and passes 3/3 alone; conventions pass.

Fork CI (run): Windows and the three relinker jobs pass. Linux fails agc_driver_image_plane_address_on_line_implicit_lod and guest_kernel_stack_protect, the same two in all three runs of this batch (#3111, #3076 and #3097 fixes, unrelated changes), so they come from main.

Fixes #3111

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code, for carrying, the conflict resolution and the Windows run; see the issue for the author's disclosure)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818121168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3393). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-11T09:40:54Z. --- Carrying @husseinkad's fix for #3111 (they can't open PRs yet). The change is theirs: `37a1b95a` and `f5991134` cherry-picked onto `main` without conflicts, authorship kept. ### What On Windows the printf family formats `%p` with the host's rules, a zero-padded 16-digit value without `0x`. It now follows FreeBSD (`0x` plus the hex digits, flags, width and precision as FreeBSD's `vfprintf` applies them) in both the narrow and the wide formatters; Linux keeps glibc's `%p`, recorded in TechnicalDebt. Details, including the 2.8 million-call comparison against FreeBSD's algorithm, in #3111. ### Tested Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, on `main` f8d8ae52: `guest_formatting` and `guest_wide_formatting` pass 3/3 and fail with `main`'s formatting code; `ctest -E agc_` 445/445 apart from one `guest_ampr_markers` run that hit a guest arena overlap in the parallel run and passes 3/3 alone; conventions pass. Fork CI ([run](https://github.com/LeandroLP23/AnyPS5/actions/runs/38126967372)): Windows and the three relinker jobs pass. Linux fails `agc_driver_image_plane_address_on_line_implicit_lod` and `guest_kernel_stack_protect`, the same two in all three runs of this batch (#3111, #3076 and #3097 fixes, unrelated changes), so they come from `main`. Fixes #3111 ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Claude Code, for carrying, the conflict resolution and the Windows run; see the issue for the author's disclosure)
adriadam10 commented 2026-10-11 09:58:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:58:01Z.


Checked FormatPointer against FreeBSD vfprintf.c (case 'p': unconditional 0x, +/space/# ignored, 0 ignored with a precision, width counts the prefix, %.0p of NULL prints 0x): matches. Built and ran libc/libs ctest on Linux (72/72); guest_wide_formatting fails without the change. The narrow Windows branch is covered by your Windows run only. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107808916 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3393#issuecomment-6107808916). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T09:58:01Z. --- Checked `FormatPointer` against FreeBSD `vfprintf.c` (`case 'p'`: unconditional `0x`, `+`/space/`#` ignored, `0` ignored with a precision, width counts the prefix, `%.0p` of NULL prints `0x`): matches. Built and ran libc/libs ctest on Linux (72/72); `guest_wide_formatting` fails without the change. The narrow Windows branch is covered by your Windows run only. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!3393
No description provided.