fix(libc): implement openlog and closelog state #5048

Merged
MarcZX10 merged 3 commits from upstream-pr/5048 into main 2026-10-13 12:18:32 +00:00
MarcZX10 commented 2026-10-13 09:38:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T09:38:36Z.


What

Implement the openlog and closelog libc exports for the existing stderr-backed syslog implementation. openlog now stores the identity and options, applies LOG_PID, and selects a valid nonzero default facility for messages without an explicit facility. A null identity retains the previous value. closelog clears the identity while retaining options and facility, following FreeBSD 11 behavior. The TechnicalDebt entry documents options that cannot affect this backend because it has no syslog daemon, child-wait, or console sink.

Tested

  • Linux, GCC 12.2: compiled the changed Syslog.cpp with the repository's GuestSyslog.cpp regression test and minimal shims for host libc dependencies; the test passed.
  • Linux GCC 12.2 and MinGW-w64 GCC: changed source and test passed -std=c++20 -Wall -Wextra -Werror -fsyntax-only.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD passed.
  • git diff --check passed.
  • Full project CMake configuration could not run in this environment because SDL2 development files are unavailable; no title or full project build was run.

Checklist

  • Based on current main; no other open PR implements these 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 under Silent stubs in the library's technical debt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4841294349 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T09:38:36Z. --- ### What Implement the `openlog` and `closelog` libc exports for the existing stderr-backed syslog implementation. `openlog` now stores the identity and options, applies `LOG_PID`, and selects a valid nonzero default facility for messages without an explicit facility. A null identity retains the previous value. `closelog` clears the identity while retaining options and facility, following FreeBSD 11 behavior. The TechnicalDebt entry documents options that cannot affect this backend because it has no syslog daemon, child-wait, or console sink. ### Tested - Linux, GCC 12.2: compiled the changed `Syslog.cpp` with the repository's `GuestSyslog.cpp` regression test and minimal shims for host libc dependencies; the test passed. - Linux GCC 12.2 and MinGW-w64 GCC: changed source and test passed `-std=c++20 -Wall -Wextra -Werror -fsyntax-only`. - `python3 tools/check_conventions.py --base upstream/main --head HEAD` passed. - `git diff --check` passed. - Full project CMake configuration could not run in this environment because SDL2 development files are unavailable; no title or full project build was run. ### Checklist - [x] Based on current `main`; no other open PR implements these 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 under Silent stubs in the library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-13 09:40:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:40:08Z.

Review: CHANGES_REQUESTED


openlog/closelog match FreeBSD 11's openlog_unlocked/closelog (null ident keeps the tag, only a nonzero valid facility replaces the default, closelog clears only the tag). One thing left:

  • docs/dev/debt/libc.md:60: FreeBSD's vsyslog falls back to getprogname() as the tag when none is set (lib/libc/gen/syslog.c, LogTag == NULL branch), including after closelog. This backend emits no tag in that case. Please add that to the syslog debt line.

Once that is in and the Build workflow is green I'll merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5501616314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#pullrequestreview-5501616314). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T09:40:08Z. **Review:** CHANGES_REQUESTED --- `openlog`/`closelog` match FreeBSD 11's `openlog_unlocked`/`closelog` (null ident keeps the tag, only a nonzero valid facility replaces the default, `closelog` clears only the tag). One thing left: - `docs/dev/debt/libc.md:60`: FreeBSD's `vsyslog` falls back to `getprogname()` as the tag when none is set (`lib/libc/gen/syslog.c`, `LogTag == NULL` branch), including after `closelog`. This backend emits no tag in that case. Please add that to the syslog debt line. Once that is in and the Build workflow is green I'll merge.
github-actions[bot] commented 2026-10-13 09:42:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T09:42:06Z.


Progress report (77b9f72 → 81f727c)

➖ System libraries: 88.41% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
libc closelog_nid_postfix
libc openlog_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142759382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#issuecomment-6142759382). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T09:42:06Z. --- <!-- progress-report --> ### Progress report (77b9f72 → 81f727c) ➖ **System libraries**: 88.41% (+0.0%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `closelog_nid_postfix` | | libc | `openlog_nid_postfix` | </details>
MarcZX10 commented 2026-10-13 09:42:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T09:42:32Z.


Added the documented limitation that FreeBSD falls back to the program name when no identity is set, while this stderr-backed implementation emits no tag. Pushed as 04f7f528c.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142766780 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#issuecomment-6142766780). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T09:42:32Z. --- Added the documented limitation that FreeBSD falls back to the program name when no identity is set, while this stderr-backed implementation emits no tag. Pushed as `04f7f528c`.
MarcZX10 commented 2026-10-13 09:50:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T09:50:03Z.


Rebased onto current main (bb9a4d8a2) and reran the Linux syslog regression harness, Linux/MinGW syntax checks, conventions, and diff checks successfully. I also corrected the regression's LOG_PID expectation when no identity is set. New head: e4716bcaf.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6142893751 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#issuecomment-6142893751). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T09:50:03Z. --- Rebased onto current `main` (`bb9a4d8a2`) and reran the Linux syslog regression harness, Linux/MinGW syntax checks, conventions, and diff checks successfully. I also corrected the regression's `LOG_PID` expectation when no identity is set. New head: `e4716bcaf`.
MarcZX10 commented 2026-10-13 09:57:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T09:57:12Z.


Rebased onto current main 77b9f7270 after the previous Build matrix passed. On the rebased head 81f727c05, the Linux syslog regression harness passes, Linux and MinGW -Wall -Wextra -Werror syntax checks pass, and conventions/diff checks pass locally. Hosted checks for this new head have started; the reviewer’s requested getprogname() fallback limitation remains documented in the libc debt entry.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6143014750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#issuecomment-6143014750). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T09:57:12Z. --- Rebased onto current main `77b9f7270` after the previous Build matrix passed. On the rebased head `81f727c05`, the Linux syslog regression harness passes, Linux and MinGW `-Wall -Wextra -Werror` syntax checks pass, and conventions/diff checks pass locally. Hosted checks for this new head have started; the reviewer’s requested `getprogname()` fallback limitation remains documented in the libc debt entry.
MarcZX10 commented 2026-10-13 10:18:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T10:18:36Z.


The getprogname() fallback limitation is now recorded in docs/dev/debt/libc.md, and the latest head (81f727c05) has passed every applicable Build job, including the Linux/macOS/Windows relinker matrix and register-context checks. The full Linux and Windows build jobs were skipped by the workflow path filter. Could you take another look when convenient?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6143377106 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#issuecomment-6143377106). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T10:18:36Z. --- The `getprogname()` fallback limitation is now recorded in `docs/dev/debt/libc.md`, and the latest head (`81f727c05`) has passed every applicable Build job, including the Linux/macOS/Windows relinker matrix and register-context checks. The full Linux and Windows build jobs were skipped by the workflow path filter. Could you take another look when convenient?
adriadam10 commented 2026-10-13 10:49:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T10:49:40Z.

Review: APPROVED


Checked openlog/closelog/vsyslog against FreeBSD 11 syslog.c (null ident keeps the tag, only a nonzero valid facility replaces the default, closelog clears only the tag), ran guest_syslog locally (passes with the change, fails to link without it), and the getprogname() fallback is now in the debt line. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5502385275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5048#pullrequestreview-5502385275). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T10:49:40Z. **Review:** APPROVED --- Checked `openlog`/`closelog`/`vsyslog` against FreeBSD 11 `syslog.c` (null ident keeps the tag, only a nonzero valid facility replaces the default, `closelog` clears only the tag), ran `guest_syslog` locally (passes with the change, fails to link without it), and the `getprogname()` fallback is now in the debt line. Merging once the full Build is green.
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!5048
No description provided.