casaroli opened a new pull request, #3904: URL: https://github.com/apache/nuttx-apps/pull/3904
## Summary In NuttX `CLOCKS_PER_SEC` is the system tick rate today, so `CLOCKS_PER_SEC`, `CLK_TCK` and the tick macros (`TICK2MSEC()`, ...) give the same numbers for a `clock()` value. But they are different things: `CLOCKS_PER_SEC` is the unit of `clock()`, and `CLK_TCK` is the tick rate (the unit of `times()` and `sysconf(_SC_CLK_TCK)`). XSI requires `CLOCKS_PER_SEC` to be 1000000 (issue apache/nuttx#3516). The dev@ thread "[DISCUSS] Breaking change: make CLOCKS_PER_SEC 1000000" (https://lists.apache.org/thread/bqxry570g9t63j63zmk4c5l82lybtx4s) proposes that change in three steps; this PR is step 1 and does not change behaviour. This PR makes the apps use each name for its own meaning: - ftpc (`replytimeo`, `conntimeo`) and cpuload (`CPULOAD_US`) used `CLOCKS_PER_SEC` as the tick rate: they use `CLK_TCK`. - dhcpc and ping converted a difference of `clock()` values with `TICK2MSEC()` and `TICK2USEC()`: they convert it with `CLOCKS_PER_SEC`. Each use is correct today, and stays correct if `CLOCKS_PER_SEC` becomes 1000000. The `TIMER` function of bas, which also divides `clock()` by `CLK_TCK`, follows in a separate PR: the style check of `interpreters/bas/bas_global.c` reports many older errors in the whole file. ## Impact None today. The values do not change while `CLOCKS_PER_SEC` is the tick rate, if `CONFIG_USEC_PER_TICK` divides one second (all in-tree configurations); see Testing for the object code. Not a breaking change. ## Testing qemu-armv8a:netnsh_smp with `CONFIG_NETUTILS_FTPC`, `CONFIG_SYSTEM_CPULOAD`, `CONFIG_NETUTILS_DHCPC`, ping and ping6 (`CONFIG_SYSTEM_PING`, `CONFIG_SYSTEM_PING6`, with `CONFIG_NET_IPv6`), built with apps master and with this PR; the objects compared with `objdump -dr` (code and relocations) and `objdump -s` (all sections but debug information): | Object | Result | |---|---| | `netutils/ftpc`: `ftpc_connect.o`, `ftpc_quit.o`, `ftpc_utils.o` | same | | `system/cpuload`: `cpuload_main.o` | same | | `netutils/dhcpc`: `dhcpc.o` | same | | `netutils/ping`: `icmp_ping.o`, `icmpv6_ping.o` | same | The compiler makes the same code from `(clk) * MSEC_PER_SEC / CLOCKS_PER_SEC` as from `TICK2MSEC(clk)` while `CLOCKS_PER_SEC` is the tick rate. `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]
