summaryrefslogtreecommitdiff
path: root/tco_go.3
diff options
context:
space:
mode:
Diffstat (limited to 'tco_go.3')
-rw-r--r--tco_go.336
1 files changed, 27 insertions, 9 deletions
diff --git a/tco_go.3 b/tco_go.3
index 531879b..ce7355d 100644
--- a/tco_go.3
+++ b/tco_go.3
@@ -1,6 +1,6 @@
.TH tco_go 3 2025-02-06
.SH NAME
-tco_go, tco_yield
+tco_go, tco_args, tco_yield
.SH LIBRARY
Tiny Coroutines
.RI ( libtco ", " \-ltco )
@@ -8,7 +8,8 @@ Tiny Coroutines
.nf
.B #include <tco.h>
.P
-.BI "int tco_go(void (*f)(void));"
+.BI "int tco_go(void (*" f ")(...));"
+.B "int tco_args(...);"
.BI "void tco_yield(void);"
.fi
.SH DESCRIPTION
@@ -19,17 +20,19 @@ The coroutine function pointer
.I f
is required to not be inlined
(the
-.BR coroutine
+.B coroutine
macro is provided as a convienient way to use the
-.BR gcc (1)
-/
-.BR clang (1)
-.BR noinline
+.BR gcc (1)/ clang (1)
+.B noinline
attribute, and to communicate the intented use of a function as a coroutine).
When the scheduler switches back to a context that has called
.BR tco_go (),
it resumes execution from after that call.
.P
+.BR tco_args ()
+sets the function arguments given to the coroutine spawned by
+.BR tco_go ().
+.P
.BR tco_yield ()
saves the current execution context and switches to the next scheduled context,
pausing execution of the current coroutine.
@@ -43,8 +46,23 @@ returns 0 on success, and a non-zero error code when the coroutine fails to
initialise.
.SH CAVEATS
This library works by preserving the state of the callee-saved registers and
-restoring them later when the coroutine is resumed. This approach may be
-incompatible with other forms of black magic voodoo, your mileage may vary.
+restoring them later when the coroutine is resumed.
+This approach may be incompatible with other forms of black magic voodoo, your
+mileage may vary.
+.P
+.BR tco_args ()
+currently only supports arguments passed by registers
+.RI ( %rdi ,
+.IR %rsi ,
+.IR %rdx ,
+.IR %r10 ,
+.IR %r8 ,
+.I %r9
+and
+.IR %xmm0\-8 ).
+Spawning coroutines that take arguments on the stack will result in stack
+corruption.
+Refer to the System V ABI for more details.
.SH AUTHOR AND LICENSE
Copyright (C) 2025 Aiden Gall
.P