-
Notifications
You must be signed in to change notification settings - Fork 7.9k
util: move utf8 utils to a separate header #95355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
util: move utf8 utils to a separate header #95355
Conversation
7ef92fc
to
a3f0834
Compare
cc @iliar |
No I caught this downstream, but that's just because nothing hit the particular combination of options that triggers the build fail, fine by me giving it one more day, just concerned about other users bumping into it, was a bit of a pain to troubleshoot would gladly spare other users from doing the same. |
CI test for this: #95395 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiobaltieri - my 2¢: leave the declarations in sys/util.h
but remove <sys/types.h>
and change the ssize_t
to int
.
The reasoning: Zephyr does occasionally get into trouble using POSIX types, especially the kind that have a length dependent on the arch.
In ISO C, time_t
and size_t
fall into that category.
In POSIX, ssize_t
, off_t
, and possibly others.
I can do that, but looking at this file I think that these utf8 utilities should have never been in this file in the first place, util.h should really just be basic utilities that can find use anywhere, these utf8 string analysis/manipulation things belongs to their own header, how about keeping this to move them out and then you can do whatever you want with the type? Feels like util.h became a bit of a dumping ground, these functions have their own C file, they should have their own header. |
d395e1d
Swapped to int, kept the separate header. |
This moves the declaration of the utf8 utils defined in lib/utils/utf8.c in their own header. Main reason to do this is that the current setup requried adding an include for sys/types.h in util.h, which can result in a build falure due to a circular header depdenecy when using: CONFIG_POSIX_API=y CONFIG_NEWLIB_LIBC=y _GNU_SOURCE the loop and error are: - include/sys/types.h:50: <- this is a NEWLIB one - include/zephyr/posix/sys/select.h:9: - include/zephyr/posix/posix_types.h:30: - include/zephyr/kernel.h:17: - include/zephyr/kernel_includes.h:25: - include/zephyr/sys/atomic.h:18: include/zephyr/sys/util.h:705:1: error: unknown type name 'ssize_t' Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
d395e1d
to
d950df9
Compare
Change utf8_count_chars return type to int and drop thesys/types.h, this way the function does not depend on posix types. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
d950df9
to
cd42ae0
Compare
Sorry one more tweak: converted the local variable in utf8.c as well and drop the header from there too. Nothing is ever easy. |
You know what, I may as well cherry pick the test while I'm at it. |
This combination (with newlib) seems to catch some build failures due to include depdenency, adding a test file so it gets caught in CI. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
|
LGTM - in general, we should avoid exposing "gnuisms" that become visible with For test purposes, I think it's OK to do as evidence to show that we don't break in the presence of that macro. |
Yeah of course, that's just for testing purposes, downstream users may do it, and we already have other tests that do it, and surprisingly some drivers code too. |
@nashif? (note that there's a CI false positive) |
Hi, bumped into a build regression since #94779, one of our downstream application uses an interesting combination of configs that triggered a circular dependency build failure (which was a lot of fun to troubleshoot).
Managed to reproduce the issue upstream with
and
west build -p -b nrf52dk/nrf52832 samples/basic/blinky -DCONFIG_POSIX_API=y -DCONFIG_NEWLIB_LIBC=y
May look into adding a test case for this but for now I think the right thing to do is to split these on their own header.
--
This moves the declaration of the utf8 utils defined in lib/utils/utf8.c in their own header. Main reason to do this is that the current setup requried adding an include for sys/types.h in util.h, which can result in a build falure due to a circular header depdenecy when using:
CONFIG_POSIX_API=y
CONFIG_NEWLIB_LIBC=y
_GNU_SOURCE
the loop and error are:
include/zephyr/sys/util.h:705:1: error: unknown type name 'ssize_t'