This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patches] [PATCH 1/2] RISC-V: Fix alignment issue in sigjmp_buf


On Wed, 17 Jan 2018 19:04:20 PST (-0800), Kito Cheng wrote:
This patch fix a potential mis-alignment issue in sigjump_buf, load a
double floating value required 8 bytes align, but we just align to
size of long, it's may cause mis-align memory access in rv32imafd.

From d23ba9ea7f842dda65b89cb80c396d1254b4e934 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Fri, 17 Nov 2017 14:50:52 +0800
Subject: [PATCH 1/2] RISC-V: Fix alignment issue in sigjmp_buf

---
 newlib/libc/include/machine/setjmp.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h
index b33f437..9212f84 100644
--- a/newlib/libc/include/machine/setjmp.h
+++ b/newlib/libc/include/machine/setjmp.h
@@ -359,7 +359,9 @@ _BEGIN_STD_C
 #endif

 #ifdef __riscv
-#define _JBTYPE long
+/* _JBTYPE using long long to make sure the alignment is align to 8 byte,
+   otherwise in rv32imafd, store/restore FPR may mis-align.  */
+#define _JBTYPE long long
 #ifdef __riscv_32e
 #define _JBLEN ((4*sizeof(long))/sizeof(long))
 #else
--
2.7.4

This looks good to me. Do you want me to co-maintain the RISC-V newlib port? IIRC you're the only maintainer, which can be a lot of work.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]