[PR #1104] runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx (OLD-9816) #1138

Open
opened 2026-11-26 20:20:13 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1104
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9816-sysinfo-shims


📝 Commits (1)

  • 7042503 runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx

📊 Changes

4 files changed (+489 additions, -2 deletions)

View changed files

📝 runtime/CMakeLists.txt (+14 -0)
➕ runtime/shims/sysinfo.cpp (+297 -0)
➕ runtime/test/sysinfo_test.cpp (+176 -0)
📝 scripts/build_runtime.ps1 (+2 -2)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1104 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9816-sysinfo-shims` --- ### 📝 Commits (1) - [`7042503`](https://github.com/ubiquitarianism/leonida/commit/7042503c7954604c566d7daa8cec21827488910e) runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx ### 📊 Changes **4 files changed** (+489 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+14 -0) ➕ `runtime/shims/sysinfo.cpp` (+297 -0) ➕ `runtime/test/sysinfo_test.cpp` (+176 -0) 📝 `scripts/build_runtime.ps1` (+2 -2) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1138
No description provided.