| plan 9 kernel history: overview | file list | diff list |
1999/1111/port/thwack.c (diff list | history)
| 1999/1022/sys/src/9/port/thwack.c:1,5 – 1999/1111/sys/src/9/port/thwack.c:1,5 (short | long | prev | next) | ||
| 1999/1001 | #include "u.h" | |
| 1999/1022 |
| |
| 1999/1111 | #include "lib.h" | |
| 1999/1001 | #include "mem.h" #include "dat.h" #include "fns.h" | |
| 1999/1022/sys/src/9/port/thwack.c:6,15 – 1999/1111/sys/src/9/port/thwack.c:6,28 | ||
| 1999/1001 | #include "thwack.h" | |
| 1999/1111 | /* * don't include compressed blocks */ #define NOUNCOMP | |
| 1999/1001 | typedef struct Huff Huff; | |
| 1999/1022 | enum { | |
| 1999/1111 | MaxFastLen = 9, BigLenCode = 0x1f4, /* minimum code for large lenth encoding */ BigLenBits = 9, BigLenBase = 4 /* starting items to encode for big lens */ }; enum { | |
| 1999/1022 | StatBytes, StatOutBytes, StatLits, | |
| 1999/1022/sys/src/9/port/thwack.c:32,46 – 1999/1111/sys/src/9/port/thwack.c:45,59 | ||
| 1999/1001 | ||
| 1999/1007 | static Huff lentab[MaxFastLen] = | |
| 1999/1001 | { | |
| 1999/1111 | {3, 0x6}, /* 110 */ | |
| 1999/1007 | {5, 0x1c}, /* 11100 */ | |
| 1999/1111 | {5, 0x1d}, /* 11101 */ {6, 0x3c}, /* 111100 */ {7, 0x7a}, /* 1111010 */ {7, 0x7b}, /* 1111011 */ {8, 0xf8}, /* 11111000 */ {8, 0xf9}, /* 11111001 */ | |
| 1999/1001 | }; void | |
| 1999/1022/sys/src/9/port/thwack.c:215,220 – 1999/1111/sys/src/9/port/thwack.c:228,239 | ||
| 1999/1022 | *twdst++ = seq - cseq; *twdst++ = cmask; | |
| 1999/1001 | ||
| 1999/1111 | #ifndef NOUNCOMP tw->slot++; if(tw->slot >= EWinBlocks) tw->slot = 0; #endif | |
| 1999/1022 | cont = (s[0] << 16) | (s[1] << 8) | s[2]; | |
| 1999/1001 | esrc = s + n; | |
| 1999/1022/sys/src/9/port/thwack.c:261,266 – 1999/1111/sys/src/9/port/thwack.c:280,286 | ||
| 1999/1022 | lits++; blocks->maxoff++; | |
| 1999/1001 | ||
| 1999/1111 | #ifdef NOUNCOMP | |
| 1999/1022 | /* * speed hack * check for compression progress, bail if none achieved | |
| 1999/1022/sys/src/9/port/thwack.c:270,275 – 1999/1111/sys/src/9/port/thwack.c:290,296 | ||
| 1999/1022 | return -1; half = esrc; } | |
| 1999/1111 | #endif | |
| 1999/1001 | ||
| 1999/1022 | if(s + MinMatch <= esrc){ blocks->hash[(h ^ blocks->seq) & HashMask] = now; | |
| 1999/1022/sys/src/9/port/thwack.c:284,301 – 1999/1111/sys/src/9/port/thwack.c:305,313 | ||
| 1999/1022 | blocks->maxoff += len; matches++; | |
| 1999/1001 | ||
| 1999/1022 |
| |
| 1999/1111 | /* * length of match */ | |
| 1999/1022 | len -= MinMatch; if(len < MaxFastLen){ bits = lentab[len].bits; | |
| 1999/1022/sys/src/9/port/thwack.c:303,313 – 1999/1111/sys/src/9/port/thwack.c:315,320 | ||
| 1999/1022 | twnbits += bits; lenbits += bits; }else{ | |
| 1999/1022/sys/src/9/port/thwack.c:315,330 – 1999/1111/sys/src/9/port/thwack.c:322,361 | ||
| 1999/1022 | while(len >= use){ len -= use; code = (code + use) << 1; | |
| 1999/1111 | use <<= (bits & 1) ^ 1; | |
| 1999/1022 | bits++; } | |
| 1999/1111 | for(; twnbits >= 8; twnbits -= 8){ if(twdst >= twdmax) return -1; *twdst++ = twbits >> (twnbits - 8); } | |
| 1999/1022 | } | |
| 1999/1111 | /* * offset in history */ toff--; for(bits = OffBase; toff >= (1 << bits); bits++) ; if(bits < MaxOff+OffBase-1){ twbits = (twbits << 3) | (bits - OffBase); if(bits != OffBase) bits--; twnbits += bits + 3; offbits += bits + 3; }else{ twbits = (twbits << 4) | 0xe | (bits - (MaxOff+OffBase-1)); bits--; twnbits += bits + 4; offbits += bits + 4; } twbits = (twbits << bits) | toff & ((1 << bits) - 1); | |
| 1999/1001 | for(; s != ss; s++){ if(s + MinMatch <= esrc){ h = hashit(cont); | |
| 1999/1022/sys/src/9/port/thwack.c:353,361 – 1999/1111/sys/src/9/port/thwack.c:384,394 | ||
| 1999/1022 | *twdst++ = twbits >> (twnbits - 8); } | |
| 1999/1111 | #ifdef NOUNCOMP | |
| 1999/1001 | tw->slot++; if(tw->slot >= EWinBlocks) tw->slot = 0; | |
| 1999/1111 | #endif | |
| 1999/1001 | ||
| 1999/1022 | stats[StatOutBytes] += twdst - dst; | |
| 1999/1001 | ||