libc/string: prevent libc in the kernel/userspace optionally

Add the `LIBC_PREVENT_STRING_KERNEL` and `LIBC_PREVENT_STRING_USER`
that are meant to be selected by the chip if no libc implementation
is going to be built. If selected, neither NuttX's software version
of the libc nor any architecture-specific implementation will be
built in the kernel or in the userspace, respectively. In this
case, the linker may provide a ROM-defined version of the libc
functions instead.
This commit is contained in:
Tiago Medicci Serrano 2023-04-28 13:55:23 -03:00 committed by Xiang Xiao
parent 6be363ff35
commit 58e97e521c
73 changed files with 405 additions and 76 deletions

View file

@ -82,6 +82,7 @@ else
endif
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libc
AFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libc
# Rule for the symbol table generation

View file

@ -27,15 +27,17 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <semaphore.h>
#ifndef __ASSEMBLY__
# include <sys/types.h>
# include <stdbool.h>
# include <stdio.h>
# include <stdlib.h>
# include <limits.h>
# include <semaphore.h>
#include <nuttx/lib/lib.h>
#include <nuttx/streams.h>
# include <nuttx/lib/lib.h>
# include <nuttx/streams.h>
#endif
/****************************************************************************
* Pre-processor Definitions
@ -53,6 +55,12 @@
#define LIB_BUFLEN_UNKNOWN INT_MAX
#if defined(CONFIG_BUILD_FLAT) || \
((!defined(CONFIG_LIBC_PREVENT_STRING_USER) && !defined(__KERNEL__)) || \
(!defined(CONFIG_LIBC_PREVENT_STRING_KERNEL) && defined(__KERNEL__)))
# define LIBC_BUILD_STRING
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@ -61,6 +69,8 @@
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
@ -157,4 +167,6 @@ void lib_cxx_initialize(void);
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __LIBS_LIBC_LIBC_H */

View file

@ -137,6 +137,30 @@ config LIBC_ARCH_ELF_64BIT
default n
depends on LIBC_ARCH_ELF
config LIBC_PREVENT_STRING_KERNEL
bool
default n
---help---
Prevent any implementation of the libc from being built and linked
in the kernel, including NuttX's software-defined version of the libc
or any other architecture-specific version of it. The ROM-defined
version should be linked instead. This option is particularly useful
when it's required that the ROM-defined libc to be used by the kernel
(for accessing some driver resource, for instance) but the userspace
is forbidden to use the same ROM-defined versions. In this case,
NuttX's software-defined version of the libc or arch-specific
assembly version is built instead.
config LIBC_PREVENT_STRING_USER
bool
default n
---help---
Prevent any implementation of the libc from being built and linked
in the userspace, including NuttX's software-defined version of the
libc or any other architecture-specific version of it. A ROM-defined
version of the libc may be linked to the userspace by the linker.
# One or more the of above may be selected by architecture specific logic
if ARCH_ARM

View file

@ -66,6 +66,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
@ 2011-02-07 david.gilbert@linaro.org
@ Extracted from local git a5b438d861
@ 2011-07-14 david.gilbert@linaro.org
@ -389,3 +393,5 @@ memchr:
#else
/* Defined in memchr-stub.c. */
#endif
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/*
* This memcpy routine is optimised for Cortex-A15 cores and takes advantage
* of VFP or NEON when built with the appropriate flags.
@ -624,3 +628,5 @@ def_fn memcpy p2align=6
bx lr
.size memcpy, . - memcpy
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
.thumb
.syntax unified
.global memmove
@ -64,3 +68,5 @@ memmove:
pop {r4}
bx lr
.size memmove, . - memmove
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
.arm
.syntax unified
.global memset
@ -144,3 +148,5 @@ memset:
strbcs r1, [r3], #1
bx lr
.size memset, . - memset
#endif

View file

@ -30,6 +30,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#ifdef __ARMEB__
#define SHFT2LSB lsl
#define SHFT2LSBEQ lsleq
@ -301,3 +305,5 @@ strcmp:
ldr r5, [sp], #4
bx lr
.size strcmp, . - strcmp
#endif

View file

@ -62,6 +62,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "acle-compat.h"
.macro def_fn f p2align=0
@ -182,3 +186,5 @@ def_fn strlen p2align=6
mov const_0, #0
b .Lstart_realigned
.size strlen, . - strlen
#endif

View file

@ -66,6 +66,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
@ 2011-02-07 david.gilbert@linaro.org
@ Extracted from local git a5b438d861
@ 2011-07-14 david.gilbert@linaro.org
@ -427,3 +431,5 @@ memchr:
#else
/* Defined in memchr-stub.c. */
#endif
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* This memcpy routine is optimised for Cortex-M3/M4 cores with/without
unaligned access.
@ -345,3 +349,5 @@ memcpy:
.cantunwind
.fnend
.size memcpy, .-memcpy
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm_asm.h"
.thumb
@ -71,3 +75,5 @@ memmove:
.cantunwind
.fnend
.size memmove, . - memmove
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm_asm.h"
.thumb
@ -114,3 +118,5 @@ memset:
.cantunwind
.fnend
.size memset, . - memset
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Very similar to the generic code, but uses Thumb2 as implemented
in ARMv7-M. */
@ -419,3 +423,5 @@ def_fn strcmp
.cantunwind
.fnend
.size strcmp, . - strcmp
#endif

View file

@ -18,6 +18,10 @@
*
***************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* This strcpy borrowed some ideas from arch_strcmp.S(). */
/* Parameters and result. */
@ -306,3 +310,4 @@ offset_3:
*dst++ = 0;
#endif /* Pseudo code end */
#endif

View file

@ -62,6 +62,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm-acle-compat.h"
#include "arm_asm.h"
@ -193,3 +197,5 @@ def_fn strlen p2align=6
.cantunwind
.fnend
.size strlen, . - strlen
#endif

View file

@ -66,6 +66,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
@ 2011-02-07 david.gilbert@linaro.org
@ Extracted from local git a5b438d861
@ 2011-07-14 david.gilbert@linaro.org
@ -389,3 +393,5 @@ memchr:
#else
/* Defined in memchr-stub.c. */
#endif
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/*
* This memcpy routine is optimised for Cortex-A15 cores and takes advantage
* of VFP or NEON when built with the appropriate flags.
@ -624,3 +628,5 @@ def_fn memcpy p2align=6
bx lr
.size memcpy, . - memcpy
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
.thumb
.syntax unified
.global memmove
@ -64,3 +68,5 @@ memmove:
pop {r4}
bx lr
.size memmove, . - memmove
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
.arm
.syntax unified
.global memset
@ -144,3 +148,5 @@ memset:
strbcs r1, [r3], #1
bx lr
.size memset, . - memset
#endif

View file

@ -30,6 +30,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#ifdef __ARMEB__
#define SHFT2LSB lsl
#define SHFT2LSBEQ lsleq
@ -301,3 +305,5 @@ strcmp:
ldr r5, [sp], #4
bx lr
.size strcmp, . - strcmp
#endif

View file

@ -62,6 +62,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "acle-compat.h"
.macro def_fn f p2align=0
@ -182,3 +186,5 @@ def_fn strlen p2align=6
mov const_0, #0
b .Lstart_realigned
.size strlen, . - strlen
#endif

View file

@ -66,6 +66,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
@ 2011-02-07 david.gilbert@linaro.org
@ Extracted from local git a5b438d861
@ 2011-07-14 david.gilbert@linaro.org
@ -427,3 +431,5 @@ memchr:
#else
/* Defined in memchr-stub.c. */
#endif
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* This memcpy routine is optimised for Cortex-M3/M4 cores with/without
unaligned access.
@ -367,3 +371,5 @@ memcpy:
.cantunwind
.fnend
.size memcpy, .-memcpy
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm_asm.h"
.thumb
@ -71,3 +75,5 @@ memmove:
.cantunwind
.fnend
.size memmove, . - memmove
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm_asm.h"
.thumb
@ -129,3 +133,5 @@ memset:
.cantunwind
.fnend
.size memset, . - memset
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Very similar to the generic code, but uses Thumb2 as implemented
in ARMv7-M. */
@ -419,3 +423,5 @@ def_fn strcmp
.cantunwind
.fnend
.size strcmp, . - strcmp
#endif

View file

@ -62,6 +62,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "arm-acle-compat.h"
#include "arm_asm.h"
@ -193,3 +197,5 @@ def_fn strlen p2align=6
.cantunwind
.fnend
.size strlen, . - strlen
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -171,3 +175,5 @@ def_fn memchr
ret
.size memchr, . - memchr
#endif

View file

@ -59,6 +59,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses.
@ -194,3 +198,5 @@ L(byte_loop):
ret
.size memcmp, . - memcmp
#endif

View file

@ -59,6 +59,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses.
@ -230,3 +234,5 @@ L(copy_long):
ret
.size memcpy, . - memcpy
#endif

View file

@ -59,6 +59,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses
@ -155,3 +159,5 @@ def_fn memmove, 6
3: ret
.size memmove, . - memmove
#endif

View file

@ -59,6 +59,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses
@ -240,3 +244,5 @@ L(zva_other):
b L(tail64)
.size memset, . - memset
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -159,3 +163,5 @@ def_fn strchr
ret
.size strchr, . - strchr
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -144,3 +148,5 @@ def_fn strchrnul
ret
.size strchrnul, . - strchrnul
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -203,3 +207,5 @@ L(done):
sub result, data1, data2
ret
.size strcmp, .-strcmp
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses, min page size 4k.
@ -336,3 +340,5 @@ def_fn STRCPY p2align=6
b .Lfp_gt8
.size STRCPY, . - STRCPY
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64, unaligned accesses, min page size 4k.
@ -240,3 +244,5 @@ L(page_cross):
b L(page_cross_entry)
.size strlen, . - strlen
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -292,3 +296,5 @@ def_fn strncmp
mov result, #0
ret
.size strncmp, . - strncmp
#endif

View file

@ -33,6 +33,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -186,3 +190,5 @@ def_fn strnlen
csel data2, data2, data2a, le
b .Lrealigned
.size strnlen, . - .Lstart /* Include pre-padding in size. */
#endif

View file

@ -29,6 +29,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/* Assumptions:
*
* ARMv8-a, AArch64
@ -177,3 +181,5 @@ def_fn strrchr
ret
.size strrchr, . - strrchr
#endif

View file

@ -18,6 +18,14 @@
*
****************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/************************************************************************************
* Public Symbols
************************************************************************************/
@ -128,3 +136,5 @@ memcpy:
bltu a1, a3, 5b
6:
ret
#endif

View file

@ -13,6 +13,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
.text
.global memset
.type memset, @function
@ -104,3 +108,5 @@ memset:
bleu a2, t1, .Ltiny
j .Laligned
.size memset, .-memset
#endif

View file

@ -13,6 +13,10 @@
*
****************************************************************************/
#include "libc.h"
#ifdef LIBC_BUILD_STRING
#include "asm.h"
.text
@ -185,3 +189,5 @@ strcmp:
mask:
.dword 0x7f7f7f7f7f7f7f7f
#endif
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
@ -276,3 +280,5 @@ __memcpy_aux:
.end schedule
.size memcpy, . - memcpy
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
@ -479,3 +483,5 @@ memmove:
.end schedule
.size memmove, . - memmove
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Public Functions
****************************************************************************/
@ -175,3 +179,5 @@ __memset_aux:
.end schedule
.size memset, . - memset
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Pre-processor Macros
****************************************************************************/
@ -760,3 +764,4 @@ strcmp:
.end schedule
.size strcmp, . - strcmp
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Public Functions
****************************************************************************/
@ -240,3 +244,5 @@ strcpy:
.end schedule
.size strcpy, . - strcpy
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Public Functions
****************************************************************************/
@ -120,3 +124,5 @@ strlen:
.end schedule
.size strlen, . - strlen
#endif

View file

@ -27,6 +27,10 @@
#include <arch/chip/core-isa.h>
#include <arch/xtensa/xtensa_abi.h>
#include "libc.h"
#ifdef LIBC_BUILD_STRING
/****************************************************************************
* Public Functions
****************************************************************************/
@ -261,3 +265,5 @@ strncpy:
.end schedule
.size strncpy, . - strncpy
#endif

View file

@ -32,61 +32,15 @@ CSRCS += lib_strsep.c lib_strerrorr.c lib_explicit_bzero.c lib_strsignal.c
CSRCS += lib_index.c lib_rindex.c lib_timingsafe_bcmp.c lib_strverscmp.c
CSRCS += lib_mempcpy.c lib_rawmemchr.c lib_bzero.c
ifneq ($(CONFIG_LIBC_ARCH_MEMCHR),y)
CSRCS += lib_memchr.c
endif
CSRCS += lib_memchr.c lib_memcmp.c lib_memmove.c lib_memset.c
CSRCS += lib_strchr.c lib_strcmp.c lib_strcpy.c lib_strlcat.c
CSRCS += lib_strlcpy.c lib_strlen.c lib_strncpy.c lib_strnlen.c
ifneq ($(CONFIG_LIBC_ARCH_MEMCMP),y)
CSRCS += lib_memcmp.c
endif
ifneq ($(CONFIG_LIBC_ARCH_MEMCPY),y)
ifeq ($(CONFIG_MEMCPY_VIK),y)
CSRCS += lib_vikmemcpy.c
else
CSRCS += lib_memcpy.c
endif
endif
ifneq ($(CONFIG_LIBC_ARCH_MEMMOVE),y)
CSRCS += lib_memmove.c
endif
ifneq ($(CONFIG_LIBC_ARCH_MEMSET),y)
CSRCS += lib_memset.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRCHR),y)
CSRCS += lib_strchr.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRCMP),y)
CSRCS += lib_strcmp.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRCPY),y)
CSRCS += lib_strcpy.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRLCAT),y)
CSRCS += lib_strlcat.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRLCPY),y)
CSRCS += lib_strlcpy.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRLEN),y)
CSRCS += lib_strlen.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRNCPY),y)
CSRCS += lib_strncpy.c
endif
ifneq ($(CONFIG_LIBC_ARCH_STRNLEN),y)
CSRCS += lib_strnlen.c
endif
ifeq ($(CONFIG_LIBC_LOCALE),y)
CSRCS += lib_strcoll.c lib_strxfrm.c

View file

@ -26,6 +26,8 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -44,6 +46,7 @@
*
****************************************************************************/
#if !defined(CONFIG_LIBC_ARCH_MEMCHR) && defined(LIBC_BUILD_STRING)
#undef memchr /* See mm/README.txt */
FAR void *memchr(FAR const void *s, int c, size_t n)
{
@ -61,3 +64,4 @@ FAR void *memchr(FAR const void *s, int c, size_t n)
return NULL;
}
#endif

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_MEMCMP
#if !defined(CONFIG_LIBC_ARCH_MEMCMP) && defined(LIBC_BUILD_STRING)
#undef memcmp /* See mm/README.txt */
no_builtin("memcmp")
int memcmp(FAR const void *s1, FAR const void *s2, size_t n)

View file

@ -26,6 +26,8 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -34,7 +36,7 @@
* Name: memcpy
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_MEMCPY
#if !defined(CONFIG_LIBC_ARCH_MEMCPY) && defined(LIBC_BUILD_STRING)
#undef memcpy /* See mm/README.txt */
no_builtin("memcpy")
FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n)

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_MEMMOVE
#if !defined(CONFIG_LIBC_ARCH_MEMMOVE) && defined(LIBC_BUILD_STRING)
#undef memmove /* See mm/README.txt */
no_builtin("memmove")
FAR void *memmove(FAR void *dest, FAR const void *src, size_t count)

View file

@ -30,6 +30,8 @@
#include <string.h>
#include <assert.h>
#include "libc.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -46,7 +48,7 @@
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_MEMSET
#if !defined(CONFIG_LIBC_ARCH_MEMSET) && defined(LIBC_BUILD_STRING)
#undef memset /* See mm/README.txt */
no_builtin("memset")
FAR void *memset(FAR void *s, int c, size_t n)

View file

@ -27,11 +27,13 @@
#include <strings.h>
#include <ctype.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCASECMP
#if !defined(CONFIG_LIBC_ARCH_STRCASECMP) && defined(LIBC_BUILD_STRING)
#undef strcasecmp /* See mm/README.txt */
int strcasecmp(FAR const char *cs, FAR const char *ct)
{

View file

@ -26,11 +26,13 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCAT
#if !defined(CONFIG_LIBC_ARCH_STRCAT) && defined(LIBC_BUILD_STRING)
#undef strcat /* See mm/README.txt */
FAR char *strcat(FAR char *dest, FAR const char *src)
{

View file

@ -26,6 +26,8 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -44,7 +46,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCHR
#if !defined(CONFIG_LIBC_ARCH_STRCHR) && defined(LIBC_BUILD_STRING)
#undef strchr /* See mm/README.txt */
FAR char *strchr(FAR const char *s, int c)
{

View file

@ -26,6 +26,8 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -44,7 +46,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCHRNUL
#if !defined(CONFIG_LIBC_ARCH_STRCHRNUL) && defined(LIBC_BUILD_STRING)
FAR char *strchrnul(FAR const char *s, int c)
{
if (s)

View file

@ -26,11 +26,13 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCMP
#if !defined(CONFIG_LIBC_ARCH_STRCMP) && defined(LIBC_BUILD_STRING)
#undef strcmp /* See mm/README.txt */
int strcmp(FAR const char *cs, FAR const char *ct)
{

View file

@ -26,6 +26,8 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -42,7 +44,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRCPY
#if !defined(CONFIG_LIBC_ARCH_STRCPY) && defined(LIBC_BUILD_STRING)
#undef strcpy /* See mm/README.txt */
FAR char *strcpy(FAR char *dest, FAR const char *src)
{

View file

@ -27,6 +27,8 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -44,7 +46,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRLCAT
#if !defined(CONFIG_LIBC_ARCH_STRLCAT) && defined(LIBC_BUILD_STRING)
size_t strlcat(FAR char *dst, FAR const char *src, size_t dsize)
{
FAR const char *odst = dst;

View file

@ -27,6 +27,8 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -43,7 +45,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRLCPY
#if !defined(CONFIG_LIBC_ARCH_STRLCPY) && defined(LIBC_BUILD_STRING)
size_t strlcpy(FAR char *dst, FAR const char *src, size_t dsize)
{
FAR const char *osrc = src;

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRLEN
#if !defined(CONFIG_LIBC_ARCH_STRLEN) && defined(LIBC_BUILD_STRING)
#undef strlen /* See mm/README.txt */
size_t strlen(const char *s)
{

View file

@ -28,11 +28,13 @@
#include <strings.h>
#include <ctype.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRNCASECMP
#if !defined(CONFIG_LIBC_ARCH_STRNCASECMP) && defined(LIBC_BUILD_STRING)
#undef strncasecmp /* See mm/README.txt */
int strncasecmp(FAR const char *cs, FAR const char *ct, size_t nb)
{

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRNCAT
#if !defined(CONFIG_LIBC_ARCH_STRNCAT) && defined(LIBC_BUILD_STRING)
#undef strncat /* See mm/README.txt */
FAR char *strncat(FAR char *dest, FAR const char *src, size_t n)
{

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRNCMP
#if !defined(CONFIG_LIBC_ARCH_STRNCMP) && defined(LIBC_BUILD_STRING)
#undef strncmp /* See mm/README.txt */
int strncmp(FAR const char *cs, FAR const char *ct, size_t nb)
{

View file

@ -26,6 +26,8 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -51,7 +53,7 @@
*
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRNCPY
#if !defined(CONFIG_LIBC_ARCH_STRNCPY) && defined(LIBC_BUILD_STRING)
#undef strncpy /* See mm/README.txt */
FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
{

View file

@ -26,11 +26,13 @@
#include <sys/types.h>
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
#ifndef CONFIG_LIBC_ARCH_STRNLEN
#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && defined(LIBC_BUILD_STRING)
size_t strnlen(const char *s, size_t maxlen)
{
const char *sc;

View file

@ -26,6 +26,8 @@
#include <string.h>
#include "libc.h"
/****************************************************************************
* Public Functions
****************************************************************************/
@ -34,7 +36,7 @@
* occurrence of the character c in the string s.
*/
#ifndef CONFIG_LIBC_ARCH_STRRCHR
#if !defined(CONFIG_LIBC_ARCH_STRRCHR) && defined(LIBC_BUILD_STRING)
#undef strrchr /* See mm/README.txt */
FAR char *strrchr(FAR const char *s, int c)
{

View file

@ -62,6 +62,10 @@
#include <stdint.h>
#include <string.h>
#include "libc.h"
#if !defined(CONFIG_LIBC_ARCH_MEMCPY) && defined(LIBC_BUILD_STRING)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -342,3 +346,5 @@ FAR void *memcpy(FAR void *dest, FAR const void *src, size_t count)
return dest;
}
#endif