linux/kernel/timeconst.pl
<<
2elT 2/spatio 2/formio 2a 2elT href="../linux+v3.7.6/kernel/timeconst.pl">2elT 2img src="../.static/gfx/right.png" alt=">>">2e2/spatio2e2spat class="lxr_search">2elT2elT 2input typptihidden" namptinavtarget" 2 2elT 2input typptitext" namptisearch" idtisearch">2elT 2butt314typptisubmit">Search2elT Prefso 2/a>2e2/spatiolT 2/diviolT 2form ac/opt="ajax+*" method="post" onsubmit="return false;">2e2input typptihidden" namptiajax_lookup" idtiajax_lookup" 2 2lT 2/formio2lT 2div class="headingbott3m">o 2div idtifile_contents"i
   12/a>#!/usr/bin/perl
   22/a># -----------------------------------------------------------------------
   32/a>#
   42/a>#   Copyright 2007-2008 rPath, Inc. - All Rights Reserved
   52/a>#
   62/a>#   This file is part of the Linux kernel, and is made available under
   72/a>#   the terms of the GNU General Public License vers83142 or (at your
   82/a>#   4   92/a>#
  1  va># -----------------------------------------------------------------------
  112/a>#
  122/a>
  132/a>#
  142/a># Usage: timeconst.pl HZ > timeconst.h
  152/a>#
  162/a>
  172/a># Precomputed 2   182/a># Generated by:
  192/a># timeconst.pl --cat 24 32 48 64 1 0 122 128 200 250 256 300 512 1 00 1024 1200
  2  va>%catned_2   212/a>        24 => [
  222/a>                '0xa6aaaaab','0x2aaaaaa',26,
  232/a>                125,3,
  242/a>                '0xc49ba5e4','0x1fbe76c8b4',37,
  252/a>                3,125,
  262/a>                '0xa2c2aaab','0xaaaa',16,
  272/a>                125 00,3,
  282/a>                '0xc9539b89','0x7fffbce4217d',47,
  292/a>                3,125 00,
  302/a>        ], 32 => [
  312/a>                '0xfa000000','0x6000000',27,
  322/a>                125,4,
  332/a>                '0x83126e98','0xfdf3b645a',36,
  342/a>                4,125,
  352/a>                '0xf4240000','0x0',17,
  362/a>                3125 ,1,
  372/a>                '0x8637bd06','0x3fff79c842fa',46,
  382/a>                1,3125 ,
  392/a>        ], 48 => [
  402/a>                '0xa6aaaaab','0x6aaaaaa',27,
  412/a>                125,6,
  422/a>                '0xc49ba5e4','0xfdf3b645a',36,
  432/a>                6,125,
  442/a>                '0xa2c2aaab','0x15555',17,
  452/a>                625 0,3,
  462/a>                '0xc9539b89','0x3fffbce4217d',46,
  472/a>                3,625 0,
  482/a>        ], 64 => [
  492/a>                '0xfa000000','0xe000000',28,
  502/a>                125,8,
  512/a>                '0x83126e98','0x7ef9db22d',35,
  522/a>                8,125,
  532/a>                '0xf4240000','0x0',18,
  542/a>                15625,1,
  552/a>                '0x8637bd06','0x1fff79c842fa',45,
  562/a>                1,15625,
  572/a>        ], 1 0 => [
  582/a>                '0xa0000000','0x0',28,
  592/a>                1 ,1,
  602/a>                '0xcccccccd','0x733333333',35,
  612/a>                1,10,
  622/a>                '0x9c400000','0x0',18,
  632/a>                10000,1,
  642/a>                '0xd1b71759','0x1fff2e48e8a7',45,
  652/a>                1,10 00,
  662/a>        ], 122 => [
  672/a>                '0x8325c53f','0xfbcda3a',28,
  682/a>                5 0,61,
  692/a>                '0xf9db22d1','0x7fbe76c8b',35,
  702/a>                61,5 0,
  712/a>                '0x8012e2a0','0x3ef36',18,
  722/a>                500000,61,
  732/a>                '0xffda4053','0x1ffffbce4217',45,
  742/a>                61,5 0 00,
  752/a>        ], 128 => [
  762/a>                '0xfa000000','0x1e000000',29,
  772/a>                125,16,
  782/a>                '0x83126e98','0x3f7ced916',34,
  792/a>                16,125,
  802/a>                '0xf4240000','0x40000',19,
  812/a>                15625,2,
  822/a>                '0x8637bd06','0xfffbce4217d',44,
  832/a>                2,15625,
  842/a>        ], 2 0 => [
  852/a>                '0xa0000000','0x0',29,
  862/a>                5,1,
  872/a>                '0xcccccccd','0x333333333',34,
  882/a>                1,5,
  892/a>                '0x9c400000','0x0',19,
  902/a>                5000,1,
  912/a>                '0xd1b71759','0xfff2e48e8a7',44,
  922/a>                1,5 00,
  932/a>        ], 250 => [
  942/a>                '0x80000000','0x0',29,
  952/a>                4,1,
  962/a>                '0x80000000','0x180000000',33,
  972/a>                1,4,
  982/a>                '0xfa000000','0x0',20,
  992/a>                4000,1,
 1002/a>                '0x83126e98','0x7ff7ced9168',43,
 1012/a>                1,4 00,
 1022/a>        ], 256 => [
 1032/a>                '0xfa000000','0x3e000000',30,
 1042/a>                125,32,
 1052/a>                '0x83126e98','0x1fbe76c8b',33,
 1062/a>                32,125,
 1072/a>                '0xf4240000','0xc0000',20,
 1082/a>                15625,4,
 1092/a>                '0x8637bd06','0x7ffde7210be',43,
 1102/a>                4,15625,
 1112/a>        ], 3 0 => [
 1122/a>                '0xd5555556','0x2aaaaaaa',30,
 1132/a>                10,3,
 1142/a>                '0x9999999a','0x1cccccccc',33,
 1152/a>                3,10,
 1162/a>                '0xd0555556','0xaaaaa',20,
 1172/a>                10 00,3,
 1182/a>                '0x9d495183','0x7ffcb923a29',43,
 1192/a>                3,10 00,
 1202/a>        ], 512 => [
 1212/a>                '0xfa000000','0x7e000000',31,
 1222/a>                125,64,
 1232/a>                '0x83126e98','0xfdf3b645',32,
 1242/a>                64,125,
 1252/a>                '0xf4240000','0x1c0000',21,
 1262/a>                15625,8,
 1272/a>                '0x8637bd06','0x3ffef39085f',42,
 1282/a>                8,15625,
 1292/a>        ], 1 00 => [
 1302/a>                '0x80000000','0x0',31,
 1312/a>                1,1,
 1322/a>                '0x80000000','0x0',31,
 1332/a>                1,1,
 1342/a>                '0xfa000000','0x0',22,
 1352/a>                1000,1,
 1362/a>                '0x83126e98','0x1ff7ced9168',41,
 1372/a>                1,10 0,
 1382/a>        ], 1024 => [
 1392/a>                '0xfa000000','0xfe000000',32,
 1402/a>                125,128,
 1412/a>                '0x83126e98','0x7ef9db22',31,
 1422/a>                128,125,
 1432/a>                '0xf4240000','0x3c0000',22,
 1442/a>                15625,16,
 1452/a>                '0x8637bd06','0x1fff79c842f',41,
 1462/a>                16,15625,
 1472/a>        ], 12 0 => [
 1482/a>                '0xd5555556','0xd5555555',32,
 1492/a>                5,6,
 1502/a>                '0x9999999a','0x66666666',31,
 1512/a>                6,5,
 1522/a>                '0xd0555556','0x2aaaaa',22,
 1532/a>                25 0,3,
 1542/a>                '0x9d495183','0x1ffcb923a29',41,
 1552/a>                3,25 0,
 1562/a>        ]
 1572/a>);
 1582/a>
 1592/a>$has_bigint = eval 'use Math::BigInt qw(bgcd); 1;';
 1602/a>
 1612/a>sub bint($)
 1622/a>{
 1632/a>        my($x) = @_;
 1642/a>        return Math::BigInt->new($x);
 1652/a>}
 1662/a>
 1672/a>#
 1682/a># Constants for divis8314by reciprocal multiplica/opt.
 1692/a># (bits, numerator, denominator)
 1702/a>#
 1712/a>sub fmul($$$)
 1722/a>{
 1732/a>        my ($b,$n,$d) = @_;
 1742/a>
 1752/a>        $n = bint($n);
 1762/a>        $d = bint($d);
 1772/a>
 1782/a>        return scalar (($n << $b)+$d-bint(1))/$d;
 1792/a>}
 1802/a>
 1812/a>sub fadj($$$)
 1822/a>{
 1832/a>        my($b,$n,$d) = @_;
 1842/a>
 1852/a>        $n = bint($n);
 1862/a>        $d = bint($d);
 1872/a>
 1882/a>        $d = $d/bgcd($n, $d);
 1892/a>        return scalar (($d-bint(1)) << $b)/$d;
 1902/a>}
 1912/a>
 1922/a>sub fmuls($$$) {
 1932/a>        my($b,$n,$d) = @_;
 1942/a>        my($s,$m);
 1952/a>        my($thres) = bint(1) << ($b-1);
 1962/a>
 1972/a>        $n = bint($n);
 1982/a>        $d = bint($d);
 1992/a>
 2002/a>        for ($s = 0; 1; $s++) {
 2012/a>                $m = fmul($s,$n,$d);
 2022/a>                return $s if ($m >= $thres);
 2032/a>        }
 2042/a>        return 0;
 2052/a>}
 2062/a>
 2072/a># Generate a hex 2  2082/a># otherwise skip.
 2092/a>sub bignum_hex($) {
 2102/a>        my($x) = @_;
 2112/a>        my $s = $x->as_hex();
 2122/a>
 2132/a>        return (length($s) > 18) ? undef : $s;
 2142/a>}
 2152/a>
 2162/a># Provides mul, adj, and shr factors for a specific
 2172/a># (bit, time, hz) combination
 2182/a>sub muladj($$$) {
 2192/a>        my($b, $t, $hz) = @_;
 2202/a>        my $s = fmuls($b, $t, $hz);
 2212/a>        my $m = fmul($s, $t, $hz);
 2222/a>        my $a = fadj($s, $t, $hz);
 2232/a>        return (bignum_hex($m), bignum_hex($a), $s);
 2242/a>}
 2252/a>
 2262/a># Provides numerator, denominator 2  2272/a>sub numden($$) {
 2282/a>        my($n, $d) = @_;
 2292/a>        my $g = bgcd($n, $d);
 2302/a>        return ($n/$g, $d/$g);
 2312/a>}
 2322/a>
 2332/a># All 2  2342/a>sub convers831s($$) {
 2352/a>        my ($t, $hz) = @_;
 2362/a>        my @val = ();
 2372/a>
 2242/a>iL123"> 1232/aoZ_TO_xxeconst.pl#L238" idtiL238" class="line" namptiL139"> 1392/a>       2     2  '0xfa000push(kern,ef="kern32"kernel/tiimeconst.pl#L237" idtiL237" class="line" na2ptiL140"> 1402/a>       2     2  125,128,
 2342/a>sub conve1M92/a>l/tiimeconst.pl#L170" idtiL170" class="line342/a>           8.pl#L142"2idtiL142" class="line" n2mptiL242"> 1422/a>  # xx2> 2HZ0" class="line342/a>           8.pl#L233" idtiL143" class="line" n2mptiL243"> 1432/a>       2     2  '0xfahzxfa0 ,f/timeco"line" namptiL234"> 2342/a.pl#L24" iidtiL24" class="line" namptiL244"> 1442/a>       2     2  125,1hzxfa0 ,f/timeco"line" namptiL234"> 2342/apl#L235" idtiL145" class="line" n2mptiL245"> 2252/a>
 1462/a>        r2   f/timeco"line" namptiL234"> 2342/apl#L237" idtiL147" class="line" n2mptiL247"> 1312/a>}
 1582/a>
 2342/a> Preccatned_um_hex($) {
 2102/a>      ($t, $hz) = @_;
 2212/a>        my @val = ();
 2222/a>      fadjmadjaadjgl = ();
 1 = ();
 1542/a>  rn $!592/a>$has__hex($) {
 1552/a>          die "$0:nst.==fahz not >%, adj"e skip.
  562/a>              "9;use Math::Bnot  made ava\n"l = ();
  572/a>  312/a>}
 1582/a>
  592/a>  # MSEC/a>sub conve582/a>
 1402/a>       2     a>sub conver    1,
 2342/.pl#L161"2idtiL161" class="line" n2mptiL26tiL170" class="line342/a>           8.pl#L162"2idtiL162" class="line" n2mptiL262"> 1422/a>  # USEC/a>sub conve582/a>
 1432/a>       2     a>sub conver       1,
 2342/..pl#L24" idtiL164" class="line" n2mptiL264"> 1842/a>
  652/a>        r2   f/timeco"line" namptiL234"> 2342/.pl#L166"2idtiL166" class="line" n2mptiL266"> 1312/a>}
 2372/a>
 2182/outPre   (fadj($$$)
 1ex($) {
 2102/a>      line1,
   t, $hz) = @_;
 2212/a>      csuf) = @_;
 2322/a>
 1732/a>  rn $defassd(
   t_hex($) {
  742/a>      rn $sline !~ /SHR/_hex($) {
 1552/a>          $  my @"U64_C(
   t"l = ();
  762/a>      312/a>}
  772/a>      pras_f@"#defass= ev7;-23s= ev7;s\n"1,
line. csuf1,
   . csuf) = @_;
 1782/a>  312/a>}
 1792/a>}
 1802/a>
 1812/outPre($@dj($$$)
 1822/a>{
 1832/a>      hzxf@   t, $hz) = @_;
 2212/a>      pfx1,
/a># $suf1,
fadjmadja) = @_;
 2252/a>
 1862/a>  pras_@"/* Autom../.ally g/a># Genera href="kernel/timeco */\n"l = ();
  872/a>  pras_@"/* C>sub conv c/a># Constantst.==fahz */\n"l = ();
 1882/a>  pras_@"\n"l = ();
 1892/a>  pras_@"#if8) ? KERNEL_TIMECONST_H\n"l = ();
  902/a>  pras_@"#defass=KERNEL_TIMECONST_H\n"l = ();
  912/a>  pras_@"\n"l = ();
 2322/a>
 1932/a>  pras_@"#includeint(1l the/param.hh($s\n"l = ();
 1942/a>  pras_@"#includeint(1l the/inpus.hh($s\n"l = ();
 2252/a>
 1862/a>  pras_@"\n"l = ();
  872/a>  pras_@"#iftst.!=fahz\n"l = ();
 1882/a>  pras_@"#errant\"href="kernel/timeh has 1892/a>  pras_@"#endif\n"l = ();
  902/a>  pras_@"\n"l = ();
 2022/a>  taneach  pfx (d); 1#L2> 2MSEC495183'MSEC2> 2HZ4951830" class="line342/a>           3..pl#L33" idtiL203" class="line" n3mptiL303"> 1032/a>                d); 1#L2> 2USEC495183'USEC2> 2HZ49518_hex($) {
 1042/a>          taneach  /a> (32_hex($) {
 1052/a>                  taneach  suf (d); 1MUL495183 d); 1ADJ495183 d); 1SHR49518_hex($) {
 1062/a>                          outPre   ("${pfx}_ suf /a>"1,shift 2    ,f/timeco"line" namptiL234"> 23423.pl#L207"3idtiL207" class="line" n3mptiL307"> 1072/a>                  792/a>}
 1082/a>          792/a>}
 1092/a>          taneach  suf (d); 1NUM495183 d); 1DEN49518_hex($) {
 1102/a>                  outPre   ("${pfx}_ suf"1,shift 2    ,f/timeco"line" namptiL234"> 23423.pl#L211"3idtiL211" class="line" n3mptiL311"> 2012/a>          792/a>}
 1122/a>  792/a>}
 1 = ();
 1942/a>  pras_@"\n"l = ();
 1152/a>  pras_@"#endif /* KERNEL_TIMECONST_H */\n"l = ();
 1312/a>}
 2372/a>
 2262/etty-pras_@Perlinator 2  2342/perlnats(@_hex($) {
 2202/a>      vl = ();
 2212/a>     @my @val = ();
 2322/a>
 2232/a>  taneach  v (@__hex($) {
 1242/a>          rn $!defassd(
 t_hex($) {
 1252/a>          152/a>  p    2l3 d); 118) ?49518_l = ();
 1262/a>          } elsrn $sv =~ /^0x/_hex($) {
 1272/a>          152/a>  p    2l3 dquot;\49518"e$v.dquot;\49518"_l = ();
 1282/a>          } elsehex($) {
 1092/a>          152/a>  p    2l3 $v.d9518&9518_l = ();
 1302/a>          312/a>}
 1312/a>  312/a>}
 1322/a>        rjoin(495183', @m_l = ();
 2312/a>}
 1842/a>
 2  ($t, $hARGVl = ();
 2062/a>
 217Usehthis to g/a># Ge%catned_ struc   e062/a>
셮_hex($) {
 1392/a>  shift 2ARGV_l = ();
 1402/a>  @hzlis_bigsort {$aint(1 12 0 $b}  2ARGV_l = ();
l/tiimeconst.pl#3170" 3dtiL170" class="line342/a>           3.pl#L142"3idtiL142" class="line" n3mptiL342"> 1422/a>  pras_@"#62/ea> Precd># All 2  1932/a>  pras_@"#72/a># Genera:\n"l = ();
 1942/a>  pras_@"# ernel/timeco -->&# "1,join(49518 ', @hzlis_),@"\n"l = ();
 1152/a>  pras_@"\ ev7;>%catned_  @v\n"l = ();
 2362/a>     $pfy @"\t"l = ();
 1472/a>  taneach  hz (@hzlis_)hex($) {
 1482/a>                med_  @a> Preccatned_um $t, $hz);
 1492/a>          pras_@"$pf hz  12 0 =\n"l = ();
 1502/a>          while (eturn (   med_t_hex($) {
 1512/a>          362/a>     $bitl = ();
 1522/a>          472/a>  taneach  /a> (32_hex($) {
 1532/a>                  362/a>     $  myshift 2   u= $thres);
 1542/a>                  362/a>     $a myshift 2   u= $thres);
 1552/a>                  362/a>     $s myshift 2   u= $thres);
  562/a>                          pras_@"\t\>"1,perlnats($m,$a,$s),@",\n"l = ();
 1072/a>                  792/a>}
 1482/a>          362/a>     $n myshift 2   u= $thres);
 1092/a>          152/a>     $d myshift 2   u= $thres);
 1102/a>                  pras_@"\t\>"1,perlnats($l($s,,@",\n"l = ();
 2012/a>          792/a>}
 1522/a>          pras_@"\t]"l = ();
 1532/a>          $pfy @&95183 d); 1l = ();
 1642/a>  792/a>}
 1152/a>  pras_@"\n);\n"l = ();
 13 elsehex($) {
 1972/a>   hz +r ($sssssssssssssssssssssss# Force to numberx($) {
 1482/a>  rn $shz ) <1_hex($) {
 1092/a>          die "Usage: $0 HZ\n"l = ();
 2102/a>  792/a>}
 1522/a>     my @@{$>%catned_{shz}}l = ();
 1732/a>  rn $!defassd(@   t_hex($) {
  742/a>      a>     my @a> Preccatned_um $t, $hz);
 1552/a>  792/a>}
  762/a>  outPre($hzxf@   t, $hz);
 1312/a>}
 1exa> eturn 0;
 1


The or$has myLXR softwareera op irn 0; LXR a> munity"> 1,hthis experrnent myub conv ra rn 0; lxr@l the.no"> 1.
lxr.l the.no kindly hosGenera rn 0; Redpill L tpro AS"> 1,hp/a># Pr of L tux c/a>ocalng, adjop># Gonve servicd_ since 1995.