summaryrefslogtreecommitdiff
path: root/spec
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #963 from ioquatix/library-pathHEADmasterLars Kanis2023-05-081-0/+9
|\ | | | | 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-0/+9
| |
* | Merge branch 'ractor'Lars Kanis2023-05-0817-35/+434
|\ \
| * | Exclude JRuby and Truffleruby at retrieval of function typesLars Kanis2023-05-083-0/+9
| | | | | | | | | | | | ..until necessary native methods are added.
| * | Register functions in Ruby codeLars Kanis2023-05-082-2/+2
| | | | | | | | | | | | For consistency and to ease proting to JRuby and Truffleruby.
| * | Freeze immutable objects and add explicit make_shareable to make library ↵Lars Kanis2023-05-078-32/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-271-6/+4
| | | | | | | | | | | | 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-273-3/+3
| | | | | | | | | | | | | | | 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-273-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+50
| | |
| * | Ensure some relevant constants are available in RactorLars Kanis2023-04-202-0/+26
| | |
| * | 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.
| * | Fix compat to JRuby and TuffleRuby regarding RactorLars Kanis2023-04-182-0/+6
| | |
| * | Freeze global typedefs and add per Ractor local custom typedefsLars Kanis2023-04-181-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-181-0/+8
| | | | | | | | | | | | No need to share per thread data object accross ractors.
| * | Use a Ractor-local callback dispatcher for calls from non-ruby threadsLars Kanis2023-04-181-0/+23
| | | | | | | | | | | | | | | 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-185-5/+110
| | | | | | | | | | | | | | | | | | | | | | | | 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-023-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | 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 tests to verify that GC.compact worksLars Kanis2023-04-201-0/+66
|/ /
* | Add a spec that adds one Function to several modulesLars Kanis2023-04-161-0/+10
| | | | | | | | It was not yet tested.
* | Merge pull request #1010 from casperisfine/pointer-write-barrierLars Kanis2023-03-063-0/+26
|\ \ | | | | | | Implement Write Barrier and dsize for FFI::Pointer
| * | Implement Write Barrier and dsize for FFI::PointerJean Boussier2023-03-063-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As well as FFI::MemoryPointer and FFI::AbstractMemory 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.
* | | Merge branch 'struct-layout-write-barrier' of ↵Lars Kanis2023-03-061-1/+33
|\ \ \ | |/ / |/| | | | | https://github.com/casperisfine/ffi into casperisfine-struct-layout-write-barrier
| * | Implement Write Barrier and dsize for FFI::StructLayoutJean Boussier2023-03-061-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #1007 from casperisfine/struct-write-barrierLars Kanis2023-03-061-0/+13
|\ \ \ | | | | | | | | Implement Write Barrier and dsize for FFI::Struct
| * | | Implement Write Barrier and dsize for FFI::StructJean Boussier2023-03-061-0/+13
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::Struct::InlineArray. 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.
* | | Merge pull request #1005 from casperisfine/type-write-barrierLars Kanis2023-03-061-0/+43
|\ \ \ | | | | | | | | Implement Write Barrier and dsize for FFI::Type
| * | | Implement Write Barrier and dsize for FFI::TypeJean Boussier2023-03-061-0/+43
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 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. While I was at it I removed the `strdup` of `BuiltinType.name`, I don't see why we wouldn't directly point at static memory, that saves copying type names, and makes freeing builtin types easier.
* | | Merge pull request #1004 from casperisfine/symbol-write-barrierLars Kanis2023-03-061-0/+17
|\ \ \ | | | | | | | | Implement Write Barrier and dsize for FFI::DynamicLibrary
| * | | Implement Write Barrier and dsize for FFI::DynamicLibraryJean Boussier2023-03-061-0/+17
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::DynamicLibrary::Symbol Ref: https://github.com/ffi/ffi/pull/991 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. It's not counting everything because some types are opaque right now, so a larger refactoring would be needed. While I was at it, I moved `Symbol.library` into the unused `Symbol.base.rbParent` which seemed appropriate and saves a pointer.
* | | Implement Write Barrier and dsize for FFI::FunctionJean Boussier2023-03-061-0/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 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. It's not counting everything because some types are opaque right now, so a larger refactoring would be needed.
* | Implement Write Barrier and dsize for FFI::FunctionTypeJean Boussier2023-03-062-0/+28
| | | | | | | | | | | | | | | | | | | | | | 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.
* | reenable last error specPavel Rosický2022-12-151-1/+0
| |
* | Skip spec failing on JRuby on WindowsBenoit Daloze2022-12-121-0/+1
| | | | | | See https://github.com/jruby/jruby/issues/7521
* | Skip spec of linker script emulation on MacosLars Kanis2022-12-121-1/+1
| | | | | | | | | | | | | | It fails in Macos-12, since that version raises a different error message than Macos-11. On the other hand, linker script emulation seems not to be in use on Macos at all, since Macos uses .dylib file extansion rather than .so. Fixes #981
* | Merge pull request #957 from matoro/masterLars Kanis2022-12-111-0/+2
|\ \ | | | | | | Rename sparc64-linux -> sparcv9-linux
| * | Also normalize sparc64 -> sparcv9 in test fixturematoro2022-06-131-0/+2
| |/
* | Exclude 64bit integer test on jruby tooFrederick Cheung2022-06-291-1/+1
| |
* | exclude spec from trufflerubyFrederick Cheung2022-06-291-1/+1
| | | | | | | | This isn't yet supported by truffleruby
* | Fix Pointer#initialize using NUM2LL instead of NUM2ULLFrederick Cheung2022-06-291-0/+8
|/ | | | | | | | | If the high bit of the address was set this would raise RangeError (bignum too big to convert into long long). This is not uncommon on platforms that use the high bits of pointers for purposes such as pointer authentication This also now matches Pointer#address which uses ULL2NUM.
* Merge pull request #949 from Kerilk/bitmask_fixLars Kanis2022-04-212-0/+91
|\ | | | | Bitmask improvement
| * Skip problematic test involving TruffleRuby.Brice Videau2022-04-131-1/+1
| |
| * Fix an issue with signed bitmasks when using flags on the most significant bit.Brice Videau2022-04-122-0/+74
| |
| * Simplify from_native and test corner case.Brice Videau2022-04-121-0/+17
| |