Date: Mon, 11 May 2020 21:24:22 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r360932 - stable/12/lib/libc/riscv/gen Message-ID: <202005112124.04BLOMMR041197@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Mon May 11 21:24:22 2020 New Revision: 360932 URL: https://svnweb.freebsd.org/changeset/base/360932 Log: MFC 357643: Tidy the _set_tp function for RISC-V. - Use a constant for the offset instead of a magic number. - Use an addi instruction that writes to tp directly instead of a mv that writes the result of a compiler-generated addi. Modified: stable/12/lib/libc/riscv/gen/_set_tp.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/riscv/gen/_set_tp.c ============================================================================== --- stable/12/lib/libc/riscv/gen/_set_tp.c Mon May 11 21:24:05 2020 (r360931) +++ stable/12/lib/libc/riscv/gen/_set_tp.c Mon May 11 21:24:22 2020 (r360932) @@ -38,13 +38,14 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <sys/types.h> -#include <machine/sysarch.h> - #include <stdlib.h> +/* NB: size of 'struct tcb'. */ +#define TP_OFFSET (sizeof(void *) * 2) + void _set_tp(void *tp) { - __asm __volatile("mv tp, %0" :: "r"((char*)tp + 0x10)); + __asm __volatile("addi tp, %0, %1" :: "r" (tp), "I" (TP_OFFSET)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005112124.04BLOMMR041197>