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

127 Коммитов

Автор SHA1 Сообщение Дата
Hiroshi SHIBATA 8f752c95d2
[ruby/fiddle] Use test-unit gem (https://github.com/ruby/fiddle/pull/69)
https://github.com/ruby/fiddle/commit/e08c4c635e

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2021-09-05 17:43:48 +09:00
Nobuyoshi Nakada bcc5a2b67e [ruby/fiddle] Simplify libc and libm path logics (https://github.com/ruby/fiddle/pull/91)
* Simplify libc_so and libm_so

If nil, no need to set to nil.

* Get rid of repeating inversions

https://github.com/ruby/fiddle/commit/4323e689d8
2021-08-24 16:18:24 +09:00
Aaron Patterson 0f1e8f38c9 [ruby/fiddle] Improve "offsetof" calculations (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
2021-08-24 16:18:22 +09:00
Nobuyoshi Nakada f347b586fb
[ruby/fiddle] Handle#file_name results in very platform dependent 2021-07-15 09:49:56 +09:00
Nobuyoshi Nakada c67c83fb68
[ruby/fiddle] Module file name may be the realpath
Even when the path which was used to dlopen may be a symlink.
2021-07-15 09:20:10 +09:00
Nobuyoshi Nakada 2fa3209a35
[ruby/fiddle] fixed the test on case-insensitive filesystem 2021-07-14 22:00:56 +09:00
Kenta Murata 67897762cf
[ruby/fiddle] Add Fiddle::Handle#file_name (https://github.com/ruby/fiddle/pull/88)
https://github.com/ruby/fiddle/commit/4ee1c6fc4b
2021-07-14 18:56:00 +09:00
Kenta Murata 818c74b7f4 [ruby/fiddle] Return the module handle value in Fiddle::Handle#to_i and add FIddle::Handle#to_ptr (https://github.com/ruby/fiddle/pull/87)
https://github.com/ruby/fiddle/commit/170111a0cb
2021-07-14 18:43:32 +09:00
Aaron Patterson 5c0d8c6369
[ruby/fiddle] Add "offsetof" to Struct classes (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>
2021-07-13 19:37:46 +09:00
Sutou Kouhei 10e26cfa76
[ruby/fiddle] Add MemoryView.export and MemoryView#release (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
2021-07-13 19:37:45 +09:00
Sutou Kouhei 9988f6ac4e
[ruby/fiddle] Add Fiddle::MemoryView#to_s (https://github.com/ruby/fiddle/pull/78)
Fix https://github.com/ruby/fiddle/pull/74

Reported by dsisnero. Thanks!!!
2021-07-13 19:37:45 +09:00
Sutou Kouhei 8c905349bb
[ruby/fiddle] test: fix SetLastError's input type
https://github.com/ruby/fiddle/commit/ca5e6a0404
2021-07-13 19:37:45 +09:00
Sutou Kouhei 37d16bb9dc
[ruby/fiddle] test: use double quote for string literal
https://github.com/ruby/fiddle/commit/fab7eab95b
2021-07-13 19:37:45 +09:00
Sutou Kouhei 5516d74ad2
[ruby/fiddle] test: add a test for win32_last_socket_error
https://github.com/ruby/fiddle/commit/c86cec03cd
2021-07-13 19:37:45 +09:00
Sutou Kouhei 303ab5da8b
[ruby/fiddle] test: add missing receiver
https://github.com/ruby/fiddle/commit/1da3b4af16
2021-07-13 19:37:45 +09:00
Sutou Kouhei d1eeb9fec9
[ruby/fiddle] windows: use GetLastError() for win32_last_error
Ruby: [Bug #11579]

Patch by cremno phobia. Thanks!!!

https://github.com/ruby/fiddle/commit/760a8f9b14
2021-07-13 19:37:45 +09:00
Nobuyoshi Nakada d172f8ac09
Skip fiddle tests if fiddle is not avaiable 2021-07-10 19:14:40 +09:00
Jeremy Evans 2579593a56 [ruby/fiddle] Do not use a libdir for glibc, it breaks Linux PPC64 (#70)
Fixes [Bug #12666]

https://github.com/ruby/fiddle/commit/a267a40be7
2021-05-18 12:48:40 +09:00
Sutou Kouhei ab5212b3c9 [ruby/fiddle] Add support for "const" in type
GitHub: fix #68

Reported by kojix2. Thanks!!!

https://github.com/ruby/fiddle/commit/d7322c234a
2021-05-18 12:48:40 +09: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
Aaron Patterson d45466dc5b
Oops! Add another test and fix to_proc implementation 2021-02-26 10:06:56 -08:00
Aaron Patterson 0590e9b677
Fiddle::Function responds to to_proc
This lets us cast a Fiddle::Function to a block, allowing is to write
things like:

```ruby
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
define_method :strcpy, &f
```
2021-02-26 09:57:13 -08:00
Kenta Murata 74652e640a
[memory_view][fiddle] Rename len to byte_size in rb_memory_view_t 2020-12-23 09:24:53 +09:00
Zoltán Mizsei 8f6cb5b70b
TEST: multiarch support for Haiku 2020-12-15 23:13:24 +09:00
Nobuyoshi Nakada eea756ac86
Strip trailing spaces [ci skip] 2020-12-11 23:14:36 +09:00
Kenta Murata 9b0c36b390
Import fiddle-1.0.4 (#3860)
I don't use tool/sync_default_gem.rb because the last sync was incomplete.

Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Co-authored-by: sinisterchipmunk <sinisterchipmunk@gmail.com>
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2020-12-11 09:41:12 +09:00
Kenta Murata 2427393b4d
Revert "test/fiddle/helper.rb: remove duplication (#3863)" (#3865)
This reverts commit bd47a8d660.

`libc_so` and `libm_so` are `nil` at line 124 because Big Sur doesn't have `/usr/lib/libSystem.B.dylib`.
The reassignment at line 127 is necessary in this case.
2020-12-08 21:58:08 +09:00
Kenta Murata bd47a8d660
test/fiddle/helper.rb: remove duplication (#3863) 2020-12-08 15:42:31 +09:00
Sutou Kouhei 5c7ef89db4 [ruby/fiddle] test: suppress shadowing outer local variable warning
https://github.com/ruby/fiddle/commit/cf168680a2
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
Hiroshi SHIBATA b7d86e330c
Workaroud for macOS Big Sur(11.0) 2020-09-08 20:39:23 +09:00
Hiroshi SHIBATA cdef17096c
libSystem.dylib is also symlink. Use libSystem.B.dylib 2020-09-08 20:38:01 +09:00
Hiroshi SHIBATA 0168094da2
Use libSystem.dylib instead of libm.dylib and libc.dylib
Because macOS 11.0(Big Sur) was removed libc and libm from `/usr/lib`.
2020-09-08 19:35:15 +09:00
Jun Aruga 265968d675 Apply timeout-scale to test_nogvl_poll. 2020-07-30 18:28:41 +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
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 a40b390b17
[ruby/fiddle] test windows: use _snprintf
https://github.com/ruby/fiddle/commit/aa261bdb9f
2020-06-27 23:54:09 +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
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
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
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
Nobuyoshi Nakada 5a81562dfe
`Dir.glob` always returns an array
It is not needed to test itself, but the element should be tested
instead.
2020-04-01 12:48:56 +09:00
Paul Jordan 3e386d76c2 Fix helper to not assume glibc 2020-04-01 15:49:02 +13:00
Nobuyoshi Nakada 502d9bcd36
Fixed never-defined symbol name 2020-03-04 21:00:17 +09:00
卜部昌平 3b9f36d6c6 pass appropriate libc path
The same as https://github.com/ruby/ruby/pull/2686, but for musl libc.
Musl is not named as libc.so.6 so the `ldd` hack implemented some lines
below does not work.
2020-01-24 10:49:35 +09:00
Jun Aruga c0d118f41a Fix "cannot find the function: strcpy()" error on arm32 on Travis CI. (#2686)
This issue happened when `libc.so` and `libm.so` path were not found
and `ldd ruby` command also failed to print the shared dependencies
in `test/fiddle/helper.rb`.

See https://travis-ci.org/ruby/ruby/jobs/611483288#L3018
/home/travis/build/ruby/ruby/build/.ext/common/fiddle/import.rb:299:in `import_function': cannot find the function: strcpy() (Fiddle::DLError)

* Set libc6:armhf as a installing dependency explicitly.
* Remove arm32 from allow_failures.
2019-12-05 14:17:16 +09:00