X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=include%2Flinux%2Fkernel.h;h=5582c79855677c158a85a5c11758c1cc593b5655;hb=6605f9ac69593d480324ba5fa05f64cfebf4db2f;hp=51b9548fd12db5b52177ae3edad144f74a63bd9a;hpb=93d68e52295fb8b65ded6db49e32e63b6a203e0b;p=karo-tx-linux.git diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 51b9548fd12d..5582c7985567 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -85,6 +85,19 @@ } \ ) +/* + * Multiplies an integer by a fraction, while avoiding unnecessary + * overflow or loss of precision. + */ +#define mult_frac(x, numer, denom)( \ +{ \ + typeof(x) quot = (x) / (denom); \ + typeof(x) rem = (x) % (denom); \ + (quot * (numer)) + ((rem * (numer)) / (denom)); \ +} \ +) + + #define _RET_IP_ (unsigned long)__builtin_return_address(0) #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })