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

138 Коммитов

Автор SHA1 Сообщение Дата
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
nobu 22c750bb8d libffi: workaround of VC12 ml
* ext/fiddle/win32/libffi.mk.tmpl: assemble without directory prefix.
  workaround of a bug of VC12 ml, by unak at [ruby-core:67792].
  [ruby-core:67789] [Bug #10780]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-24 15:42:27 +00:00
nobu 8cfce15387 fiddle: --disable-bundled-libffi
* ext/fiddle/extconf.rb: disable bundled libffi if explicitly
  disabled by --disable-bundled-libffi.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-17 10:52:17 +00:00
nobu 24b6863f79 fiddle: check assembler
* ext/fiddle/extconf.rb: requires assembler for src/win{32,64}.S.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-11 03:54:45 +00:00
nobu 463856a7c4 fiddle: fix for old VC
* ext/fiddle/win32/libffi-3.2.1-mswin.patch (include/ffi.h.in):
  old version VCs did not support long long, use __int64 instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-11 03:54:35 +00:00
nobu 544651a2fb cparser.rb: limit word number
* ext/fiddle/lib/fiddle/cparser.rb (parse_ctype): limit split word
  number as the rest are not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 09:53:30 +00:00
hsbt 1ba6e8868c * ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import with
type_alias
* test/fiddle/test_cparser.rb: added type_alias test for parse_ctype
  and parse_struct_signature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 09:23:43 +00:00
svn f661c0be44 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 00:54:40 +00:00
hsbt 3afd0f9a91 * ext/fiddle/lib/fiddle/cparser.rb: Support for Fiddle::CParser
to handle rich signatures including parameter names and function
  pointer types. Patch by @theryan [fix GH-590]
* test/fiddle/test_cparser.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 00:54:37 +00:00
nobu 5cc1e95be3 fiddle: append libffi config.log
* ext/fiddle/extconf.rb: copy config.log of libffi when failed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-30 06:13:33 +00:00
nobu e0c64486ad libffi.mk.tmpl: fix STATICLIB
* ext/fiddle/win32/libffi.mk.tmpl (STATICLIB): fix static library
  name.  [ruby-core:67128]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 15:02:12 +00:00
nobu a9f70432d4 extconf.rb: libffi PIC objects
* ext/fiddle/extconf.rb: make PIC objects if it will be linked as
  a shared object eventually.  [ruby-core:67128]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 12:58:18 +00:00
usa 990a0bb897 * ext/fiddle/win32/libffi-3.2.1-mswin.patch: support mswin32.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 10:01:41 +00:00
nobu 0a841035df fiddle: depend rules
* ext/fiddle/depend: mark PHONY targets, and workaround of
  unexpected DEPEND_RULES on mswin.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 06:58:34 +00:00
nobu 0cd829c339 fiddle: win32/libffi-config.rb
* ext/fiddle/win32/libffi-config.rb: generate necessary files to
  build on mswin.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 02:29:56 +00:00
usa a54aae45a6 * ext/fiddle/extconf.rb: remove ffitarget.h generated by configure on
mswin, because it's not normal file (cygwin's symlink) and have
  system attribute.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 00:36:42 +00:00
nobu 840fa8086e fiddle: extlibs
* ext/fiddle/extlibs: libffi-3.2.1 and patch for mswin.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 13:39:13 +00:00
nobu 132415bf9e extconf.rb: no empty CPP
* ext/fiddle/extconf.rb: pass CPP only if necessary, should not
  make it empty.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 13:07:39 +00:00
nobu 5b6fc3f006 extmk.rb: replace current directory name
* ext/extmk.rb (extmake): replace "./" at beginning in LOCAL_LIBS
  with the current directory name for values cached in previous
  Makefile.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 13:05:47 +00:00
nobu b9ffe579da fiddle: use RMALL
* ext/fiddle/depend (realclean-libffi): use RMALL instead of
  RMDIRS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 11:57:11 +00:00
nobu 276065f870 fiddle: clean-libffi
* ext/fiddle/depend (clean-libffi): clean libffi directory.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 11:33:54 +00:00
nobu 4c0a560cac extconf.rb: try modversion ff pkg_config succeeded
* ext/fiddle/extconf.rb: when pkg_config failed, module version is
  not available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 06:22:00 +00:00
nobu b2c4e778ba extconf.rb: libffi on mswin
* ext/fiddle/extconf.rb: try to compile libffi as mingw on mswin
  if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 06:21:49 +00:00
nobu 458cffce1a extconf.rb: libffi with libruby
* ext/fiddle/extconf.rb: link libffi with libruby for symbols
  provided by ruby on some platforms, e.g. alloca.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-22 03:42:13 +00:00
nobu 055ae0c859 extconf.rb: configure libffi first
* ext/fiddle/extconf.rb: configure libffi for the check requires
  the headers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-22 03:17:36 +00:00
nobu 80036df9e3 fiddle: modversion may be unavailable
* ext/fiddle/extconf.rb: modversion may be unavailable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-21 08:12:18 +00:00
nobu 0c8b964ef7 fiddle: do not disturb other checks
* ext/fiddle/extconf.rb: add the local ffi library and header just
  before create_makefile, not to disturb other checks.
  also prepend the extension path name to the local library name
  for static linked ext.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-21 07:15:04 +00:00
nobu bade6e467e handle.c: suppress warnings
* ext/fiddle/handle.c (CHECK_DLERROR): suppress warnings for using
  the result of an assignment as a condition without parentheses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-21 05:51:23 +00:00
nobu 53a7c96417 fiddle: fix build failures
* ext/fiddle/depend (build-libffi): get rid of eventually empty
  target for nmake.

* ext/fiddle/extconf.rb: omit stuffs for libffi unless bundled
  libffi is found and used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-21 05:45:01 +00:00
nobu cfe3357581 handle.c: suppress a warning
* ext/fiddle/handle.c (rb_fiddle_handle_initialize): suppress an
  unused-but-set-variable warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-21 05:26:20 +00:00
nobu 96fc3108b5 fiddle: configure in mflags
* ext/fiddle/extconf.rb: configure is already in mflags, use
  system instead of xsystem which requires a string, and logging
  libffi configure output.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-20 03:53:05 +00:00