|
|
Subscribe / Log in / New account

Better handling of integer wraparound in the kernel

Better handling of integer wraparound in the kernel

Posted Jan 27, 2024 21:07 UTC (Sat) by donald.buczek (subscriber, #112892)
In reply to: Better handling of integer wraparound in the kernel by ballombe
Parent article: Better handling of integer wraparound in the kernel

> Since which version of gcc ? on which platform ? This would be useful.

Sorry, I'm note sure, I understand that question? gcc understands `__builtin_add_overflow` since 5.1 (2015) and clang since 3.8 (2016) . Or is this a counter-argument, because using the builtin would make the code to much dependent on the compiler version and variant? True, but the proposed macros use the builtin, too. And for the purpose to support other compilers, it would be enough to use one level of macro with no change of function or even #define __builtin_add_overflow only for those compilers which don't provide it.


to post comments

Better handling of integer wraparound in the kernel

Posted Jan 27, 2024 23:30 UTC (Sat) by ballombe (subscriber, #9523) [Link]

> gcc understands `__builtin_add_overflow` since 5.1 (2015) and clang since 3.8 (2016) .

Thanks. Most gcc builtin are CPU-specific. It seems these ones are an exception!


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds