commit 9a054520852368c0a0d179bedfce60776587a645 from: Russ Cox date: Mon Feb 08 00:51:28 2010 UTC make flate crc32 work when ulong is 64 bits R=, rsc CC= http://codereview.appspot.com/203061 commit - 28afa898ee3281afde739c9a09e59264680756ae commit + 9a054520852368c0a0d179bedfce60776587a645 blob - e908ec25252d0d8bc074f32edc87b8ea247c6290 blob + e4855597b67b8a9dabd25dd1c509bc447130cdf2 --- include/flate.h +++ include/flate.h @@ -42,10 +42,10 @@ int deflatezlibblock(uchar *dst, int dsize, uchar *src char *flateerr(int err); -ulong *mkcrctab(ulong); -ulong blockcrc(ulong *tab, ulong crc, void *buf, int n); +uint32 *mkcrctab(uint32); +uint32 blockcrc(uint32 *tab, uint32 crc, void *buf, int n); -ulong adler32(ulong adler, void *buf, int n); +uint32 adler32(uint32 adler, void *buf, int n); #if defined(__cplusplus) } #endif blob - e42791790d617417f58e2211096d4d9cf5ab7eae blob + 0e56f98b677a5ec45c02961f1efd774b8e98b6f2 --- include/u.h +++ include/u.h @@ -157,6 +157,13 @@ typedef intptr_t intptr; typedef uint32_t u32int; typedef int32_t s32int; +typedef u32int uint32; +typedef s32int int32; +typedef u16int uint16; +typedef s16int int16; +typedef u64int uint64; +typedef s64int int64; + #undef _NEEDUCHAR #undef _NEEDUSHORT #undef _NEEDUINT blob - 2985c5ffc392b965eada90f4506dd97a21f7a30a blob + 5fdbc1dbb5600cde822d19c587753cb6dd5b2e16 --- src/cmd/jpg/readpng.c +++ src/cmd/jpg/readpng.c @@ -44,11 +44,11 @@ typedef struct ZlibR{ ZlibW *w; } ZlibR; -static ulong *crctab; +static uint32 *crctab; static uchar PNGmagic[] = {137,80,78,71,13,10,26,10}; static char memerr[] = "ReadPNG: malloc failed: %r"; -static ulong +static uint32 get4(uchar *a) { return (a[0]<<24) | (a[1]<<16) | (a[2]<<8) | a[3]; @@ -87,7 +87,7 @@ static int getchunk(Biobuf *b, char *type, uchar *d, int m) { uchar buf[8]; - ulong crc = 0, crc2; + uint32 crc = 0, crc2; int n, nr; if(Bread(b, buf, 8) != 8) blob - 3b63bb7f3a16a4944b44c9d24962b910f0c5050c blob + 76835e017a8e7bf1c834155b4f129873f975e11f --- src/cmd/jpg/writepng.c +++ src/cmd/jpg/writepng.c @@ -31,11 +31,11 @@ typedef struct ZlibW{ uchar *e; /* past end of buf */ } ZlibW; -static ulong *crctab; +static uint32 *crctab; static uchar PNGmagic[] = {137,80,78,71,13,10,26,10}; static void -put4(uchar *a, ulong v) +put4(uchar *a, uint32 v) { a[0] = v>>24; a[1] = v>>16; @@ -47,7 +47,7 @@ static void chunk(Biobuf *bo, char *type, uchar *d, int n) { uchar buf[4]; - ulong crc = 0; + uint32 crc = 0; if(strlen(type) != 4) return; blob - 158dd1c71aaf2495426e03144cc32297f18058dc blob + 6be98145788e9c2baf81aea577ad7e6f3e28e4cb --- src/cmd/scat/sky.h +++ src/cmd/scat/sky.h @@ -1,4 +1,3 @@ -typedef s32int int32; #define DIR "#9/sky" /* blob - 22fb8f6d59a0f94a401c05dfff70c09b07cb36c5 blob + 538e70f756b29f0dd0ebd61fe41e737aa822401d --- src/libflate/adler.c +++ src/libflate/adler.c @@ -8,10 +8,10 @@ enum ADLERBASE = 65521 /* largest prime smaller than 65536 */ }; -ulong -adler32(ulong adler, void *vbuf, int n) +uint32 +adler32(uint32 adler, void *vbuf, int n) { - ulong s1, s2; + uint32 s1, s2; uchar *buf, *ebuf; int m; blob - 4da78f6cca3e44d374a45bd14d81e752366714ac blob + 8085c23e8189ef82d9bc90b2d7f51845f2798422 --- src/libflate/crc.c +++ src/libflate/crc.c @@ -2,11 +2,11 @@ #include #include -ulong* -mkcrctab(ulong poly) +uint32* +mkcrctab(uint32 poly) { - ulong *crctab; - ulong crc; + uint32 *crctab; + uint32 crc; int i, j; crctab = malloc(256 * sizeof(ulong)); @@ -26,8 +26,8 @@ mkcrctab(ulong poly) return crctab; } -ulong -blockcrc(ulong *crctab, ulong crc, void *vbuf, int n) +uint32 +blockcrc(uint32 *crctab, uint32 crc, void *vbuf, int n) { uchar *buf, *ebuf;