2012-10-24 18:30 UTC+0200 Viktor Szakats (harbour syenar.net)

* contrib/hbmlzo/core.c
    * LZO_ADLER32() changed to use core checksum function.
      it's equivalent to HB_ADLER32( <s>, 1 )

  * src/rtl/hbadler.c
    % hb_adler32(): applied the loop unrolling optimization 
      found in the mzlo implementation.
This commit is contained in:
Viktor Szakats
2012-10-24 16:31:52 +00:00
parent 845658b407
commit a0bd1cd972
3 changed files with 34 additions and 9 deletions

View File

@@ -16,6 +16,15 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-10-24 18:30 UTC+0200 Viktor Szakats (harbour syenar.net)
* contrib/hbmlzo/core.c
* LZO_ADLER32() changed to use core checksum function.
it's equivalent to HB_ADLER32( <s>, 1 )
* src/rtl/hbadler.c
% hb_adler32(): applied the loop unrolling optimization
found in the mzlo implementation.
2012-10-24 15:35 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbexprb.c
! fixed typo in function IDs.

View File

@@ -54,6 +54,7 @@
#include "hbapi.h"
#include "hbapierr.h"
#include "hbchksum.h"
#include "hbinit.h"
#include "hbvm.h"
@@ -266,11 +267,7 @@ HB_FUNC( LZO_ADLER32 )
const char * src = hb_parc( 1 );
if( src )
{
lzo_uint32 checksum = lzo_adler32( 0, NULL, 0 );
hb_retnint( ( HB_MAXINT ) lzo_adler32( checksum, ( lzo_bytep ) src, hb_parclen( 1 ) ) );
}
hb_retnint( ( HB_MAXINT ) hb_adler32( 1, ( lzo_bytep ) src, hb_parclen( 1 ) ) );
else
hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}

View File

@@ -59,6 +59,12 @@
#define BASE 65521 /* largest prime smaller than 65536 */
#define NMAX 5552 /* largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define LOOP_DO1( buf, i ) s1 += buf[ i ]; s2 += s1
#define LOOP_DO2( buf, i ) LOOP_DO1( buf, i ); LOOP_DO1( buf, i + 1 );
#define LOOP_DO4( buf, i ) LOOP_DO2( buf, i ); LOOP_DO2( buf, i + 2 );
#define LOOP_DO8( buf, i ) LOOP_DO4( buf, i ); LOOP_DO4( buf, i + 4 );
#define LOOP_DO16( buf, i ) LOOP_DO8( buf, i ); LOOP_DO8( buf, i + 8 );
HB_U32 hb_adler32( HB_U32 adler, const void * buf, HB_SIZE len )
{
HB_U32 s1 = adler & 0xffff;
@@ -71,12 +77,25 @@ HB_U32 hb_adler32( HB_U32 adler, const void * buf, HB_SIZE len )
{
HB_ISIZ n = len < NMAX ? len : NMAX;
len -= n;
do
if( n >= 16 )
{
s1 += *ucbuf++;
s2 += s1;
do
{
LOOP_DO16( ucbuf, 0 );
ucbuf += 16;
n -= 16;
}
while( n >= 16 );
}
if( n )
{
do
{
s1 += *ucbuf++;
s2 += s1;
}
while( --n );
}
while( --n );
s1 %= BASE;
s2 %= BASE;
}