diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-10-09 00:00:47 +0000 |
commit | d6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch) | |
tree | e2be02f33984c48ec019c654051d27964e42c441 /lib | |
parent | 609d1e803baf519487233b765eb487f9ec227a18 (diff) |
Merge with 2.3.19.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/inflate.c | 23 | ||||
-rw-r--r-- | lib/string.c | 2 | ||||
-rw-r--r-- | lib/vsprintf.c | 9 |
3 files changed, 22 insertions, 12 deletions
diff --git a/lib/inflate.c b/lib/inflate.c index 65e435bdb..3dca73c72 100644 --- a/lib/inflate.c +++ b/lib/inflate.c @@ -1,16 +1,17 @@ -#ifndef DEBG #define DEBG(x) -#endif -#ifndef DEBG1 #define DEBG1(x) -#endif - /* inflate.c -- Not copyrighted 1992 by Mark Adler version c10p1, 10 January 1993 */ /* * Adapted for booting Linux by Hannu Savolainen 1993 * based on gzip-1.0.3 + * + * Nicolas Pitre <nico@visuaide.com>, 1999/04/14 : + * Little mods for all variable to reside either into rodata or bss segments + * by marking constant variables with 'const' and initializing all the others + * at run-time only. This allows for the kernel uncompressor to run + * directly from Flash or ROM memory on embeded systems. */ /* @@ -137,8 +138,8 @@ struct huft { /* Function prototypes */ -STATIC int huft_build OF((unsigned *, unsigned, unsigned, const ush *, const ush *, - struct huft **, int *)); +STATIC int huft_build OF((unsigned *, unsigned, unsigned, + const ush *, const ush *, struct huft **, int *)); STATIC int huft_free OF((struct huft *)); STATIC int inflate_codes OF((struct huft *, struct huft *, int, int)); STATIC int inflate_stored OF((void)); @@ -1007,7 +1008,7 @@ STATIC int inflate() **********************************************************************/ static ulg crc_32_tab[256]; -static ulg crc; /* shift register contents */ +static ulg crc; /* initialized in makecrc() so it'll reside in bss */ #define CRC_VALUE (crc ^ 0xffffffffL) /* @@ -1026,7 +1027,7 @@ makecrc(void) int k; /* byte being shifted into crc apparatus */ /* terms of polynomial defining this crc (except x^32): */ - static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; /* Make exclusive-or pattern from polynomial */ e = 0; @@ -1046,6 +1047,9 @@ makecrc(void) } crc_32_tab[i] = c; } + + /* this is initialized here so this code could reside in ROM */ + crc = (ulg)0xffffffffL; /* shift register contents */ } /* gzip flag byte */ @@ -1069,7 +1073,6 @@ static int gunzip(void) ulg orig_len = 0; /* original uncompressed length */ int res; - crc = (ulg)0xffffffffL; magic[0] = (unsigned char)get_byte(); magic[1] = (unsigned char)get_byte(); method = (unsigned char)get_byte(); diff --git a/lib/string.c b/lib/string.c index d63f624d9..5e82ce28c 100644 --- a/lib/string.c +++ b/lib/string.c @@ -367,7 +367,7 @@ char * strstr(const char * s1,const char * s2) #ifndef __HAVE_ARCH_MEMCHR void *memchr(const void *s, int c, size_t n) { - unsigned char *p = s; + const unsigned char *p = s; while (n-- != 0) { if ((unsigned char)c == *p++) { return p-1; diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 48959e3a8..54904a2c8 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -156,7 +156,9 @@ int vsprintf(char *buf, const char *fmt, va_list args) int precision; /* min. # of digits for integers; max number of chars for from string */ int qualifier; /* 'h', 'l', or 'L' for integer fields */ + /* 'z' support added 23/7/1999 S.H. */ + for (str=buf ; *fmt ; ++fmt) { if (*fmt != '%') { *str++ = *fmt; @@ -206,7 +208,7 @@ int vsprintf(char *buf, const char *fmt, va_list args) /* get the conversion qualifier */ qualifier = -1; - if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='z') { qualifier = *fmt; ++fmt; } @@ -255,6 +257,9 @@ int vsprintf(char *buf, const char *fmt, va_list args) if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf); + } else if (qualifier == 'z') { + size_t * ip = va_arg(args, size_t *); + *ip = (str - buf); } else { int * ip = va_arg(args, int *); *ip = (str - buf); @@ -292,6 +297,8 @@ int vsprintf(char *buf, const char *fmt, va_list args) } if (qualifier == 'l') num = va_arg(args, unsigned long); + else if (qualifier == 'z') + num = va_arg(args, size_t); else if (qualifier == 'h') { num = (unsigned short) va_arg(args, int); if (flags & SIGN) |