Skip to content

macOS platform bindings: Syscall.rux, Platform.rux, and smoke test#5

Open
devsker wants to merge 1 commit into
rux-lang:mainfrom
devsker:main
Open

macOS platform bindings: Syscall.rux, Platform.rux, and smoke test#5
devsker wants to merge 1 commit into
rux-lang:mainfrom
devsker:main

Conversation

@devsker

@devsker devsker commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Implements the macOS platform bindings for Rux, providing both a low-level raw syscall FFI module (MacOS) and a Platform module that fulfills the Std library contract.

Changes

Src/Syscall.rux — Raw macOS syscall FFI:

  • Syscall constants using the BSD class mask (0x2000000 | number): SYS_READ, SYS_WRITE, SYS_CLOSE, SYS_MMAP, SYS_MUNMAP, SYS_EXIT, SYS_GETPID
  • macOS-specific mmap flags (MAP_PRIVATE = 0x0002, MAP_ANONYMOUS = 0x1000)
  • extern block via @[Import(lib: "rux-macos")] consuming the __rux_macos_syscall* thunks added in Add __rux_macos_syscall thunks for raw macOS syscall access Rux#182
  • Typed wrappers: Read, Write, Close, Exit, GetPid, Mmap, Munmap, Syscall0Syscall6, IsError, Errno

Src/Platform.rux — Std library contract implementation:

  • PlatformAlloc/Realloc/Free — mmap-based allocator with 8-byte header tracking
  • PlatformCopy/Fill/Zero/Compare — byte-level utilities
  • PlatformReadStdin/PlatformWriteStdout/PlatformWriteStdoutWide — I/O primitives
  • PlatformExit — process termination

Examples/Smoke/ — Smoke test exercising Read, Write, GetPid, Mmap, and Munmap (exit code 0 on success).

Notes

  • x86-64 only — the Mach-O linker currently emits only x86-64 machine code. Apple Silicon support is blocked on the compiler side.
  • nanosleep and clock_gettime are intentionally omitted — on macOS these are implemented in libSystem, not as raw kernel traps, so they cannot be exposed through this raw syscall interface.
  • The pub keyword on struct fields is parsed but cross-module field access is not yet fully resolved in the compiler, so Timespec helpers were removed from the API surface.

Related

Depends on rux-lang/Rux#182 which adds the __rux_macos_syscall* linker thunks.

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.

1 participant