Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/lib/reciprocal_div.c

  1 #include <linux/kernel.h>
  2 #include <asm/div64.h>
  3 #include <linux/reciprocal_div.h>
  4 #include <linux/export.h>
  5 
  6 /*
  7  * For a description of the algorithm please have a look at
  8  * include/linux/reciprocal_div.h
  9  */
 10 
 11 struct reciprocal_value reciprocal_value(u32 d)
 12 {
 13         struct reciprocal_value R;
 14         u64 m;
 15         int l;
 16 
 17         l = fls(d - 1);
 18         m = ((1ULL << 32) * ((1ULL << l) - d));
 19         do_div(m, d);
 20         ++m;
 21         R.m = (u32)m;
 22         R.sh1 = min(l, 1);
 23         R.sh2 = max(l - 1, 0);
 24 
 25         return R;
 26 }
 27 EXPORT_SYMBOL(reciprocal_value);
 28 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us