ffi 1.17.3-aarch64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +498 -0
- data/COPYING +49 -0
- data/Gemfile +26 -0
- data/LICENSE +24 -0
- data/LICENSE.SPECS +22 -0
- data/README.md +138 -0
- data/Rakefile +209 -0
- data/Steepfile +8 -0
- data/ffi.gemspec +41 -0
- data/lib/3.4/ffi_c.so +0 -0
- data/lib/4.0/ffi_c.so +0 -0
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +186 -0
- data/lib/ffi/buffer.rb +4 -0
- data/lib/ffi/callback.rb +4 -0
- data/lib/ffi/compat.rb +54 -0
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/dynamic_library.rb +118 -0
- data/lib/ffi/enum.rb +302 -0
- data/lib/ffi/errno.rb +43 -0
- data/lib/ffi/ffi.rb +109 -0
- data/lib/ffi/function.rb +94 -0
- data/lib/ffi/io.rb +62 -0
- data/lib/ffi/library.rb +592 -0
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +84 -0
- data/lib/ffi/memorypointer.rb +1 -0
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +181 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +175 -0
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
- data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
- data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/arm-linux/types.conf +132 -0
- data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
- data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/lib/ffi/platform/i386-windows/types.conf +52 -0
- data/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
- data/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/lib/ffi/platform/mips64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
- data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/lib/ffi/platform/powerpc-linux/types.conf +130 -0
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
- data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/lib/ffi/platform/sparcv9-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +130 -0
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +132 -0
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
- data/lib/ffi/platform.rb +187 -0
- data/lib/ffi/pointer.rb +167 -0
- data/lib/ffi/struct.rb +317 -0
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +227 -0
- data/lib/ffi/tools/const_generator.rb +232 -0
- data/lib/ffi/tools/generator.rb +105 -0
- data/lib/ffi/tools/generator_task.rb +32 -0
- data/lib/ffi/tools/struct_generator.rb +195 -0
- data/lib/ffi/types.rb +222 -0
- data/lib/ffi/union.rb +43 -0
- data/lib/ffi/variadic.rb +80 -0
- data/lib/ffi/version.rb +3 -0
- data/lib/ffi.rb +27 -0
- data/samples/getlogin.rb +8 -0
- data/samples/getpid.rb +8 -0
- data/samples/gettimeofday.rb +18 -0
- data/samples/hello.rb +8 -0
- data/samples/hello_ractor.rb +19 -0
- data/samples/inotify.rb +60 -0
- data/samples/pty.rb +75 -0
- data/samples/qsort.rb +20 -0
- data/samples/qsort_ractor.rb +36 -0
- data/sig/ffi/abstract_memory.rbs +165 -0
- data/sig/ffi/auto_pointer.rbs +26 -0
- data/sig/ffi/buffer.rbs +18 -0
- data/sig/ffi/data_converter.rbs +10 -0
- data/sig/ffi/dynamic_library.rbs +9 -0
- data/sig/ffi/enum.rbs +38 -0
- data/sig/ffi/errno.rbs +8 -0
- data/sig/ffi/function.rbs +39 -0
- data/sig/ffi/library.rbs +42 -0
- data/sig/ffi/native_type.rbs +86 -0
- data/sig/ffi/platform.rbs +49 -0
- data/sig/ffi/pointer.rbs +42 -0
- data/sig/ffi/struct.rbs +76 -0
- data/sig/ffi/struct_by_reference.rbs +11 -0
- data/sig/ffi/struct_by_value.rbs +7 -0
- data/sig/ffi/struct_layout.rbs +9 -0
- data/sig/ffi/struct_layout_builder.rbs +5 -0
- data/sig/ffi/type.rbs +39 -0
- data/sig/ffi.rbs +29 -0
- metadata +179 -0
data/lib/ffi/function.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2008-2010 JRuby project
|
|
3
|
+
#
|
|
4
|
+
# This file is part of ruby-ffi.
|
|
5
|
+
#
|
|
6
|
+
# All rights reserved.
|
|
7
|
+
#
|
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
12
|
+
# list of conditions and the following disclaimer.
|
|
13
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
# and/or other materials provided with the distribution.
|
|
16
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
|
17
|
+
# may be used to endorse or promote products derived from this software
|
|
18
|
+
# without specific prior written permission.
|
|
19
|
+
#
|
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
module FFI
|
|
32
|
+
class Function
|
|
33
|
+
# Only MRI allows function type queries
|
|
34
|
+
if private_method_defined?(:type)
|
|
35
|
+
# Retrieve the return type of the function
|
|
36
|
+
#
|
|
37
|
+
# This method returns FFI type returned by the function.
|
|
38
|
+
#
|
|
39
|
+
# @return [FFI::Type]
|
|
40
|
+
def return_type
|
|
41
|
+
type.return_type
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Retrieve Array of parameter types
|
|
45
|
+
#
|
|
46
|
+
# This method returns an Array of FFI types accepted as function parameters.
|
|
47
|
+
#
|
|
48
|
+
# @return [Array<FFI::Type>]
|
|
49
|
+
def param_types
|
|
50
|
+
type.param_types
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if RUBY_PLATFORM == 'aarch64-mingw-ucrt'
|
|
55
|
+
# Use a workaround for https://github.com/libffi/libffi/issues/905
|
|
56
|
+
def attach(mod, name)
|
|
57
|
+
this = self
|
|
58
|
+
body = proc do |*args, &block|
|
|
59
|
+
this.call(*args, &block)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
mod.define_method(name, body)
|
|
63
|
+
mod.define_singleton_method(name, body)
|
|
64
|
+
|
|
65
|
+
# Store function Proc's for re-definition as Ractor-shareable in Library#freeze
|
|
66
|
+
funcs = mod.instance_variable_get("@ffi_function_procs")
|
|
67
|
+
unless funcs
|
|
68
|
+
funcs = {}
|
|
69
|
+
mod.instance_variable_set("@ffi_function_procs", funcs)
|
|
70
|
+
end
|
|
71
|
+
funcs[name] = self
|
|
72
|
+
|
|
73
|
+
self
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Stash the Function in a module variable so it can be inspected by attached_functions.
|
|
78
|
+
# On CRuby it also ensures that it does not get garbage collected.
|
|
79
|
+
module RegisterAttach
|
|
80
|
+
def attach(mod, name)
|
|
81
|
+
funcs = mod.instance_variable_defined?("@ffi_functions") && mod.instance_variable_get("@ffi_functions")
|
|
82
|
+
unless funcs
|
|
83
|
+
funcs = {}
|
|
84
|
+
mod.instance_variable_set("@ffi_functions", funcs)
|
|
85
|
+
end
|
|
86
|
+
funcs[name.to_sym] = self
|
|
87
|
+
# Jump to the native attach method of CRuby, JRuby or Tuffleruby
|
|
88
|
+
super
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
private_constant :RegisterAttach
|
|
92
|
+
prepend RegisterAttach
|
|
93
|
+
end
|
|
94
|
+
end
|
data/lib/ffi/io.rb
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2008, 2009 Wayne Meissner
|
|
3
|
+
#
|
|
4
|
+
# This file is part of ruby-ffi.
|
|
5
|
+
#
|
|
6
|
+
# All rights reserved.
|
|
7
|
+
#
|
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
12
|
+
# list of conditions and the following disclaimer.
|
|
13
|
+
# * Redistributions in binary form must reproduce the above copyright notice
|
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
# and/or other materials provided with the distribution.
|
|
16
|
+
# * Neither the name of the Ruby FFI project nor the names of its contributors
|
|
17
|
+
# may be used to endorse or promote products derived from this software
|
|
18
|
+
# without specific prior written permission.
|
|
19
|
+
#
|
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#
|
|
30
|
+
|
|
31
|
+
module FFI
|
|
32
|
+
|
|
33
|
+
# This module implements a couple of class methods to play with IO.
|
|
34
|
+
module IO
|
|
35
|
+
# @param [Integer] fd file decriptor
|
|
36
|
+
# @param [String] mode mode string
|
|
37
|
+
# @return [::IO]
|
|
38
|
+
# Synonym for IO::for_fd.
|
|
39
|
+
def self.for_fd(fd, mode = "r")
|
|
40
|
+
::IO.for_fd(fd, mode)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @param [#read] io io to read from
|
|
44
|
+
# @param [AbstractMemory] buf destination for data read from +io+
|
|
45
|
+
# @param [nil, Integer] len maximul number of bytes to read from +io+. If +nil+,
|
|
46
|
+
# read until end of file.
|
|
47
|
+
# @return [Integer] length really read, in bytes
|
|
48
|
+
#
|
|
49
|
+
# A version of IO#read that reads data from an IO and put then into a native buffer.
|
|
50
|
+
#
|
|
51
|
+
# This will be optimized at some future time to eliminate the double copy.
|
|
52
|
+
#
|
|
53
|
+
def self.native_read(io, buf, len)
|
|
54
|
+
tmp = io.read(len)
|
|
55
|
+
return -1 unless tmp
|
|
56
|
+
buf.put_bytes(0, tmp)
|
|
57
|
+
tmp.length
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|