-
Notifications
You must be signed in to change notification settings - Fork 8.2k
libc: add strtoll and strtoull functions #16511
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
libc: add strtoll and strtoull functions #16511
Conversation
7eded00 to
63b1db5
Compare
|
All checks are passing now. Review history of this comment for details about previous failed status. |
They differ only in details. I elevated the basic "working" type to unsigned long long to handle larger types with the same function. Signed-off-by: Piotr Zierhoffer <[email protected]>
From IEEE Std 1003.1-2017: These functions shall convert the initial portion of the string pointed to by str to a type unsigned long and unsigned long long representation, respectively. Signed-off-by: Piotr Zierhoffer <[email protected]>
989daa1 to
55be7d8
Compare
They are no longer needed in the sample shim layer, as they are available in minimal-libc. Signed-off-by: Piotr Zierhoffer <[email protected]>
55be7d8 to
71e16e8
Compare
|
Closing/reopening to restart CI. |
|
I'm +1 for further elaborating minlibc, as I said on multiple occasions, and it's especially important as we're going to bloat up newlib: zephyrproject-rtos/sdk-ng#62 But to vote this up with clear conscience, code size change stats would rather be provided. |
For example, stats on enabling long long support for newlib stdio: zephyrproject-rtos/sdk-ng#101 (comment) . +13K or 100% code size growth for a simple app. (Yeah, that accounts for disabling "nano formatting" support, not just switching all existing calculations in print/scanf from long to long long). |
|
Thanks @pfalcon , I will try to provide some results when I'm at my PC |
|
@pfalcon I am not 100% sure if my test is ok or not, please advise. I took samples/hello_world and added My PR: Test on There is some increase in the size, but it's not up to me to decide if it's acceptable or not. Just to be clear, I don't have any work relying on this PR, just had it prepared earlier and thought it could be useful regardless of our civetweb PRs. |
Yes, 916 for ARM Thumb2 specifically. Let me also skip IMHOish commentary whether it's much or not (it's definitely not too much). The point is however that we should control the codesize of minlibc, e.g. performs code size comparisons like you did. As it's done, this patch should be clear from this PoV. And we definitely should keep growing functionality of minlibc, and should encourage people who do this (in sustainable manner, per above). So, 2 more reasons to vote this up beyond pure usefulness, so let me do just that. |
pfalcon
left a comment
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.
This is useful addition. For many real-world scenarios, 32-bit are not enough. And as we add networking into mix, bigger-than-32-bit values need to be exchanges using various protocols, many of which are text based. There should be a way to deal with these for cases when full libc (like newlib) is too much.
andrewboie
left a comment
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.
code looks fine but I would like this patch a lot more if there were some tests provided to show that these newly added APIs work.
|
@andrewboie would |
@PiotrZierhoffer that looks like a good place to me, unless @andrewboie has some better suggestion |
|
@PiotrZierhoffer any plans to add tests? |
|
It went off my radar, but I'll get back to it, hopefully next week |
|
@PiotrZierhoffer Do you have any update on strtoll and stroull support for minimal libc? Due to the usage of Civetweb I'm stuck with minimal libc and can't use new libc. But now I'm using a lib from Nordic that needs strtoll and stroull. See here https://devzone.nordicsemi.com/f/nordic-q-a/76717/nordic-nrf-sdk-v1-6-issue-with-at_cmd_parser/317127#317127 |
This PR unifies the implementation of the conversion mechanism from string to integer type.
It also adds two missing functions:
strtollandstrtoull.