summaryrefslogtreecommitdiff
path: root/ext/ffi_c/compat.h
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-04-16 20:40:17 +0200
committerLars Kanis <lars@greiz-reinsdorf.de>2023-04-18 11:27:14 +0200
commit5247d3e736f77ce19bbb3e69cf5186fa5a7084f4 (patch)
tree9675fed8212b9ca4ffbe0929112be10bdd1c5919 /ext/ffi_c/compat.h
parent250c31a25d81339cfe928a433ada3c0f17eae580 (diff)
downloadffi-5247d3e736f77ce19bbb3e69cf5186fa5a7084f4.tar.gz
Add support for using FFI in Ractor
All objects are shareable now when frozen. All objects can be created in a non-main Ractor. Typedefs are a global mutable state and are not accessable from Ractor other than the main Ractor. So all Function, Struct, etc. must be defined in the main Ractor and can then be used in other Ractors.
Diffstat (limited to 'ext/ffi_c/compat.h')
-rw-r--r--ext/ffi_c/compat.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/ffi_c/compat.h b/ext/ffi_c/compat.h
index 889a4be..a8fdcbe 100644
--- a/ext/ffi_c/compat.h
+++ b/ext/ffi_c/compat.h
@@ -79,6 +79,8 @@
# define RB_GC_GUARD(x) (x)
#endif
+
+/* For compatibility with ruby < 2.7 */
#ifdef HAVE_RB_GC_MARK_MOVABLE
#define ffi_compact_callback(x) .dcompact = (x),
#define ffi_gc_location(x) x = rb_gc_location(x)
@@ -88,4 +90,13 @@
#define ffi_gc_location(x)
#endif
+
+/* For compatibility with ruby < 3.0 */
+#ifndef RUBY_TYPED_FROZEN_SHAREABLE
+#define FFI_RUBY_TYPED_FROZEN_SHAREABLE 0
+#else
+#define FFI_RUBY_TYPED_FROZEN_SHAREABLE RUBY_TYPED_FROZEN_SHAREABLE
+#endif
+
+
#endif /* RBFFI_COMPAT_H */