Page MenuHomeFreeBSD

linuxkpi: math.h: Add mul_u64_u32_div and mul_u64_u32_shr
ClosedPublic

Authored by manu on Jul 26 2022, 9:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 17, 2:39 PM
Unknown Object (File)
Oct 11 2024, 12:16 AM
Unknown Object (File)
Oct 4 2024, 11:50 PM
Unknown Object (File)
Oct 3 2024, 10:06 AM
Unknown Object (File)
Oct 1 2024, 4:24 PM
Unknown Object (File)
Sep 24 2024, 8:34 AM
Unknown Object (File)
Sep 19 2024, 9:51 PM
Unknown Object (File)
Sep 19 2024, 3:41 PM

Details

Summary

Needed by drm-kmod.

Obtained from: OpenBSD
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

manu requested review of this revision.Jul 26 2022, 9:30 AM
hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/math64.h
106

This looks wrong and may overflow! Do it like shown below instead, and implement mul_u64_u64_div() at the same time:

static inline uint64_t
mul_u64_u64_div(uint64_t num, uint64_t mul, uint64_t div)
{
       const uint64_t rem = num % div;

       return (num / div) * mul + (rem * mul) / div;
}
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/math64.h
106

In any case, BSD style is putting the return (value) in ().

sys/compat/linuxkpi/common/include/linux/math64.h
104

x->num and y->rem

Looks good.

sys/compat/linuxkpi/common/include/linux/math64.h
108

Maybe add ()'s

This revision is now accepted and ready to land.Aug 2 2022, 8:11 AM