|
|
Subscribe / Log in / New account

Better handling of integer wraparound in the kernel

Better handling of integer wraparound in the kernel

Posted Jan 28, 2024 10:46 UTC (Sun) by khim (subscriber, #9252)
In reply to: Better handling of integer wraparound in the kernel by epa
Parent article: Better handling of integer wraparound in the kernel

> And this finally explains why common C programming style is to use signed integer types, even for quantities that will never be negative in practice.

Nah, that's simply because C grew out of B and latter only had one datatype: word.

When B evolved into C loops started using int for indexes and then CPUs (sic!) grew various hacks to make these efficient (AMD and Intel have macrops fusion, RISC-V have special instructions to cope, etc).

> I’m sure it’s not just for-loops and there are other important optimizations, just that this is one of the easier cases to explain.

Nope. Most of the time there are no difference, but without various hacks on all levels size_t would have been faster, of course.

On base RV64G they are faster, but who uses these?


to post comments


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