From 0b2178e5ae4ac448c9a50bdb369bc6059a02d915 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 5 Feb 2026 12:30:52 -0800 Subject: [PATCH] feat: support compilation with TruffleRuby --- .github/workflows/memcheck.yml | 2 +- ext/numo/narray/narray.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/memcheck.yml b/.github/workflows/memcheck.yml index 54ae8cf2..bb694ffe 100644 --- a/.github/workflows/memcheck.yml +++ b/.github/workflows/memcheck.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: Install valgrind - run: sudo apt-get install valgrind + run: sudo apt-get update && sudo apt-get install valgrind - name: Set up Ruby 3.4 uses: ruby/setup-ruby@v1 with: diff --git a/ext/numo/narray/narray.c b/ext/numo/narray/narray.c index 4115ece1..268cd0b8 100644 --- a/ext/numo/narray/narray.c +++ b/ext/numo/narray/narray.c @@ -7,6 +7,14 @@ #include #include +#ifndef RBASIC_FLAGS +#define RBASIC_FLAGS(obj) (RBASIC(obj)->flags) +#endif + +#ifndef RBASIC_SET_FLAGS +#define RBASIC_SET_FLAGS(obj, flags_to_set) (RBASIC(obj)->flags = (flags_to_set)) +#endif + /* global variables within this module */ VALUE numo_cNArray; VALUE rb_mNumo; @@ -852,8 +860,10 @@ void na_copy_flags(VALUE src, VALUE dst) { na2->flag[0] = na1->flag[0]; // na2->flag[1] = NA_FL1_INIT; - RBASIC(dst)->flags |= (RBASIC(src)->flags) & (FL_USER1 | FL_USER2 | FL_USER3 | FL_USER4 | - FL_USER5 | FL_USER6 | FL_USER7); + RBASIC_SET_FLAGS( + dst, RBASIC_FLAGS(dst) | (RBASIC_FLAGS(src) & (FL_USER1 | FL_USER2 | FL_USER3 | FL_USER4 | + FL_USER5 | FL_USER6 | FL_USER7)) + ); } // fix name, ex, allow_stride_for_flatten_view