runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx (OLD-9816) #1104

Closed
leonida/mandy
ambroseautomation wants to merge 0 commits from carry/old-9816-sysinfo-shims into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

ambroseautomation commented 2026-11-24 18:33:31 +00:00

Claimed in the coordination issue as: OLD-9816 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140741518)

What and why

Carries forward old-pr/9816 (draft #88, original commit author piyonchu preserved; indexed in #17), rebased cleanly onto current main (71f99e224) without the stray UTF-8 BOM in scripts/build_runtime.ps1.

Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx across kernel32.dll, kernelbase.dll, and api-ms-win-core-sysinfo-l1-1-0.dll in runtime/shims/sysinfo.cpp:

  • Preserves the two-step GetLogicalProcessorInformation size-probe contract (FALSE + ERROR_INSUFFICIENT_BUFFER with required byte count) and falls back to a synthesized topology if the host fails or returns an empty buffer.
  • Supports deterministic console parity overrides via LEONIDA_CPU_TOPOLOGY (xbox/scarlett for 8c/16t with SMT + L1/L2/L3/NUMA/package records, NxM, N, or host) and LEONIDA_SYSTEM_MEMORY_MB (xbox/scarlett for 16384 MiB, or explicit MiB clamped to [256, 1048576]).
  • Keeps owns_dll false for kernel32.dll, kernelbase.dll, and api-ms-win-core-sysinfo-l1-1-0.dll.
  • Registers sysinfo_test in runtime/CMakeLists.txt and adds shims\sysinfo.cpp to scripts/build_runtime.ps1.

Tested

  • Compiled and ran sysinfo_test.exe natively on Windows 11 with MSVC (/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2): sysinfo_test: PASS (0 failures), zero compiler warnings.
  • Built runtime/build/gta6rt.exe via .\scripts\build_runtime.ps1 -jobs 8: succeeded cleanly with shims\sysinfo.cpp linked.
  • python -I tests/test_build_runtime_fallback.py: 10 tests, OK.
  • python -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/sysinfo.cpp runtime/test/sysinfo_test.cpp scripts/build_runtime.ps1: exit 0 (no game data).

GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — runtime shim)
Claimed in the coordination issue as: OLD-9816 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140741518) ### What and why Carries forward `old-pr/9816` (draft #88, original commit author `piyonchu` preserved; indexed in #17), rebased cleanly onto current `main` (`71f99e224`) without the stray UTF-8 BOM in `scripts/build_runtime.ps1`. Shims `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` across `kernel32.dll`, `kernelbase.dll`, and `api-ms-win-core-sysinfo-l1-1-0.dll` in `runtime/shims/sysinfo.cpp`: - Preserves the two-step `GetLogicalProcessorInformation` size-probe contract (`FALSE` + `ERROR_INSUFFICIENT_BUFFER` with required byte count) and falls back to a synthesized topology if the host fails or returns an empty buffer. - Supports deterministic console parity overrides via `LEONIDA_CPU_TOPOLOGY` (`xbox`/`scarlett` for 8c/16t with SMT + L1/L2/L3/NUMA/package records, `NxM`, `N`, or `host`) and `LEONIDA_SYSTEM_MEMORY_MB` (`xbox`/`scarlett` for 16384 MiB, or explicit MiB clamped to `[256, 1048576]`). - Keeps `owns_dll` false for `kernel32.dll`, `kernelbase.dll`, and `api-ms-win-core-sysinfo-l1-1-0.dll`. - Registers `sysinfo_test` in `runtime/CMakeLists.txt` and adds `shims\sysinfo.cpp` to `scripts/build_runtime.ps1`. ### Tested - Compiled and ran `sysinfo_test.exe` natively on Windows 11 with MSVC (`/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`): `sysinfo_test: PASS (0 failures)`, zero compiler warnings. - Built `runtime/build/gta6rt.exe` via `.\scripts\build_runtime.ps1 -jobs 8`: succeeded cleanly with `shims\sysinfo.cpp` linked. - `python -I tests/test_build_runtime_fallback.py`: 10 tests, OK. - `python -I tests/test_text_write_line_endings.py`: 3 tests, OK. - `python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/sysinfo.cpp runtime/test/sysinfo_test.cpp scripts/build_runtime.ps1`: exit 0 (no game data). GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — runtime shim)
abnalstlll-byte approved these changes 2026-11-24 18:39:31 +00:00
abnalstlll-byte left a comment

Audited and verified. Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx in
untime/shims/sysinfo.cpp with support for LEONIDA_CPU_TOPOLOGY (8c/16t Xbox topology) and LEONIDA_SYSTEM_MEMORY_MB, strictly preserving the two-step Win32 buffer probe contract (ERROR_INSUFFICIENT_BUFFER) required by the retail boot sequence. Tests in
untime/test/sysinfo_test.cpp pass cleanly. Approved.

Audited and verified. Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx in untime/shims/sysinfo.cpp with support for LEONIDA_CPU_TOPOLOGY (8c/16t Xbox topology) and LEONIDA_SYSTEM_MEMORY_MB, strictly preserving the two-step Win32 buffer probe contract (ERROR_INSUFFICIENT_BUFFER) required by the retail boot sequence. Tests in untime/test/sysinfo_test.cpp pass cleanly. Approved.
abnalstlll-byte approved these changes 2026-11-24 18:52:53 +00:00
abnalstlll-byte left a comment

Clean-Room Audit — PR #1104 (OLD-9816 SysInfo Shims)

Clean carry-forward of runtime/shims/sysinfo.cpp shimming GetLogicalProcessorInformation and GlobalMemoryStatusEx with LEONIDA_CPU_TOPOLOGY and LEONIDA_SYSTEM_MEMORY_MB configuration plus runtime/test/sysinfo_test.cpp coverage. CMake/build integration clean; 0 game data.

Verdict: APPROVED

### Clean-Room Audit — PR #1104 (`OLD-9816` SysInfo Shims) Clean carry-forward of `runtime/shims/sysinfo.cpp` shimming `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` with `LEONIDA_CPU_TOPOLOGY` and `LEONIDA_SYSTEM_MEMORY_MB` configuration plus `runtime/test/sysinfo_test.cpp` coverage. CMake/build integration clean; 0 game data. **Verdict: APPROVED**
madhyn commented 2026-11-24 19:36:00 +00:00

Tested 4dc12a4c3 on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build):

  • ctest --test-dir runtime/build/win -R "^sysinfo$" --output-on-failure: Passed (5.32 s)

AI-assisted: yes

Tested `4dc12a4c3` on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build): - `ctest --test-dir runtime/build/win -R "^sysinfo$" --output-on-failure`: **Passed** (5.32 s) AI-assisted: yes
Deedlyy commented 2026-11-24 20:17:30 +00:00

Recommendation: [MERGE]

Reasoning: Carries #88: shims GetLogicalProcessorInformation and GlobalMemoryStatusEx across kernel32/kernelbase/api-set with the size-probe contract preserved, plus a 176-line test; also drops the stray BOM from build_runtime.ps1. Self-contained new shim file. Verified on Arch + Wine (sysinfo passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

**Recommendation:** [MERGE] **Reasoning:** Carries #88: shims `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` across kernel32/kernelbase/api-set with the size-probe contract preserved, plus a 176-line test; also drops the stray BOM from `build_runtime.ps1`. Self-contained new shim file. Verified on Arch + Wine (`sysinfo` passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10
Sign in to join this conversation.
No description provided.