From e9967889a09ba6b27eae030b34bfe4d223845119 Mon Sep 17 00:00:00 2001 From: KAAAsS Date: Thu, 21 Apr 2022 23:22:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20cat=20=E6=8C=87=E4=BB=A4=E7=9A=84?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab5/user/lab5/apps/init.c | 2 -- lab5/user/lib/string.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lab5/user/lab5/apps/init.c b/lab5/user/lab5/apps/init.c index 7531246..34bf91c 100644 --- a/lab5/user/lab5/apps/init.c +++ b/lab5/user/lab5/apps/init.c @@ -453,8 +453,6 @@ int fs_read_all(char *path, void **ret_buf) if (cur < 0) { return cur; } - // FIXME: 此处在 Release 模式下第一次读取前 16 字节为空 - memcpy(buf, (const void *) TMPFS_READ_BUF_VADDR, cur); memcpy(buf, (const void *) TMPFS_READ_BUF_VADDR, cur); pos += cur; buf += cur; diff --git a/lab5/user/lib/string.c b/lab5/user/lib/string.c index 5f4893a..3ce3240 100644 --- a/lab5/user/lib/string.c +++ b/lab5/user/lib/string.c @@ -12,6 +12,10 @@ void memset(void *dst, int c, u64 len) } } +// FIXME: 此处 workaround 用于避免 GCC 插入 SIMD 指令使用未被备份的寄存器导致程序问题 +// See also: https://ipads.se.sjtu.edu.cn/mospi/discussion/d/205-memcpy-gcc +#pragma GCC push_options +#pragma GCC optimize("O0") void memcpy(void *dst, const void *src, u64 len) { u64 i = 0; @@ -19,6 +23,7 @@ void memcpy(void *dst, const void *src, u64 len) ((u8 *) dst)[i] = ((u8 *) src)[i]; } } +#pragma GCC pop_options int memcmp(const void *s1, const void *s2, size_t n) {