Replies: 2 comments 2 replies
-
@nslowell - it might be possible to adjust the symbolic values for _SC_PAGE_SIZE and others within Zephyr to align with those from Newlib without introducing any regressions. If there is some base offset that needs to be subtracted to fit compactly in an array, it should be relatively easy to do. Are you comfortable making a PR for that? |
Beta Was this translation helpful? Give feedback.
-
@cfriedt - The simple change is switching the current enum list to this:
which allows If we switch to a list of #defines like newlib, then more changes will be needed (unknown at the moment) b/c z_sysconf will break. Thoughts? |
Beta Was this translation helpful? Give feedback.
-
The following issue doesn't seem to exist in any currently supported workflows, but external workflows (i.e. meta-zephyr for building zephyr with yocto) have led me to the following issue that I thought was worth bringing up, especially b/c I think it will be a problem at somepoint in the future assuming continued newlib & picolib upgrades in the SDK and it might dictate some adjustments that are needed in zephyr's posix code domain.
TL;DR
Newlib added sysconf for arm which can cause precompiled newlib to call into zephyr's sysconf function, but the symbolic constants for sysconf (e.g. _SC_PAGE_SIZE) are currently defined with different values b/w newlib's unistd.h and zephyr, which cause incorrect sysconf processing.
Reproduction:
cd ~/zephyrproject/zephyr
Add
printk("%s(%d)\n", __func__, x);
to the top of the sysconf function
prj.conf:
CMakeLists.txt:
src/main.cpp:
If you look in ~/sdk-ng/newlib/newlib/libc/stdlib/_mallocr.c, line 666, you will see the sysconf(_SC_PAGE_SIZE) call.
The problem is that newlib was built using ~/sdk-ng/newlib/newlib/libc/include/sys/unistd.h which defines _SC_PAGE_SIZE as 8.
But zephyr is using include/zephyr/posix/sys/sysconf.h and sees _SC_PAGE_SIZE as 110 and 8 is _SC_MAPPED_FILES.
So zephyr's sysconf isn't returning the correct switch case value when called from newlib.
Resolution
I'm not really sure what the "correct" fix is, since at first glance it seems like there are a few changes that could be made, so the following is very much me thinking out loud.
I'm interested to have @cfriedt and @ycsin give their take on this, since its POSIX.
But this has a libc component, so @stephanosio @aescolar @nashif and @keith-packard might also have good input.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions