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

268 Коммитов

Автор SHA1 Сообщение Дата
Sutou Kouhei aff5eaced4 [ruby/fiddle] Add workaround for RubyInstaller for Windows
See comment for details.

https://github.com/ruby/fiddle/commit/0c76f03dc4
2020-11-18 09:05:13 +09:00
Aaron Patterson 307388ea19 [ruby/fiddle] Add a "pinning" reference (#44)
* Add a "pinning" reference

A `Fiddle::Pinned` objects will prevent the objects they point to from
moving.  This is useful in the case where you need to pass a reference
to a C extension that keeps the address in a global and needs the
address to be stable.

For example:

```ruby
class Foo
  A = "hi" # this is an embedded string

  some_c_function A # A might move!
end
```

If `A` moves, then the underlying string buffer may also move.
`Fiddle::Pinned` will prevent the object from moving:

```ruby
class Foo
  A = "hi" # this is an embedded string

  A_pinner = Fiddle::Pinned.new(A) # :nodoc:

  some_c_function A # A can't move because of `Fiddle::Pinned`
end
```

This is a similar strategy to what Graal uses:

  https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/PinnedObject.html#getObject--

* rename global to match exception name

* Introduce generic Fiddle::Error and rearrange error classes

Fiddle::Error is the generic exception base class for Fiddle exceptions.
This commit introduces the class and rearranges Fiddle exceptions to
inherit from it.

https://github.com/ruby/fiddle/commit/ac52d00223
2020-11-18 09:05:13 +09:00
Sutou Kouhei e2dfc0c26b [ruby/fiddle] Add support for specifying types by name as String or Symbol
For example, :voidp equals to Fiddle::TYPE_VOID_P.

https://github.com/ruby/fiddle/commit/3b4de54899
2020-11-18 09:05:13 +09:00
Sutou Kouhei ae7b53546c [ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"
Add rb_fiddle_ prefix to conversion functions.h to keep backward
compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING
and not String src. Use rb_fiddle_value_to_generic() instead.

https://github.com/ruby/fiddle/commit/0ffcaa39e5
2020-11-18 09:05:13 +09:00
卜部昌平 490010084e sed -i '/rmodule.h/d' 2020-08-27 16:42:06 +09:00
卜部昌平 756403d775 sed -i '/r_cast.h/d' 2020-08-27 15:03:36 +09:00
卜部昌平 0da2a3f1fc sed -i '\,2/extern.h,d' 2020-08-27 14:07:49 +09:00
Hiroshi SHIBATA 8fb02b7a97
Update the license for the default gems to dual licenses 2020-08-18 20:26:39 +09:00
Nobuyoshi Nakada 48fb6299c6
[ruby/fiddle] support for very old libffi
Define `Fiddle::TYPE_VARIADIC` only when `ffi_prep_cif_var` is
available, otherwise skip the test for it.
2020-06-28 10:40:31 +09:00
Nobuyoshi Nakada c405a8d37a
[ruby/fiddle] try bundled libffi by default
If no installed libffi found, use bundled libffi unless explicitly
`--disable-bundled-libffi` option is given.
2020-06-28 01:03:21 +09:00
Sutou Kouhei f2bcdc7283
[ruby/fiddle] Support MSWIN (#43)
https://github.com/ruby/fiddle/commit/f16e7ff6e0
2020-06-27 23:54:09 +09:00
Sutou Kouhei 6429b6d973
[ruby/fiddle] Add missing include
https://github.com/ruby/fiddle/commit/4ca61efcd7
2020-06-27 23:54:08 +09:00
Sutou Kouhei ae18220f99
[ruby/fiddle] Add support for variadic arguments
GitHub: fix GH-39

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/6c4cb904dc
2020-06-27 23:54:08 +09:00
Sutou Kouhei 9f740acaf9
[ruby/fiddle] Use meaningful variable name
https://github.com/ruby/fiddle/commit/2cac24b7c8
2020-06-27 23:54:08 +09:00
Sutou Kouhei 50fbd00e76
[ruby/fiddle] Use "do { } while (0)" to ensure requiring ";"
https://github.com/ruby/fiddle/commit/2155ae5979
2020-06-27 23:54:08 +09:00
Nobuyoshi Nakada 4949df498a
[ruby/fiddle] Fixed typos
https://github.com/ruby/fiddle/commit/a09e66adf4
https://github.com/ruby/fiddle/commit/6cab9b45d6
https://github.com/ruby/fiddle/commit/ab72b19bed
2020-06-26 17:05:27 +09:00
Nobuyoshi Nakada 6dbc3a2871
autoconf may not be available 2020-05-27 23:46:55 +09:00
Nobuyoshi Nakada 135c6a4b99
fiddle: need to update configure after updating config tools 2020-05-27 00:30:59 +09:00
Nobuyoshi Nakada 5917fe2303
_GNU_SOURCE is needed for mkostemp on Cygwin 2020-05-26 19:17:47 +09:00
Yusuke Endoh f27e0d90c8 ext/fiddle/fiddle.gemspec: avoid require lib/fiddle/version.rb
It loads `ext/fiddle/lib/fiddle/version.rb`, which causes constant
redefinition warning:

http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200523T153003Z.log.html.gz
```
[ 6317/20193] TestDefaultGems#test_validate_gemspec/home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/ext/fiddle/lib/fiddle/version.rb:2: warning: already initialized constant Fiddle::VERSION
/home/chkbuild/chkbuild/tmp/build/20200523T153003Z/ruby/.ext/common/fiddle/version.rb:2: warning: previous definition of VERSION was here
 = 0.16 s
```

This changeset read the version by manual parsing hack which is also
used in stringio and zlib.
2020-05-24 04:01:20 +09:00
Chris Seaton 3015a7aae7 [ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33)
https://github.com/ruby/fiddle/commit/e59cfd708a
2020-05-23 14:34:07 +09:00
Sutou Kouhei 24b615e82e [ruby/fiddle] Export Fiddle::VERSION
https://github.com/ruby/fiddle/commit/1b93a2d9db
2020-05-23 14:29:16 +09:00
Sutou Kouhei 74a4558c14 [ruby/fiddle] Update file list
https://github.com/ruby/fiddle/commit/b04cb92d7b
2020-05-23 14:29:16 +09:00
Sutou Kouhei d5c0018a9a [ruby/fiddle] Fix a typo
https://github.com/ruby/fiddle/commit/445ca6b501
2020-05-23 14:29:16 +09:00
Sutou Kouhei a0dcdd64c5 [ruby/fiddle] Bump version
https://github.com/ruby/fiddle/commit/f8fb7c4823
2020-05-23 14:29:16 +09:00
Sutou Kouhei 13f64333ea [ruby/fiddle] Add Fiddle::VERSION
https://github.com/ruby/fiddle/commit/9dcf64c096
2020-05-23 14:29:16 +09:00
Sutou Kouhei 5fb7ca33e6 [ruby/fiddle] Add missing spec.extensions
https://github.com/ruby/fiddle/commit/2ce36b1fdc
2020-05-23 14:29:16 +09:00
sinisterchipmunk 77cc13943c [ruby/fiddle] Fix assignment to array within struct (#26)
* Allow access to a struct's underlying memory with `struct[offset, length]`.

https://github.com/ruby/fiddle/commit/24083690a6
2020-05-23 14:29:16 +09:00
sinisterchipmunk 4a835621ce [ruby/fiddle] Make array access override compatible with base class (#25)
* Allow access to a struct's underlying memory with `struct[offset, length]`.

* Make accessing a struct's underlying memory more convenient.

* refactor memory access unit tests for improved clarity


https://github.com/ruby/fiddle/commit/c082c81bb5
2020-05-23 14:29:16 +09:00
sinisterchipmunk aa1d3c7d2c [ruby/fiddle] Initialize memory to 0 when calling Fiddle.malloc(). (#24)
https://github.com/ruby/fiddle/commit/8414239ca3
2020-05-23 14:29:16 +09:00
Yusuke Endoh b68dab8667 ext/fiddle/extconf.rb: Fix the condition of libffi <= 3.1
ver is [3, 1, 0] which is not less then or equal to [3, 1]
2020-05-13 10:57:14 +09:00
Yusuke Endoh 9cfa811b0f Do not try ffi_closure_alloc if libffi is <= 3.1
Maybe due to e1855100e4, CentOS, RHEL, and
Fedora CIs have started failing with SEGV.  Try to avoid
ffi_closure_alloc on those environments.

https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200512T183004Z.fail.html.gz
https://rubyci.org/logs/rubyci.s3.amazonaws.com/fedora32/ruby-master/log/20200512T183004Z.fail.html.gz
https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20200512T183003Z.fail.html.gz
2020-05-13 08:42:48 +09:00
Yusuke Endoh e1855100e4 ext/fiddle/extconf.rb: check if ffi_closure_alloc is available
to define HAVE_FFI_CLOSURE_ALLOC.
The macro is used in closure.c, so have_func check is needed.

If pkg-config is not installed, extconf.rb fails to detect the version
of libffi, and does not add "-DUSE_FFI_CLOSURE_ALLOC=1" even when system
libffi version is >= 3.2.

If USE_FFI_CLOSURE_ALLOC is not defined, closure.c attempts to check if
HAVE_FFI_CLOSURE_ALLOC is defined or not, but have_func was removed with
528a3a1797, so the macro is always not
defined.

This resulted in this deprecation warning:

https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200512T123003Z.log.html.gz
```
compiling closure.c
closure.c: In function 'initialize':
closure.c:265:5: warning: 'ffi_prep_closure' is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
  265 |     result = ffi_prep_closure(pcl, cif, callback, (void *)self);
      |     ^~~~~~
In file included from ./fiddle.h:42,
                 from closure.c:1:
/usr/include/x86_64-linux-gnu/ffi.h:334:1: note: declared here
  334 | ffi_prep_closure (ffi_closure*,
      | ^~~~~~~~~~~~~~~~
```
2020-05-13 01:17:30 +09:00
Nobuyoshi Nakada 317fdd6df2 fiddle: share the same config tools 2020-05-12 15:57:47 +09:00
Nobuyoshi Nakada d1748484e8 extlibs.rb: added variable references
Reduce duplicate parts such as package name and version numbers.
2020-05-12 15:57:47 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada 318be1cb2f
Show libffi version only if set 2020-03-21 16:38:29 +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
Hiroshi SHIBATA 47a1872cd8
Use osuosl instead of GitHub releases
Because the package provided by GitHub releases is different from sourceware.
2020-03-07 20:45:09 +09:00
Hiroshi SHIBATA 8602216746
Switch to download libffi source package to github releases from sourceware.org 2020-03-07 19:57:28 +09:00
Nobuyoshi Nakada e4a9e926f0
Fixed a typo 2020-03-05 13:31:25 +09:00
Nobuyoshi Nakada 261569d4aa
[ruby/fiddle] always use ffi_closure_alloc on Windows 2020-03-05 11:31:08 +09:00
Nobuyoshi Nakada 528a3a1797
[ruby/fiddle] use ffi_closure_alloc only with 3.2 or later 2020-03-04 23:19:35 +09:00
Nobuyoshi Nakada 95f387f61a
[ruby/fiddle] ffi_closure_free is available in the bundled libffi 2020-03-04 18:41:47 +09: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
Kazuhiro NISHIYAMA c90fc55a1f Drop executable bit of *.{yml,h,mk.tmpl} 2020-01-22 16:04:38 +09:00
Nobuyoshi Nakada e1b2341488
Update dependencies 2019-11-18 23:16:22 +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
Jeremy Evans b809784817 [ruby/fiddle] Remove taint support (#21)
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.
https://github.com/ruby/fiddle/commit/18d6fb6915
2019-10-24 19:34:49 +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
Aaron Patterson 7733db665a [ruby/fiddle] Fiddle::Function must maintain a reference to the closure
If the first parameter to Fiddle::Function is a closure object (rather
than an interger), `rb_Integer` will cast it to an integer but not
maintain a reference to the closure.  Then if the closure gets GC'd, we
have a segv.  This commit keeps a reference to the original parameter to
initialize so that the object will not be GC'd.

Fixes: https://bugs.ruby-lang.org/issues/13286

https://github.com/ruby/fiddle/commit/0fc697bbc5
2019-10-24 19:34:15 +09:00
Nobuyoshi Nakada 715955ff27
Include ruby/assert.h in ruby/ruby.h so that assertions can be there 2019-07-14 17:58:03 +09:00
nobu 3d1c86a26f Removed moving toplevel header since r12501
Moving public headers was 12-years ago, no depend files would
expect ruby.h in the top source directory now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-08 02:46:22 +00:00
tadd b640b21d9c fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 07:40:45 +00:00
hsbt d303a2c45a Merge fiddle from github repository.
* ext/fiddle/extconf.rb: It supports to build libffi with standalone gem.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 07:27:18 +00:00
svn 50281e8ca3 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10 04:24:11 +00:00
ko1 228fc417ce revisit `RARRAY_PTR()`.
* ext/fiddle/function.c (initialize): use RARRAY_AREF() instead of
  using RARRAY_PTR().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10 04:24:10 +00:00
nobu eb02a846a4 fiddle/import.rb: suppress warning
* ext/fiddle/lib/fiddle/import.rb: suppress exception report when
  $DEBUG is enabled.  [ruby-core:86536] [Bug #14686]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19 23:35:39 +00:00
normal 604a96d9de ext/fiddle/lib/fiddle/pack.rb: pack "void *" properly on 32-bit
Fixes: r62450 (commit 1aaeeb326e)
       ("long long is a C99ism")

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-18 00:38:35 +00:00
shyouhei 1aaeeb326e long long is a C99ism
so SIZEOF_LONG_LONG is not always available.
We have to check its defined?-ness before using.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-17 09:51:23 +00:00
shyouhei 28d0fee9f6 add casts (cosmetic; just be explicit)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16 08:49:09 +00:00
nobu c8094ff154 no ID cache in Init functions
Init functions are called only once, cache is useless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16 08:39:48 +00:00
hsbt 9ef078e2a7 Bump fiddle-1.0.0 for released version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 08:35:13 +00:00
hsbt 7d2e5fb979 Added explicitly require to example code.
https://github.com/ruby/ruby/pull/1666

  Patch by @guilherme [fix GH-1666]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:55:22 +00:00
hsbt eccbd8c0ef Fixup r59961. Use http for libffi downloading.
A few environments couldn't handle https download.
    * https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20170919T032511Z.fail.html.gz
    * https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20170919T040500Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 05:01:02 +00:00
hsbt e9f5265bd7 Use https instead of ftp for libffi downloading.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 02:25:16 +00: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
hsbt 0a907a3792 Make string literal to frozen object on gemspec of defulte gems.
Added following gemspecs.

    * extensions: date, dbm, etc, fiddle, gdbm, sdbm, stringio, strscan, zlib
    * pure ruby libraries: cmath, csv, fileutils, scanf, webrick

  psych and rdoc is out of scope of this commit. I will merge after
  upstream was change to `frozen_string_literal: true`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-19 13:03:06 +00:00
nobu 966bfb07f6 Add sha512
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-22 00:27:14 +00:00
hsbt 4389ba641f Added initial gemspec for ruby/fiddle.
[Feature #13403][ruby-core:80577]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-05 11:04:25 +00:00
shyouhei 20c72dc89d ruby tool/update-deps --fix
Onigumo 6 (r57045) introduced new onigumo.h header file, which is
required from quite much everywhere.  This commit adds necessary
dependencies.

Note: ruby/oniguruma.h now includes onigumo.h,
      ruby/io.h includes oniguruma.h,
      ruby/encoding.h also includes oniguruma.h,
      and internal.h includes encoding.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22 06:00:18 +00:00
nobu 0da70829f1 fiddle/depend: build-libffi
* ext/fiddle/depend (build-libffi): get rid of making $(LIBFFI_A)
  a sole target, which may be empty when installed libffi is
  found.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-11 10:33:05 +00:00
nobu 35533d0346 fiddle: fix $(SUBMAKE_PRE)
* ext/fiddle/extconf.rb: fix $(SUBMAKE_PRE) to chdir to
  $(LIBFFI_DIR) instead of $(@D), since $(LIBFFI_A) is not
  underneath libffi but under .libs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-10 04:24:08 +00:00
nobu 3c06d3a6bd fiddle: jobserver for libffi
* ext/fiddle/depend (libffi): use $(MAKE) explicitly for recursive
  make, so that jobserver works.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-09 12:08:56 +00:00
nobu 64fea27496 Update dependencies
* common.mk (compile.o, loadpath.o): update dependencies.

* common.mk (vm_call.o): remove stale object dependencies.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-06 05:48:13 +00:00
nobu bf6a8134f8 fiddle/import.rb: suppress warnings
* ext/fiddle/lib/fiddle/import.rb (type_alias, handler): suppress
  "not initialized instance variable" warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11 04:28:16 +00:00
nagachika 79c7a51893 * ext/fiddle/handle.c: check tainted string arguments.
Patch provided by tenderlove and nobu.

* test/fiddle/test_handle.rb (class TestHandle): add test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 12:08:49 +00:00
naruse c4fdfabcc8 handle ext/ as r53141
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts
fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&#
frozen_string_literal: false\n");f.rewind;f.write s}}'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:31:54 +00:00
nobu 4977af3c3d function.c: fix typo
* ext/fiddle/function.c (initialize): fix typo "ary" to "args",
  and adjust type of variables to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13 10:57:51 +00:00
usa de577357e8 * ext/fiddle/function.c: fix build error introduced at r53082.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13 10:25:01 +00:00
nobu bcc2421b49 function.c: check arguments
* ext/fiddle/function.c (initialize): check all arguments first.
  reported by Marcin 'Icewall' Noga of Cisco Talos.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13 09:35:58 +00:00
nobu 34a0df159b conversions.h: PTR2NUM
* ext/fiddle/conversions.h (PTR2NUM): use signed integer to make
  Fixnum for negative values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13 09:35:10 +00:00
normal a26d09da85 NEWS: add note about Fiddle GVL release
* NEWS: note Fiddle GVL release [Feature #11607]
* ext/fiddle/function.c (Init_fiddle_function): document above, too

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11 07:43:09 +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
nobu 52912db4a8 ext: adjust index type
* ext: use long for index instead of int and RARRAY_LENINT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 07:18:01 +00:00
nobu 898fd2ed2a use rb_check_arity [ci skip]
* ext: use rb_check_arity and rb_error_arity to raise
  ArgumentError.  [Feature #9025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-25 00:43:06 +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 07900180ec fiddle: $LOCAL_LIBS needs to be expanded
* ext/fiddle/extconf.rb: revert part of r51401 and expand
  $LOCAL_LIBS as it will be extracted and copied to exts.mk.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 07:53:12 +00:00
nobu 7d8ac59131 fiddle: clean dot dir
* ext/fiddle/depend (distclean-libffi): clean dot directory too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-27 03:46:07 +00:00
nobu 50a585ed25 fiddle: unexpand LIBFFI_DIR
* ext/fiddle/extconf.rb: use LIBFFI_DIR instead of expanding it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-27 03:45:11 +00:00
hsbt 5d6ca9e950 * include/ruby/ruby.h: $SAFE=2 is now obsolete.
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c
  gc.c, io.c, process.c, safe.c, signal.c, win32/file.c:
  removed code for $SAFE=2
* test/erb/test_erb.rb, test/fiddle/test_handle.rb
  test/ruby/test_env.rb: removed tests for $SAFE=2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18 14:21:03 +00:00
akr 606274b55d * ext/fiddle/depend: Fix "Wrong mix of special targets" error with
OpenBSD make.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 00:10:52 +00:00
nobu dc8d595461 libff: fix enable-shared condition
* ext/fiddle/extconf.rb: needs --enable-shared when linked to
  libruby or fiddle.so.  since --with-static-linked-ext does no
  longer link extensions to ruby program with --enable-shared, the
  only combination needs --enable-static is --disable-shared and
  --with-static-linked-ext.  [ruby-dev:48901] [Bug #10960]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13 02:37:49 +00:00