VirtualBox

Changeset 21921 in vbox


Ignore:
Timestamp:
Jul 31, 2009 3:45:43 PM (16 years ago)
Author:
vboxsync
Message:

SSM: moved out the Adler32 code. (it sucked)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/SSM-new.cpp

    r21902 r21921  
    264264#define SSM_ZIP_BLOCK_SIZE                      _4K
    265265AssertCompile(SSM_ZIP_BLOCK_SIZE / _1K * _1K == SSM_ZIP_BLOCK_SIZE);
    266 
    267 #if 0
    268 static uint32_t RTCrcAdler32Start(void)
    269 {
    270     return 1;
    271 }
    272 
    273 static uint32_t RTCrcAdler32Process(uint32_t u32Crc, void const *pv, size_t cb)
    274 {
    275     uint8_t const  *pbSrc = (uint8_t const *)pv;
    276     uint32_t        a     = u32Crc & 0xffff;
    277     uint32_t        b     = u32Crc >> 16;
    278     if (cb < 64)
    279     {
    280         while (cb-- > 0)
    281         {
    282             a += *pbSrc++;
    283             a %= 65521;
    284             b += a;
    285             b %= 65521;
    286         }
    287     }
    288     else
    289     {
    290         while (((uintptr_t)pbSrc & 0x3))
    291         {
    292             a += *pbSrc++;
    293             a %= 65521;
    294             b += a;
    295             b %= 65521;
    296             cb--;
    297         }
    298 
    299         while (cb >= 4)
    300         {
    301             uint32_t u32 = *(uint32_t const *)pbSrc;
    302             pbSrc += 4;
    303 
    304             a += u32 & 0xff;
    305             a %= 65521;
    306             b += a;
    307             b %= 65521;
    308 
    309             a += (u32 >> 8) & 0xff;
    310             a %= 65521;
    311             b += a;
    312             b %= 65521;
    313 
    314             a += (u32 >> 16) & 0xff;
    315             a %= 65521;
    316             b += a;
    317             b %= 65521;
    318 
    319             a += (u32 >> 24) & 0xff;
    320             a %= 65521;
    321             b += a;
    322             b %= 65521;
    323 
    324             cb -= 4;
    325         }
    326 
    327         while (cb > 0)
    328         {
    329             a += *pbSrc++;
    330             a %= 65521;
    331             b += a;
    332             b %= 65521;
    333             cb--;
    334         }
    335     }
    336 
    337     return a | (b << 16);
    338 }
    339 
    340 static uint32_t RTCrcAdler32Finish(uint32_t u32Crc)
    341 {
    342     return u32Crc;
    343 
    344 }
    345 
    346 static uint32_t RTCrcAdler32(void const *pv, size_t cb)
    347 {
    348     return RTCrcAdler32Process(RTCrcAdler32Start(), pv, cb);
    349 }
    350 
    351 # define RTCrc32            RTCrcAdler32
    352 # define RTCrc32Start       RTCrcAdler32Start
    353 # define RTCrc32Process     RTCrcAdler32Process
    354 # define RTCrc32Finish      RTCrcAdler32Finish
    355 
    356 #endif
    357266
    358267
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette