shithub: drawterm

Download patch

ref: cfda4c39d69c6653c16520276b7209cfcdf031cb
parent: d744632a356e28dd453c084dc9a2172559103b31
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Dec 22 18:04:43 EST 2020

add preliminary riscv64 support from archlinux (thanks Sören Tempel)

ape/diff: b/posix-riscv64/null: No such file or directory
--- /dev/null	Mon Oct 18 12:05:45 2021
+++ b/posix-riscv64/Makefile	Tue Dec 22 18:04:43 2020
@@ -0,0 +1,18 @@
+ROOT=..
+include ../Make.config
+LIB=../libmachdep.a
+
+OFILES=\
+	getcallerpc.$O\
+	tas.$O
+
+default: $(LIB)
+$(LIB): $(OFILES)
+	$(AR) r $(LIB) $(OFILES)
+	$(RANLIB) $(LIB)
+
+%.$O: %.c
+	$(CC) $(CFLAGS) $*.c
+
+%.$O: %.s
+	$(AS) -o $*.$O $*.s
--- /dev/null	Mon Oct 18 12:05:45 2021
+++ b/posix-riscv64/getcallerpc.c	Tue Dec 22 18:04:43 2020
@@ -0,0 +1,8 @@
+#include "u.h"
+#include "libc.h"
+
+uintptr
+getcallerpc(void *a)
+{
+	return ((uintptr*)a)[-1];
+}
--- /dev/null	Mon Oct 18 12:05:45 2021
+++ b/posix-riscv64/tas.c	Tue Dec 22 18:04:43 2020
@@ -0,0 +1,28 @@
+#include "u.h"
+#include "libc.h"
+
+int
+tas(int *x)
+{
+	int v, i = 1;
+
+	__asm__(
+		"1:	lr.w t0, (%1)\n"
+		"	sc.w t1, %2, (%1)\n"
+		"	bnez t1, 1b\n"
+		"       mv %0, t0"
+		: "=r" (v)
+		: "r" (x), "r" (i)
+		: "t1", "t0"
+	);
+
+	switch(v) {
+	case 0:
+	case 1:
+		return v;
+	default:
+		print("canlock: corrupted 0x%lux\n", v);
+		return 1;
+	}
+}
+