Page MenuHomeFreeBSD

linuxkpi: Add overflow.h
ClosedPublic

Authored by manu on May 26 2020, 10:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 3:07 AM
Unknown Object (File)
Sat, Oct 19, 10:56 AM
Unknown Object (File)
Oct 17 2024, 12:32 PM
Unknown Object (File)
Oct 11 2024, 1:09 AM
Unknown Object (File)
Sep 29 2024, 6:13 PM
Unknown Object (File)
Sep 25 2024, 7:20 PM
Unknown Object (File)
Sep 16 2024, 5:30 PM
Unknown Object (File)
Aug 31 2024, 11:43 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
41

Should there be an #else case here?

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

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

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

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

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

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.