Shanks0224 opened a new pull request, #22169:
URL: https://github.com/apache/nuttx/pull/22169

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
     
     This PR collects fixes and additions to the C library (`libs/libc`), 
grouped
     by area. Each commit is self-contained and explains its own motivation.
     
     **Conformance fixes**
     - stdio: `ungetc()`/`fseek()` clear the EOF indicator, reads stop while EOF
       is set, `fdopen()` enables line buffering only for terminals, new streams
       start with an empty pushback buffer, `freopen()` updates the mode when 
the
       path is NULL, scanf `%%` skips leading whitespace and `%p` is correct on
       64-bit, locking in `puts()`/`fputws_unlocked()`.
     - scanf: arguments of conversions that did not match are no longer cleared
       (`sscanf("30 ", "%d %d", &a, &b)` leaves `b` unchanged).
     - fflush: on a seekable input stream it now sets the file offset to the
       stream position and discards pushed-back characters, instead of failing
       with EBADF.
     - strftime: `%C`, `%x` and `%r` were wrong, `%c` and `%D` were missing.
     - setlocale: returns NULL for an invalid category.
     - strtol/strtold, pathconf/fpathconf, `nl_langinfo`, `strncmp`/`toupper`
       signedness, `setenv`/`unsetenv` without a task_info, `ether_ntoa_r`
       bounds, `openpty` error checks, `regex` stack depth, and others.
     - time: `difftime`, 32-bit overflow in `mktime`, `tzset` copy of TZ,
       recursive zone loading, time zone loading outside the zone lock.
     
     **New functions / options**
     - `getaddrinfo_a()`, `gai_suspend()`, `gai_cancel()`, `gai_error()`
     - `fallocate()` (and `posix_fallocate()` built on it), `statx()`
     - `timingsafe_memcmp()`, `bcmp()` for FORTIFY_SOURCE
     - `CONFIG_LIBC_QSORT_SMALL` (heapsort variant of `qsort()`)
     - missing `pthread_cond_*`, `pthread_mutex_*`, `fseeko`, `ftello`, `strtof`
       entries in `libc.csv`
     
     **Architecture string/memory function optimizations**
     - ARM (armv7-a, armv7-r, armv8-r, armv7-m, armv8-m): new `memcmp`, 
`strchr`,
       `strchrnul`, `strncmp`, `strnlen`, `strrchr`; faster `memmove` 
(NEON/MVE);
       8-byte `memcmp` on ARM state; MVE paths for `memchr`, `strlen`, `strcpy`
       on armv8-m.
     - arm64 `memcpy` with Advanced SIMD; x86_64 `strnlen` and AVX2 functions;
       Xtensa string/memory functions.
     - All of these are opt-in through their Kconfig options (default n).
     
     ## Impact
     
     - scanf: code that relied on unmatched arguments being zeroed will see the
       old value instead, as C and POSIX require.
     - fflush on an input stream now returns success and repositions the file
       instead of returning EBADF.
     - The assembly functions are opt-in; other behavior changes are limited to
       the fixes listed above.
     - No documentation changes; no impact on the build system or hardware.
     
     ## Testing
     
     Build host: Linux x86_64.
     
     Simulator (`sim:nsh`):
     - Builds with no warning.
     - `ostest`: the set of 43 subtests is identical to unmodified master, with
       no failure, assert or panic.
     - strftime (36 conversions x 6 hours of the day), scanf (integer, float,
       string, char) and fflush results were compared with glibc.
     
     String functions, 2904 cases (offsets 0-32, lengths 0-300) for `memcmp`,
     `memchr`, `strlen`, `strnlen`, `strchr`, `strchrnul`, `strrchr`, `strcmp`,
     `strncmp`, `strcpy` and `memcpy`, run on QEMU with the optimized functions
     enabled; all pass:
     - x86_64 `qemu-intel64:nsh` (KVM): SSE2 path, and AVX2 path.
     - arm64 `qemu-armv8a:nsh`: `ARM64_STRING_FUNCTION` (Advanced SIMD memcpy).
     - RISC-V `rv-virt:nsh64`: existing RISC-V string functions
       (this PR has no RISC-V specific change; this run checks for regressions).
     
     ARM assembly, compared with a byte-by-byte reference over offsets, lengths
     and overlaps (memmove: 100800 combinations), on QEMU; all pass:
     - qemu-armv7a (Cortex-A7), qemu-armv7r (Cortex-R5F),
       mps2-an500 (Cortex-M7), mps3-an547 (Cortex-M55, MVE path).
     - Measured on Cortex-A7 with `-icount shift=0`: memmove of 4096 bytes
       32819 us -> 2092 us, memcmp of 4096 bytes 16432 us -> 9265 us.
     
     Not verified:
     - armv8-r assembly was only compiled (the qemu-armv8r-aarch32 board does
       not start on the QEMU version used).
     - Pointer authentication (PAC/BTI) code paths were only assembled.
     - The Cortex-M55 test cases were reduced in number on the final master
       because the host was heavily loaded; the full set passed earlier.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to