go-lib 0.4.0

rust native goroutines
Documentation
// SPDX-License-Identifier: Apache-2.0
//! Goroutine scheduler internals.
//!
//! Ported from `src/runtime/` in <https://github.com/golang/go>.  Each submodule
//! maps to the Go source file(s) shown below.
//!
//! ## v0.2.0 additions
//!
//! | New module / symbol | Purpose |
//! |----|-----|
//! | `stack` — `newstack`, `copystack`, `sigsegv_handler` | Dynamic goroutine stack growth (Step 3) |
//! | `m` — `pthread_id`, `setup_sigaltstack` | Per-M thread ID + 64 KiB alternate signal stack (Step 4) |
//! | `sched` — `async_preempt2`, `sigurg_handler` | Non-cooperative goroutine preemption via SIGURG (Step 4) |
//! | `asm_amd64`/`asm_arm64` — `async_preempt_trampoline` | Save/restore all registers around the preemption yield (Step 4) |
//! | `sysmon` — `pthread_kill(SIGURG)` in `preemptone` | Signal delivery for async preemption (Step 4) |
//! | `netpoll` | epoll (Linux) / kqueue (macOS) / IOCP (Windows) I/O backend (Step 5) |
//!
//! ## v0.3.0 additions
//!
//! | New module / symbol | Purpose |
//! |----|-----|
//! | `g` — `casgstatus`, `castogscanstatus`, `casfrom_gscanstatus`, `readgstatus` | Centralised atomic G state-transition helpers (mirrors Go's `casgstatus`) |
//! | `g` — `scan_stack` | GSCAN freeze/unfreeze scaffolding for a future GC stack scanner |
//! | `syscall` — `entersyscall`/`exitsyscall` | G transitions to/from `GSYSCALL` state |
//! | `stack` — `copystack` | G transitions through `GCOPYSTACK` during stack-copy |
//! | `sched` — `preemptm` | G transitions through `GPREEMPTED` (Go 1.14+ async-preempt protocol) |
//! | `park` — `goready` | Accepts `GPREEMPTED` as well as `GWAITING` when readying a G |
//! | `asm_amd64`/`asm_arm64` — `systemstack`, `systemstack_call` | Runs a closure on the M's g0 stack via a naked RSP/SP switch |
//!
//! | This module   | Go source                                                   |
//! |---------------|-------------------------------------------------------------|
//! | `g`           | `runtime/runtime2.go`                                       |
//! | `m`           | `runtime/runtime2.go`, `runtime/proc.go`                    |
//! | `p`           | `runtime/runtime2.go`, `runtime/proc.go`                    |
//! | `sched`       | `runtime/proc.go`, `runtime/preempt.go`                     |
//! | `stack`       | `runtime/stack.go`, `runtime/signal_unix.go`                |
//! | `netpoll`     | `runtime/netpoll_epoll.go`, `runtime/netpoll_kqueue.go`, `runtime/netpoll_windows.go` |
//! | `park`        | `runtime/proc.go` (gopark / goready)                        |
//! | `sudog`       | `runtime/runtime2.go`, `runtime/proc.go`                    |
//! | `syscall`     | `runtime/proc.go` (entersyscall / exitsyscall)              |
//! | `sysmon`      | `runtime/proc.go` (sysmon / retake)                         |
//! | `time`        | `runtime/time.go`                                           |
//! | `asm_amd64`   | `runtime/asm_amd64.s`, `runtime/preempt_amd64.s`           |
//! | `asm_arm64`   | `runtime/asm_arm64.s`, `runtime/preempt_arm64.s`           |


pub(crate) mod g;
pub(crate) mod m;
pub(crate) mod rawmutex;
pub(crate) mod netpoll;
pub(crate) mod p;
pub(crate) mod park;
pub(crate) mod sched;
pub(crate) mod stack;
pub(crate) mod sudog;
pub(crate) mod syscall;
pub(crate) mod sysmon;
pub(crate) mod time;

#[cfg(target_arch = "x86_64")]
pub(crate) mod asm_amd64;
#[cfg(target_arch = "aarch64")]
pub(crate) mod asm_arm64;

// Re-export the three context-switch primitives from the correct asm module
// so the rest of the runtime uses `crate::runtime::{gogo, mcall, systemstack}`
// without caring about the target architecture.
#[cfg(target_arch = "aarch64")]
pub(crate) use asm_arm64::{gogo, mcall, systemstack};