You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "tmedicci (via GitHub)" <gi...@apache.org> on 2023/04/29 14:29:44 UTC

[GitHub] [nuttx] tmedicci commented on a diff in pull request #9138: libc/string: select arch's libc for kernel/userspace optionally

tmedicci commented on code in PR #9138:
URL: https://github.com/apache/nuttx/pull/9138#discussion_r1181085999


##########
libs/libc/machine/Kconfig:
##########
@@ -137,6 +137,50 @@ config LIBC_ARCH_ELF_64BIT
 	default n
 	depends on LIBC_ARCH_ELF
 
+config LIBC_ARCH_ALLOW_KERNEL_ONLY
+	bool
+	default n
+
+config LIBC_ARCH_ALLOW_USER_ONLY
+	bool
+	default n
+
+if BUILD_PROTECTED || BUILD_KERNEL
+
+choice LIBC_ARCH_USAGE
+	prompt "libc architecture-specific usage"
+	default LIBC_ARCH_BOTH
+	depends on LIBC_ARCH_ALLOW_KERNEL_ONLY || LIBC_ARCH_ALLOW_USER_ONLY
+
+config LIBC_ARCH_BOTH
+	bool "Use architecture-specific on kernel and userspace"
+	depends on LIBC_ARCH_ALLOW_KERNEL_ONLY
+	depends on LIBC_ARCH_ALLOW_USER_ONLY

Review Comment:
   Well, the considerations of this comment are the same of the next one's (https://github.com/apache/nuttx/pull/9138#pullrequestreview-1406556561), so I'll answer here, alright?
   
   Well, first of all, I tried to avoid the need of fixing other architectures and make this change very isolated. If none of the `LIBC_ARCH_ALLOW_KERNEL_ONLY` and `LIBC_ARCH_ALLOW_USER_ONLY` options are selected, the build system will use the arch-specific for both the kernel and the userspace (as it works currently). These two options, however, if selected by the chip, state that the chip allows using arch-specific's libc on kernel/userspace only (and that's why I used `_ALLOW_xxx_ONLY`). However, it doesn't select it. This is done by the `LIBC_ARCH_USAGE` choice.
   
   That being said, if only one of the `LIBC_ARCH_ALLOW_xxx_ONLY` is selected, the choice will be selected automatically to use the arch-specific implementation on kernel/userspace only. There might exist, however, a situation that - for a specific chip - both options are valid: the chip allows arch-specific to be used only in the kernel, only in the userspace, or both in the kernel and the userspace (same effect of the current implementation). So, if the chip selects both the `LIBC_ARCH_ALLOW_KERNEL_ONLY` and `LIBC_ARCH_ALLOW_USER_ONLY` options, it's up to the user/`defconfig` to select which combination (using the `LIBC_ARCH_USAGE` choice) will be used and `LIBC_ARCH_BOTH` is necessary to be able to not select one of the `LIBC_ARCH_xxx_ONLY` choices automatically. You can think as a non-restrictive option.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org