changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: libthread: initial support for arm64

changeset 7189: 5f30fb0ada5d
parent 7188: e5cc45b34cf9
child 7190: 41fb44a3b2dc
author: cinap_lenrek@felloff.net
date: Fri, 03 May 2019 21:03:12 +0200
files: sys/src/libthread/arm64.c
description: libthread: initial support for arm64
     1.1new file mode 100644
     1.2--- /dev/null
     1.3+++ b/sys/src/libthread/arm64.c
     1.4@@ -0,0 +1,28 @@
     1.5+#include <u.h>
     1.6+#include <libc.h>
     1.7+#include <thread.h>
     1.8+#include "threadimpl.h"
     1.9+
    1.10+/* first argument goes in a register; simplest just to ignore it */
    1.11+static void
    1.12+launcherarm64(int, void (*f)(void *arg), void *arg)
    1.13+{
    1.14+	(*f)(arg);
    1.15+	threadexits(nil);
    1.16+}
    1.17+
    1.18+void
    1.19+_threadinitstack(Thread *t, void (*f)(void*), void *arg)
    1.20+{
    1.21+	uintptr *tos;
    1.22+
    1.23+	tos = (uintptr*)&t->stk[t->stksize&~15];
    1.24+	*--tos = (uintptr)arg;
    1.25+	*--tos = (uintptr)f;
    1.26+	*--tos = 0;	/* first arg to launcherarm64 */
    1.27+	*--tos = 0;	/* place to store return PC */
    1.28+
    1.29+	t->sched[JMPBUFPC] = (uintptr)launcherarm64+JMPBUFDPC;
    1.30+	t->sched[JMPBUFSP] = (uintptr)tos;
    1.31+}
    1.32+