* Fix styling

This commit is contained in:
2015-05-18 20:24:56 -07:00
parent 423a9a37d2
commit 6ee11b9a08
160 changed files with 11539 additions and 7742 deletions

267
extern/lzo/src/lzo1a.c vendored
View File

@@ -91,8 +91,8 @@
#if (LZO_COLLECT_STATS)
static lzo1a_stats_t lzo_statistics;
lzo1a_stats_t *lzo1a_stats = &lzo_statistics;
static lzo1a_stats_t lzo_statistics;
lzo1a_stats_t* lzo1a_stats = &lzo_statistics;
# define lzo_stats lzo1a_stats
#endif
@@ -101,15 +101,17 @@
// get algorithm info, return memory required for compression
************************************************************************/
LZO_EXTERN(lzo_uint) lzo1a_info ( int *rbits, int *clevel );
LZO_EXTERN(lzo_uint) lzo1a_info(int* rbits, int* clevel);
LZO_PUBLIC(lzo_uint)
lzo1a_info ( int *rbits, int *clevel )
lzo1a_info(int* rbits, int* clevel)
{
if (rbits)
*rbits = RBITS;
if (clevel)
*clevel = CLEVEL;
return D_SIZE * lzo_sizeof(lzo_bytep);
}
@@ -121,9 +123,9 @@ lzo1a_info ( int *rbits, int *clevel )
************************************************************************/
LZO_PUBLIC(int)
lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem )
lzo1a_decompress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem)
{
lzo_bytep op;
const lzo_bytep ip;
@@ -135,6 +137,7 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
op = out;
ip = in;
while (ip < ip_end)
{
t = *ip++; /* get marker */
@@ -143,9 +146,11 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
if (t == 0) /* a R0 literal run */
{
t = *ip++;
if (t >= R0FAST - R0MIN) /* a long R0 run */
{
t -= R0FAST - R0MIN;
if (t == 0)
t = R0FAST;
else
@@ -155,33 +160,41 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
#else
/* help the optimizer */
lzo_uint tt = 256;
do tt <<= 1; while (--t > 0);
do tt <<= 1;
while (--t > 0);
t = tt;
#endif
}
MEMCPY8_DS(op,ip,t);
MEMCPY8_DS(op, ip, t);
continue;
}
t += R0MIN;
goto literal;
}
else if (t < R0MIN) /* a short literal run */
{
literal:
MEMCPY_DS(op,ip,t);
MEMCPY_DS(op, ip, t);
/* after a literal a match must follow */
/* after a literal a match must follow */
while (ip < ip_end)
{
t = *ip++; /* get R1 marker */
if (t >= R0MIN)
goto match;
/* R1 match - a context sensitive 3 byte match + 1 byte literal */
/* R1 match - a context sensitive 3 byte match + 1 byte literal */
assert((t & OMASK) == t);
m_pos = op - MIN_OFFSET;
m_pos -= t | (((lzo_uint) *ip++) << OBITS);
assert(m_pos >= out); assert(m_pos < op);
m_pos -= t | (((lzo_uint) * ip++) << OBITS);
assert(m_pos >= out);
assert(m_pos < op);
*op++ = m_pos[0];
*op++ = m_pos[1];
*op++ = m_pos[2];
@@ -193,8 +206,9 @@ literal:
match:
/* get match offset */
m_pos = op - MIN_OFFSET;
m_pos -= (t & OMASK) | (((lzo_uint) *ip++) << OBITS);
assert(m_pos >= out); assert(m_pos < op);
m_pos -= (t & OMASK) | (((lzo_uint) * ip++) << OBITS);
assert(m_pos >= out);
assert(m_pos < op);
/* get match len */
if (t < ((MSIZE - 1) << OBITS)) /* a short match */
@@ -202,7 +216,7 @@ match:
t >>= OBITS;
*op++ = *m_pos++;
*op++ = *m_pos++;
MEMCPY_DS(op,m_pos,t);
MEMCPY_DS(op, m_pos, t);
}
else /* a long match */
{
@@ -213,13 +227,16 @@ match:
#endif
*op++ = *m_pos++;
*op++ = *m_pos++;
MEMCPY_DS(op,m_pos,t);
MEMCPY_DS(op, m_pos, t);
#if (LBITS < 8)
/* a very short literal following a long match */
t = ip[-1] >> LBITS;
if (t) do
*op++ = *ip++;
while (--t);
*op++ = *ip++;
while (--t);
#endif
}
}
@@ -229,7 +246,7 @@ match:
/* the next line is the only check in the decompressor */
return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
}
@@ -243,9 +260,9 @@ match:
#include "lzo1a_cr.ch"
static int
do_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem )
do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem)
{
const lzo_bytep ip;
#if defined(__LZO_HASH_INCREMENTAL)
@@ -253,8 +270,8 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
#endif
const lzo_bytep m_pos;
lzo_bytep op;
const lzo_bytep const ip_end = in+in_len - DVAL_LEN - MIN_MATCH_LONG;
const lzo_bytep const in_end = in+in_len - DVAL_LEN;
const lzo_bytep const ip_end = in + in_len - DVAL_LEN - MIN_MATCH_LONG;
const lzo_bytep const in_end = in + in_len - DVAL_LEN;
const lzo_bytep ii;
lzo_dict_p const dict = (lzo_dict_p) wrkmem;
const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */
@@ -272,45 +289,56 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
/* init dictionary */
#if (LZO_DETERMINISTIC)
BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE);
BZERO8_PTR(wrkmem, sizeof(lzo_dict_t), D_SIZE);
#endif
DVAL_FIRST(dv,ip); UPDATE_D(dict,0,dv,ip,in); ip++;
DVAL_NEXT(dv,ip);
DVAL_FIRST(dv, ip);
UPDATE_D(dict, 0, dv, ip, in);
ip++;
DVAL_NEXT(dv, ip);
do {
do
{
LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
lzo_uint dindex;
DINDEX1(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,MAX_OFFSET))
DINDEX1(dindex, ip);
GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match;
DINDEX2(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,MAX_OFFSET))
DINDEX2(dindex, ip);
GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match;
goto literal;
literal:
UPDATE_I(dict,0,dindex,ip,in);
UPDATE_I(dict, 0, dindex, ip, in);
if (++ip >= ip_end)
break;
continue;
match:
UPDATE_I(dict,0,dindex,ip,in);
UPDATE_I(dict, 0, dindex, ip, in);
#if !defined(NDEBUG) && (LZO_DICT_USE_PTR)
assert(m_pos == NULL || m_pos >= in);
m_pos_sav = m_pos;
#endif
m_pos += 3;
{
/* we have found a match (of at least length 3) */
/* we have found a match (of at least length 3) */
#if !defined(NDEBUG) && !(LZO_DICT_USE_PTR)
assert((m_pos_sav = ip - m_off) == (m_pos - 3));
@@ -320,22 +348,22 @@ match:
assert(ip < ip_end);
/* 1) store the current literal run */
if (pd(ip,ii) > 0)
if (pd(ip, ii) > 0)
{
lzo_uint t = pd(ip,ii);
lzo_uint t = pd(ip, ii);
if (ip - r1 == MIN_MATCH + 1)
{
/* Code a context sensitive R1 match.
* This is tricky and somewhat difficult to explain:
* multiplex a literal run of length 1 into the previous
* short match of length MIN_MATCH.
* The key idea is:
* - after a short run a match MUST follow
* - therefore the value m = 000 in the mmmooooo marker is free
* - use 000ooooo to indicate a MIN_MATCH match (this
* is already coded) plus a 1 byte literal
*/
/* Code a context sensitive R1 match.
* This is tricky and somewhat difficult to explain:
* multiplex a literal run of length 1 into the previous
* short match of length MIN_MATCH.
* The key idea is:
* - after a short run a match MUST follow
* - therefore the value m = 000 in the mmmooooo marker is free
* - use 000ooooo to indicate a MIN_MATCH match (this
* is already coded) plus a 1 byte literal
*/
assert(t == 1);
/* modify marker byte */
assert((op[-2] >> OBITS) == (MIN_MATCH - THRESHOLD));
@@ -350,11 +378,11 @@ match:
{
/* inline the copying of a short run */
#if (LBITS < 8)
if (t < (1 << (8-LBITS)) && ii - im >= MIN_MATCH_LONG)
if (t < (1 << (8 - LBITS)) && ii - im >= MIN_MATCH_LONG)
{
/* Code a very short literal run into the
* previous long match length byte.
*/
/* Code a very short literal run into the
* previous long match length byte.
*/
LZO_STATS(lzo_stats->lit_runs_after_long_match++);
LZO_STATS(lzo_stats->lit_run_after_long_match[t]++);
assert(ii - im <= MAX_MATCH_LONG);
@@ -376,13 +404,15 @@ match:
{
/* inline the copying of a short R0 run */
LZO_STATS(lzo_stats->r0short_runs++);
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
*op++ = 0;
*op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ii, t);
r1 = ip; /* set new R1 pointer */
}
else
op = store_run(op,ii,t);
op = store_run(op, ii, t);
}
#if (LBITS < 8)
im = ip;
#endif
@@ -402,37 +432,38 @@ match:
#define PS *m_pos++ != *ip++
#if (MIN_MATCH_LONG - MIN_MATCH == 2) /* MBITS == 2 */
if (PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 6) /* MBITS == 3 */
if (PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 14) /* MBITS == 4 */
if (PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS)
PS || PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 30) /* MBITS == 5 */
if (PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS)
PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS)
#else
# error "MBITS not yet implemented"
#endif
{
/* we've found a short match */
/* we've found a short match */
lzo_uint m_len;
/* 2a) compute match parameters */
assert(ip-m_pos == (int)m_off);
/* 2a) compute match parameters */
assert(ip - m_pos == (int)m_off);
--ip; /* ran one too far, point back to non-match */
m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_SHORT);
assert(m_len <= MAX_MATCH_SHORT);
assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
assert(m_len >= MIN_MATCH_SHORT);
assert(m_len <= MAX_MATCH_SHORT);
assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET);
assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
m_off -= MIN_OFFSET;
/* 2b) code a short match */
/* 2b) code a short match */
/* code short match len + low offset bits */
*op++ = LZO_BYTE(((m_len - THRESHOLD) << OBITS) |
(m_off & OMASK));
@@ -443,50 +474,58 @@ match:
#if (LZO_COLLECT_STATS)
lzo_stats->short_matches++;
lzo_stats->short_match[m_len]++;
if (m_off < OSIZE)
lzo_stats->short_match_offset_osize[m_len]++;
if (m_off < 256)
lzo_stats->short_match_offset_256[m_len]++;
if (m_off < 1024)
lzo_stats->short_match_offset_1024[m_len]++;
#endif
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#define SI /* nothing */
#define DI ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,0,dv,ii,in);
#define XI assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
#if (CLEVEL == 9) || (CLEVEL >= 7 && MBITS <= 4) || (CLEVEL >= 5 && MBITS <= 3)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
++ii;
do {
DVAL_NEXT(dv,ii);
UPDATE_D(dict,0,dv,ii,in);
} while (++ii < ip);
DVAL_NEXT(dv,ii);
do
{
DVAL_NEXT(dv, ii);
UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv,ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 3)
SI DI DI XI
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
XI
#endif
}
else
{
/* we've found a long match - see how far we can still go */
/* we've found a long match - see how far we can still go */
const lzo_bytep end;
lzo_uint m_len;
assert(ip <= in_end);
assert(ii == ip - MIN_MATCH_LONG);
if (pd(in_end,ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG))
if (pd(in_end, ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG))
end = in_end;
else
{
@@ -496,20 +535,21 @@ match:
while (ip < end && *m_pos == *ip)
m_pos++, ip++;
assert(ip <= in_end);
/* 2a) compute match parameters */
/* 2a) compute match parameters */
m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_LONG);
assert(m_len <= MAX_MATCH_LONG);
assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
assert(pd(ip,m_pos) == m_off);
assert(m_len >= MIN_MATCH_LONG);
assert(m_len <= MAX_MATCH_LONG);
assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET);
assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
assert(pd(ip, m_pos) == m_off);
m_off -= MIN_OFFSET;
/* 2b) code the long match */
/* 2b) code the long match */
/* code long match flag + low offset bits */
*op++ = LZO_BYTE(((MSIZE - 1) << OBITS) | (m_off & OMASK));
/* code high offset bits */
@@ -524,18 +564,22 @@ match:
#endif
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it is slow. */
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it is slow. */
++ii;
do {
DVAL_NEXT(dv,ii);
UPDATE_D(dict,0,dv,ii,in);
} while (++ii < ip);
DVAL_NEXT(dv,ii);
do
{
DVAL_NEXT(dv, ii);
UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv,ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7)
@@ -551,7 +595,7 @@ match:
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
XI
#endif
}
@@ -559,12 +603,14 @@ match:
assert(ii == ip);
}
} while (ip < ip_end);
}
while (ip < ip_end);
assert(ip <= in_end);
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
/* return -1 if op == out to indicate that we
* couldn't compress and didn't copy anything.
*/
@@ -573,11 +619,12 @@ match:
*out_len = 0;
return LZO_E_NOT_COMPRESSIBLE;
}
#endif
/* store the final literal run */
if (pd(in_end+DVAL_LEN,ii) > 0)
op = store_run(op,ii,pd(in_end+DVAL_LEN,ii));
if (pd(in_end + DVAL_LEN, ii) > 0)
op = store_run(op, ii, pd(in_end + DVAL_LEN, ii));
*out_len = pd(op, out);
return 0; /* compression went ok */
@@ -589,15 +636,15 @@ match:
************************************************************************/
LZO_PUBLIC(int)
lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem )
lzo1a_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem)
{
int r = LZO_E_OK;
#if (LZO_COLLECT_STATS)
lzo_memset(lzo_stats,0,sizeof(*lzo_stats));
lzo_memset(lzo_stats, 0, sizeof(*lzo_stats));
lzo_stats->rbits = RBITS;
lzo_stats->clevel = CLEVEL;
lzo_stats->dbits = DBITS;
@@ -623,11 +670,11 @@ lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
r = LZO_E_NOT_COMPRESSIBLE;
#else
*out_len = pd(store_run(out,in,in_len), out);
*out_len = pd(store_run(out, in, in_len), out);
#endif
}
else
r = do_compress(in,in_len,out,out_len,wrkmem);
r = do_compress(in, in_len, out, out_len, wrkmem);
#if (LZO_COLLECT_STATS)