lib: sbi: Fix compile errors using -Os option
authorAnup Patel <anup.patel@wdc.com>
Thu, 2 Dec 2021 11:22:16 +0000 (16:52 +0530)
committerAnup Patel <anup@brainfault.org>
Sat, 11 Dec 2021 12:07:29 +0000 (17:37 +0530)
commitd249d6544c3cbf6a817e2fac40b4be0e006ba965
treec2923c89439daf4f3ddbde8a308ed857d036b499
parent69d7e536138ae71a24028ca849d401a4d64d564b
lib: sbi: Fix compile errors using -Os option

When compiling with -Os option along with -ffreestanding, both GCC
and clang will add implicit calls to memcpy() and memset() for stack
variables initialized in declaration.

The C standard as per Clause 4, the compiler cannot necessarily
assume that anything beyond:

 * float.h
 * iso646.h
 * limits.h
 * stdalign.h
 * stdarg.h
 * stdbool.h
 * stddef.h
 * stdint.h
 * stdnoreturn.h
 * fenv.h
 * math.h
 * and the numeric conversion functions of stdlib.h.

This patch maps memcpy() and memset() as weak-alias of sbi_memcpy()
and sbi_memset() respectively so that implicit calls to memcpy()
and memset() will compile properly.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn>
Reviewed-by: Xiang W <wxjstz@126.com>
lib/sbi/sbi_string.c