-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
lib: os: PoT utilities, hash function, hash map (hash table) #53405
Conversation
d5dc0b6
to
8438353
Compare
Need to also make test permutations for each of the different libc's because the default allocator is |
4070a47
to
eb48d35
Compare
@JordanYates - would you ack? |
@carlocaione - look reasonable to you now? If so, please ack :-) |
As just discovered by @aborisovich ,
|
@marc-hb - this is specifically a workaround for |
@cfriedt I'm not asking about any specific workaround or other detail. https://docs.zephyrproject.org/latest/develop/languages/c/index.html clearly states "In summary, it is recommended to use a compiler toolchain that supports at least the C11 standard for developing with Zephyr" https://docs.zephyrproject.org/latest/develop/languages/cpp/index.html does not seem to mention any specific C++ version right now. If your recent change requires a C++14 toolchain for any C++ use then it is significantly different from the C11 requirement (3 years newer!) and it should be mentioned on that page. Zephyr has a very complex toolchain abstraction layer to support a broad range of toolchains, so bumping the requirements and excluding a number of old toolchains is a pretty big deal. A doc update really looks like a minimum.
Sorry but I'm not a C++ expert, I don't know which C++ feature is available in each C++ version and I'm not the one who just bumped some C++ requirement. In fact I'm merely trusting @aborisovich here who noticed because his C++ workspace just started failing somehow. To make sure there's no confusion: I have no opinion on which C++ hard dependencies the Zephyr C++ "core" should have versus not (others might). On the other hand, if C++ requires a newer toolchain than C then a brief mention on https://docs.zephyrproject.org/latest/develop/languages/cpp/index.html looks like a bare minimum. Next time some advance notice would not hurt either. |
@marc-hb - If your C compiler is ISO compliant, then anything contained within
The ISO C standard (C11) and the ISO C++ standard (C++14) are not very closely related. I would defer to the C++ maintainer for that. CC @stephanosio.
Again, feel free to make a PR.
I am also not a C++ expert. Feel free to file an issue, @aborisovich.
I'm sorry for the inconvenience. Thank you for bringing it up. Just for clarification, |
Not clear on the details here. Is the contention that Zephyr headers after this patch aren't going to build with existing C++11 projects? If so that does indeed seem like something we should fix; we're essentially breaking user apps. If it's just an issue of constexpr that's probably something we can do with some preprocessor magic, we don't generally expose C++ APIs per se, though I do see a few here. But then as @cfriedt points out, constexpr itself isn't new. What's the problem that got introduced? |
@andyross - the root cause was that |
OK... I'm coming up to speed. So the issue here (please correct what I'm getting wrong) is that this PR introduces a new generic API implemented both with C11 That does seem like it's likely to break things with oddball toolchains, yeah. Maybe we want to slow-walk this a little and move the new bits out into their own header, so that (Edit: heh, crossed. But yeah, I think I got it mostly right if I understand the explanation.) |
This very page is littered with references to later versions of the C++ standard, it took me a few seconds to see that. C++14 is referenced 10 times, C++17 is referenced 4 times, C++20 is referenced 20 times, C++23 is referenced 9 times.
I've been "pointing fingers" at technical and documentation issues only and only where they happened. Thanks for doing the same.
Yes please. |
@cfriedt nobody is pointing fingers, this is feedback from us because if external clients of Zephyr project discover that you suddenly require newer standard than before by compilation errors/warnings, that means you are doing something wrong. |
@aborisovich - respectfully, please file a bug report and report details of your issue rather than continuing here. This PR was thoroughly approved and merged.
As mentioned above, this is all in line with Zephyr's suggested ISO C and C++ standards (C11, C++11).
Good, then please make a PR. I take it you're using C++98?
Please report an issue with whatever detail you have. Zephyr CI is fairly extensive and this passed without issue, which is enough confidence to merge it.
Please tell me @aborisovich - how am I supposed to know that your client will have a problem with their CI system. I'm sorry, I don't have ESP. This is the definition of finger pointing. Please refer to the Code of Conduct. Thanks. https://github.com/zephyrproject-rtos/zephyr/blob/main/CODE_OF_CONDUCT.md |
@aborisovich - you seem to be very upset about this. Let me help you: Point number 1. Always frame your critique around the code, not the author. The latter makes you come off as being rude & demanding. "you are doing something wrong" as an example. It's probably better to say, this line of code is causing an issue - better yet, just put that in a bug report.
I'm having a hard time understanding why you think the Zephyr Project should change the publicly facing documentation because you discovered a bug that was specific to your project. Why would we make public announcements when someone can just apply a Bugfix? I can only suspect that it's to be able to point a finger. Point Number 2 Bugs are a fact of life here. If you are not basing your product from a tagged release, then it is an inevitability that your code will break. If you are concerned with stability, use a stable release.
Point Number 3 Good - you have solved your own problem. For the Nth time, please, file a PR. An issue, sure, if you like.
Lol.. no, my friend. Point number 4 Sorry, but you seem to believe that just because we have CI it's a guarantee that there will never be a single obscure bug due to some wild permutation of config variables. That's not how this works. If you believe otherwise, I welcome you to read the Apache 2.0 License.
This is exactly my point. Stop making demands. Stop telling me what to do. I do not work for you, and I pray I never do. Demanding that someone else fix a bunch of things for you is the wrong approach here. Had you asked politely in the first place instead of assuming some authoritative role here, I would probably have made the 2-line change for you, which you yourself had described above. Given all of the above, it makes me infinitely less likely to ever solve a problem for you. So please, file a PR. CC @carlescufi |
@cfriedt this is not about you. I've submitted the bug to draw attention to the matter so we start to track standard conformance better in Zephyr. Please stop being defensive. |
G++ doesn't "choke badly", you are trying to use a C feature in C++, that's totally invalid C++ code. |
The biggest restriction in C++11 is that a constexpr function can only have a single |
If the issue is simply wanting type-generic #ifdef __cplusplus
extern "C" {
#endif
float cbrtf(float);
double cbrt(double);
long double (cbrtl(long double);
#ifdef __cplusplus
// Additional overloads for float and long double
inline float cbrt(float f) { return cbrtf(f); }
inline long double cbrt(long double f) { return cbrtl(f); }
} // extern "C"
#endif You don't need to do anything with C11 generics, and you don't need |
@jwakely - That is not the issue encountered here but the simplest possible test case to show that g++ fails to parse The actual code in question was for compile-time constant power-of-two macros.
Actually I do, and I do (but mainly as a workaround for g++ not supporting Bug was filed (and quickly marked invalid / closed) here |
That just means clang has a non-standard extension. It's not a GCC bug that it doesn't support it. It's not in C++.
Yes, I know - I closed it. Looking at your A valid C++11 implementation would be: template <typename T> constexpr int __z_log2_impl(T x)
{
/* No declaration of __ASSERT is available here */
static_assert(sizeof(x) <= sizeof(unsigned long long), "unsupported type for LOG2()");
return sizeof(x) < sizeof(unsigned int) ?
((x) < 1) * (-1) +
((x) >= 1) * (NUM_BITS(unsigned int) - __builtin_clz(x) - 1)
: sizeof(x) <= sizeof(unsigned long long) ?
((x) < 1) * (-1) +
((x) >= 1) * (NUM_BITS(unsigned long long) - __builtin_clzll(x) - 1)
: -1;
} |
#define __z_log2_impl(x) \ | ||
(((x) < 1) * (-1) + \ | ||
((x) >= 1) * _Generic((x), char \ | ||
: (NUM_BITS(unsigned int) - __builtin_clz(x) - 1), unsigned char \ |
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.
Is omitting signed char
intentional?
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.
@jwakely - no... because .. it wasn't omitted?
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.
Yes it was. char
and signed char
are distinct types.
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.
Thanks for clarifying - patches welcome!
@jwakely Oh, ok. Then should I file an issue as a feature request? I didn't see that option in bugzilla. Would it receive any more attention than what it was given today?
Thanks for the tips! |
Is there any chance that this discussion could continue in a new issue so that people who were subscribed to the PR do not continue to get updates that may not be relevant to them? |
@aborisovich filed #55204 two days ago and Github automatically added a link above. Its description seems very detailed and some discussion has already started there. Anyone who feels the need to file yet another, separate issue should of course do so. @andyross just submitted PR |
Note: Compliance failure is a false positive
IS_POWER_OF_TWO()
LOG2()
LOG2CEIL()
forceil(log2(x))
NHPOT()
for2^ceil(log2(x))
realloc()
semantics, withfree()
-like behaviour when size 0 is specifiedstd::unordered_map
for benchmarking purposessys_hashmap_oa_lp
on par withstd::unordered_map