|
|
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 1:02 UTC (Sat) by NYKevin (subscriber, #129325)
In reply to: Better handling of integer wraparound in the kernel by ikm
Parent article: Better handling of integer wraparound in the kernel

C23 will finally introduce checked integer arithmetic functions in the stdlib. It's about 20+ years too late, but at least it's here now... I would suggest either using that or using one of the __builtin implementation-defined equivalents (you can use preprocessor magic to figure out what's available and wrap it in a macro).


to post comments

Better handling of integer wraparound in the kernel

Posted Jan 28, 2024 10:24 UTC (Sun) by khim (subscriber, #9252) [Link] (5 responses)

> you can use preprocessor magic to figure out what's available and wrap it in a macro

Why would you need to do that? Minimum GCC version supported by kernel is GCC 5.1, all the required functions are already in that version.

Better handling of integer wraparound in the kernel

Posted Jan 29, 2024 2:02 UTC (Mon) by NYKevin (subscriber, #129325) [Link] (4 responses)

It depends on whether you want to support compilers other than GCC. I'm not sure if they all spell the intrinsic the same. I believe people have at least been looking into compiling the kernel with clang...?

Better handling of integer wraparound in the kernel

Posted Jan 29, 2024 9:18 UTC (Mon) by khim (subscriber, #9252) [Link] (3 responses)

They threatened to drop support for clang if clang wouldn't implement some obscure GCC feature and yet wouldn't use some easily implementable (and actually implemented) function?

Hard to believe, sorry.

Better handling of integer wraparound in the kernel

Posted Jan 29, 2024 20:13 UTC (Mon) by NYKevin (subscriber, #129325) [Link] (2 responses)

> Hard to believe, sorry.

And you see folks, this is why I'm so reluctant to comment on LWN (or any other technical forum). I throw in a parenthetical to cover a case I'm not sure about, and get grilled about it in the replies, even though it was utterly tangential to my actual point.

Not just what one has to say, but how one chooses to say it

Posted Jan 30, 2024 8:49 UTC (Tue) by sdalley (subscriber, #18550) [Link]

Please don't go away, NYKevin. Your contributions are greatly appreciated by me and I'm sure many others. Highly knowledgeable without being condescending, able to bring another side without being contentious or wanting to always prove oneself right and get in the last word.

Better handling of integer wraparound in the kernel

Posted Jan 30, 2024 11:22 UTC (Tue) by Wol (subscriber, #4433) [Link]

Seconded. Don't go away. What matters imho is you're well known, and you have a good reputation. If you're happy keeping a low profile, fine.

Just do what I do - get to know people by their nym. Plenty of people here think I'm brilliant - plenty also think I'm an idiot! I've had a lot of people tell me I'm "the voice of reason". I chose Wol for other reasons, but as the Owl who's not as clever as he thinks he is, he seems rather appropriate. Personally, I think I'm a damn good high-level analyst, I tend to struggle with the details but I can spot design flaws a mile off!

And then - it had to be Khim, didn't it ... personally, I respect him, our views are very similar about the *societal* effects around us. Him more than me, but I think we both get a bit dogmatic - and then sparks fly - Sorry Jon!

But no, this is a society like anywhere else. Some people keep their heads down, some are flamboyant, some just like to sit in the corner dispensing wisdom. That last sounds like you. Just try to learn who is not worth talking to, and don't respond to them. And then they might come up with an absolute gem ...

Cheers,
Wol


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