Page MenuHomeFreeBSD

linuxkpi: Add overflow.h
ClosedPublic

Authored by manu on May 26 2020, 10:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 22 2023, 9:49 PM
Unknown Object (File)
Dec 14 2023, 8:29 PM
Unknown Object (File)
Nov 28 2023, 3:02 AM
Unknown Object (File)
Aug 25 2023, 11:51 PM
Unknown Object (File)
Aug 20 2023, 6:37 PM
Unknown Object (File)
Jul 15 2023, 4:42 PM
Unknown Object (File)
Jul 5 2023, 2:08 PM
Unknown Object (File)
Jun 28 2023, 8:26 PM
Subscribers

Details

Summary

Only add check_add_overflow and check_mul_overflow as those are the only
two needed function by DRM v5.3.
Since both gcc and clang have builtin to do this check, use them directly.

Sponsored-by: The FreeBSD Foundation

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

manu requested review of this revision.May 26 2020, 10:57 AM

Should there be an ifdef for LINT builds?

Should there be an ifdef for LINT builds?

What do you mean ?

Have a look at: sys/cdefs.h

--HPS

You might want to ifdef the use of __builting for compilers not supporting it like done in sys/cdefs.h --- OK ?

Only add the macros if the compiler have the builtin.
Old compiler aren't supported.

sys/compat/linuxkpi/common/include/linux/overflow.h
42

Should there be an #else case here?

sys/compat/linuxkpi/common/include/linux/overflow.h
42

As said in the comment old compilers aren't supported.
Do you think it's really necessary to support compilers that don't have this builtin ?
I'll check when they appeared on each one.

sys/compat/linuxkpi/common/include/linux/overflow.h
42

It might not be an old compiler but a code checker. Make sure there is an else case there.

Thank you!

sys/compat/linuxkpi/common/include/linux/overflow.h
42

And just #define check_mul_overflow(a, b, c) (0) ?
Or #error ?
What do you prefer ?

sys/compat/linuxkpi/common/include/linux/overflow.h
42

I think we need to use #error "Missing support for check_mul_overflow()."

Add #error if the compiler doesn't have the required builtin.

sys/compat/linuxkpi/common/include/linux/overflow.h
42

I've added some error but logging the missing builtin name so the users compiling stuff doesn't have to look up this file to see what the problem is.

This revision is now accepted and ready to land.May 27 2020, 9:19 AM
This revision was automatically updated to reflect the committed changes.