wok-stable annotate linux/stuff/linux-unlzma-2.6.34.u @ rev 7091

Changed libsexy TARBALL to .tar.bz2. Fixed libsexy to build in clean chroot.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Nov 03 02:35:47 2010 +0000 (2010-11-03)
parents
children
rev   line source
pankso@5640 1 --- linux-2.6.30.4/init/initramfs.c
pankso@5640 2 +++ linux-2.6.30.4/init/initramfs.c
pankso@5640 3 @@ -425,7 +425,8 @@
pankso@5640 4 return len - count;
pankso@5640 5 }
pankso@5640 6
pankso@5640 7 -static int __init flush_buffer(void *bufv, unsigned len)
pankso@5640 8 +#define flush_buffer cpio_flush_buffer
pankso@5640 9 +int __init flush_buffer(void *bufv, unsigned len)
pankso@5640 10 {
pankso@5640 11 char *buf = (char *) bufv;
pankso@5640 12 int written;
pankso@5640 13
pankso@5640 14 --- linux-2.6.30.4/lib/decompress_unlzma.c
pankso@5640 15 +++ linux-2.6.30.4/lib/decompress_unlzma.c
pankso@5640 16 @@ -278,6 +278,10 @@
pankso@5640 17 size_t global_pos;
pankso@5640 18 int(*flush)(void*, unsigned int);
pankso@5640 19 struct lzma_header *header;
pankso@5640 20 + int is_cpio_flush;
pankso@5640 21 + uint8_t **buffer_index;
pankso@5640 22 + int next_index;
pankso@5640 23 + int max_index;
pankso@5640 24 };
pankso@5640 25
pankso@5640 26 struct cstate {
pankso@5640 27 @@ -294,6 +298,14 @@
pankso@5640 28 static inline uint8_t INIT peek_old_byte(struct writer *wr,
pankso@5640 29 uint32_t offs)
pankso@5640 30 {
pankso@5640 31 + if (wr->is_cpio_flush) {
pankso@5640 32 + int32_t pos;
pankso@5640 33 + while (offs > wr->header->dict_size)
pankso@5640 34 + offs -= wr->header->dict_size;
pankso@5640 35 + pos = wr->buffer_pos - offs;
pankso@5640 36 + return wr->buffer_index[pos / LZMA_IOBUF_SIZE]
pankso@5640 37 + [pos % LZMA_IOBUF_SIZE];
pankso@5640 38 + }
pankso@5640 39 if (!wr->flush) {
pankso@5640 40 int32_t pos;
pankso@5640 41 while (offs > wr->header->dict_size)
pankso@5640 42 @@ -309,8 +321,41 @@
pankso@5640 43
pankso@5640 44 }
pankso@5640 45
pankso@5640 46 +static inline void INIT write_byte_if_cpio(struct writer *wr, uint8_t byte)
pankso@5640 47 +{
pankso@5640 48 + if (wr->buffer_pos % LZMA_IOBUF_SIZE == 0) {
pankso@5640 49 + // if the following large_malloc fails, the initramfs
pankso@5640 50 + // whould not be load with is_cpio_flush forced 0 too.
pankso@5640 51 + // Remember we do not allocate historic buffer.
pankso@5640 52 + // Let's assume it will never fail !
pankso@5640 53 + if (wr->next_index >= wr->max_index) {
pankso@5640 54 + // realloc wr->buffer_index
pankso@5640 55 + uint8_t **p = wr->buffer_index;
pankso@5640 56 + wr->buffer_index = (uint8_t **)
pankso@5640 57 + large_malloc(LZMA_IOBUF_SIZE +
pankso@5640 58 + sizeof(*p) * wr->max_index);
pankso@5640 59 + if (wr->max_index) {
pankso@5640 60 + memcpy(wr->buffer_index, p,
pankso@5640 61 + sizeof(*p) * wr->max_index);
pankso@5640 62 + free(p);
pankso@5640 63 + }
pankso@5640 64 + wr->max_index += LZMA_IOBUF_SIZE / sizeof(*p);
pankso@5640 65 + }
pankso@5640 66 + wr->buffer_index[wr->next_index++] =
pankso@5640 67 + (uint8_t *) large_malloc(LZMA_IOBUF_SIZE);
pankso@5640 68 + }
pankso@5640 69 + wr->buffer_index[wr->buffer_pos / LZMA_IOBUF_SIZE]
pankso@5640 70 + [wr->buffer_pos % LZMA_IOBUF_SIZE] =
pankso@5640 71 + wr->previous_byte = byte;
pankso@5640 72 + wr->buffer_pos++;
pankso@5640 73 +}
pankso@5640 74 +
pankso@5640 75 static inline void INIT write_byte(struct writer *wr, uint8_t byte)
pankso@5640 76 {
pankso@5640 77 + if (wr->is_cpio_flush) {
pankso@5640 78 + write_byte_if_cpio(wr, byte);
pankso@5640 79 + return;
pankso@5640 80 + }
pankso@5640 81 wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte;
pankso@5640 82 if (wr->flush && wr->buffer_pos == wr->header->dict_size) {
pankso@5640 83 wr->buffer_pos = 0;
pankso@5640 84 @@ -328,7 +373,21 @@
pankso@5640 85 static inline void INIT copy_bytes(struct writer *wr,
pankso@5640 86 uint32_t rep0, int len)
pankso@5640 87 {
pankso@5640 88 - do {
pankso@5640 89 + if (wr->is_cpio_flush) {
pankso@5640 90 + int32_t pos;
pankso@5640 91 + uint32_t offs = rep0;
pankso@5640 92 + while (offs > wr->header->dict_size)
pankso@5640 93 + offs -= wr->header->dict_size;
pankso@5640 94 + pos = wr->buffer_pos - offs;
pankso@5640 95 + do {
pankso@5640 96 + write_byte_if_cpio(wr,
pankso@5640 97 + wr->buffer_index[pos / LZMA_IOBUF_SIZE]
pankso@5640 98 + [pos % LZMA_IOBUF_SIZE]);
pankso@5640 99 + pos++;
pankso@5640 100 + len--;
pankso@5640 101 + } while (len != 0 && wr->buffer_pos < wr->header->dst_size);
pankso@5640 102 + }
pankso@5640 103 + else do {
pankso@5640 104 copy_byte(wr, rep0);
pankso@5640 105 len--;
pankso@5640 106 } while (len != 0 && wr->buffer_pos < wr->header->dst_size);
pankso@5640 107 @@ -339,6 +398,9 @@
pankso@5640 108 int pos_state, uint16_t *prob,
pankso@5640 109 int lc, uint32_t literal_pos_mask) {
pankso@5640 110 int mi = 1;
pankso@5640 111 + static const int state[LZMA_NUM_STATES] =
pankso@5640 112 + { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
pankso@5640 113 +
pankso@5640 114 rc_update_bit_0(rc, prob);
pankso@5640 115 prob = (p + LZMA_LITERAL +
pankso@5640 116 (LZMA_LIT_SIZE
pankso@5640 117 @@ -369,18 +431,13 @@
pankso@5640 118 rc_get_bit(rc, prob_lit, &mi);
pankso@5640 119 }
pankso@5640 120 write_byte(wr, mi);
pankso@5640 121 - if (cst->state < 4)
pankso@5640 122 - cst->state = 0;
pankso@5640 123 - else if (cst->state < 10)
pankso@5640 124 - cst->state -= 3;
pankso@5640 125 - else
pankso@5640 126 - cst->state -= 6;
pankso@5640 127 + cst->state = state[cst->state];
pankso@5640 128 }
pankso@5640 129
pankso@5640 130 static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
pankso@5640 131 struct cstate *cst, uint16_t *p,
pankso@5640 132 int pos_state, uint16_t *prob) {
pankso@5640 133 - int offset;
pankso@5640 134 + int offset;
pankso@5640 135 uint16_t *prob_len;
pankso@5640 136 int num_bits;
pankso@5640 137 int len;
pankso@5640 138 @@ -396,7 +453,7 @@
pankso@5640 139 prob = p + LZMA_LEN_CODER;
pankso@5640 140 } else {
pankso@5640 141 rc_update_bit_1(rc, prob);
pankso@5640 142 - prob = p + LZMA_IS_REP_G0 + cst->state;
pankso@5640 143 + prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
pankso@5640 144 if (rc_is_bit_0(rc, prob)) {
pankso@5640 145 rc_update_bit_0(rc, prob);
pankso@5640 146 prob = (p + LZMA_IS_REP_0_LONG
pankso@5640 147 @@ -417,13 +474,13 @@
pankso@5640 148 uint32_t distance;
pankso@5640 149
pankso@5640 150 rc_update_bit_1(rc, prob);
pankso@5640 151 - prob = p + LZMA_IS_REP_G1 + cst->state;
pankso@5640 152 + prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
pankso@5640 153 if (rc_is_bit_0(rc, prob)) {
pankso@5640 154 rc_update_bit_0(rc, prob);
pankso@5640 155 distance = cst->rep1;
pankso@5640 156 } else {
pankso@5640 157 rc_update_bit_1(rc, prob);
pankso@5640 158 - prob = p + LZMA_IS_REP_G2 + cst->state;
pankso@5640 159 + prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
pankso@5640 160 if (rc_is_bit_0(rc, prob)) {
pankso@5640 161 rc_update_bit_0(rc, prob);
pankso@5640 162 distance = cst->rep2;
pankso@5640 163 @@ -444,24 +501,24 @@
pankso@5640 164 prob_len = prob + LZMA_LEN_CHOICE;
pankso@5640 165 if (rc_is_bit_0(rc, prob_len)) {
pankso@5640 166 rc_update_bit_0(rc, prob_len);
pankso@5640 167 - prob_len = (prob + LZMA_LEN_LOW
pankso@5640 168 + prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
pankso@5640 169 + (pos_state <<
pankso@5640 170 - LZMA_LEN_NUM_LOW_BITS));
pankso@5640 171 + LZMA_LEN_NUM_LOW_BITS);
pankso@5640 172 offset = 0;
pankso@5640 173 num_bits = LZMA_LEN_NUM_LOW_BITS;
pankso@5640 174 } else {
pankso@5640 175 rc_update_bit_1(rc, prob_len);
pankso@5640 176 - prob_len = prob + LZMA_LEN_CHOICE_2;
pankso@5640 177 + prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
pankso@5640 178 if (rc_is_bit_0(rc, prob_len)) {
pankso@5640 179 rc_update_bit_0(rc, prob_len);
pankso@5640 180 - prob_len = (prob + LZMA_LEN_MID
pankso@5640 181 + prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
pankso@5640 182 + (pos_state <<
pankso@5640 183 - LZMA_LEN_NUM_MID_BITS));
pankso@5640 184 + LZMA_LEN_NUM_MID_BITS);
pankso@5640 185 offset = 1 << LZMA_LEN_NUM_LOW_BITS;
pankso@5640 186 num_bits = LZMA_LEN_NUM_MID_BITS;
pankso@5640 187 } else {
pankso@5640 188 rc_update_bit_1(rc, prob_len);
pankso@5640 189 - prob_len = prob + LZMA_LEN_HIGH;
pankso@5640 190 + prob_len += LZMA_LEN_HIGH - LZMA_LEN_CHOICE_2;
pankso@5640 191 offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
pankso@5640 192 + (1 << LZMA_LEN_NUM_MID_BITS));
pankso@5640 193 num_bits = LZMA_LEN_NUM_HIGH_BITS;
pankso@5640 194 @@ -529,6 +586,7 @@
pankso@5640 195 void(*error_fn)(char *x)
pankso@5640 196 )
pankso@5640 197 {
pankso@5640 198 + extern int cpio_flush_buffer(void*, unsigned int);
pankso@5640 199 struct lzma_header header;
pankso@5640 200 int lc, pb, lp;
pankso@5640 201 uint32_t pos_state_mask;
pankso@5640 202 @@ -563,6 +621,10 @@
pankso@5640 203 wr.global_pos = 0;
pankso@5640 204 wr.previous_byte = 0;
pankso@5640 205 wr.buffer_pos = 0;
pankso@5640 206 + wr.is_cpio_flush = 0;
pankso@5640 207 + if (flush == cpio_flush_buffer)
pankso@5640 208 + wr.is_cpio_flush = 1;
pankso@5640 209 + wr.buffer_index = NULL;
pankso@5640 210
pankso@5640 211 rc_init(&rc, fill, inbuf, in_len);
pankso@5640 212
pankso@5640 213 @@ -596,23 +658,23 @@
pankso@5640 214 if (header.dict_size == 0)
pankso@5640 215 header.dict_size = 1;
pankso@5640 216
pankso@5640 217 - if (output)
pankso@5640 218 + if (output || wr.is_cpio_flush)
pankso@5640 219 wr.buffer = output;
pankso@5640 220 else {
pankso@5640 221 wr.bufsize = MIN(header.dst_size, header.dict_size);
pankso@5640 222 wr.buffer = large_malloc(wr.bufsize);
pankso@5640 223 }
pankso@5640 224 - if (wr.buffer == NULL)
pankso@5640 225 + if (wr.buffer == NULL && !wr.is_cpio_flush)
pankso@5640 226 goto exit_1;
pankso@5640 227
pankso@5640 228 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
pankso@5640 229 p = (uint16_t *) large_malloc(num_probs * sizeof(*p));
pankso@5640 230 if (p == 0)
pankso@5640 231 goto exit_2;
pankso@5640 232 - num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));
pankso@5640 233 + num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
pankso@5640 234 for (i = 0; i < num_probs; i++)
pankso@5640 235 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
pankso@5640 236 -
pankso@5640 237 + wr.max_index = wr.next_index = 0;
pankso@5640 238 rc_init_code(&rc);
pankso@5640 239
pankso@5640 240 while (get_pos(&wr) < header.dst_size) {
pankso@5640 241 @@ -631,12 +693,25 @@
pankso@5640 242
pankso@5640 243 if (posp)
pankso@5640 244 *posp = rc.ptr-rc.buffer;
pankso@5640 245 - if (wr.flush)
pankso@5640 246 + if (wr.is_cpio_flush) {
pankso@5640 247 + int i;
pankso@5640 248 + for (i = 0; i < wr.next_index -1; i++) {
pankso@5640 249 + wr.flush(wr.buffer_index[i], LZMA_IOBUF_SIZE);
pankso@5640 250 + large_free(wr.buffer_index[i]);
pankso@5640 251 + }
pankso@5640 252 + if (i < wr.next_index) {
pankso@5640 253 + wr.flush(wr.buffer_index[i],
pankso@5640 254 + wr.buffer_pos % LZMA_IOBUF_SIZE);
pankso@5640 255 + large_free(wr.buffer_index[i]);
pankso@5640 256 + }
pankso@5640 257 + large_free(wr.buffer_index);
pankso@5640 258 + }
pankso@5640 259 + else if (wr.flush)
pankso@5640 260 wr.flush(wr.buffer, wr.buffer_pos);
pankso@5640 261 ret = 0;
pankso@5640 262 large_free(p);
pankso@5640 263 exit_2:
pankso@5640 264 - if (!output)
pankso@5640 265 + if (!output && !wr.is_cpio_flush)
pankso@5640 266 large_free(wr.buffer);
pankso@5640 267 exit_1:
pankso@5640 268 if (!buf)