/ Check-in [96bfaf9c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge change [83e47ca006] into the 3.6.1 branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.6.1
Files: files | file ages | folders
SHA1: 96bfaf9c8c26e24d72111ed970f85f25f5b1b62e
User & Date: dan 2010-03-03 15:34:39
Original User & Date: dan 2010-03-03 08:34:39
Context
2010-03-03
15:49
Fix some extra instances of the problematic constant in util.c on the 3.6.1 branch. check-in: 527c71d5 user: dan tags: branch-3.6.1
15:34
Merge change [83e47ca006] into the 3.6.1 branch. check-in: 96bfaf9c user: dan tags: branch-3.6.1
2010-02-25
14:44
Add some technically unnecessary variable initializations to silence compiler warnings. check-in: a2550597 user: dan tags: branch-3.6.1
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/util.c.

   540    540     if( (v & ~0x3fff)==0 ){
   541    541       p[0] = (v>>7) | 0x80;
   542    542       p[1] = v & 0x7f;
   543    543       return 2;
   544    544     }
   545    545     return sqlite3PutVarint(p, v);
   546    546   }
          547  +
          548  +/*
          549  +** Bitmasks used by sqlite3GetVarint().  These precomputed constants
          550  +** are defined here rather than simply putting the constant expressions
          551  +** inline in order to work around bugs in the RVT compiler.
          552  +**
          553  +** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f
          554  +**
          555  +** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0
          556  +*/
          557  +#define SLOT_2_0     0x001fc07f
          558  +#define SLOT_4_2_0   0xf01fc07f
          559  +
   547    560   
   548    561   /*
   549    562   ** Read a 64-bit variable-length integer from memory starting at p[0].
   550    563   ** Return the number of bytes read.  The value is stored in *v.
   551    564   */
   552    565   int sqlite3GetVarint(const unsigned char *p, u64 *v){
   553    566     u32 a,b,s;
................................................................................
   568    581       a &= 0x7f;
   569    582       a = a<<7;
   570    583       a |= b;
   571    584       *v = a;
   572    585       return 2;
   573    586     }
   574    587   
          588  +  /* Verify that constants are precomputed correctly */
          589  +  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
          590  +  assert( SLOT_4_2_0 == ((0xf<<28) | (0x7f<<14) | (0x7f)) );
          591  +
   575    592     p++;
   576    593     a = a<<14;
   577    594     a |= *p;
   578    595     /* a: p0<<14 | p2 (unmasked) */
   579    596     if (!(a&0x80))
   580    597     {
   581         -    a &= (0x7f<<14)|(0x7f);
          598  +    a &= SLOT_2_0;
   582    599       b &= 0x7f;
   583    600       b = b<<7;
   584    601       a |= b;
   585    602       *v = a;
   586    603       return 3;
   587    604     }
   588    605   
   589    606     /* CSE1 from below */
   590         -  a &= (0x7f<<14)|(0x7f);
          607  +  a &= SLOT_2_0;
   591    608     p++;
   592    609     b = b<<14;
   593    610     b |= *p;
   594    611     /* b: p1<<14 | p3 (unmasked) */
   595    612     if (!(b&0x80))
   596    613     {
   597         -    b &= (0x7f<<14)|(0x7f);
          614  +    b &= SLOT_2_0;
   598    615       /* moved CSE1 up */
   599    616       /* a &= (0x7f<<14)|(0x7f); */
   600    617       a = a<<7;
   601    618       a |= b;
   602    619       *v = a;
   603    620       return 4;
   604    621     }
   605    622   
   606    623     /* a: p0<<14 | p2 (masked) */
   607    624     /* b: p1<<14 | p3 (unmasked) */
   608    625     /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
   609    626     /* moved CSE1 up */
   610    627     /* a &= (0x7f<<14)|(0x7f); */
   611         -  b &= (0x7f<<14)|(0x7f);
          628  +  b &= SLOT_2_0;
   612    629     s = a;
   613    630     /* s: p0<<14 | p2 (masked) */
   614    631   
   615    632     p++;
   616    633     a = a<<14;
   617    634     a |= *p;
   618    635     /* a: p0<<28 | p2<<14 | p4 (unmasked) */
................................................................................
   637    654     b = b<<14;
   638    655     b |= *p;
   639    656     /* b: p1<<28 | p3<<14 | p5 (unmasked) */
   640    657     if (!(b&0x80))
   641    658     {
   642    659       /* we can skip this cause it was (effectively) done above in calc'ing s */
   643    660       /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
   644         -    a &= (0x7f<<14)|(0x7f);
          661  +    a &= SLOT_2_0;
   645    662       a = a<<7;
   646    663       a |= b;
   647    664       s = s>>18;
   648    665       *v = ((u64)s)<<32 | a;
   649    666       return 6;
   650    667     }
   651    668   
   652    669     p++;
   653    670     a = a<<14;
   654    671     a |= *p;
   655    672     /* a: p2<<28 | p4<<14 | p6 (unmasked) */
   656    673     if (!(a&0x80))
   657    674     {
   658         -    a &= (0x0f<<28)|(0x7f<<14)|(0x7f);
   659         -    b &= (0x7f<<14)|(0x7f);
          675  +    a &= SLOT_4_2_0;
          676  +    b &= SLOT_2_0;
   660    677       b = b<<7;
   661    678       a |= b;
   662    679       s = s>>11;
   663    680       *v = ((u64)s)<<32 | a;
   664    681       return 7;
   665    682     }
   666    683   
   667    684     /* CSE2 from below */
   668         -  a &= (0x7f<<14)|(0x7f);
          685  +  a &= SLOT_2_0;
   669    686     p++;
   670    687     b = b<<14;
   671    688     b |= *p;
   672    689     /* b: p3<<28 | p5<<14 | p7 (unmasked) */
   673    690     if (!(b&0x80))
   674    691     {
   675         -    b &= (0x0f<<28)|(0x7f<<14)|(0x7f);
          692  +    b &= SLOT_4_2_0;
   676    693       /* moved CSE2 up */
   677    694       /* a &= (0x7f<<14)|(0x7f); */
   678    695       a = a<<7;
   679    696       a |= b;
   680    697       s = s>>4;
   681    698       *v = ((u64)s)<<32 | a;
   682    699       return 8;
................................................................................
   685    702     p++;
   686    703     a = a<<15;
   687    704     a |= *p;
   688    705     /* a: p4<<29 | p6<<15 | p8 (unmasked) */
   689    706   
   690    707     /* moved CSE2 up */
   691    708     /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */
   692         -  b &= (0x7f<<14)|(0x7f);
          709  +  b &= SLOT_2_0;
   693    710     b = b<<8;
   694    711     a |= b;
   695    712   
   696    713     s = s<<4;
   697    714     b = p[-4];
   698    715     b &= 0x7f;
   699    716     b = b>>3;