9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e09ca953b0530280da880964f35d371fdbfc7519
parent 6e09d19535fdb94f2ed751bee214c6a8dfa7399b
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date:   Thu, 17 Nov 2022 09:33:46 +0100

os9: Rename savectx() to dupctx() and add am64 version

Diffstat:
Minclude/os9/os9.h | 2+-
Msrc/os9/arch/arm64/ctx.c | 15+++++++++++++++
Msrc/os9/hosted/ctx.c | 2+-
Msrc/os9/proc.c | 4++--
4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/include/os9/os9.h b/include/os9/os9.h @@ -274,7 +274,7 @@ extern noreturn void swtch(Context *ctx); extern noreturn void trap(Context *ctx); extern Ptable *initptable(Task *); extern void ictx(Task *, void *); -extern int savectx(Task *); +extern int dupctx(Task *); extern char *getconf(char *); extern void idle(void); diff --git a/src/os9/arch/arm64/ctx.c b/src/os9/arch/arm64/ctx.c @@ -107,6 +107,21 @@ panic(const char *msg) fault(msg, NULL); } +int +dupctx(Task *tp) +{ + proc->ctx.r[X29] = 1; + getctx(&tp->ctx); + tp->ctx[X29] = 0; + + /* + * When this function is called tp and proc are different pointers + * but when the context of tp is restored and the execution comes + * here then tp and proc are the same pointer + */ + return proc->ctx.r[X29]; +} + void ictx(Task *tp, void *fn) { diff --git a/src/os9/hosted/ctx.c b/src/os9/hosted/ctx.c @@ -1,7 +1,7 @@ #include <os9/os9.h> int -savectx(Task *tp) +dupctx(Task *tp) { tp->m = 0; tp->ctx.entry = proc->ctx.entry; diff --git a/src/os9/proc.c b/src/os9/proc.c @@ -423,10 +423,10 @@ rfork(int flags) if ((tp = clone(proc)) == NULL) return -1; /* - * if savectx() returns 0 then we are the child and + * if dupctx() returns 0 then we are the child and * the mutex was already released by the parent */ - if (savectx(tp) == 0) + if (dupctx(tp) == 0) return 0; }