Skip to content

Commit 1ce6625

Browse files
committed
Use z_size_t version functions
1 parent 486153f commit 1ce6625

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

ext/zlib/extconf.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@
121121
$defs << "-DHAVE_CRC32_COMBINE"
122122
$defs << "-DHAVE_ADLER32_COMBINE"
123123
$defs << "-DHAVE_TYPE_Z_CRC_T"
124+
$defs << "-DHAVE_TYPE_Z_SIZE_T"
124125
else
125126
have_func('crc32_combine', 'zlib.h')
126127
have_func('adler32_combine', 'zlib.h')
127128
have_type('z_crc_t', 'zlib.h')
129+
have_type('z_size_t', 'zlib.h')
128130
end
129131

130132
create_makefile('zlib') {|conf|

ext/zlib/zlib.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
#endif
4545
#endif
4646

47+
#if defined(HAVE_TYPE_Z_SIZE_T)
48+
typedef uLong (*checksum_func)(uLong, const Bytef*, z_size_t);
49+
# define crc32 crc32_z
50+
# define adler32 adler32_z
51+
#else
52+
typedef uLong (*checksum_func)(uLong, const Bytef*, uInt);
53+
#endif
54+
4755
#if SIZEOF_LONG > SIZEOF_INT
4856
static inline uInt
4957
max_uint(long n)
@@ -65,7 +73,7 @@ static ID id_dictionaries, id_read, id_buffer;
6573

6674
static NORETURN(void raise_zlib_error(int, const char*));
6775
static VALUE rb_zlib_version(VALUE);
68-
static VALUE do_checksum(int, VALUE*, uLong (*)(uLong, const Bytef*, uInt));
76+
static VALUE do_checksum(int, VALUE*, checksum_func);
6977
static VALUE rb_zlib_adler32(int, VALUE*, VALUE);
7078
static VALUE rb_zlib_crc32(int, VALUE*, VALUE);
7179
static VALUE rb_zlib_crc_table(VALUE);
@@ -380,7 +388,7 @@ rb_zlib_version(VALUE klass)
380388
# define mask32(x) (x)
381389
#endif
382390

383-
#if SIZEOF_LONG > SIZEOF_INT
391+
#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_TYPE_Z_SIZE_T)
384392
static uLong
385393
checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *ptr, long len)
386394
{
@@ -399,7 +407,7 @@ checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *
399407
#endif
400408

401409
static VALUE
402-
do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
410+
do_checksum(int argc, VALUE *argv, checksum_func func)
403411
{
404412
VALUE str, vsum;
405413
unsigned long sum;

0 commit comments

Comments
 (0)