Page MenuHomeFreeBSD

linuxkpi: Add overflow.h
ClosedPublic

Authored by manu on May 26 2020, 10:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 6:55 AM
Unknown Object (File)
Mon, Nov 18, 6:55 AM
Unknown Object (File)
Mon, Nov 18, 6:47 AM
Unknown Object (File)
Mon, Nov 18, 6:37 AM
Unknown Object (File)
Mon, Nov 18, 4:39 AM
Unknown Object (File)
Tue, Nov 5, 3:07 AM
Unknown Object (File)
Oct 19 2024, 10:56 AM
Unknown Object (File)
Oct 17 2024, 12:32 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 Not Applicable
Unit
Tests Not Applicable

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
41 ↗(On Diff #72305)

Should there be an #else case here?

sys/compat/linuxkpi/common/include/linux/overflow.h
41 ↗(On Diff #72305)

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
41 ↗(On Diff #72305)

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
41 ↗(On Diff #72305)

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

sys/compat/linuxkpi/common/include/linux/overflow.h
41 ↗(On Diff #72305)

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
41 ↗(On Diff #72305)

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.