:: commit 71d0feb23ae127c1ff3c701bcda38cebdf7052e7

mintsuki <mintsuki@protonmail.com> — 2021-03-01 22:51

parents: 8c0c36ea74

tinf: Remove legacy stage 3 stuff

diff --git a/decompressor/Makefile b/decompressor/Makefile
index 2fe9a9e1..a2f86164 100644
--- a/decompressor/Makefile
+++ b/decompressor/Makefile
@@ -5,7 +5,6 @@ OBJCOPY = i386-elf-objcopy
 CFLAGS = -flto -Os -pipe -Wall -Wextra -Werror
 
 INTERNAL_CFLAGS = \
-	-DIN_DECOMPRESSOR \
 	-std=gnu11 \
 	-ffreestanding \
 	-fno-stack-protector \
diff --git a/tinf/tinfgzip.c b/tinf/tinfgzip.c
index 44e86e08..7935a50e 100644
--- a/tinf/tinfgzip.c
+++ b/tinf/tinfgzip.c
@@ -23,13 +23,6 @@
  *      distribution.
  */
 
-#ifndef IN_DECOMPRESSOR
-#  include <lib/blib.h>
-#else
-#  define stage3_text
-#  define stage3_data
-#endif
-
 #include "tinf.h"
 
 typedef enum {
@@ -40,7 +33,7 @@ typedef enum {
     FCOMMENT = 16
 } tinf_gzip_flag;
 
-stage3_text int tinf_gzip_uncompress(void *dest,
+int tinf_gzip_uncompress(void *dest,
                          const void *source, unsigned int sourceLen) {
     const unsigned char *src = (const unsigned char *) source;
     unsigned char *dst = (unsigned char *) dest;
diff --git a/tinf/tinflate.c b/tinf/tinflate.c
index b45e3b48..79d43e83 100644
--- a/tinf/tinflate.c
+++ b/tinf/tinflate.c
@@ -23,13 +23,6 @@
  *      distribution.
  */
 
-#ifndef IN_DECOMPRESSOR
-#  include <lib/blib.h>
-#else
-#  define stage3_text
-#  define stage3_data
-#endif
-
 #include "tinf.h"
 
 #include <limits.h>
@@ -62,13 +55,13 @@ struct tinf_data {
 
 /* -- Utility functions -- */
 
-stage3_text static unsigned int read_le16(const unsigned char *p) {
+static unsigned int read_le16(const unsigned char *p) {
     return ((unsigned int) p[0])
          | ((unsigned int) p[1] << 8);
 }
 
 /* Build fixed Huffman trees */
-stage3_text static void tinf_build_fixed_trees(struct tinf_tree *lt, struct tinf_tree *dt) {
+static void tinf_build_fixed_trees(struct tinf_tree *lt, struct tinf_tree *dt) {
     int i;
 
     /* Build fixed literal/length tree */
@@ -110,7 +103,7 @@ stage3_text static void tinf_build_fixed_trees(struct tinf_tree *lt, struct tinf
 }
 
 /* Given an array of code lengths, build a tree */
-stage3_text static int tinf_build_tree(struct tinf_tree *t, const unsigned char *lengths,
+static int tinf_build_tree(struct tinf_tree *t, const unsigned char *lengths,
                            unsigned int num) {
     unsigned short offs[16];
     unsigned int i, num_codes, available;
@@ -174,7 +167,7 @@ stage3_text static int tinf_build_tree(struct tinf_tree *t, const unsigned char
 
 /* -- Decode functions -- */
 
-stage3_text static void tinf_refill(struct tinf_data *d, int num) {
+static void tinf_refill(struct tinf_data *d, int num) {
 
     /* Read bytes until at least num bits available */
     while (d->bitcount < num) {
@@ -189,7 +182,7 @@ stage3_text static void tinf_refill(struct tinf_data *d, int num) {
 
 }
 
-stage3_text static unsigned int tinf_getbits_no_refill(struct tinf_data *d, int num) {
+static unsigned int tinf_getbits_no_refill(struct tinf_data *d, int num) {
     unsigned int bits;
 
 
@@ -204,18 +197,18 @@ stage3_text static unsigned int tinf_getbits_no_refill(struct tinf_data *d, int
 }
 
 /* Get num bits from source stream */
-stage3_text static unsigned int tinf_getbits(struct tinf_data *d, int num) {
+static unsigned int tinf_getbits(struct tinf_data *d, int num) {
     tinf_refill(d, num);
     return tinf_getbits_no_refill(d, num);
 }
 
 /* Read a num bit value from stream and add base */
-stage3_text static unsigned int tinf_getbits_base(struct tinf_data *d, int num, int base) {
+static unsigned int tinf_getbits_base(struct tinf_data *d, int num, int base) {
     return base + (num ? tinf_getbits(d, num) : 0);
 }
 
 /* Given a data stream and a tree, decode a symbol */
-stage3_text static int tinf_decode_symbol(struct tinf_data *d, const struct tinf_tree *t) {
+static int tinf_decode_symbol(struct tinf_data *d, const struct tinf_tree *t) {
     int base = 0, offs = 0;
     int len;
 
@@ -248,7 +241,7 @@ stage3_text static int tinf_decode_symbol(struct tinf_data *d, const struct tinf
 }
 
 /* Given a data stream, decode dynamic trees from it */
-stage3_text static int tinf_decode_trees(struct tinf_data *d, struct tinf_tree *lt,
+static int tinf_decode_trees(struct tinf_data *d, struct tinf_tree *lt,
                              struct tinf_tree *dt) {
     unsigned char lengths[288 + 32];
 
@@ -374,7 +367,7 @@ stage3_text static int tinf_decode_trees(struct tinf_data *d, struct tinf_tree *
 /* -- Block inflate functions -- */
 
 /* Given a stream and two trees, inflate a block of data */
-stage3_text static int tinf_inflate_block_data(struct tinf_data *d, struct tinf_tree *lt,
+static int tinf_inflate_block_data(struct tinf_data *d, struct tinf_tree *lt,
                                    struct tinf_tree *dt) {
     /* Extra bits and base tables for length codes */
     static const unsigned char length_bits[30] = {
@@ -459,7 +452,7 @@ stage3_text static int tinf_inflate_block_data(struct tinf_data *d, struct tinf_
 }
 
 /* Inflate an uncompressed block of data */
-stage3_text static int tinf_inflate_uncompressed_block(struct tinf_data *d) {
+static int tinf_inflate_uncompressed_block(struct tinf_data *d) {
     unsigned int length, invlength;
 
     if (d->source_end - d->source < 4) {
@@ -492,7 +485,7 @@ stage3_text static int tinf_inflate_uncompressed_block(struct tinf_data *d) {
 }
 
 /* Inflate a block of data compressed with fixed Huffman trees */
-stage3_text static int tinf_inflate_fixed_block(struct tinf_data *d) {
+static int tinf_inflate_fixed_block(struct tinf_data *d) {
     /* Build fixed Huffman trees */
     tinf_build_fixed_trees(&d->ltree, &d->dtree);
 
@@ -501,7 +494,7 @@ stage3_text static int tinf_inflate_fixed_block(struct tinf_data *d) {
 }
 
 /* Inflate a block of data compressed with dynamic Huffman trees */
-stage3_text static int tinf_inflate_dynamic_block(struct tinf_data *d) {
+static int tinf_inflate_dynamic_block(struct tinf_data *d) {
     /* Decode trees from stream */
     int res = tinf_decode_trees(d, &d->ltree, &d->dtree);
 
@@ -516,7 +509,7 @@ stage3_text static int tinf_inflate_dynamic_block(struct tinf_data *d) {
 /* -- Public functions -- */
 
 /* Inflate stream from source to dest */
-stage3_text int tinf_uncompress(void *dest,
+int tinf_uncompress(void *dest,
                     const void *source, unsigned int sourceLen) {
     struct tinf_data d;
     int bfinal;
tab: 248 wrap: offon