aboutsummaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_string.c
AgeCommit message (Collapse)Author
2021-12-23firmware: Move memcpy/memset mapping to fw_base.SAnup Patel
Some of the external firmwares using OpenSBI as library are facing issues with the weak memcpy() and memset() aliases in libsbi.a so we move these to fw_base.S. This way mapping of implicit memcpy() or memset() calls to sbi_memcpy() or sbi_memset() will only be done for OpenSBI firmwares. (Refer, https://github.com/riscv-software-src/opensbi/issues/234) In addition, we also add memmove() and memcmp() mappings in fw_base.S because as-per the GCC documentation the freestanding environment must provide memcpy(), memmove(), memset(), and memcmp(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2021-12-11lib: sbi: Fix compile errors using -Os optionAnup Patel
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>
2021-08-07lib: sbi: Fix bug in strncmp function when count is 0Dong Du
No need to compare characters when the count turns to 0. Fix the issue in sbi_strncmp. Signed-off-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-07-29lib: Add sbi_strncmp implementationAbner Chang
This commit add an implementation of sbi_strncmp. Signed-off-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2019-06-19lib: Rename string.x to sbi_string.xAtish Patra
All string functions are part of libsbi. It makes more sense to rename them to sbi_string.x as the libsbi can be linked with external libraries that can have similar implementation. Signed-off-by: Atish Patra <atish.patra@wdc.com> Acked-by: Anup Patel <anup.patel@wdc.com>