Skip to content

Add initial Darwin ARM64 context switching support - #1

Open
M1ralai wants to merge 1 commit into
0intro:mainfrom
M1ralai:port/darwin64
Open

M1ralai wants to merge 1 commit into
0intro:mainfrom
M1ralai:port/darwin64

Conversation

@M1ralai

@M1ralai M1ralai commented Oct 18, 2026

Copy link
Copy Markdown

Summary

This PR introduces native macOS ARM64 (Apple Silicon) support for libtask by adding an architecture-specific context switching implementation.

The existing scheduler, channel implementation, and public API remain unchanged.

Changes

Added arm64-ucontext.h defining the ARM64 machine context structure.

Implemented ARM64 assembly routines for saving and restoring execution contexts in asm.S.

Added ARM64-specific makecontext() initialization in context.c.

Updated architecture detection in taskimpl.h to recognize Apple Silicon instead of falling back to PowerPC.

Preserved existing implementations for other architectures.

Testing

Tested locally on Apple Silicon running macOS:

make — builds successfully.

./primes 11 — executes successfully, exercising task creation, channel communication, and cooperative context switching.

The implementation has not yet undergone comprehensive ABI compatibility or optimization-level testing.

Notes

This change focuses exclusively on adding Darwin ARM64 support while preserving the original library's design and behavior.

Feedback and suggestions are welcome!

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