Commit Graph

21 Commits

Author SHA1 Message Date
zhanghongyu 908814a575 libc/lib_bzero:Add bzero prototype.
Implement the bzero function as an alternative to macro expansion.

and support gcc FORTIFY_SOURCE features for nuttx libc

This function will use gcc's function
__builtin_dynamic_object_size and __builtin_object_size

Its function is to obtain the size of the object through compilation,
so as to judge whether there are out-of-bounds operations in commonly used functions.
It should be noted that the option -O2 and above is required to enable this function

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-05-07 14:59:05 +02:00
yinshengkai b87804c2ba libc/string: replace __builtin_ffsl with inline function
In the gcc-riscv compiler, __builtin_ffs will call ffs, and calling __builtin_ffs in ffs will cause recursion

Change ffs to an inline function, and compile ffs implemented by nuttx by default.
Only call the implementation of nuttx when the compiler cannot provide an ffs implementation.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-04-30 19:47:08 +08:00
chenrun1 f12c4fb887 Revert "libc/lib_bzero:Add bzero prototype." 2023-11-21 07:56:52 -08:00
anjiahao d5981375a6 Support gcc FORTIFY_SOURCE features for nuttx libc
This function will use gcc's function
__builtin_dynamic_object_size and __builtin_object_size

Its function is to obtain the size of the object through compilation,
so as to judge whether there are out-of-bounds operations in commonly used functions.
It should be noted that the option -O2 and above is required to enable this function

Signed-off-by: anjiahao <1090959677@qq.com>
2023-06-22 20:38:45 +08:00
chenrun1 4f3c73fb45 libc/lib_bzero:Add bzero prototype.
Implement the bzero function as an alternative to macro expansion.
2023-02-25 08:07:07 +02:00
Xiang Xiao ef1a98dd00 Remove the unneeded void cast
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-17 23:32:05 +03:00
Xiang Xiao cdc781bdfd libc: Implement local_t related functions
since local_t isn't really implemented on NuttX,
we can simply redirect to the non-locale version.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-30 09:43:26 -03:00
mage1 def007e2d7 add #undef for some libc function
since it's useful to redirect these functions to others
sometime(e.g. validate the memory before write).

Change-Id: I6253a9231af8809e8362f4bc5a1bd67fb094c3b0
2021-07-14 15:09:58 -03:00
Alin Jerpelea 9b9be7e1f0 include: Author: Gregory Nutt: update licenses to Apache 2.0
Update files from Gregory Nutt to Apache 2.0 license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-04 03:33:58 -08:00
Xiang Xiao ba3f12c93f libc: Implement popcount/popcountl/popcountll
specified here:
https://www.unix.com/man-page/netbsd/3/popcountll/

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-21 07:37:04 -07:00
Xiang Xiao 5c67eac27f libc: Change index/rindex from macro to function
to avoid the confliction with the same name variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-05 04:39:03 -07:00
Xiang Xiao 60fe0a0f96 libc: Refine the inline handling
1.Remove CONFIG_HAVE_INLINE macro
2.Change the ANSI C function to normal function
3.Other simple non ANSI function to macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-04 11:10:29 +09:00
Xiang Xiao a7174cee30 libc: Unify the selection of inline or macro
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I44a26550ff856af07d2d96a6f0a6066f988d6da3
2020-06-02 09:32:25 -06:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Jussi Kivilinna d0c54039dc Add ffsl(), ffsll(), fls(), flsl(), flsll() and use GCC's __builtin_ctz/__builtin_clz for faster implementation of these 2017-03-24 09:41:31 -06:00
Gregory Nutt 8c7ec7419a Eliminate a warning 2017-02-22 14:04:06 -06:00
Gregory Nutt 4539988d00 Removed CONFIG_LIBC_ARCH_BZERO. bzero() is a deprecated interface. There are no architecture-specific replacements and, if there were, they should replace memset(), not bzero(). 2017-02-22 10:41:49 -06:00
Gregory Nutt fb0e4d66c0 Fix ordering of parameters in call to memmove() in strings.h. Noted by David Sidrane. 2017-02-22 10:34:10 -06:00
Gregory Nutt cb7c5f9921 Implement strings.h macros as inline functions when possible for better C++ compatibility. 2017-02-22 10:20:58 -06:00
Gregory Nutt 22a8c2178d cstring: undefine macros defined in new strings.h. 2017-02-22 06:59:39 -06:00
Gregory Nutt 4f5879f998 C library: Add ffs(). Add strings.h. Move strcasecmp, strncasecmp, bzero, bcmp, and bcopy to where they belong in strings.h.h, not string.h. bzero, bcmp, and bcopy are legacy functions; the contemporary counterparts should be used instead. 2017-02-16 16:10:09 -06:00