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

   ## Summary
   
   C11 7.26.5.5 defines `thrd_exit()` as a library function. In `threads.h` it 
was a `static inline` function, so a program could not take its address, and 
`#pragma weak thrd_exit` failed with "weak declaration of 'thrd_exit' must be 
public".
   
   This PR adds `thrd_exit()` to libc (`libs/libc/pthread/thrd_exit.c`). It 
calls `pthread_exit()` with the result, as the inline version did; the cast now 
goes through `intptr_t`, so the conversion from `int` to a pointer is correct 
on 64-bit targets. `threads.h` keeps only the prototype, inside an `extern "C"` 
block, and the function is added to `libc.csv`.
   
   ## Impact
   
   `thrd_exit()` is now a real function. Its behaviour does not change.
   
   ## Testing
   
   A test program on `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4) takes 
the address of `thrd_exit`, calls it directly and through a pointer from 
threads made by `thrd_create()`, and checks that `thrd_join()` gets 42 and -7: 
it passes. `#pragma weak thrd_exit` fails to compile on master and compiles 
with this PR.
   
   `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: 
Exiting with status 0`. `lm3s6965-ek:qemu-flat` builds. `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