Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/zstdruby/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "mkmf"

have_func('rb_gc_mark_movable')

$CFLAGS = '-I. -O3 -std=c99 -DZSTD_STATIC_LINKING_ONLY'
$CPPFLAGS += " -fdeclspec" if CONFIG['CXX'] =~ /clang/

Expand Down
26 changes: 23 additions & 3 deletions ext/zstdruby/streaming_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ static void
streaming_compress_mark(void *p)
{
struct streaming_compress_t *sc = p;
#ifdef HAVE_RB_GC_MARK_MOVABLE
rb_gc_mark_movable(sc->buf);
#else
rb_gc_mark(sc->buf);
#endif
}

static void
Expand All @@ -31,10 +35,26 @@ streaming_compress_memsize(const void *p)
return sizeof(struct streaming_compress_t);
}

#ifdef HAVE_RB_GC_MARK_MOVABLE
static size_t
streaming_compress_compact(void *p)
{
struct streaming_compress_t *sc = p;
sc->buf = rb_gc_location(sc->buf);
}
#endif

static const rb_data_type_t streaming_compress_type = {
"streaming_compress",
{ streaming_compress_mark, streaming_compress_free, streaming_compress_memsize, },
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
"streaming_compress",
{
streaming_compress_mark,
streaming_compress_free,
streaming_compress_memsize,
#ifdef HAVE_RB_GC_MARK_MOVABLE
streaming_compress_compact,
#endif
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};

static VALUE
Expand Down
26 changes: 23 additions & 3 deletions ext/zstdruby/streaming_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ static void
streaming_decompress_mark(void *p)
{
struct streaming_decompress_t *sd = p;
#ifdef HAVE_RB_GC_MARK_MOVABLE
rb_gc_mark_movable(sd->buf);
#else
rb_gc_mark(sd->buf);
#endif
}

static void
Expand All @@ -30,10 +34,26 @@ streaming_decompress_memsize(const void *p)
return sizeof(struct streaming_decompress_t);
}

#ifdef HAVE_RB_GC_MARK_MOVABLE
static size_t
streaming_decompress_compact(void *p)
{
struct streaming_decompress_t *sd = p;
sd->buf = rb_gc_location(sd->buf);
}
#endif

static const rb_data_type_t streaming_decompress_type = {
"streaming_decompress",
{ streaming_decompress_mark, streaming_decompress_free, streaming_decompress_memsize, },
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
"streaming_decompress",
{
streaming_decompress_mark,
streaming_decompress_free,
streaming_decompress_memsize,
#ifdef HAVE_RB_GC_MARK_MOVABLE
streaming_decompress_compact,
#endif
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};

static VALUE
Expand Down