Directory: include/linux

#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. */ struct reciprocal_value { u32 m; u8 sh1, sh2; }; struct reciprocal_value reciprocal_value(u32 d);

static inline u32 reciprocal_divide(u32 a, struct reciprocal_value R) { u32 t = (u32)(((u64)a * R.m) >> 32); return (t + ((a - t) >> R.sh1)) >> R.sh2; }## Contributors

Person | Tokens | Prop | Commits | CommitProp |

Hannes Frederic Sowa | 30 | 53.57% | 1 | 50.00% |

Eric Dumazet | 26 | 46.43% | 1 | 50.00% |

Total | 56 | 100.00% | 2 | 100.00% |

#endif /* _LINUX_RECIPROCAL_DIV_H */

Person | Tokens | Prop | Commits | CommitProp |

Hannes Frederic Sowa | 48 | 53.33% | 1 | 50.00% |

Eric Dumazet | 42 | 46.67% | 1 | 50.00% |

Total | 90 | 100.00% | 2 | 100.00% |

Directory: include/linux

Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.

Created with cregit.