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

   ## Summary
   
   `pthread_sigqueue()` is implemented in the kernel 
(`sched/pthread/pthread_sigqueue.c`), but it has no entry in the system call 
table: only `libs/libc/libc.csv` lists it. So in a protected or kernel build a 
user program that calls `pthread_sigqueue()` does not link. The CI of 
apache/nuttx-apps#3931 shows it: `undefined reference to 'pthread_sigqueue'` in 
`nuttx_user.elf` of `smartl-c906:knsh`.
   
   This PR adds `pthread_sigqueue` to `syscall/syscall.csv` (in alphabetical 
order; the `union sigval` argument is passed as for `sigqueue`) and to 
`include/sys/syscall_lookup.h`, next to `pthread_sigmask`. It removes the 
`libc.csv` entry, because the function is not in libc. The condition is 
`!defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_ALL_SIGNALS)`: 
`pthread_sigqueue.c` is built with pthreads, and it calls `nxsig_dispatch()`, 
which is built only with signals.
   
   ## Impact
   
   `pthread_sigqueue()` is available to user programs in protected and kernel 
builds. Adding a system call changes the numbers of the calls after it, as for 
any new system call; programs of a kernel build must be built again. Flat 
builds call the same function as before; the system symbol table now takes the 
entry from `syscall.csv`.
   
   ## Testing
   
   A test program (a thread waits in `sigwaitinfo()`; the main thread sends 
`SIGUSR1` with `pthread_sigqueue()`, first with a `sival_int`, then with a 
`sival_ptr`, and then with signal 1000):
   
   - `qemu-armv8a:knsh` (kernel build, QEMU 11 with HVF on an Apple M4):
     - master: the program does not link (`undefined references: 
pthread_sigqueue`).
     - this PR: both signals arrive with `si_code == SI_QUEUE` and the sent 
value; signal 1000 gives `EINVAL`.
   - `mps2-an500:knsh` (protected build, QEMU TCG), this PR: the same output.
   
   ```
   psqtest: send int ret=0
   psqtest: send ptr ret=0
   psqtest: badsig   PASS
   psqtest: int      PASS
   psqtest: ptr      PASS
   psqtest: PASS
   ```
   
   `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: 
Exiting with status 0`. With `CONFIG_DISABLE_ALL_SIGNALS=y` the generated 
`STUB_pthread_sigqueue.c` is under the same `#if`, so no stub is built (the 
full build of `mps2-an500:knsh` with that option fails on master too, in 
`boards/arm/mps/mps2-an500/kernel/mps_userspace.c:113`, for another reason). 
`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]

Reply via email to