summaryrefslogtreecommitdiff
path: root/ext/ffi_c/FunctionInfo.c
Commit message (Collapse)AuthorAgeFilesLines
* Freeze immutable objects and add explicit make_shareable to make library ↵Lars Kanis2023-05-071-0/+2
| | | | | | | | | | | | | | | | | | | 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-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.
* Add support for using FFI in RactorLars Kanis2023-04-181-1/+1
| | | | | | | | 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.
* Make FFI classes GC.compact friendlyLars Kanis2023-04-141-4/+22
| | | | | | This allows to relocate all FFI objects. Also remove marking of StructLayout->cache_row in favour of clearing it at GC.compact only.
* Increment callbackCount outside of the macro RB_OBJ_WRITELars Kanis2023-03-061-1/+2
| | | | .. to ensure it is called exactly once.
* Implement Write Barrier and dsize for FFI::FunctionTypeJean Boussier2023-03-061-15/+35
| | | | | | | | | | | 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.
* Convert FFI::Type and descendants to TypedDataJean Boussier2023-03-021-10/+23
| | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* Remove win32/stdint.h and stdbool.hLars Kanis2020-09-231-6/+2
| | | | | | | | Only very old Visual-C compilers before 2010 didn't contain these files. Since the copyright of the included files conflicts with ffi's license, we better remove it. Fixes #693
* Reject callback with :string return typeLars Kanis2020-05-241-2/+1
| | | | | | | | | | | | Callbacks returning a :string type were not supported so far and did not work. It was possible to define such a callback, but the value returned was NULL in any case. This implementation rejects :string return type of callbacks at the definition. The reason for the reject is the following: In contrast to :string parameters to called functions there is no well defined ownership of the memory of the string returned by callbacks. Instead an explicit FFI::MemoryPointer or similar should be used, which allows to track the validity of underlying memory instead of relying on some Ruby implementation details. Fixes #751
* Revert "Do closures via libffi"Lars Kanis2018-06-031-0/+4
| | | | | | | | | | | | This reverts commit 9f257af19e6088c2986f85dea17455e52a2be405. This is due to issues with callback in combination with fork() on Centos. See https://github.com/ffi/ffi/issues/621 . It is caused by specialized handling of callback allocation on SE-Linux protected systems through ffi_closure_alloc(), which is incompatible to fork(). Reverting this now, pending more investigation, how we can solve callback allocation in a way that is compatible to both PaX and SE-Linux.
* Do closures via libffiMihail Konev2017-07-131-4/+0
| | | | | | | | | | | | This removes ClosurePool. It has been switching pages protection between writable and executable, which was making it incompatible with PaX MPROTECT. libffi instead leaves its closures (closure trampolines) non-executable, relying on PaX to recognize and emulate them, which allows it to work even under such circumstances. Remove CUSTOM_TRAMPOLINE and USE_RAW to avoid ifdef hassle.
* Fix stdcall ABI call convention.Lars Kanis2013-11-101-2/+2
| | | | | FFI_STDCALL is no define, so stdcall was never used. This fixes issue #302 and adds a test case for stdcall callbacks..
* Fix bad search and replace in C code.1.9.2Charles Oliver Nutter2013-10-291-31/+1
|
* Switch license to BSD throughout codebase. See #288.Charles Oliver Nutter2013-10-291-12/+22
|
* Licensing audit. Restore BSD license text from files where it was ↵Wayne Meissner2013-10-271-0/+30
| | | | mistakenly removed, and add it to those that had contributions under that license.
* Extract all win32 MSC stdbool compat typedefs into win32/stdbool.hWayne Meissner2013-04-221-6/+6
|
* Check for the presence of FFI_STDCALL - some arches do not have it definedWayne Meissner2013-03-051-1/+1
|
* Remove rbffi_gc_mark_locations()Wayne Meissner2013-01-081-1/+1
|
* Add rbffi_gc_mark_locations() that behaves like rb_gc_mark_locations(), for ↵Wayne Meissner2012-12-291-1/+1
| | | | VMs that do not have it.
* Merge remote-tracking branch 'upstream/master'Sylvain Daubert2012-12-081-0/+8
|\ | | | | | | | | | | Conflicts: ext/ffi_c/MemoryPointer.c lib/ffi/struct.rb
| * initial releaseunknown2012-01-091-0/+8
| |
* | Add documentation (mainly for Struct and its decendants).Sylvain Daubert2011-10-021-2/+27
|/
* Add documentation for ArrayType, Buffer, DynamicLibrary, Function, Enum, EnumsSylvain Daubert2011-09-251-0/+9
| | | | and ConstGenerator.
* Add documentation for DataConverter, LastError, AutoPointer, FFI::IO, ↵Sylvain Daubert2011-09-211-0/+3
| | | | Library, Platform and FFI class methods from types.rb.
* Fix warningsWayne Meissner2011-08-011-1/+1
|
* Fix up call convention determination for win321.0.4Wayne Meissner2010-12-281-21/+16
|
* Fix calling convention issues on windowsAndrea Fazzi2009-10-041-1/+2
| | | | Fix libtest compilation issues on windows
* Use ClosurePool to speed up callback allocationWayne Meissner2009-09-181-0/+4
|
* Implement FFI bypass for 0,1,2,3 int arg/return functionsWayne Meissner2009-09-151-0/+3
|
* Add result_type and param_types method to FunctionTypeWayne Meissner2009-08-111-0/+22
|
* Rename FunctionInfo to FunctionTypeWayne Meissner2009-08-071-19/+22
|
* Remove size and alignment fields from FFI::Type, as they are provided by ↵Wayne Meissner2009-08-051-2/+0
| | | | ffi_type
* Start adding low level support needed for struct return and param support.Wayne Meissner2009-08-051-0/+10
|
* Add blocking functionsWayne Meissner2009-08-021-1/+3
|
* Remove unused includes and cleanup fninfo_free()Wayne Meissner2009-08-011-22/+31
|
* Fix 1.9.1 cross compileWayne Meissner2009-07-271-1/+0
|
* Handle callback parameter types, :enums and :convention optionsWayne Meissner2009-07-241-4/+35
|
* Replace CallbackInfo with FunctionInfoWayne Meissner2009-07-241-1/+3
|
* Store a copy of the parameter Type array in a ruby arrayWayne Meissner2009-07-241-7/+3
|
* Add FunctionInfo that will eventually replace CallbackInfoWayne Meissner2009-07-241-0/+141