Page MenuHomeFreeBSD

linuxkpi: Add overflow.h
ClosedPublic

Authored by manu on May 26 2020, 10:57 AM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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.