From 9121588ae9bcd076a444f8ef15070e8e4706f42f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 7 Nov 2026 13:27:52 +0900 Subject: [PATCH 1/3] Use `rb_len_t` for crc32 conversions --- ext/zlib/zlib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index e279bb9..03546de 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -17,7 +17,9 @@ typedef long rb_len_t; typedef unsigned long rb_ulen_t; # define SIZEOF_RB_LEN_T SIZEOF_LONG # define LEN2NUM LONG2NUM +# define ULEN2NUM ULONG2NUM # define NUM2LEN NUM2LONG +# define NUM2ULEN NUM2ULONG # define PRIdLEN "ld" #endif @@ -532,8 +534,8 @@ rb_zlib_crc32(int argc, VALUE *argv, VALUE klass) static VALUE rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2) { - return ULONG2NUM( - crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2LONG(len2))); + return ULEN2NUM( + crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2ULEN(len2))); } #else #define rb_zlib_crc32_combine rb_f_notimplement From 20762479608057c89c2d66fe1c334ee5e4e73211 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 10 Nov 2026 18:45:27 +0900 Subject: [PATCH 2/3] Split the conditions for each definition of the `rb_len_t` macro Since the update to the Windows binaries used by `setup-ruby` has stalled at an incomplete stage, temporarily split the conditions. --- ext/zlib/zlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 03546de..a2f1397 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -15,11 +15,23 @@ #ifndef HAVE_RB_LEN_T typedef long rb_len_t; typedef unsigned long rb_ulen_t; +#endif +#ifndef SIZEOF_RB_LEN_T # define SIZEOF_RB_LEN_T SIZEOF_LONG +#endif +#ifndef LEN2NUM # define LEN2NUM LONG2NUM +#endif +#ifndef ULEN2NUM # define ULEN2NUM ULONG2NUM +#endif +#ifndef NUM2LEN # define NUM2LEN NUM2LONG +#endif +#ifndef NUM2LEN # define NUM2ULEN NUM2ULONG +#endif +#ifndef PRIdLEN # define PRIdLEN "ld" #endif From 7c655b391b07d7d5e6ba009bd6641ddb4d246fad Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 18 Nov 2026 05:28:51 +0900 Subject: [PATCH 3/3] Fix the guard for the `NUM2ULEN` fallback It tested `NUM2LEN`, which is defined just above, so `NUM2ULEN` was left undefined on Ruby without `rb_len_t`. Co-Authored-By: Claude Opus 5.5 --- ext/zlib/zlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index a2f1397..5dcc7cf 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -28,7 +28,7 @@ typedef unsigned long rb_ulen_t; #ifndef NUM2LEN # define NUM2LEN NUM2LONG #endif -#ifndef NUM2LEN +#ifndef NUM2ULEN # define NUM2ULEN NUM2ULONG #endif #ifndef PRIdLEN