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

   ## Summary
   
   `uname()` copied `CONFIG_ARCH` into the `machine` field: `arm64` for the 
64-bit Arm architecture and `risc-v` for RISC-V. Linux gives `aarch64`, 
`riscv64` and `riscv32` for the same CPUs, and programs and scripts compare the 
field with these names (for example to select a binary by the output of `uname 
-m`, or for the platform name of a scripting language).
   
   Now `uname()` gives `aarch64` for `CONFIG_ARCH_ARM64`, `riscv64` for 
`CONFIG_ARCH_RV64` and `riscv32` for `CONFIG_ARCH_RV32`. x86_64 already gives 
`x86_64`. The other architectures keep `CONFIG_ARCH`: their Linux name is the 
same (xtensa, mips), depends on the CPU version (arm: armv6l, armv7l, ...; x86: 
i386 .. i686), or does not exist.
   
   A second commit says in the NSH `uname` documentation which name `uname -m` 
prints.
   
   ## Impact
   
   The `machine` field of `uname()` changes on arm64 (`arm64` to `aarch64`) and 
on RISC-V (`risc-v` to `riscv64` or `riscv32`), in flat, protected and kernel 
builds. NSH `uname -m` and `uname -a`, the assert dump header and the core dump 
`NT_UTSNAME` note show the new name. No layout, symbol or system call changes.
   
   Users in the tree: nuttx (`sched/misc/assert.c`, 
`fs/procfs/fs_procfsversion.c`, `include/nuttx/coredump.h`, 
`boards/arm/stm32h7/stm32h7s8-dk/src/stm32_xip_boot.c`) and apps 
(`nshlib/nsh_syscmds.c`, `netutils/webserver/httpd_dirlist.c`, 
`examples/webpanel/cgi_sysinfo.c`, `examples/lvglcam/lvglcam_main.c`) only 
print or copy the field; none compares it with a name. A program outside the 
tree that compares the field with `arm64` or `risc-v` must also accept the new 
name.
   
   The `uname -a` examples in the board documentation are logs of older 
releases (they name the release), so they stay as they are.
   
   ## Testing
   
   The apps PR adds `test_nuttx_syscall_uname01` to `cmocka_syscall_test`. It 
checks `sysname` and the Linux name of the CPU (`aarch64`, `riscv64`, 
`riscv32`, `x86_64`), and on other architectures only that `machine` is not 
empty.
   
   | Configuration | master 1af7ac541e4 | this PR |
   |---|---|---|
   | qemu-armv8a:nsh (flat, arm64, QEMU TCG) + `CM_SYSCALL_TEST` | `uname -a`: 
`... arm64 qemu-armv8a`; uname01 FAIL (`"arm64" != "aarch64"`) | `... aarch64 
qemu-armv8a`; uname01 OK |
   | rv-virt:nsh64 (flat, riscv64, QEMU TCG) + `CM_SYSCALL_TEST` | `... risc-v 
rv-virt`; uname01 FAIL (`"risc-v" != "riscv64"`) | `... riscv64 rv-virt`; 
uname01 OK |
   | rv-virt:nsh (flat, riscv32, QEMU TCG) + `CM_SYSCALL_TEST` | - | `... 
riscv32 rv-virt`; uname01 OK |
   | rv-virt:knsh64 (kernel, riscv64, QEMU TCG with OpenSBI) | `uname -m`: 
`risc-v` | `uname -m`: `riscv64` |
   | qemu-intel64:nsh (flat, x86_64, QEMU KVM) | - | `uname -m`: `x86_64` (no 
change) |
   
   Builds with the CI image (`-Werror`): the configurations above, 
rv-virt:pnsh64 (protected) and qemu-armv8a:knsh (kernel): all OK.
   
   `tools/checkpatch.sh -c -u -m -g`: pass.
   


-- 
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]

  • [PR] libs/libc/uname: Use the... casaroli (via GitHub) via commits

Reply via email to