#ifndef _LINUX_RECIPROCAL_DIV_H#define _LINUX_RECIPROCAL_DIV_H#include <linux/types.h>/* * This algorithm is based on the paper "Division by Invariant * Integers Using Multiplication" by Torbjörn Granlund and Peter * L. Montgomery. * * The assembler implementation from Agner Fog, which this code is * based on, can be found here: * http://www.agner.org/optimize/asmlib.zip * * This optimization for A/B is helpful if the divisor B is mostly * runtime invariant. The reciprocal of B is calculated in the * slow-path with reciprocal_value(). The fast-path can then just use * a much faster multiplication operation with a variable dividend A * to calculate the division A/B. */structreciprocal_value{u32m;u8sh1,sh2;};structreciprocal_valuereciprocal_value(u32d);staticinlineu32reciprocal_divide(u32a,structreciprocal_valueR){u32t=(u32)(((u64)a*R.m)>>32);return(t+((a-t)>>R.sh1))>>R.sh2;}#endif /* _LINUX_RECIPROCAL_DIV_H */