summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #963 from ioquatix/library-pathHEADmasterLars Kanis2023-05-082-10/+58
|\ | | | | Add support for passing ABI version to `FFI.map_library_name`.
| * Add support for passing ABI version to `FFI.map_library_name`.Samuel Williams2022-06-242-10/+58
| |
* | Merge branch 'ractor'Lars Kanis2023-05-0849-174/+975
|\ \
| * | Exclude JRuby and Truffleruby at retrieval of function typesLars Kanis2023-05-083-0/+9
| | | | | | | | | | | | ..until necessary native methods are added.
| * | Add Ractor compatibility to READMELars Kanis2023-05-081-1/+2
| | |
| * | Register functions in Ruby codeLars Kanis2023-05-086-15/+22
| | | | | | | | | | | | For consistency and to ease proting to JRuby and Truffleruby.
| * | Add documentation to new query methodsLars Kanis2023-05-073-0/+26
| | | | | | | | | | | | of commit e987ab50366a4b08617a20568eabdaa1fb761317
| * | Freeze immutable objects and add explicit make_shareable to make library ↵Lars Kanis2023-05-0721-61/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | definitions Ractor usable Freeze objects which are immutable from the start are now freezed. This allows these objects to be used by Ractor without make_shareable. This partially reverts commit 4fc6a8c5ec8a9a720330946af9d1103015c62942 in such a way, that functions are stored in a module variable @ffi_functions. Enums are implemented per FFI::Library not per attached function. To make them shareable they would have to be copied and freezed per function. This would increase memory footprint for the sake of Ractor support. IMHO it's better to mark the module explicit as finished by .freeze to allow its use in a Ractor. This also enables querying the enum definitions from a Ractor. Using a Hash instead of per-function variables allow to use foo! and bar? methods as wished in #971. Fixes #971
| * | Ensure enums are usable in RactorLars Kanis2023-05-022-0/+27
| | |
| * | Bump required ruby version to 2.5Lars Kanis2023-04-273-10/+6
| | | | | | | | | | | | And remove support for older rubies.
| * | Do not run any Ractor specs on ruby-3.0Lars Kanis2023-04-272-5/+1
| | | | | | | | | | | | | | | Shareable instance variables on modules are essential for most Ractor specs. They were introduced in ruby-3.1.
| * | Rename result_type to return_typeLars Kanis2023-04-276-10/+10
| | | | | | | | | | | | | | | The term "return_type" is already used in Truffleruby and sounds better to me. On the other hand the term "result_type" was only used in C-ffi as FunctionInfo#result_type, which is an internal class only.
| * | Store each FFI::Function in it's own instance variabe in the module to be ↵Lars Kanis2023-04-278-31/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attached This allows to freeze the FFI::Function immediately, so that it is shareable by Ractor without the need to freeze the module explicit. To make it shareable the typedef hash used for variadic functions is duplicated and made frozen. This creates a small compatibility issue: Only typedefs defined above the variadic function can be used by that function. If a typedef is created after the definition of the variadic function, then this typedef can no longer be used as parameter to that variadic function. Also fix the retrieval of simple (non-struct) global variables per #attached_variables. Closes #975
| * | Add the possibility to query attached funtions and variablesLars Kanis2023-04-2711-16/+166
| | |
| * | Ensure some relevant constants are available in RactorLars Kanis2023-04-205-15/+43
| | |
| * | Add a spec file for FFI::DynamicLibraryLars Kanis2023-04-203-18/+57
| | | | | | | | | | | | .. and test Ractor compatibility there.
| * | Skip struct specs on Ruby-3.0Lars Kanis2023-04-181-1/+5
| | | | | | | | | | | | It is incompatible to our usage of instance variables by the Struct class.
| * | Freeze constant in StructLayoutBuilderLars Kanis2023-04-181-2/+2
| | | | | | | | | | | | since there's no need to modify it later on
| * | Fix compat to JRuby and TuffleRuby regarding RactorLars Kanis2023-04-183-1/+16
| | |
| * | Freeze global typedefs and add per Ractor local custom typedefsLars Kanis2023-04-183-5/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ractor-local custom typedefs are used now, since global writable typedefs aren't compatible with Ractor isolation. Now the builtin typedefs are frozen and available for all Ractors. But all custom typedefs are only per Ractor. Actually the global typedefs already were useable in Ractors, if they are resolved in C code. This is because the C code doesn't check the Ractor boundaries.
| * | Ensure errno is usable in RactorLars Kanis2023-04-182-1/+9
| | | | | | | | | | | | No need to share per thread data object accross ractors.
| * | Use a Ractor-local callback dispatcher for calls from non-ruby threadsLars Kanis2023-04-182-64/+171
| | | | | | | | | | | | | | | The callback is now routet to the Ractor, that created the FFI::Function . Within this Ractor a new ruby thread is created to execute the Proc, like before.
| * | Add support for using FFI in RactorLars Kanis2023-04-1826-27/+216
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #1031 from larskanis/rm-structfield-getLars Kanis2023-05-042-11/+2
|\ \ \ | | | | | | | | Remove no longer used StructField.get and .put
| * | | Remove no longer used StructField.get and .putLars Kanis2023-05-042-11/+2
|/ / / | | | | | | | | | | | | It was introduced in commit 9d68c7f87ad7c869ee1ce3139269525af70e5df4 but moved to ruby code in commit 3f96bbb61b2f17ba9761a1d02745101a60cd26e1 . These fields are a leftover from the commit.
* | | Merge pull request #1029 from larskanis/private-releaseLars Kanis2023-05-046-27/+18
|\ \ \ | | | | | | | | Allow private release method for ManagedStruct and AutoPointer
| * | | Allow private release method for ManagedStruct and AutoPointerLars Kanis2023-05-026-27/+18
|/ / / | | | | | | | | | | | | | | | | | | | | | FFI users might not want to expose `release` as a public class method, but want to keep it private. Also re-enable GC tests that were disabled as part of #427, but make them opt-in per env var FFI_TEST_GC. Derivations of Releaser are no longer necessary, so that they are removed now.
* | | Merge pull request #1028 from cfis/masterLars Kanis2023-04-203-8/+10
|\ \ \ | | | | | | | | MSVC Test Support
| * | | MSVC does not include <sys/param.h>Charlie Savage2023-04-201-0/+2
| | | |
| * | | Visual Studio 22 does not compile va_arg that are function pointers. ↵Charlie Savage2023-04-201-6/+6
| | | | | | | | | | | | | | | | Instead, the function pointers must be a typdef. For what its worth, see https://stackoverflow.com/a/37114318.
| * | | CreateNamedPipe and CreateFile map to CreateNamedPipeW and CreateFileW when ↵Charlie Savage2023-04-201-2/+2
|/ / / | | | | | | | | | compiling with MSVC 22. These apis take a widechar - LPCWSTR. Thus these tests fail because Windows considers the pipe names to be invalid. Thus switch to the Ansi versions.
* | | Add some build file to gitignoreLars Kanis2023-04-201-5/+8
| | |
* | | Add some tests to verify that GC.compact worksLars Kanis2023-04-201-0/+66
| | |
* | | Merge pull request #1017 from thesamesam/hppaLars Kanis2023-04-203-0/+357
|\ \ \ | | | | | | | | Use libffi closure allocations on hppa
| * | | Add types.conf for hppa1.1-linuxSam James2023-04-121-0/+178
| | | |
| * | | Add types.conf for hppa2.0-linuxSam James2023-04-121-0/+178
| | | |
| * | | Use libffi closure allocations on hppaSam James2023-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | We currently do this for Apple arm64, but we need to do it for hppa too. The test suite passes for both ffi and dependent gems with this. Previously they would segfault.
* | | | Merge pull request #1027 from cfis/masterLars Kanis2023-04-201-0/+3
|\ \ \ \ | | | | | | | | | | Free Allocated Buffer
| * | | | Free the message allocated by FormatMessageA (should have been in last commit).Charlie Savage2023-04-201-0/+3
|/ / / /
* | | | Merge pull request #1026 from cfis/masterLars Kanis2023-04-201-2/+10
|\ \ \ \ | | | | | | | | | | Windows - Update LoadLibrary Error Message to include Error Code
| * | | | On Windows FormatMessageA can return a NULL message - for example when ↵Charlie Savage2023-04-191-2/+10
|/ / / / | | | | | | | | | | | | | | | | | | | | trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message full of garbage characters which makes it impossible to know what the problem is. This commit updates the message so that it at least returns the error code (in this case 193) which makes it possible to debug the problem.
* | | | Merge pull request #1025 from peterzhu2118/pz-rarray-ptrLars Kanis2023-04-192-2/+2
|\ \ \ \ | | | | | | | | | | Remove use of RARRAY_PTR
| * | | | Remove use of RARRAY_PTRPeter Zhu2023-04-182-2/+2
| | |/ / | |/| | | | | | | | | | | | | | RARRAY_PTR is bad for GC performance as it exposes the internal buffer of the array meaning that the array becomes write barrier unprotected.
* | | | Merge pull request #1024 from peterzhu2118/pz-old-compatLars Kanis2023-04-191-23/+0
|\ \ \ \ | |/ / / |/| | | Remove old definitions in compat.h for Ruby 1.x
| * | | Remove old definitions in compat.h for Ruby 1.xPeter Zhu2023-04-181-23/+0
|/ / / | | | | | | | | | | | | These definitions all exist in all recent versions of Ruby, so it's dead code that we can remove.
* | | Merge branch 'remove-sizetypes'Lars Kanis2023-04-181-16/+13
|\ \ \
| * | | Remove unused FFI::SizeTypesLars Kanis2023-04-181-16/+13
| | | | | | | | | | | | | | | | It is not used in C or Ruby code.
* | | | Merge pull request #1018 from F16shen/masterLars Kanis2023-04-171-0/+141
|\ \ \ \ | |/ / / |/| | | Add types.conf for sw_64-linux
| * | | Add types.conf for sw_64-linuxlixin2023-04-111-0/+141
| |/ /
* | | Add a spec that adds one Function to several modulesLars Kanis2023-04-161-0/+10
| | | | | | | | | | | | It was not yet tested.