summaryrefslogtreecommitdiff
path: root/ext/fiddle
Commit message (Collapse)AuthorAgeFilesLines
* Update the depend filesMatt Valentine-House2023-02-281-8/+0
|
* Remove intern/gc.h from Make depsMatt Valentine-House2023-02-271-8/+0
|
* Prefer to use File.foreach instead of IO.foreachHiroshi SHIBATA2023-02-271-1/+1
|
* Prefer to use File.binwrite instead of IO.binwriteHiroshi SHIBATA2023-02-271-2/+2
|
* Prefer to use File.binread instead of IO.binreadHiroshi SHIBATA2023-02-271-2/+2
|
* Extract include/ruby/internal/attr/packed_struct.hNobuyoshi Nakada2023-02-081-0/+8
| | | | | | | | | Split `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED` macros into the macros bellow: * `RBIMPL_ATTR_PACKED_STRUCT_BEGIN` * `RBIMPL_ATTR_PACKED_STRUCT_END` * `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN` * `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END`
* [ruby/fiddle] fiddle: Use C11 _Alignof to define ALIGN_OF whenKhem Raj2023-01-271-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | possible (https://github.com/ruby/fiddle/pull/120) WG14 N2350 made very clear that it is an UB having type definitions within "offsetof" [1]. This patch enhances the implementation of macro ALIGN_OF to use builtin "_Alignof" to avoid undefined behavior when using std=c11 or newer clang 16+ has started to flag this [2] Fixes build when using -std >= gnu11 and using clang16+ Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it may support C11, exclude those compiler versions [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm [2] https://reviews.llvm.org/D133574 Signed-off-by: Khem Raj <raj.khem@gmail.com> https://github.com/ruby/fiddle/commit/ad6c9aa826
* [ruby/fiddle] Fix comment formattingAaron Patterson2023-01-271-12/+12
| | | | https://github.com/ruby/fiddle/commit/36b2432575
* [ruby/fiddle] Update documentationAaron Patterson2023-01-271-14/+19
| | | | | | | | (https://github.com/ruby/fiddle/pull/119) The documentation for `Fiddle.dlwrap` and `Fiddle.dlunwrap` were not very accurate and pretty confusing. This commit updates the documentation so it's easier to understand what the methods do.
* [ruby/fiddle] Prefer String#unpack1 in Fiddle::ValueUtilMau Magnaguagno2022-12-261-15/+13
| | | | | | | | (https://github.com/ruby/fiddle/pull/118) String#unpack1 is available since Ruby 2.4, and support for older than Ruby 2.5 was dropped by #85. Also simplified a common return statement.
* [ruby/fiddle] Bump versionSutou Kouhei2022-12-261-1/+1
| | | | https://github.com/ruby/fiddle/commit/3033266902
* Merge fiddle-1.1.1Hiroshi SHIBATA2022-12-092-1/+25
|
* [ruby/fiddle] Free closures immediatelyAaron Patterson2022-10-181-0/+2
| | | | | | | | | (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
* [ruby/fiddle] Add support for linker script on LinuxSutou Kouhei2022-10-181-1/+30
| | | | | | | | GitHub: fix https://github.com/ruby/fiddle/pull/107 Reported by nicholas a. evans. Thanks!!! https://github.com/ruby/fiddle/commit/49ea1490df
* [ruby/fiddle] Bump versionSutou Kouhei2022-10-181-1/+1
|
* fiddle: use the old rb_ary_tmp_new() aliasNobuyoshi Nakada2022-10-181-1/+1
| | | | | Fiddle is a gem and has the external upstream which supports older versions of Ruby.
* Add --with-libffi-source-dir feature and removed --enable-bundled-libffi ↵Hiroshi SHIBATA2022-10-072-25/+6
| | | | | | | | | option. (#113) https://bugs.ruby-lang.org/issues/18571 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* [ruby/fiddle] closure: follow variable name changeSutou Kouhei2022-10-071-1/+1
| | | | | | GitHub: GH-102 https://github.com/ruby/fiddle/commit/2530496602
* [ruby/fiddle] closure: free resources when an exception is raised in Closure.newSutou Kouhei2022-10-071-13/+43
| | | | | | GitHub: GH-102 https://github.com/ruby/fiddle/commit/81a8a56239
* [ruby/fiddle] Add Fiddle::Closure.create and Fiddle::Closure.freeSutou Kouhei2022-10-072-7/+73
| | | | | | | | | | | | | | | | 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
* [ruby/fiddle] Add `sym_defined?` methods to test if a symbol is defined ↵Aaron Patterson2022-10-071-4/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/fiddle/pull/108) I would like to check if a symbol is defined before trying to access it. Some symbols aren't available on all platforms, so instead of raising an exception, I want to check if it's defined first. Today we have to do: ```ruby begin addr = Fiddle::Handle.sym("something") # do something rescue Fiddle::DLError end ``` I want to write this: ```ruby if Fiddle::Handle.sym_defined?("something") addr = Fiddle::Handle.sym("something") # do something end ``` https://github.com/ruby/fiddle/commit/9d3371de13 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* [ruby/fiddle] Move "type" constants to `Fiddle::Types` ↵Aaron Patterson2022-10-072-58/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/fiddle/pull/112) This helps to reduce repetition in code. Instead of doing "TYPE_*" everywhere, you can do `include Fiddle::Types`, and write the type name directly. This PR is to help reduce repetition when writing Fiddle code. Right now we have to type `TYPE_` everywhere, and you also have to include all of `Fiddle` to access `TYPE_*` constants. With this change, you can just include `Fiddle::Types` and it will shorten your code and also you only have to include those constants. Here is an example before: ```ruby require "fiddle" module MMAP # All Fiddle constants included include Fiddle def self.make_function name, args, ret ptr = Handle::DEFAULT[name] func = Function.new ptr, args, ret, name: name define_singleton_method name, &func.to_proc end make_function "munmap", [TYPE_VOIDP, # addr TYPE_SIZE_T], # len TYPE_INT make_function "mmap", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT], TYPE_VOIDP make_function "mprotect", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT], TYPE_INT end ``` After: ```ruby require "fiddle" module MMAP # Only type names included include Fiddle::Types def self.make_function name, args, ret ptr = Fiddle::Handle::DEFAULT[name] func = Fiddle::Function.new ptr, args, ret, name: name define_singleton_method name, &func.to_proc end make_function "munmap", [VOIDP, # addr SIZE_T], # len INT make_function "mmap", [VOIDP, SIZE_T, INT, INT, INT, INT], VOIDP make_function "mprotect", [VOIDP, SIZE_T, INT], INT end ``` We only need to import the type names, and you don't have to type `TYPE_` over and over. I think this makes Fiddle code easier to read. https://github.com/ruby/fiddle/commit/49fa7233e5 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* [ruby/fiddle] Add constants for unsigned values ↵Aaron Patterson2022-10-076-44/+173
| | | | | | | | | | | | | | | (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](https://github.com/ruby/ruby/blob/3a56bf0bcc66e14ffe5ec89efc32ecfceed180f4/lib/mjit/c_type.rb#L31-L38) https://github.com/ruby/fiddle/commit/2bef0f1082 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* [ruby/fiddle] Fix PACK_MAP for unsigned types ↵Takashi Kokubun2022-09-111-7/+8
| | | | | | (https://github.com/ruby/fiddle/pull/110) https://github.com/ruby/fiddle/commit/4a71246645ccff001292c9d80b855b2ef5bf06c1
* No longer bundle external library sourcesNobuyoshi Nakada2022-09-091-13/+0
|
* Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu2022-07-261-1/+1
| | | | | | 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.
* [Feature #18249] Update dependenciesPeter Zhu2022-02-221-0/+8
|
* Do not need to print to stderrKoichi Sasada2022-01-261-1/+1
|
* Update dependenciesNobuyoshi Nakada2021-11-211-8/+0
|
* ruby tool/update-deps --fix卜部昌平2021-10-051-0/+18
|
* [ruby/fiddle] Use test-unit gem (https://github.com/ruby/fiddle/pull/69)Hiroshi SHIBATA2021-09-051-4/+0
| | | | | | https://github.com/ruby/fiddle/commit/e08c4c635e Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* [ruby/fiddle] Improve "offsetof" calculations ↵Aaron Patterson2021-08-241-16/+44
| | | | | | | | | (https://github.com/ruby/fiddle/pull/90) I need to get the offset of members inside sub structures. This patch adds sub-structure offset support for structs. https://github.com/ruby/fiddle/commit/cf78eddbb6
* [ruby/fiddle] Add Fiddle::Handle#file_name ↵Kenta Murata2021-07-143-1/+51
| | | | | | (https://github.com/ruby/fiddle/pull/88) https://github.com/ruby/fiddle/commit/4ee1c6fc4b
* [ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version ↵Nobuyoshi Nakada2021-07-144-11/+7
| | | | | | (https://github.com/ruby/fiddle/pull/86) https://github.com/ruby/fiddle/commit/c5abcc3a7e
* [ruby/fiddle] Return the module handle value in Fiddle::Handle#to_i and add ↵Kenta Murata2021-07-143-5/+31
| | | | | | FIddle::Handle#to_ptr (https://github.com/ruby/fiddle/pull/87) https://github.com/ruby/fiddle/commit/170111a0cb
* [ruby/fiddle] update dependenciesNobuyoshi Nakada2021-07-131-0/+3
|
* [ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API versionNobuyoshi Nakada2021-07-131-2/+1
| | | | https://github.com/ruby/fiddle/commit/93f9564446
* [ruby/fiddle] Update required_ruby_version ↵Nobuyoshi Nakada2021-07-131-1/+1
| | | | | | | | | (https://github.com/ruby/fiddle/pull/85) Drop supports for old versions, keeping 2.5 as CI supports it for now. https://github.com/ruby/fiddle/commit/90634e7c55
* [ruby/fiddle] Use have_header and have_type to detect memory view availabilitySutou Kouhei2021-07-134-16/+11
| | | | | | | | | | | | | | Fix https://github.com/ruby/fiddle/pull/84 It may detect ruby/memory_view.h for system Ruby that is installed in /usr. We can use RUBY_API_VERSION_MAJOR to detect memory view availability because memory view is available since Ruby 3.0. Reported by Jun Aruga. Thanks!!! https://github.com/ruby/fiddle/commit/3292929830
* [ruby/fiddle] Add "offsetof" to Struct classes ↵Aaron Patterson2021-07-131-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/fiddle/pull/83) * Add "offsetof" to Struct classes I need to get the offset of a member inside a struct without allocating the struct. This patch adds an "offsetof" class method to structs that are generated. The usage is like this: ```ruby MyStruct = struct [ "int64_t i", "char c", ] MyStruct.offsetof("i") # => 0 MyStruct.offsetof("c") # => 8 ``` * Update test/fiddle/test_c_struct_builder.rb Co-authored-by: Sutou Kouhei <kou@cozmixng.org> https://github.com/ruby/fiddle/commit/4e3b60c5b6 Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
* [ruby/fiddle] Bump versionSutou Kouhei2021-07-131-1/+1
| | | | | https://github.com/ruby/fiddle/commit/049138b4b8
* [ruby/fiddle] MemoryView: ensure reset rb_memory_view_t::obj on errorSutou Kouhei2021-07-131-0/+1
| | | | | https://github.com/ruby/fiddle/commit/0ed39345fe
* [ruby/fiddle] StringValuePtr may change the valSutou Kouhei2021-07-131-0/+1
| | | | | https://github.com/ruby/fiddle/commit/bddca7c895
* [ruby/fiddle] Add MemoryView.export and MemoryView#release ↵Sutou Kouhei2021-07-131-3/+39
| | | | | | | | | | | | | (https://github.com/ruby/fiddle/pull/80) fix https://github.com/ruby/fiddle/pull/79 Users can release memory views explicitly before process exit. Reported by xtkoba. Thanks!!! https://github.com/ruby/fiddle/commit/1de64b7e76
* [ruby/fiddle] Add Fiddle::MemoryView#to_s ↵Sutou Kouhei2021-07-131-0/+32
| | | | | | | (https://github.com/ruby/fiddle/pull/78) Fix https://github.com/ruby/fiddle/pull/74 Reported by dsisnero. Thanks!!!
* [ruby/fiddle] windows: use GetLastError() for win32_last_errorSutou Kouhei2021-07-131-1/+2
| | | | | | | | | Ruby: [Bug #11579] Patch by cremno phobia. Thanks!!! https://github.com/ruby/fiddle/commit/760a8f9b14
* [ruby/fiddle] Bump versionSutou Kouhei2021-07-131-1/+1
| | | | | https://github.com/ruby/fiddle/commit/3784cfeec4
* [ruby/fiddle] windows: link to ws2_32 for WSAGetLastError()Sutou Kouhei2021-05-181-0/+2
| | | | https://github.com/ruby/fiddle/commit/e9955d74ae
* [ruby/fiddle] windows: add Fiddle.win32_last_socket_error{,=}Sutou Kouhei2021-05-182-2/+21
| | | | | | | | | | | | | GitHub: fix GH-72 Users can't use WSAGetLastError() with Ruby 3.0 or later because rb_funcall() resets the last socket error internally. Users can get the last socket error by Fiddle.win32_last_socket_error. Reported by Kentaro Hayashi. Thanks!!! https://github.com/ruby/fiddle/commit/76158db00a
* [ruby/fiddle] Add support for "const" in typeSutou Kouhei2021-05-181-2/+4
| | | | | | | | GitHub: fix #68 Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/d7322c234a