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

   ## Summary
   
   `<stdlib.h>` defines `srandom()` as a macro for `srand()`, and libc has no 
`srandom()` function. A program cannot take its address or declare it, and a 
configure check that links a call to `srandom()` without the header does not 
find it.
   
   This PR adds `srandom()` to libc as a function that calls `srand()` 
(`random()` and `rand()` share one generator), declares it in `<stdlib.h>` and 
lists it in `libc.csv`.
   
   ## Impact
   
   `srandom()` is a function now; calls behave as before. Code that tests 
`#ifdef srandom` sees no macro now (no code in nuttx or nuttx-apps does). All 
build modes and architectures. Documentation: no change 
(`Documentation/standards/posix.rst` already lists `srandom()` as supported).
   
   ## Testing
   
   Test program `srandomtest.c`: it takes the address of `srandom`, seeds the 
generator through it, and checks that `srandom()` with the same seed gives the 
same `random()` value.
   
   | | master | this PR |
   |---|---|---|
   | `srandomtest.c` on `qemu-armv8a:knsh` (QEMU with HVF) | does not compile: 
`'srandom' undeclared` | PASS |
   | ostest, `qemu-armv8a:knsh` and `qemu-armv8a:nsh` | status 0 | status 0 |
   
   Build, each OK: `qemu-armv8a:nsh` (flat, arm64), `qemu-armv8a:knsh` (kernel, 
arm64), `rv-virt:knsh64` (kernel, rv64), `rv-virt:pnsh64` (protected, rv64), 
`lm3s6965-ek:qemu-protected` (protected, armv7-m). No new warnings.
   
   `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