Commit Graph

13 Commits

Author SHA1 Message Date
yangguangcai f07aba5c1e libc string:Separate code.
Separate the code that follows the BSD license into independent files.

Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-23 09:49:19 +08:00
yangguangcai 6e87f11083 Merge the newlibc string into NuttX.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-17 22:52:42 +08:00
Alin Jerpelea 6b5dddd5d7 libs/libc: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-01 12:25:52 +08:00
yangdongdong 1956385a7d libs/libc: Breakdown LIBC_BUILD_STRING into specific string operations macro.
Provide a way to only customize specific string operations,
such as for memcpy with the DMA capability by ROM.

Signed-off-by: yangdongdong <yangdongdong@xiaomi.com>
2023-08-29 22:55:18 +08:00
Tiago Medicci Serrano 58e97e521c 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.
2023-05-17 13:58:48 +08:00
zhangyuan21 fae5aef4fe libc: add arm64 libc function
Porting memory and string optimize functions from newlib and bionic

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-10 11:31:26 +08:00
Juha Niskanen a17bfec43d libc/string: simplify strrchr
Do not call strlen() here. Old implementation iterated
over string twice, if searched for position was at the
beginning. This commit changes strrchr() to scan string
only once, regardless of input.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2022-05-10 23:29:23 +08:00
Xiang Xiao 4a16cf71f9 Fix -Werror=nonnull-compare and -Werror=format-truncation=
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
  203 |   strncpy(modp->modname, modname, MODLIB_NAMEMAX);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wqueue/kwork_thread.c: In function 'work_start_lowpri':
Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=]
  212 |   snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue);

local/local_sockif.c: In function 'local_getsockname':
Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  392 |           strncpy(unaddr->sun_path, conn->lc_path, namelen);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse':
Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
   memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer));
                                     ^

stdio/lib_fputs.c: In function 'fputs':
Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
         ^
Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
                           ^

stdio/lib_vfprintf.c: In function 'vfprintf':
Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (stream)
      ^

string/lib_strdup.c: In function 'strdup':
Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strndup.c: In function 'strndup':
Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strpbrk.c: In function 'strpbrk':
Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
       ^~~~
Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
               ^~~~~~~~

string/lib_strrchr.c: In function 'strrchr':
Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                                                  ^~
time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            1900 + tp->tm_year);
            ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 15:55:38 +08: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 b5d4a01821 libs: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-03-03 18:52:53 -08:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Petteri Aimonen fe0532c226 Merged in paimonen/nuttx/pullreq_libc_libnx_updates (pull request #757)
Pullreq libc libnx updates

* NuttX: make strerror() return 'Success' for 0

* NuttX: fix strrchr() so that it considers null terminator as part of string

    From strrchr(3) man page:
    "The terminating null byte is considered part of the string, so that if c
    is specified as '\0', these functions return a pointer to the terminator."

* NuttX: mm_free(): Add DEBUGASSERT()'s to catch memory corruption early.

    It's easier to find the source when asserts fail already when freeing
    an overflowed buffer, than if the corruption is only detected on next
    malloc().

* MM_FILL_ALLOCATIONS: Add debug option to fill all mallocs()

    This is helpful for detecting uninitialized variables,
    especially in C++ code. I seem to be forgetting to initialize
    member variables and then they just get random values..

* NuttX: nxtk_bitmapwindow: Fix warning message when bitmap is fully off-screen.

* nxfonts_getfont: Avoid unnecessary warnings for other whitespace chars also.

* NuttX: Fix kerning of 'I' in Sans17x22 font

    The I character was running together with some other
    characters, e.g. in sequence "IMI".

* NXMU: Revalidate window pointer for mouse events.

    NXMU caches the previous window pointer so that further mouse
    events can be sent to the same window. However, if the window
    is destroyed while mouse button is held down, the pointer may
    become invalid and cause a crash. This patch revalidates the
    pointer before using it.

Approved-by: GregoryN <gnutt@nuttx.org>
2018-11-12 15:36:35 +00:00
Gregory Nutt cf99fb40c9 This commit moves all of the libraries under a common directory called libs/. This most certainly break libcxx and uClibc++ for now.
Squashed commit of the following:

    libs/libxx:  Fix some confusing in naming.  If the directory is called libxx, then the library must be libxx.a (unless perhaps LIBCXX is selected).
    libs/:  Fix paths in moved library directories.
    libs:  Brute force move of libc, libnx, and libxx to libs.  Cannot yet build it in that configuration.
2018-05-29 13:21:26 -06:00