summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #963 from ioquatix/library-pathHEADmasterLars Kanis2023-05-081-10/+49
|\ | | | | 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-241-10/+49
| |
* | Merge branch 'ractor'Lars Kanis2023-05-0811-36/+232
|\ \
| * | Register functions in Ruby codeLars Kanis2023-05-083-1/+20
| | | | | | | | | | | | 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-075-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | Rename result_type to return_typeLars Kanis2023-04-271-2/+2
| | | | | | | | | | | | | | | 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-272-20/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-274-12/+79
| | |
| * | Ensure some relevant constants are available in RactorLars Kanis2023-04-203-15/+17
| | |
| * | 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-181-1/+10
| | |
| * | Freeze global typedefs and add per Ractor local custom typedefsLars Kanis2023-04-181-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | Add support for using FFI in RactorLars Kanis2023-04-184-1/+46
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Allow private release method for ManagedStruct and AutoPointerLars Kanis2023-05-022-21/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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 #1017 from thesamesam/hppaLars Kanis2023-04-202-0/+356
|\ \ \ | |/ / |/| | 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
| | |
* | | Add types.conf for sw_64-linuxlixin2023-04-111-0/+141
|/ /
* | Implement Write Barrier and dsize for FFI::StructLayoutJean Boussier2023-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::StructLayout::Field Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. I had to get rid of the `memset(0)` in `struct_layout_mark` has with Write Barriers it's not guaranteed that the layout will be marked before `fieldName` is moved. I don't think it was a good fix anyway, it's better to mark these VALUE so the GC pin them. I think we could go back to an `st_table` and mark only the keys with `rb_mark_set`. But I didn't want to go down this rabbit hole.
* | Check the pointer in AutoPointer before superLars Kanis2023-01-131-2/+2
| | | | | | | | It makes no sense to initialize the base class with a potentially invalid pointer.
* | Merge pull request #957 from matoro/masterLars Kanis2022-12-111-0/+0
|\ \ | | | | | | Rename sparc64-linux -> sparcv9-linux
| * | Rename sparc64-linux -> sparcv9-linuxmatoro2022-05-251-0/+0
| |/ | | | | | | | | | | | | | | In https://github.com/ffi/ffi/pull/575, 64-bit sparc was changed to also use sparcv9 as the platform name, but the types.conf directory was never renamed. This breaks only on Ruby 3.0 and later due to the fileutils change to use keyword arguments in https://github.com/ruby/fileutils/commit/482de6d397742526d1111576e2791f9b7051e3c0
* | Merge pull request #968 from eregon/refactor-library-lookupLars Kanis2022-12-112-54/+94
|\ \ | | | | | | Refactor library lookup
| * | Simplify errors to an arrayBenoit Daloze2022-07-171-7/+4
| | | | | | | | | | | | | | | * The keys are not used, and the paths are typically already part of the error message. * Makes it possible to just use a recursive call instead of retry.
| * | Refactor library lookupBenoit Daloze2022-07-172-54/+97
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Try every prefix, not just the first one where the file exists. The first existing file might be for the wrong architecture or have other issues and cannot be loaded. * Show which directories were searched in error message. * Only consider /opt/homebrew/lib on darwin-aarch64. * Only rescue LoadError and RuntimeError, not Exception. * Refactor in smaller functions to improve readability. * Fixes #880. * Example error message: Could not open library 'notexist': notexist: cannot open shared object file: No such file or directory. (LoadError) Could not open library 'libnotexist.so': libnotexist.so: cannot open shared object file: No such file or directory. Searched in <system library path>, /usr/lib, /usr/local/lib, /opt/local/lib
* | Fix typo in data_converter.rbIkko Ashimine2022-07-071-2/+2
|/ | | overriden -> overridden
* Merge pull request #943 from daaitudian/masterLars Kanis2022-04-211-0/+141
|\ | | | | Add types.conf for loongarch64-linux
| * Add types.conf for loongarch64-linuxwangluwei2022-03-031-0/+141
| |
* | Fix an issue with signed bitmasks when using flags on the most significant bit.Brice Videau2022-04-121-1/+10
| |
* | Simplify from_native and test corner case.Brice Videau2022-04-121-5/+3
| |
* | Remove unneeded affectations.Brice Videau2022-04-121-4/+4
| |
* | Fix typo.Brice Videau2022-04-121-1/+1
|/
* Bump VERSION to 1.15.5Lars Kanis2022-01-101-1/+1
|
* prevent usage same binary file simultaneouslymaierru2022-01-041-4/+5
|
* Bump VERSION to 1.15.4 and add CHANGELOG entryv1.15.4Lars Kanis2021-09-011-1/+1
|
* Correct module lookup when including ffi-moduleDaniel Evans2021-08-141-1/+1
|
* Bump VERSION to 1.15.4.pre1Lars Kanis2021-07-091-1/+1
|
* Lower the JRuby version guard to 9.2.20Lars Kanis2021-07-091-1/+1
| | | | | FFI improvments will probably backported to 9.2 branch. See https://github.com/jruby/jruby/pull/6747#issuecomment-876610443
* Bump VERSION to 1.15.3v1.15.3Lars Kanis2021-06-161-1/+1
|
* Bump VERSION to 1.15.2Lars Kanis2021-06-161-1/+1
|
* Fix Windows libc detection for MSYS2-ucrt build (#903)Lars Kanis2021-06-151-5/+2
| | | | | | | Take the same approach for detection as used in fiddle: https://github.com/ruby/ruby/blob/79717f81f8ba24960cca6c934d00c72db64139ed/test/fiddle/helper.rb#L55-L56 And use "_time" function on all Windows UCRT platforms.
* Regen types.conf for FreeBSD12 aarch64MikaelUrankar2021-06-101-58/+111
|
* Switch time_t and suseconds_t types to long on FreeBSD aarch64MikaelUrankar2021-06-102-4/+4
| | | | Same as https://github.com/ffi/ffi/pull/627
* Merge pull request #882 from OleMchls/patch-1tduehr2021-06-021-1/+1
|\ | | | | dynlib support for homebrew 3 on Apple Silicon M1
| * dynlib support for homebrew 3 on Apple Silicon M1Ole Michaelis2021-02-121-1/+1
| | | | | | As the homebrew team discussed in https://github.com/Homebrew/brew/issues/9177 the new library path for homebrew on apple silicon is `/opt/homebrew/lib`. Alongside the PR to support MacPorts https://github.com/ffi/ffi/pull/638 this commits adds support for the new homebrew path.
* | Bump VERSION to 1.15.1v1.15.1Lars Kanis2021-05-221-1/+1
| |
* | Allow overriding `gcc` with the `CC` env var in `const_generator.rb` and ↵Alexey Zagarin2021-04-152-2/+4
| | | | | | | | `struct_generator.rb`
* | Revert "Enable loading FFI gem on rubinius"Lars Kanis2021-04-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 195e12f3ee52a8f5620fd8286c2b94737b6b4fc2. Removing constants is contrary to expectation. It was introduced to replace Rubinius internal FFI in favor of the gem. We no longer test on Rubinius and Rubinius seems to be dead. So we can remove this line. Fixes 896
* | Prepare ffi-1.15.0Lars Kanis2021-03-051-1/+1
| |