Skip to content

Match platform bindings to the C ABI - #57

Merged
levovix0 merged 4 commits into
levovix0:masterfrom
elcritch:fix/platform-c-abi-upstream
Oct 6, 2026
Merged

levovix0 merged 4 commits into
levovix0:masterfrom
elcritch:fix/platform-c-abi-upstream

Conversation

@elcritch

@elcritch elcritch commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Wayland and GLX pointer declarations can use the wrong C calling convention on 32-bit targets, and pointer-sized Vulkan surfaces lose their upper 32 bits. This follows the merged #56 and corrects the bindings and their callers.

  • Bind Wayland display/proxy functions with native pointer signatures; pass .raw from Siwin callers.
  • Preserve public EGL bool results using small wrappers around private cuint bindings. The dynamically loaded function pointer must return unsigned int; declaring it as bool does not insert a conversion. The wrappers explicitly compare the full result with zero.
  • Correct GLX pointer and swap-interval signatures while preserving existing call patterns.
  • Use uint64 for Vulkan surface handles on every architecture, including platform bindings and the public API; the C header uses uint64_t.

This replaces elcritch#7 and addresses both review comments there. Direct Wayland callers now pass raw pointers, and Vulkan callers receive a 64-bit integer. EGL callers retain boolean checks; availability and teardown checks use the private native entry points.

Validation on FreeBSD amd64 with Nim 2.2.10 and the existing X11 display (AMD Radeon 780M):

  • atlas-run tests _dynlib_loading passed with the default memory manager and --mm:refc. Includes full-width integer-to-bool regression coverage, API type checks, native EGL failure results, and a real EGL display lifecycle.
  • atlas-run tests _opengl.nim _offscreen _vulkan _x11_api _event_loop passed (5/5), including live Vulkan rendering and X11/XCB queries.
  • nim check --os:linux --path:src src/siwin.nim passed for amd64; nim check --os:linux --cpu:i386 --path:src tests/t_dynlib_loading.nim passed for i386.
  • C header syntax and 8-byte Vulkan surface assertion passed; git diff --check passed.

GitHub CI passes on Linux, macOS, and Windows. The local i386 validation is compile-time only; local live-display checks used X11. Downstream integration is tracked in Merenda #138.

@levovix0
levovix0 merged commit dd39b78 into levovix0:master Oct 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants