Граф коммитов

49 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada bbd5b8ddae
[ruby/fiddle] Ractor support
(https://github.com/ruby/fiddle/pull/139)

https://github.com/ruby/fiddle/commit/91d0ea9849

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-10-16 11:24:25 +09:00
Aaron Patterson 0e1182f93c [ruby/fiddle] Remove Vim commands
(https://github.com/ruby/fiddle/pull/140)

Some of these commands just don't work (for example `sws` is not a Vim
setting). I think we should just remove these.

https://github.com/ruby/fiddle/commit/c3dbf7ba9a
2024-06-20 15:16:57 +09:00
Sutou Kouhei c19ea1066a [ruby/fiddle] Include stdbool.h explicitly for old Ruby
https://github.com/ruby/fiddle/commit/74a05fb358
2023-11-08 09:25:45 +09:00
Sutou Kouhei 2a6d6d3d65 [ruby/fiddle] Use Ruby's true/false for C bool
GitHub: fix https://github.com/ruby/fiddle/pull/130

Reported by Benoit Daloze. Thanks!!!

https://github.com/ruby/fiddle/commit/2640e0148e
2023-11-08 09:25:44 +09:00
Jean byroot Boussier f1313caec1 [ruby/fiddle] Mark Closure, Function and Handle as write barrier
protected
(https://github.com/ruby/fiddle/pull/129)

They don't have a mark function, so they don't need any change.

https://github.com/ruby/fiddle/commit/9bbc732aef

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-06-28 16:36:53 +09:00
Aaron Patterson dffca50bb6 [ruby/fiddle] Free closures immediately
(https://github.com/ruby/fiddle/pull/109)

These structs don't need to be freed as part of finalization, so lets
free them immediately.

https://github.com/ruby/fiddle/commit/8a10ec1152
2022-10-18 17:21:45 +09:00
Nobuyoshi Nakada 091e3522d7 fiddle: use the old rb_ary_tmp_new() alias
Fiddle is a gem and has the external upstream which supports older
versions of Ruby.
2022-10-18 17:21:45 +09:00
Sutou Kouhei ada9f8a9f7 [ruby/fiddle] closure: follow variable name change
GitHub: GH-102

https://github.com/ruby/fiddle/commit/2530496602
2022-10-07 15:18:54 +09:00
Sutou Kouhei a4ad6bd9aa [ruby/fiddle] closure: free resources when an exception is raised in Closure.new
GitHub: GH-102

https://github.com/ruby/fiddle/commit/81a8a56239
2022-10-07 15:18:53 +09:00
Sutou Kouhei 255e617bc3 [ruby/fiddle] Add Fiddle::Closure.create and Fiddle::Closure.free
GitHub: fix GH-102

It's for freeing a closure explicitly.

We can't use Fiddle::Closure before we fork the process. If we do it,
the process may be crashed with SELinux.

See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091
for details.

Reported by Vít Ondruch. Thanks!!!

https://github.com/ruby/fiddle/commit/a0ccc6bb1b
2022-10-07 15:18:51 +09:00
Aaron Patterson 48a6498406 [ruby/fiddle] Add constants for unsigned values (https://github.com/ruby/fiddle/pull/111)
This commit adds constants for unsigned values. Currently we can use `-`
to mean "unsigned", but I think having a specific name makes Fiddle more
user friendly. This commit continues to support `-`, but introduces
negative constants with "unsigned" names

I think this will help to eliminate [this
code](3a56bf0bcc/lib/mjit/c_type.rb (L31-L38))

https://github.com/ruby/fiddle/commit/2bef0f1082

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07 15:18:49 +09:00
Peter Zhu efb91ff19b Rename rb_ary_tmp_new to rb_ary_hidden_new
rb_ary_tmp_new suggests that the array is temporary in some way, but
that's not true, it just creates an array that's hidden and not on the
transient heap. This commit renames it to rb_ary_hidden_new.
2022-07-26 09:12:09 -04:00
Sutou Kouhei 881b2dc898 [ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62

Reported by Cody Krieger. Thanks!!!

https://github.com/ruby/fiddle/commit/284b820f2d
2021-05-18 12:48:40 +09:00
Sutou Kouhei b2de5999d8 [ruby/fiddle] closure: accept symbol as type
https://github.com/ruby/fiddle/commit/dc2da6633e
2021-05-18 12:48:40 +09:00
Jeremy Evans 040cfc89b9 Do not set USE_FFI_CLOSURE_ALLOC=1 in fiddle on OpenBSD
On OpenBSD, USE_FFI_CLOSURE_ALLOC was always set to 0 previously. In
633a1f15d8, the code was modified in a
way that it ended up being set to 1 on OpenBSD.  However, that results
in SIGABRT when running make test-all, inside ffi_closure_free.
Setting USE_FFI_CLOSURE_ALLOC back to 0 fixes the issue.
2020-03-08 17:47:48 -07:00
Nobuyoshi Nakada 633a1f15d8
[ruby/fiddle] Use ffi_closure_free if available 2020-03-04 18:14:18 +09:00
Yusuke Endoh d732bc51bd Revert "Revert "Revert "[ruby/fiddle] Use ffi_closure_free by default. (#20)"""
This reverts commit 87f6154bb4.

It turned out that the change fails to build on macOS

https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20200304T074503Z.fail.html.gz
```
+ make 'TESTS=--hide-skip -v fiddle' RUBYOPT=-w test-all
dyld: lazy symbol binding failed: Symbol not found: _ffi_closure_alloc
  Referenced from: /Users/hsbt/Documents/cb/tmp/build/20200304T074503Z/ruby/.ext/x86_64-darwin18/fiddle.bundle
  Expected in: flat namespace

dyld: Symbol not found: _ffi_closure_alloc
  Referenced from: /Users/hsbt/Documents/cb/tmp/build/20200304T074503Z/ruby/.ext/x86_64-darwin18/fiddle.bundle
  Expected in: flat namespace

make: *** [yes-test-all] Abort trap: 6
```
2020-03-04 17:28:21 +09:00
Yusuke Endoh 87f6154bb4 Revert "Revert "[ruby/fiddle] Use ffi_closure_free by default. (#20)""
This reverts commit efd641ffab.

This changeset seems to be needed to suppress a warning on Ubuntu 20.04
https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20200304T033004Z.log.html.gz
```
closure.c:264:5: warning: 'ffi_prep_closure' is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
  264 |     result = ffi_prep_closure(pcl, cif, callback, (void *)self);
      |     ^~~~~~
```

I guess there was a reason why the commit was reverted (maybe some CIs
failed?), so try it again.
2020-03-04 15:46:26 +09:00
Hiroshi SHIBATA efd641ffab Revert "[ruby/fiddle] Use ffi_closure_free by default. (#20)"
This reverts commit ce6caade7c.
2019-10-24 20:58:32 +09:00
Vít Ondruch ce6caade7c [ruby/fiddle] Use ffi_closure_free by default. (#20)
* Use ffi_closure_free unconditionally.

The current conditionals reflect historic heritage of FFI. Usage of
ffi_closure_free should be better default nowadays, because libffi 3.0.5
fixing issues of ffi_closure_free should be widely available.

* RUBY_LIBFFI_MODVERSION is not used anymore.

Because `ffi_closure_free()` is not used unconditionally, there is no
other use for RUBY_LIBFFI_MODVERSION define, so drop its usage.

* Use more meaningful variable name.

`ver` variable used to be used to pupulate RUBY_LIBFFI_MODVERSION
define. Since the define was removed, the `libffi_dir` variable name
should better describe the remaining usage of the variable.

https://github.com/ruby/fiddle/commit/c49cc79eb8
2019-10-24 19:34:43 +09:00
hsbt 7f24b0aabd Merge fiddle-1.0.0.beta2 from upstream.
* ext/fiddle/closure.c: use directly declaration for standalone gem
    without internal.h.
  * Specify frozen string literal is true.
  * Update gemspec configuration for release version.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-12 11:52:23 +00:00
ko1 dff42b0ea0 * ext/**/*.c (*_memsize): same as r52986 for extensions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 01:01:17 +00:00
normal 15476c695d fiddle: release GVL for ffi_call
Some external functions I wish to call may take a long time
and unnecessarily block other threads.  This may lead to performance
regressions for fast functions as releasing/acquiring the GVL is not
cheap, but can improve performance for long-running functions
in multi-threaded applications.

This also means we must reacquire the GVL when calling Ruby-defined
callbacks for Fiddle::Closure, meaning we must detect whether the
current thread has the GVL by exporting ruby_thread_has_gvl_p
in internal.h

* ext/fiddle/function.c (struct nogvl_ffi_call_args):
  new struct for GVL release
  (nogvl_ffi_call): new function
  (function_call): adjust for GVL release
  [ruby-core:71642] [Feature #11607]
* ext/fiddle/closure.c (struct callback_args):
  new struct for GVL acquire
  (with_gvl_callback): adjusted original callback function
  (callback): wrapper for conditional GVL acquire
* ext/fiddle/depend: add dependencies
* ext/fiddle/extconf.rb: include top_srcdir for internal.h
* internal.h (ruby_thread_has_gvl_p): expose for fiddle
* vm_core.h (ruby_thread_has_gvl_p): moved to internal.h
* test/fiddle/test_function.rb (test_nogvl_poll): new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23 21:20:56 +00:00
nobu 57e2877e7b ext: use RARRAY_AREF
* ext/**/*.c: prefer RARRAY_AREF to indexing RARRAY_CONST_PTR.
  pointed out by hanmac.
  https://github.com/ruby/ruby/commit/3553a86#commitcomment-14187670

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-05 01:09:17 +00:00
nobu 3553a86eb5 ext: use RARRAY_CONST_PTR
* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore
  reference instead of RARRAY_PTR, to keep the array WB-protected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 07:27:10 +00:00
normal cfa2f95476 ext/fiddle/closure.c (callback): static function
The `callback' function is not used outside of closure.c and
should not be able to cause namespace conflicts in compilers
without visibility pragmas.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-19 20:56:08 +00:00
nobu 28b9f11d5a protoize no-arguments functions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 05:25:32 +00:00
mame 995d330779 * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value.
[ruby-core:57599] [Bug #8978].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-29 23:27:14 +00:00
tenderlove 2ee916752c * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value.
[ruby-core:57599] [Bug #8978].  Thanks mame!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 18:53:23 +00:00
naruse cddd37aae2 * ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): define 0 on
Mac OS X and Linux [Bug #3371]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-11 07:10:39 +00:00
naruse c0e0a684d7 * ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): add missing case:
RUBY_LIBFFI_MODVERSION is not defined (usually on Windows).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-11 01:40:11 +00:00
naruse a0f7f29215 * ext/fiddle/extconf.rb: define RUBY_LIBFFI_MODVERSION macro.
* ext/fiddle/closure.c (USE_FFI_CLOSURE_ALLOC): define 0 or 1
  with platform and libffi's version. [Bug #3371]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-10 21:15:37 +00:00
naruse 2570f838da * ext/fiddle/closure.c (initialize): check mprotect's return value.
If mprotect is failed because of PaX or something, its function call
  will cause SEGV.
  http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130401T210301Z.diff.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-10 18:35:21 +00:00
ngoto 97de2b36e9 * ext/fiddle/closure.c (Fiddle::Closure.new): fix typo in documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-07 04:39:39 +00:00
nagachika 7b6e26ae14 * ext/fiddle/closure.c: cosmetic fix for rdoc comment. (fix for r37917)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 14:55:41 +00:00
zzak 4ed6a88b74 * ext/fiddle/closure.c: Documentation for Fiddle
* ext/fiddle/lib/fiddle/import.rb: ditto
* ext/fiddle/lib/fiddle/value.rb: ditto
* ext/fiddle/lib/fiddle/pack.rb: ditto
* ext/fiddle/lib/fiddle/cparser.rb: ditto
* ext/fiddle/lib/fiddle/struct.rb: ditto
* ext/fiddle/lib/fiddle/function.rb: ditto



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 02:08:39 +00:00
zzak 9c831edbf4 * ext/fiddle/closure.c: Documentation for Fiddle
* ext/fiddle/pointer.c: ditto
* ext/fiddle/function.c: ditto
* ext/fiddle/lib/fiddle.rb: ditto
* ext/fiddle/fiddle.c: ditto
* ext/fiddle/handle.c: ditto



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 23:26:07 +00:00
nobu 34be46a32e * ext/fiddle/closure.c (callback): deal with unsinged integers.
[ruby-core:42458][Bug #5991][Bug #6022]
* ext/fiddle/conversions.c (value_to_generic, generic_to_value):
  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 10:57:05 +00:00
nobu fa65df0d08 * ext/fiddle/closure.c (callback): same as r34506.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 10:52:31 +00:00
akr 3d25acdccc * io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: use
__linux__ macro for consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15 11:09:47 +00:00
drbrain 87ff4b24ae * ext/.document (fiddle): Remove duplicate entry
* ext/fiddle:  Complete documentation of Fiddle.  Patch by Vincent
  Batts.  [#5192]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-15 23:48:59 +00:00
ngoto 4d71d34855 * ext/fiddle/conversions.c (generic_to_value): ffi_arg and ffi_sarg
should be used to handle shorter return value. fix [Bug #3861]
  [ruby-core:32504]
* ext/fiddle/closure.c (callback): ditto
* ext/fiddle/conversions.h (fiddle_generic): ditto
* ext/fiddle/conversions.c (value_to_generic): char, short and int
  are strictly distinguished on big-endian CPU, e.g. sparc64.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-09 05:31:47 +00:00
nagachika 60053a0a50 * ext/fiddle/closure.c (callback): use rb_ary_tmp_new() instead of
xmalloc() to allocate an array for arguments of callback procedure,
  to prevent arguments from being swept by GC. [ruby-core:38546]
  [Bug #4929]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-28 14:47:51 +00:00
nobu 6b48289bb7 * ext/fiddle/closure.c (fiddle_closure): embed cif not reference
so that the content surely get initialized.  [ruby-dev:42480]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-30 00:08:30 +00:00
tenderlove 204f8d6820 * ext/fiddle/closure.c : Don't use FFI closure alloc on OpenBSD.
Thanks Jeremy Evans! [ruby-core:32384]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-14 17:15:30 +00:00
nobu 6de2f601af * ext/fiddle/closure.c (closure_data_type),
ext/fiddle/function.c (function_data_type): rb_data_type_t has
  changed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-20 09:23:08 +00:00
naruse 7eec027f06 * ext/fiddle/closure.c (dealloc): refix workaround r28300.
don't use ffi_closure_alloc, ffi_prep_closure_loc and
  ffi_closure_free on MACOSX and __linux__.
  [ruby-dev:41483] [ruby-dev:41214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-13 19:06:25 +00:00
naruse 5422161026 * ext/fiddle/closure.c (dealloc): workaround fix for libffi's
ffi_closure_free. [ruby-dev:41483] [ruby-dev:41214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-12 15:28:40 +00:00
tenderlove 4bada8b864 * ext/fiddle/*: Adding fiddle library to wrap libffi
* test/fiddle/*: testing fiddle extension
* ext/dl/lib/dl.rb: Requiring fiddle if it is available
* ext/dl/lib/dl/callback.rb: using Fiddle if it is available
* ext/dl/lib/dl/func.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-06 06:59:24 +00:00