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

   ## Summary
   
   `struct rusage` had `ru_utime`, `ru_stime` and `ru_maxrss` only. POSIX 
requires only `ru_utime` and `ru_stime`, but Linux, macOS and the BSDs have the 
14 fields of 4.3BSD, and programs use them without a check (`uv_getrusage()` of 
libuv, for example). Such programs did not compile.
   
   This PR adds the 13 missing fields (`ru_ixrss`, `ru_idrss`, `ru_isrss`, 
`ru_minflt`, `ru_majflt`, `ru_nswap`, `ru_inblock`, `ru_oublock`, `ru_msgsnd`, 
`ru_msgrcv`, `ru_nsignals`, `ru_nvcsw`, `ru_nivcsw`) in the order of the other 
systems. `getrusage()` clears the whole structure, so they are zero, as 
`ru_maxrss` was.
   
   ## Impact
   
   - The size of `struct rusage` changes (from 2 `struct timeval` + 1 `long` to 
2 `struct timeval` + 14 `long`; 40 to 144 bytes on LP64). Programs that use 
`getrusage()`, `wait3()` or `wait4()` must be built again.
   - No change of behaviour: `getrusage()` stays as it was, and all fields 
except `ru_utime` and `ru_stime` are zero.
   - In nuttx-apps, the libuv and toybox patches leave out the fields that 
NuttX did not have. They still compile, and could use the fields later.
   - No documentation change: `Documentation/standards/posix.rst` lists 
`getrusage()` only.
   
   ## Testing
   
   Test program `rusagebsd.c`: `fields` (a program that uses all 16 fields 
compiles; the size is 2 `struct timeval` + 14 `long`), `self` 
(`getrusage(RUSAGE_SELF)` sets every field), `child` (`wait4()` of a child that 
exited sets every field and gives its status), `einval` (`getrusage()` with 
NULL fails with `EINVAL`).
   
   | Build | Config | master (192ac6d3fbc) | this PR |
   |---|---|---|---|
   | kernel, arm64 | `qemu-armv8a:knsh` (QEMU, HVF) | does not compile (no 
`ru_ixrss` ...) | `fields` (size 144), `self`, `child`, `einval`: PASS |
   | flat, arm64 | `qemu-armv8a:nsh` (QEMU, HVF; the test as a builtin app) | 
not run (the same header as the kernel build) | `fields` (size 144), `self`, 
`child`, `einval`: PASS |
   
   ostest exits with status 0 on `qemu-armv8a:knsh`, `qemu-armv8a:nsh` and the 
flat run above.
   
   Builds (make): `nucleo-f072rb:nsh` (flat, armv6-m), 
`lm3s6965-ek:qemu-protected` (protected, armv7-m), `rv-virt:pnsh64` (protected, 
risc-v), `rv-virt:knsh64` (kernel, risc-v): OK.
   
   `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