From: Daniel Axtens Date: Fri, 8 May 2015 09:36:07 +0000 (+1000) Subject: z_const -> const X-Git-Tag: 1.9.9-b1~827 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48f9b2a0e992c59db68ab36f597f3893f3fcb98d;p=thirdparty%2Fzlib-ng.git z_const -> const Signed-off-by: Daniel Axtens Conflicts: arch/x86/crc_folding.c crc32.c --- diff --git a/arch/x86/crc_folding.c b/arch/x86/crc_folding.c index 88a50ee42..f16cb82ea 100644 --- a/arch/x86/crc_folding.c +++ b/arch/x86/crc_folding.c @@ -40,7 +40,7 @@ _mm_storeu_si128((__m128i *)s->crc0 + 4, xmm_crc_part);\ } while (0); -ZLIB_INTERNAL void crc_fold_init(deflate_state *z_const s) +ZLIB_INTERNAL void crc_fold_init(deflate_state *const s) { CRC_LOAD(s) @@ -54,11 +54,11 @@ ZLIB_INTERNAL void crc_fold_init(deflate_state *z_const s) s->strm->adler = 0; } -local void fold_1(deflate_state *z_const s, +local void fold_1(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) { - z_const __m128i xmm_fold4 = _mm_set_epi32( + const __m128i xmm_fold4 = _mm_set_epi32( 0x00000001, 0x54442bd4, 0x00000001, 0xc6e41596); @@ -80,11 +80,11 @@ local void fold_1(deflate_state *z_const s, *xmm_crc3 = _mm_castps_si128(ps_res); } -local void fold_2(deflate_state *z_const s, +local void fold_2(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) { - z_const __m128i xmm_fold4 = _mm_set_epi32( + const __m128i xmm_fold4 = _mm_set_epi32( 0x00000001, 0x54442bd4, 0x00000001, 0xc6e41596); @@ -114,11 +114,11 @@ local void fold_2(deflate_state *z_const s, *xmm_crc3 = _mm_castps_si128(ps_res31); } -local void fold_3(deflate_state *z_const s, +local void fold_3(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) { - z_const __m128i xmm_fold4 = _mm_set_epi32( + const __m128i xmm_fold4 = _mm_set_epi32( 0x00000001, 0x54442bd4, 0x00000001, 0xc6e41596); @@ -154,11 +154,11 @@ local void fold_3(deflate_state *z_const s, *xmm_crc3 = _mm_castps_si128(ps_res32); } -local void fold_4(deflate_state *z_const s, +local void fold_4(deflate_state *const s, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3) { - z_const __m128i xmm_fold4 = _mm_set_epi32( + const __m128i xmm_fold4 = _mm_set_epi32( 0x00000001, 0x54442bd4, 0x00000001, 0xc6e41596); @@ -202,7 +202,7 @@ local void fold_4(deflate_state *z_const s, *xmm_crc3 = _mm_castps_si128(ps_res3); } -local z_const unsigned __attribute__((aligned(32))) pshufb_shf_table[60] = { +local const unsigned __attribute__((aligned(32))) pshufb_shf_table[60] = { 0x84838281,0x88878685,0x8c8b8a89,0x008f8e8d, /* shl 15 (16 - 1)/shr1 */ 0x85848382,0x89888786,0x8d8c8b8a,0x01008f8e, /* shl 14 (16 - 3)/shr2 */ 0x86858483,0x8a898887,0x8e8d8c8b,0x0201008f, /* shl 13 (16 - 4)/shr3 */ @@ -220,16 +220,16 @@ local z_const unsigned __attribute__((aligned(32))) pshufb_shf_table[60] = { 0x0201008f,0x06050403,0x0a090807,0x0e0d0c0b /* shl 1 (16 -15)/shr15*/ }; -local void partial_fold(deflate_state *z_const s, z_const size_t len, +local void partial_fold(deflate_state *const s, const size_t len, __m128i *xmm_crc0, __m128i *xmm_crc1, __m128i *xmm_crc2, __m128i *xmm_crc3, __m128i *xmm_crc_part) { - z_const __m128i xmm_fold4 = _mm_set_epi32( + const __m128i xmm_fold4 = _mm_set_epi32( 0x00000001, 0x54442bd4, 0x00000001, 0xc6e41596); - z_const __m128i xmm_mask3 = _mm_set1_epi32(0x80808080); + const __m128i xmm_mask3 = _mm_set1_epi32(0x80808080); __m128i xmm_shl, xmm_shr, xmm_tmp1, xmm_tmp2, xmm_tmp3; __m128i xmm_a0_0, xmm_a0_1; @@ -270,8 +270,8 @@ local void partial_fold(deflate_state *z_const s, z_const size_t len, *xmm_crc3 = _mm_castps_si128(ps_res); } -ZLIB_INTERNAL void crc_fold_copy(deflate_state *z_const s, - unsigned char *dst, z_const unsigned char *src, long len) +ZLIB_INTERNAL void crc_fold_copy(deflate_state *const s, + unsigned char *dst, const unsigned char *src, long len) { unsigned long algn_diff; __m128i xmm_t0, xmm_t1, xmm_t2, xmm_t3; @@ -395,7 +395,7 @@ done: CRC_SAVE(s) } -local z_const unsigned __attribute__((aligned(16))) crc_k[] = { +local const unsigned __attribute__((aligned(16))) crc_k[] = { 0xccaa009e, 0x00000000, /* rk1 */ 0x751997d0, 0x00000001, /* rk2 */ 0xccaa009e, 0x00000000, /* rk5 */ @@ -404,18 +404,18 @@ local z_const unsigned __attribute__((aligned(16))) crc_k[] = { 0xdb710640, 0x00000001 /* rk8 */ }; -local z_const unsigned __attribute__((aligned(16))) crc_mask[4] = { +local const unsigned __attribute__((aligned(16))) crc_mask[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000 }; -local z_const unsigned __attribute__((aligned(16))) crc_mask2[4] = { +local const unsigned __attribute__((aligned(16))) crc_mask2[4] = { 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; -uint32_t ZLIB_INTERNAL crc_fold_512to32(deflate_state *z_const s) +uint32_t ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s) { - z_const __m128i xmm_mask = _mm_load_si128((__m128i *)crc_mask); - z_const __m128i xmm_mask2 = _mm_load_si128((__m128i *)crc_mask2); + const __m128i xmm_mask = _mm_load_si128((__m128i *)crc_mask); + const __m128i xmm_mask2 = _mm_load_si128((__m128i *)crc_mask2); uint32_t crc; __m128i x_tmp0, x_tmp1, x_tmp2, crc_fold; diff --git a/arch/x86/deflate_quick.c b/arch/x86/deflate_quick.c index 338af0ed5..2f5d63ba3 100644 --- a/arch/x86/deflate_quick.c +++ b/arch/x86/deflate_quick.c @@ -19,8 +19,8 @@ extern void fill_window_sse(deflate_state *s); extern void flush_pending (z_stream *strm); -local inline long compare258(z_const unsigned char *z_const src0, - z_const unsigned char *z_const src1) +local inline long compare258(const unsigned char *const src0, + const unsigned char *const src1) { long ax, dx, cx; __m128i xmm_src0; @@ -73,11 +73,11 @@ local inline long compare258(z_const unsigned char *z_const src0, return ax - 16; } -local z_const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1]; -local z_const unsigned quick_dist_codes[8192]; +local const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1]; +local const unsigned quick_dist_codes[8192]; -local inline void quick_send_bits(deflate_state *z_const s, z_const int value, - z_const int length) +local inline void quick_send_bits(deflate_state *const s, const int value, + const int length) { unsigned code, out, w, b; @@ -99,8 +99,8 @@ local inline void quick_send_bits(deflate_state *z_const s, z_const int value, s->bi_valid = w - (b << 3); } -local inline void static_emit_ptr(deflate_state *z_const s, z_const int lc, - z_const unsigned dist) +local inline void static_emit_ptr(deflate_state *const s, const int lc, + const unsigned dist) { unsigned code, len; @@ -113,16 +113,16 @@ local inline void static_emit_ptr(deflate_state *z_const s, z_const int lc, quick_send_bits(s, code, len); } -z_const ct_data static_ltree[L_CODES+2]; +const ct_data static_ltree[L_CODES+2]; -local inline void static_emit_lit(deflate_state *z_const s,z_const int lit) +local inline void static_emit_lit(deflate_state *const s,const int lit) { quick_send_bits(s, static_ltree[lit].Code, static_ltree[lit].Len); Tracecv(isgraph(lit), (stderr," '%c' ", lit)); } -local void static_emit_tree(deflate_state *z_const s, - z_const int flush) +local void static_emit_tree(deflate_state *const s, + const int flush) { unsigned last; @@ -131,7 +131,7 @@ local void static_emit_tree(deflate_state *z_const s, } -local void static_emit_end_block(deflate_state *z_const s, +local void static_emit_end_block(deflate_state *const s, int last) { send_code(s, END_BLOCK, static_ltree); @@ -143,7 +143,7 @@ local void static_emit_end_block(deflate_state *z_const s, flush_pending(s->strm); } -local inline Pos quick_insert_string(deflate_state *z_const s, z_const Pos str) +local inline Pos quick_insert_string(deflate_state *const s, const Pos str) { Pos ret; unsigned h = 0; @@ -218,7 +218,7 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) return block_done; } -local z_const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = { +local const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = { 0x00004007, 0x00002007, 0x00006007, 0x00001007, 0x00005007, 0x00003007, 0x00007007, 0x00000807, 0x00004808, 0x0000c808, 0x00002808, 0x0000a808, @@ -285,7 +285,7 @@ local z_const unsigned quick_len_codes[MAX_MATCH-MIN_MATCH+1] = { 0x001c230d, 0x001d230d, 0x001e230d, 0x0000a308, }; -local z_const unsigned quick_dist_codes[8192] = { +local const unsigned quick_dist_codes[8192] = { 0x00000005, 0x00001005, 0x00000805, 0x00001805, 0x00000406, 0x00002406, 0x00001406, 0x00003406, 0x00000c07, 0x00002c07, 0x00004c07, 0x00006c07, diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index 9b1781cd4..89a33cf8b 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -17,7 +17,7 @@ extern int read_buf (z_stream *strm, Byte *buf, unsigned size); ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { - z_const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); + const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); register unsigned n; register Pos *p; diff --git a/compress.c b/compress.c index c703f244b..d2e8459cb 100644 --- a/compress.c +++ b/compress.c @@ -25,7 +25,7 @@ int ZEXPORT compress2 (Byte *dest, uLong *destLen, const Byte *source, z_stream stream; int err; - stream.next_in = (z_const Byte *)source; + stream.next_in = (const Byte *)source; stream.avail_in = (uInt)sourceLen; stream.next_out = dest; stream.avail_out = (uInt)*destLen; diff --git a/crc32.c b/crc32.c index 775442b8f..338e9dcfe 100644 --- a/crc32.c +++ b/crc32.c @@ -416,10 +416,10 @@ uint32_t ZEXPORT crc32_combine64(uint32_t crc1, uint32_t crc2, z_off64_t len2) #ifdef X86_PCLMULQDQ_CRC #include "arch/x86/x86.h" -extern void ZLIB_INTERNAL crc_fold_init(deflate_state *z_const s); -extern void ZLIB_INTERNAL crc_fold_copy(deflate_state *z_const s, - unsigned char *dst, z_const unsigned char *src, long len); -extern uint32_t ZLIB_INTERNAL crc_fold_512to32(deflate_state *z_const s); +extern void ZLIB_INTERNAL crc_fold_init(deflate_state *const s); +extern void ZLIB_INTERNAL crc_fold_copy(deflate_state *const s, + unsigned char *dst, const unsigned char *src, long len); +extern uint32_t ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s); #endif ZLIB_INTERNAL void crc_reset(deflate_state *const s) diff --git a/deflate.c b/deflate.c index 738ff59ac..fe4995f65 100644 --- a/deflate.c +++ b/deflate.c @@ -169,7 +169,7 @@ local const config configuration_table[10] = { * (except for the last MIN_MATCH-1 bytes of the input file). */ #ifdef X86_SSE4_2_CRC_HASH -local inline Pos insert_string_sse(deflate_state *z_const s, z_const Pos str) +local inline Pos insert_string_sse(deflate_state *const s, const Pos str) { Pos ret; unsigned *ip, val, h = 0; @@ -193,7 +193,7 @@ local inline Pos insert_string_sse(deflate_state *z_const s, z_const Pos str) } #endif -local inline Pos insert_string_c(deflate_state *z_const s, z_const Pos str) +local inline Pos insert_string_c(deflate_state *const s, const Pos str) { Pos ret; @@ -204,7 +204,7 @@ local inline Pos insert_string_c(deflate_state *z_const s, z_const Pos str) return ret; } -local inline Pos insert_string(deflate_state *z_const s, z_const Pos str) +local inline Pos insert_string(deflate_state *const s, const Pos str) { #ifdef X86_SSE4_2_CRC_HASH if (x86_cpu_has_sse42) @@ -216,7 +216,7 @@ local inline Pos insert_string(deflate_state *z_const s, z_const Pos str) #ifndef NOT_TWEAK_COMPILER local inline void -bulk_insert_str(deflate_state *s, Pos startpos, uInt count) { +bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) { uInt idx; for (idx = 0; idx < count; idx++) { insert_string(s, startpos + idx); @@ -358,7 +358,7 @@ int ZEXPORT deflateSetDictionary (z_stream *strm, const Byte *dictionary, uInt uInt str, n; int wrap; unsigned avail; - z_const unsigned char *next; + const unsigned char *next; if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) return Z_STREAM_ERROR; @@ -388,7 +388,7 @@ int ZEXPORT deflateSetDictionary (z_stream *strm, const Byte *dictionary, uInt avail = strm->avail_in; next = strm->next_in; strm->avail_in = dictLength; - strm->next_in = (z_const Byte *)dictionary; + strm->next_in = (const Byte *)dictionary; fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; diff --git a/gzwrite.c b/gzwrite.c index 9ee0de807..5e4b3a14c 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -223,7 +223,7 @@ int ZEXPORT gzwrite(gzFile file, void const *buf, unsigned len) /* directly compress user buffer to file */ strm->avail_in = len; - strm->next_in = (z_const Byte *)buf; + strm->next_in = (const Byte *)buf; state->x.pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; diff --git a/infback.c b/infback.c index 137c41fe6..290e839d6 100644 --- a/infback.c +++ b/infback.c @@ -238,7 +238,7 @@ int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) { struct inflate_state *state; - z_const unsigned char *next; /* next input */ + const unsigned char *next; /* next input */ unsigned char *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ diff --git a/inffast.c b/inffast.c index 3e36746e4..cd56802df 100644 --- a/inffast.c +++ b/inffast.c @@ -77,8 +77,8 @@ void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned start) { /* start: inflate()'s starting value for strm->avail_out */ struct inflate_state *state; - z_const unsigned char *in; /* local strm->next_in */ - z_const unsigned char *last; /* have enough input while in < last */ + const unsigned char *in; /* local strm->next_in */ + const unsigned char *last; /* have enough input while in < last */ unsigned char *out; /* local strm->next_out */ unsigned char *beg; /* inflate()'s initial strm->next_out */ unsigned char *end; /* while out < end, enough space available */ diff --git a/inflate.c b/inflate.c index dcb3c973a..cf3959dc2 100644 --- a/inflate.c +++ b/inflate.c @@ -578,7 +578,7 @@ local int updatewindow(z_stream *strm, const Byte *end, unsigned copy) int ZEXPORT inflate(z_stream *strm, int flush) { struct inflate_state *state; - z_const unsigned char *next; /* next input */ + const unsigned char *next; /* next input */ unsigned char *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ diff --git a/match.c b/match.c index d1c8a185e..d76a5d0a8 100644 --- a/match.c +++ b/match.c @@ -31,10 +31,10 @@ * Standard longest_match * */ -ZLIB_INTERNAL unsigned longest_match(deflate_state *z_const s, IPos cur_match) +ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { - z_const unsigned wmask = s->w_mask; - z_const Pos *prev = s->prev; + const unsigned wmask = s->w_mask; + const Pos *prev = s->prev; unsigned chain_length; IPos limit; @@ -151,10 +151,10 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *z_const s, IPos cur_match) * UNALIGNED_OK longest_match * */ -ZLIB_INTERNAL unsigned longest_match(deflate_state *z_const s, IPos cur_match) +ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { - z_const unsigned wmask = s->w_mask; - z_const Pos *prev = s->prev; + const unsigned wmask = s->w_mask; + const Pos *prev = s->prev; unsigned short scan_start, scan_end; unsigned chain_length; @@ -334,7 +334,7 @@ ZLIB_INTERNAL unsigned longest_match(deflate_state *z_const s, IPos cur_match) * ------------------------------------------------- */ -ZLIB_INTERNAL unsigned longest_match(deflate_state *z_const s, IPos cur_match) +ZLIB_INTERNAL unsigned longest_match(deflate_state *const s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Byte *scan = s->window + s->strstart; /* current string */ diff --git a/test/example.c b/test/example.c index 15bf81050..a448b7e24 100644 --- a/test/example.c +++ b/test/example.c @@ -20,7 +20,7 @@ } \ } -z_const char hello[] = "hello, hello!"; +const char hello[] = "hello, hello!"; /* "hello world" would be more standard, but the repeated "hello" * stresses the compression code better, sorry... */ @@ -172,7 +172,7 @@ void test_deflate(Byte *compr, uLong comprLen) err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.next_out = compr; while (c_stream.total_in != len && c_stream.total_out < comprLen) { @@ -339,7 +339,7 @@ void test_flush(Byte *compr, uLong *comprLen) err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.next_out = compr; c_stream.avail_in = 3; c_stream.avail_out = (uInt)*comprLen; @@ -424,7 +424,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) c_stream.next_out = compr; c_stream.avail_out = (uInt)comprLen; - c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_in = (const unsigned char *)hello; c_stream.avail_in = (uInt)strlen(hello)+1; err = deflate(&c_stream, Z_FINISH); diff --git a/uncompr.c b/uncompr.c index 955507c6b..59d44b22b 100644 --- a/uncompr.c +++ b/uncompr.c @@ -26,7 +26,7 @@ int ZEXPORT uncompress (Byte *dest, uLong *destLen, const Byte *source, uLong so z_stream stream; int err; - stream.next_in = (z_const Byte *)source; + stream.next_in = (const Byte *)source; stream.avail_in = (uInt)sourceLen; stream.next_out = dest; stream.avail_out = (uInt)*destLen; diff --git a/zconf.h.in b/zconf.h.in index 1258b2da4..6612f6d37 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -25,12 +25,6 @@ # endif #endif -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # define MAX_MEM_LEVEL 9 diff --git a/zlib.h b/zlib.h index 1fdc1523e..732c94b7e 100644 --- a/zlib.h +++ b/zlib.h @@ -91,7 +91,7 @@ typedef void (*free_func) (void *opaque, void *address); struct internal_state; typedef struct z_stream_s { - z_const Byte *next_in; /* next input byte */ + const Byte *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total number of input bytes read so far */ @@ -99,7 +99,7 @@ typedef struct z_stream_s { uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ - z_const char *msg; /* last error message, NULL if no error */ + const char *msg; /* last error message, NULL if no error */ struct internal_state *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ @@ -1022,7 +1022,7 @@ ZEXTERN int ZEXPORT inflateBackInit (z_stream *strm, int windowBits, */ typedef unsigned (*in_func) (void *, - z_const unsigned char * *); + const unsigned char * *); typedef int (*out_func) (void *, unsigned char *, unsigned); ZEXTERN int ZEXPORT inflateBack (z_stream *strm, diff --git a/zutil.c b/zutil.c index d38280e2e..d7646481d 100644 --- a/zutil.c +++ b/zutil.c @@ -10,7 +10,7 @@ # include "gzguts.h" #endif -z_const char * const z_errmsg[10] = { +const char * const z_errmsg[10] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ diff --git a/zutil.h b/zutil.h index 0c74b359f..de1aa95ea 100644 --- a/zutil.h +++ b/zutil.h @@ -34,7 +34,7 @@ typedef unsigned char uch; typedef unsigned short ush; typedef unsigned long ulg; -extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]