casaroli opened a new pull request, #21648: URL: https://github.com/apache/nuttx/pull/21648
## Summary `<search.h>` has the hash table and binary tree functions, but not the XSI linear search and queue functions. shadow-utils, for example, calls `lfind()`. Commit 1 adds them to `libs/libc/search`: - `lfind()` compares the key with each element of a table and returns the first match. `lsearch()` does the same, and adds a missing key at the end of the table. - `insque()` and `remque()` link and unlink an element of a doubly linked queue (linear or circular). `insque(e, NULL)` starts a linear queue. - The prototypes go into `<search.h>` and the four functions into `libc.csv`. - With `CONFIG_FDPIC`, `lfind()` resolves the function descriptor that an FDPIC module gives as `compar`, as `bsearch()` and `qsort()` do. `lsearch()` gives `compar` to `lfind()`, so it is resolved one time. Commit 2 adds the functions to the libc search page and marks them as supported in the POSIX table. ## Impact Four new functions in libc. No Kconfig option, no change to other code. A program that does not call them gets no new code (`nucleo-f072rb:nsh`: text, data and bss are the same as on master). The behaviour is the same as glibc and musl, also for the cases that POSIX names: `insque()` with a NULL predecessor, and circular queues. ## Testing Test: apache/nuttx-apps#NNNN (`testing/libc/lsearch`, 17 checks of `lfind()`, `lsearch()`, `insque()` and `remque()`, linear and circular queues). On master the test does not compile on `qemu-armv8a:nsh`: implicit declaration of `lfind`, `lsearch`, `insque` and `remque`. With this PR, 0 errors, and ostest after it exits with status 0: - `qemu-armv8a:knsh` (kernel build, arm64, QEMU with HVF). - `qemu-armv8a:nsh` (flat build, arm64, QEMU with HVF). - `mps2-an500:knsh` (protected build, armv7-m, QEMU), built with `EXTRAFLAGS=-Werror`. - `qemu-armv8a:nsh` built with CMake (test only, no ostest). No new warnings in these builds. On a Linux host, the same test gives the same 17 results with glibc 2.43, with the musl sources and with the two files of this PR. FDPIC: `mps2-an500:xipfs` with `CONFIG_FDPIC`. I changed the callback module of `examples/fdpicxip` by hand to also call `lfind()` and `lsearch()` with its comparison function. `xipfs_test fdpic`: 34 passed, 0 failed. Without the `fdpic_callback()` lines in `lfind()`, the module stops with a usage fault (invalid state, PC in the module's data). `tools/checkpatch.sh -c -u -m -g` passes. -- 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]
