rbdc 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bindings/ruby/rbdc/extconf.rb +57 -0
- data/bindings/ruby/rbdc/rbdc.c +304 -0
- data/dyncall/AUTHORS +4 -0
- data/dyncall/BUGS +3 -0
- data/dyncall/CMakeLists.txt +79 -0
- data/dyncall/ChangeLog +165 -0
- data/dyncall/LICENSE +15 -0
- data/dyncall/Makefile.M +15 -0
- data/dyncall/Makefile.embedded +71 -0
- data/dyncall/Makefile.generic +36 -0
- data/dyncall/Nmakefile +45 -0
- data/dyncall/README +92 -0
- data/dyncall/ToDo +114 -0
- data/dyncall/autovar/LICENSE.txt +15 -0
- data/dyncall/autovar/README.txt +69 -0
- data/dyncall/autovar/autovar_ABI.h +44 -0
- data/dyncall/autovar/autovar_ARCH.h +56 -0
- data/dyncall/autovar/autovar_CC.h +46 -0
- data/dyncall/autovar/autovar_OS.h +78 -0
- data/dyncall/autovar/autovar_OSFAMILY.h +39 -0
- data/dyncall/buildsys/cmake/Modules/FindDynCall.cmake +43 -0
- data/dyncall/buildsys/cmake/Modules/FindDynCallback.cmake +43 -0
- data/dyncall/buildsys/cmake/Modules/FindDynLoad.cmake +45 -0
- data/dyncall/buildsys/cmake/Modules/UseLATEX.cmake +811 -0
- data/dyncall/buildsys/dynmake/Makefile.base.M +82 -0
- data/dyncall/buildsys/dynmake/dynmake.bat +2 -0
- data/dyncall/buildsys/dynmake/dynmake.sh +4 -0
- data/dyncall/buildsys/lua/Makefile +10 -0
- data/dyncall/buildsys/lua/README.txt +4 -0
- data/dyncall/buildsys/lua/bootstrap.sh +34 -0
- data/dyncall/buildsys/lua/cleanup.sh +6 -0
- data/dyncall/buildsys/lua/mkfile +34 -0
- data/dyncall/buildsys/lua/setenv.sh +4 -0
- data/dyncall/buildsys/mk/app.mk +30 -0
- data/dyncall/buildsys/mk/dirs.mk +27 -0
- data/dyncall/buildsys/mk/epilog.mk +30 -0
- data/dyncall/buildsys/mk/lib.mk +23 -0
- data/dyncall/buildsys/mk/pcc.mk +60 -0
- data/dyncall/buildsys/mk/prolog.mk +35 -0
- data/dyncall/buildsys/nmake/common.nmake +61 -0
- data/dyncall/buildsys/nmake/epilog.nmake +28 -0
- data/dyncall/buildsys/nmake/prolog.nmake +76 -0
- data/dyncall/buildsys/nmake/tool_gcc.nmake +82 -0
- data/dyncall/buildsys/nmake/tool_msvc.nmake +67 -0
- data/dyncall/buildsys/scripts/batch-build-linux.sh +11 -0
- data/dyncall/buildsys/scripts/batch-build-minix.sh +11 -0
- data/dyncall/buildsys/scripts/batch-build-psp.sh +11 -0
- data/dyncall/buildsys/scripts/conf-nds.bat +41 -0
- data/dyncall/buildsys/scripts/setenv-cross-ios.sh +8 -0
- data/dyncall/buildsys/scripts/setenv-sdk-ios.sh +22 -0
- data/dyncall/buildsys/vs2005/dyncall/dyncall.vcproj +245 -0
- data/dyncall/buildsys/vs2005/test_plain/test_plain.vcproj +202 -0
- data/dyncall/buildsys/vs2005/vs2005.sln +29 -0
- data/dyncall/configure +152 -0
- data/dyncall/configure.bat +157 -0
- data/dyncall/configure.rc +234 -0
- data/dyncall/dynMakefile +4 -0
- data/dyncall/dyncall/CMakeLists.txt +53 -0
- data/dyncall/dyncall/DynCallConfig.cmake +3 -0
- data/dyncall/dyncall/Makefile.M +10 -0
- data/dyncall/dyncall/Makefile.embedded +20 -0
- data/dyncall/dyncall/Makefile.generic +16 -0
- data/dyncall/dyncall/Nmakefile +62 -0
- data/dyncall/dyncall/README-Developer.txt +45 -0
- data/dyncall/dyncall/README.txt +65 -0
- data/dyncall/dyncall/TODO +9 -0
- data/dyncall/dyncall/dynMakefile +4 -0
- data/dyncall/dyncall/dyncall.3 +189 -0
- data/dyncall/dyncall/dyncall.h +135 -0
- data/dyncall/dyncall/dyncall_alloc.h +40 -0
- data/dyncall/dyncall/dyncall_api.c +167 -0
- data/dyncall/dyncall/dyncall_call.S +72 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm.S +80 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm.h +61 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.S +96 -0
- data/dyncall/dyncall/dyncall_call_arm32_arm_armhf.h +44 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb.h +65 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_apple.s +80 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_armhf.S +121 -0
- data/dyncall/dyncall/dyncall_call_arm32_thumb_gas.s +101 -0
- data/dyncall/dyncall/dyncall_call_mips.h +50 -0
- data/dyncall/dyncall/dyncall_call_mips_eabi.h +61 -0
- data/dyncall/dyncall/dyncall_call_mips_eabi_gas.s +115 -0
- data/dyncall/dyncall/dyncall_call_mips_gas.S +36 -0
- data/dyncall/dyncall/dyncall_call_mips_n32.h +67 -0
- data/dyncall/dyncall/dyncall_call_mips_n32_gas.s +192 -0
- data/dyncall/dyncall/dyncall_call_mips_n64.h +67 -0
- data/dyncall/dyncall/dyncall_call_mips_n64_gas.s +192 -0
- data/dyncall/dyncall/dyncall_call_mips_o32.h +70 -0
- data/dyncall/dyncall/dyncall_call_mips_o32_gas.s +109 -0
- data/dyncall/dyncall/dyncall_call_ppc32.S +266 -0
- data/dyncall/dyncall/dyncall_call_ppc32.h +62 -0
- data/dyncall/dyncall/dyncall_call_sparc.S +192 -0
- data/dyncall/dyncall/dyncall_call_sparc.h +42 -0
- data/dyncall/dyncall/dyncall_call_sparc64.S +361 -0
- data/dyncall/dyncall/dyncall_call_sparc64.h +42 -0
- data/dyncall/dyncall/dyncall_call_sparc_v9.S +220 -0
- data/dyncall/dyncall/dyncall_call_sparc_v9.h +42 -0
- data/dyncall/dyncall/dyncall_call_x64-att.S +146 -0
- data/dyncall/dyncall/dyncall_call_x64.S +149 -0
- data/dyncall/dyncall/dyncall_call_x64.h +63 -0
- data/dyncall/dyncall/dyncall_call_x64_generic_masm.asm +70 -0
- data/dyncall/dyncall/dyncall_call_x86.S +238 -0
- data/dyncall/dyncall/dyncall_call_x86.h +70 -0
- data/dyncall/dyncall/dyncall_call_x86_8a.s +127 -0
- data/dyncall/dyncall/dyncall_call_x86_generic_masm.asm +136 -0
- data/dyncall/dyncall/dyncall_call_x86_nasm.asm +234 -0
- data/dyncall/dyncall/dyncall_callf.c +112 -0
- data/dyncall/dyncall/dyncall_callf.h +52 -0
- data/dyncall/dyncall/dyncall_callvm.c +68 -0
- data/dyncall/dyncall/dyncall_callvm.h +88 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.c +250 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm.h +59 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.c +204 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_arm_armhf.h +63 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.c +271 -0
- data/dyncall/dyncall/dyncall_callvm_arm32_thumb.h +59 -0
- data/dyncall/dyncall/dyncall_callvm_base.c +33 -0
- data/dyncall/dyncall/dyncall_callvm_mips.c +40 -0
- data/dyncall/dyncall/dyncall_callvm_mips.h +37 -0
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.c +181 -0
- data/dyncall/dyncall/dyncall_callvm_mips_eabi.h +61 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n32.c +268 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n64.c +268 -0
- data/dyncall/dyncall/dyncall_callvm_mips_n64.h +53 -0
- data/dyncall/dyncall/dyncall_callvm_mips_o32.c +235 -0
- data/dyncall/dyncall/dyncall_callvm_mips_o32.h +45 -0
- data/dyncall/dyncall/dyncall_callvm_ppc32.c +372 -0
- data/dyncall/dyncall/dyncall_callvm_ppc32.h +61 -0
- data/dyncall/dyncall/dyncall_callvm_sparc.c +155 -0
- data/dyncall/dyncall/dyncall_callvm_sparc.h +44 -0
- data/dyncall/dyncall/dyncall_callvm_sparc64.c +239 -0
- data/dyncall/dyncall/dyncall_callvm_sparc64.h +47 -0
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.c +182 -0
- data/dyncall/dyncall/dyncall_callvm_sparc_v9.h +45 -0
- data/dyncall/dyncall/dyncall_callvm_x64.c +228 -0
- data/dyncall/dyncall/dyncall_callvm_x64.h +111 -0
- data/dyncall/dyncall/dyncall_callvm_x86.c +667 -0
- data/dyncall/dyncall/dyncall_callvm_x86.h +75 -0
- data/dyncall/dyncall/dyncall_config.h +46 -0
- data/dyncall/dyncall/dyncall_macros.h +248 -0
- data/dyncall/dyncall/dyncall_signature.h +71 -0
- data/dyncall/dyncall/dyncall_struct.c +255 -0
- data/dyncall/dyncall/dyncall_struct.h +69 -0
- data/dyncall/dyncall/dyncall_types.h +74 -0
- data/dyncall/dyncall/dyncall_utils.h +38 -0
- data/dyncall/dyncall/dyncall_value.h +73 -0
- data/dyncall/dyncall/dyncall_vector.c +52 -0
- data/dyncall/dyncall/dyncall_vector.h +56 -0
- data/dyncall/dyncall/gen-masm.sh +7 -0
- data/dyncall/dyncall/mkfile +29 -0
- data/dyncall/dyncallback/CMakeLists.txt +55 -0
- data/dyncall/dyncallback/DynCallbackConfig.cmake +2 -0
- data/dyncall/dyncallback/Makefile.M +10 -0
- data/dyncall/dyncallback/Makefile.embedded +15 -0
- data/dyncall/dyncallback/Makefile.generic +20 -0
- data/dyncall/dyncallback/Nmakefile +71 -0
- data/dyncall/dyncallback/README.txt +9 -0
- data/dyncall/dyncallback/TODO +4 -0
- data/dyncall/dyncallback/dynMakefile +4 -0
- data/dyncall/dyncallback/dyncall_alloc_wx.c +35 -0
- data/dyncall/dyncallback/dyncall_alloc_wx.h +46 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_malloc.c +40 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_mmap.c +42 -0
- data/dyncall/dyncallback/dyncall_alloc_wx_win32.c +42 -0
- data/dyncall/dyncallback/dyncall_args.c +45 -0
- data/dyncall/dyncallback/dyncall_args.h +65 -0
- data/dyncall/dyncallback/dyncall_args_arm32_arm.c +112 -0
- data/dyncall/dyncallback/dyncall_args_arm32_arm.h +40 -0
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_args_arm32_thumb.h +32 -0
- data/dyncall/dyncallback/dyncall_args_mips.c +81 -0
- data/dyncall/dyncallback/dyncall_args_mips.h +41 -0
- data/dyncall/dyncallback/dyncall_args_ppc32.c +88 -0
- data/dyncall/dyncallback/dyncall_args_ppc32.h +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc32.c +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc32.h +37 -0
- data/dyncall/dyncallback/dyncall_args_sparc64.c +41 -0
- data/dyncall/dyncallback/dyncall_args_sparc64.h +37 -0
- data/dyncall/dyncallback/dyncall_args_x64.c +73 -0
- data/dyncall/dyncallback/dyncall_args_x64.h +44 -0
- data/dyncall/dyncallback/dyncall_args_x86.c +121 -0
- data/dyncall/dyncallback/dyncall_args_x86.h +58 -0
- data/dyncall/dyncallback/dyncall_callback.c +45 -0
- data/dyncall/dyncallback/dyncall_callback.h +51 -0
- data/dyncall/dyncallback/dyncall_callback_arch.S +71 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.c +63 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm.h +45 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm_apple.s +73 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_arm_gas.s +73 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb.h +33 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb_apple.s +32 -0
- data/dyncall/dyncallback/dyncall_callback_arm32_thumb_gas.s +32 -0
- data/dyncall/dyncallback/dyncall_callback_mips.c +61 -0
- data/dyncall/dyncallback/dyncall_callback_mips.h +42 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.S +33 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.c +60 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32.h +43 -0
- data/dyncall/dyncallback/dyncall_callback_ppc32_apple.s +180 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.c +57 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.h +43 -0
- data/dyncall/dyncallback/dyncall_callback_sparc32.s +30 -0
- data/dyncall/dyncallback/dyncall_callback_sparc64.c +57 -0
- data/dyncall/dyncallback/dyncall_callback_sparc64.s +30 -0
- data/dyncall/dyncallback/dyncall_callback_x64.S +187 -0
- data/dyncall/dyncallback/dyncall_callback_x64.c +69 -0
- data/dyncall/dyncallback/dyncall_callback_x64.h +44 -0
- data/dyncall/dyncallback/dyncall_callback_x64_apple.s +122 -0
- data/dyncall/dyncallback/dyncall_callback_x64_gas.s +119 -0
- data/dyncall/dyncallback/dyncall_callback_x64_gas_w64.s +102 -0
- data/dyncall/dyncallback/dyncall_callback_x64_masm.asm +89 -0
- data/dyncall/dyncallback/dyncall_callback_x86.S +115 -0
- data/dyncall/dyncallback/dyncall_callback_x86.c +281 -0
- data/dyncall/dyncallback/dyncall_callback_x86.h +49 -0
- data/dyncall/dyncallback/dyncall_callback_x86_8a.s +100 -0
- data/dyncall/dyncallback/dyncall_callback_x86_masm.asm +74 -0
- data/dyncall/dyncallback/dyncall_thunk.c +47 -0
- data/dyncall/dyncallback/dyncall_thunk.h +84 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.c +45 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_arm.h +40 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.c +29 -0
- data/dyncall/dyncallback/dyncall_thunk_arm32_thumb.h +35 -0
- data/dyncall/dyncallback/dyncall_thunk_mips.c +52 -0
- data/dyncall/dyncallback/dyncall_thunk_mips.h +37 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc32.c +51 -0
- data/dyncall/dyncallback/dyncall_thunk_ppc32.h +40 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc32.c +32 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc32.h +36 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc64.c +32 -0
- data/dyncall/dyncallback/dyncall_thunk_sparc64.h +36 -0
- data/dyncall/dyncallback/dyncall_thunk_x64.c +48 -0
- data/dyncall/dyncallback/dyncall_thunk_x64.h +39 -0
- data/dyncall/dyncallback/dyncall_thunk_x86.c +44 -0
- data/dyncall/dyncallback/dyncall_thunk_x86.h +39 -0
- data/dyncall/dyncallback/dyncallback.3 +134 -0
- data/dyncall/dyncallback/gen-masm.sh +8 -0
- data/dyncall/dyncallback/mkfile +29 -0
- data/dyncall/dynload/CMakeLists.txt +25 -0
- data/dyncall/dynload/DynLoadConfig.cmake +3 -0
- data/dyncall/dynload/Makefile.M +10 -0
- data/dyncall/dynload/Makefile.embedded +22 -0
- data/dyncall/dynload/Makefile.generic +18 -0
- data/dyncall/dynload/Nmakefile +57 -0
- data/dyncall/dynload/README.txt +113 -0
- data/dyncall/dynload/TODO +20 -0
- data/dyncall/dynload/dynMakefile +4 -0
- data/dyncall/dynload/dynload.3 +64 -0
- data/dyncall/dynload/dynload.c +38 -0
- data/dyncall/dynload/dynload.h +65 -0
- data/dyncall/dynload/dynload_alloc.h +40 -0
- data/dyncall/dynload/dynload_darwin.c +89 -0
- data/dyncall/dynload/dynload_syms.c +38 -0
- data/dyncall/dynload/dynload_syms_elf.c +214 -0
- data/dyncall/dynload/dynload_syms_mach-o.c +167 -0
- data/dyncall/dynload/dynload_syms_pe.c +109 -0
- data/dyncall/dynload/dynload_unix.c +57 -0
- data/dyncall/dynload/dynload_windows.c +59 -0
- data/dyncall/mkfile +36 -0
- data/dyncall/portasm/README.txt +42 -0
- data/dyncall/portasm/gen-masm.sh +3 -0
- data/dyncall/portasm/portasm-arm.S +36 -0
- data/dyncall/portasm/portasm-ppc.S +98 -0
- data/dyncall/portasm/portasm-x64-att.S +155 -0
- data/dyncall/portasm/portasm-x86.S +127 -0
- metadata +311 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
#//////////////////////////////////////////////////////////////////////
|
2
|
+
#
|
3
|
+
# extconf.rb
|
4
|
+
# Copyright (c) 2007-2014 Daniel Adler <dadler@uni-goettingen.de>,
|
5
|
+
# Tassilo Philipp <tphilipp@potion-studios.com>
|
6
|
+
#
|
7
|
+
# Permission to use, copy, modify, and distribute this software for any
|
8
|
+
# purpose with or without fee is hereby granted, provided that the above
|
9
|
+
# copyright notice and this permission notice appear in all copies.
|
10
|
+
#
|
11
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
12
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
13
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
14
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
15
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
16
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
17
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
18
|
+
#
|
19
|
+
# Configuration file for dyncall/ruby extension. This script creates
|
20
|
+
# a makefile that can be used to compile the C-extension. It is
|
21
|
+
# configured such that every .c file in this directory will be used
|
22
|
+
# for compilation.
|
23
|
+
#
|
24
|
+
#///////////////////////////////////////////////////////////////////////
|
25
|
+
|
26
|
+
require 'mkmf'
|
27
|
+
|
28
|
+
dir_config 'rbdc'
|
29
|
+
base_dir = '../../../dyncall/'
|
30
|
+
|
31
|
+
# Build dyncall libs.
|
32
|
+
puts 'Building dyncall libraries:'
|
33
|
+
Dir.chdir(base_dir) do
|
34
|
+
cmd = case
|
35
|
+
when RUBY_PLATFORM =~ /mswin/ then 'configure.bat && nmake /f Nmakefile'
|
36
|
+
else './configure && env CFLAGS="-fPIC" make'
|
37
|
+
end
|
38
|
+
puts cmd
|
39
|
+
raise "'#{cmd}' failed" unless system(cmd)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Search for dyncall libs.
|
43
|
+
puts 'Using the following dyncall libraries to build native ruby extension:'
|
44
|
+
Dir[base_dir+'**/*'].each { |d|
|
45
|
+
if d =~ /(lib)?dyn(call(back)?|load)_s\./
|
46
|
+
$LOCAL_LIBS << '"'+d+'" '
|
47
|
+
puts d
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
if($LOCAL_LIBS.size > 0) then
|
52
|
+
# Write out a makefile for our dyncall extension.
|
53
|
+
create_makefile 'rbdc'
|
54
|
+
else
|
55
|
+
puts "Couldn't find dyncall and dynload libraries - dyncall build seems to have failed!"
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,304 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
rbdc.c
|
4
|
+
Copyright (c) 2007-2014 Daniel Adler <dadler@uni-goettingen.de>,
|
5
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
6
|
+
|
7
|
+
Permission to use, copy, modify, and distribute this software for any
|
8
|
+
purpose with or without fee is hereby granted, provided that the above
|
9
|
+
copyright notice and this permission notice appear in all copies.
|
10
|
+
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
12
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
13
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
14
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
15
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
16
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
17
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
18
|
+
|
19
|
+
Ruby/dyncall extension implementation.
|
20
|
+
|
21
|
+
*/
|
22
|
+
|
23
|
+
|
24
|
+
#include <ruby.h>
|
25
|
+
#include "../../../dyncall/dyncall/dyncall.h"
|
26
|
+
#include "../../../dyncall/dyncallback/dyncall_callback.h"
|
27
|
+
#include "../../../dyncall/dynload/dynload.h"
|
28
|
+
#include "../../../dyncall/dyncall/dyncall_signature.h"
|
29
|
+
|
30
|
+
/* Our ruby module and its classes. */
|
31
|
+
static VALUE rb_dcModule;
|
32
|
+
static VALUE rb_dcExtLib;
|
33
|
+
|
34
|
+
|
35
|
+
typedef struct {
|
36
|
+
void* lib;
|
37
|
+
void* syms;
|
38
|
+
DCCallVM* cvm;
|
39
|
+
} rb_dcLibHandle;
|
40
|
+
|
41
|
+
|
42
|
+
/* Allocator for handle and mark-and-sweep GC handlers. */
|
43
|
+
static void GCMark_ExtLib(rb_dcLibHandle* h)
|
44
|
+
{
|
45
|
+
}
|
46
|
+
|
47
|
+
static void GCSweep_ExtLib(rb_dcLibHandle* h)
|
48
|
+
{
|
49
|
+
if(h->lib != NULL) dlFreeLibrary(h->lib);
|
50
|
+
if(h->syms != NULL) dlSymsCleanup(h->syms);
|
51
|
+
|
52
|
+
dcFree(h->cvm);
|
53
|
+
free(h);
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE AllocExtLib(VALUE cl)
|
57
|
+
{
|
58
|
+
rb_dcLibHandle* h = malloc(sizeof(rb_dcLibHandle));
|
59
|
+
h->lib = NULL;
|
60
|
+
h->syms = NULL;
|
61
|
+
h->cvm = dcNewCallVM(4096/*@@@*/);
|
62
|
+
return Data_Wrap_Struct(cl, GCMark_ExtLib, GCSweep_ExtLib, h);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
/* Helpers */
|
67
|
+
static void ExtLib_SecCheckLib(rb_dcLibHandle* h)
|
68
|
+
{
|
69
|
+
if(h->lib == NULL)
|
70
|
+
rb_raise(rb_eRuntimeError, "no library loaded - use ExtLib#load");
|
71
|
+
}
|
72
|
+
|
73
|
+
static void ExtLib_SecCheckSyms(rb_dcLibHandle* h)
|
74
|
+
{
|
75
|
+
if(h->syms == NULL)
|
76
|
+
rb_raise(rb_eRuntimeError, "no symbol table initialized - use ExtLib#symsInit");
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
/* Methods for lib access */
|
82
|
+
static VALUE ExtLib_Load(VALUE self, VALUE path)
|
83
|
+
{
|
84
|
+
void* newLib;
|
85
|
+
rb_dcLibHandle* h;
|
86
|
+
|
87
|
+
if(TYPE(path) != T_STRING)
|
88
|
+
rb_raise(rb_eRuntimeError, "argument must be of type 'String'");/*@@@ respond to to_s*/
|
89
|
+
|
90
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
91
|
+
newLib = dlLoadLibrary(RSTRING_PTR(path));
|
92
|
+
if(newLib) {
|
93
|
+
dlFreeLibrary(h->lib);
|
94
|
+
h->lib = newLib;
|
95
|
+
|
96
|
+
return self;
|
97
|
+
}
|
98
|
+
|
99
|
+
return Qnil;
|
100
|
+
}
|
101
|
+
|
102
|
+
static VALUE ExtLib_ExistsQ(VALUE self, VALUE sym)
|
103
|
+
{
|
104
|
+
rb_dcLibHandle* h;
|
105
|
+
|
106
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
107
|
+
ExtLib_SecCheckLib(h);
|
108
|
+
|
109
|
+
return dlFindSymbol(h->lib, rb_id2name(SYM2ID(sym))) ? Qtrue : Qfalse;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
/* Methods for syms parsing */
|
114
|
+
static VALUE ExtLib_SymsInit(VALUE self, VALUE path)
|
115
|
+
{
|
116
|
+
void* newSyms;
|
117
|
+
rb_dcLibHandle* h;
|
118
|
+
|
119
|
+
if(TYPE(path) != T_STRING)
|
120
|
+
rb_raise(rb_eRuntimeError, "argument must be of type 'String'");/*@@@ respond to to_s*/
|
121
|
+
|
122
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
123
|
+
newSyms = dlSymsInit(RSTRING_PTR(path));
|
124
|
+
|
125
|
+
if(newSyms) {
|
126
|
+
dlSymsCleanup(h->syms);
|
127
|
+
h->syms = newSyms;
|
128
|
+
|
129
|
+
return self;
|
130
|
+
}
|
131
|
+
|
132
|
+
return Qnil;
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
static VALUE ExtLib_SymsCount(VALUE self)
|
137
|
+
{
|
138
|
+
rb_dcLibHandle* h;
|
139
|
+
|
140
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
141
|
+
ExtLib_SecCheckSyms(h);
|
142
|
+
|
143
|
+
return LONG2NUM(dlSymsCount(h->syms));
|
144
|
+
}
|
145
|
+
|
146
|
+
|
147
|
+
static VALUE ExtLib_SymsEach(int argc, VALUE* argv, VALUE self)
|
148
|
+
{
|
149
|
+
rb_dcLibHandle* h;
|
150
|
+
size_t i, c;
|
151
|
+
|
152
|
+
if(!rb_block_given_p())
|
153
|
+
rb_raise(rb_eRuntimeError, "no block given");
|
154
|
+
|
155
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
156
|
+
ExtLib_SecCheckSyms(h);
|
157
|
+
|
158
|
+
c = dlSymsCount(h->syms);
|
159
|
+
for(i=0; i<c; ++i)
|
160
|
+
rb_yield(ID2SYM(rb_intern(dlSymsName(h->syms, i))));
|
161
|
+
|
162
|
+
return self;
|
163
|
+
}
|
164
|
+
|
165
|
+
/* expose dlSymsName @@@ */
|
166
|
+
|
167
|
+
|
168
|
+
/* Methods interfacing with dyncall */
|
169
|
+
static VALUE ExtLib_Call(int argc, VALUE* argv, VALUE self)
|
170
|
+
{
|
171
|
+
/* argv[0] - symbol to call *
|
172
|
+
* argv[1] - signature *
|
173
|
+
* argv[2] - first parameter *
|
174
|
+
* argv[x] - parameter x-2 */
|
175
|
+
|
176
|
+
rb_dcLibHandle* h;
|
177
|
+
DCpointer fptr;
|
178
|
+
int i, t, b;
|
179
|
+
VALUE r;
|
180
|
+
DCCallVM* cvm;
|
181
|
+
const char* sig;
|
182
|
+
|
183
|
+
|
184
|
+
/* Security checks. */
|
185
|
+
if(argc < 2)
|
186
|
+
rb_raise(rb_eRuntimeError, "wrong number of arguments for function call");
|
187
|
+
|
188
|
+
if(TYPE(argv[0]) != T_SYMBOL)
|
189
|
+
rb_raise(rb_eRuntimeError, "syntax error - argument 0 must be of type 'Symbol'");
|
190
|
+
|
191
|
+
if(TYPE(argv[1]) != T_STRING)
|
192
|
+
rb_raise(rb_eRuntimeError, "syntax error - argument 1 must be of type 'String'");
|
193
|
+
|
194
|
+
Data_Get_Struct(self, rb_dcLibHandle, h);
|
195
|
+
cvm = h->cvm;
|
196
|
+
|
197
|
+
if(argc != RSTRING_LEN(argv[1])) /* Don't count the return value in the signature @@@ write something more secure */
|
198
|
+
rb_raise(rb_eRuntimeError, "number of provided arguments doesn't match signature");
|
199
|
+
|
200
|
+
ExtLib_SecCheckLib(h);
|
201
|
+
|
202
|
+
|
203
|
+
/* Flush old arguments. */
|
204
|
+
dcReset(cvm);
|
205
|
+
|
206
|
+
|
207
|
+
/* Get a pointer to the function and start pushing. */
|
208
|
+
fptr = (DCpointer)dlFindSymbol(h->lib, rb_id2name(SYM2ID(argv[0])));
|
209
|
+
sig = RSTRING_PTR(argv[1]);
|
210
|
+
|
211
|
+
for(i=2; i<argc; ++i) {
|
212
|
+
t = TYPE(argv[i]);
|
213
|
+
|
214
|
+
switch(sig[i-2]) {
|
215
|
+
case DC_SIGCHAR_BOOL:
|
216
|
+
b = 1;
|
217
|
+
switch(t) {
|
218
|
+
case T_TRUE: dcArgBool(cvm, DC_TRUE); break; /* TrueClass. */
|
219
|
+
case T_FALSE: /* FalseClass. */
|
220
|
+
case T_NIL: dcArgBool(cvm, DC_FALSE); break; /* NilClass. */
|
221
|
+
case T_FIXNUM: dcArgBool(cvm, FIX2LONG(argv[i]) != 0); break; /* Fixnum. */
|
222
|
+
default: b = 0; break;
|
223
|
+
}
|
224
|
+
break;
|
225
|
+
|
226
|
+
case DC_SIGCHAR_CHAR:
|
227
|
+
case DC_SIGCHAR_UCHAR: if(b = (t == T_FIXNUM)) dcArgChar (cvm, (DCchar) FIX2LONG(argv[i])); break;
|
228
|
+
case DC_SIGCHAR_SHORT:
|
229
|
+
case DC_SIGCHAR_USHORT: if(b = (t == T_FIXNUM)) dcArgShort (cvm, (DCshort) FIX2LONG(argv[i])); break;
|
230
|
+
case DC_SIGCHAR_INT:
|
231
|
+
case DC_SIGCHAR_UINT: if(b = (t == T_FIXNUM)) dcArgInt (cvm, (DCint) FIX2LONG(argv[i])); break;
|
232
|
+
case DC_SIGCHAR_LONG:
|
233
|
+
case DC_SIGCHAR_ULONG: if(b = (t == T_FIXNUM)) dcArgLong (cvm, (DClong) FIX2LONG(argv[i])); break;
|
234
|
+
case DC_SIGCHAR_LONGLONG:
|
235
|
+
case DC_SIGCHAR_ULONGLONG: if(b = (t == T_FIXNUM)) dcArgLongLong(cvm, (DClonglong)FIX2LONG(argv[i])); break;
|
236
|
+
case DC_SIGCHAR_FLOAT: if(b = (t == T_FLOAT)) dcArgFloat (cvm, (DCfloat) RFLOAT_VALUE(argv[i])); break;
|
237
|
+
case DC_SIGCHAR_DOUBLE: if(b = (t == T_FLOAT)) dcArgDouble (cvm, (DCdouble) RFLOAT_VALUE(argv[i])); break;
|
238
|
+
|
239
|
+
case DC_SIGCHAR_POINTER:
|
240
|
+
case DC_SIGCHAR_STRING:
|
241
|
+
b = 1;
|
242
|
+
switch(t) {
|
243
|
+
case T_STRING: dcArgPointer(cvm, RSTRING_PTR(argv[i])); break; /* String. */
|
244
|
+
default: b = 0; break;
|
245
|
+
}
|
246
|
+
break;
|
247
|
+
|
248
|
+
default:
|
249
|
+
b = 0;
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
if(!b)
|
255
|
+
rb_raise(rb_eRuntimeError, "syntax error in signature or type mismatch at argument %d", i-2);
|
256
|
+
}
|
257
|
+
|
258
|
+
|
259
|
+
/* Get the return type and call the function. */
|
260
|
+
switch(sig[i-1]) {
|
261
|
+
case DC_SIGCHAR_VOID: r = Qnil; dcCallVoid (cvm, fptr); break;
|
262
|
+
case DC_SIGCHAR_BOOL: r = dcCallBool (cvm, fptr) ? Qtrue : Qfalse; break;
|
263
|
+
case DC_SIGCHAR_CHAR:
|
264
|
+
case DC_SIGCHAR_UCHAR: r = CHR2FIX( dcCallChar (cvm, fptr)); break;
|
265
|
+
case DC_SIGCHAR_SHORT:
|
266
|
+
case DC_SIGCHAR_USHORT: r = INT2FIX( dcCallShort (cvm, fptr)); break;
|
267
|
+
case DC_SIGCHAR_INT:
|
268
|
+
case DC_SIGCHAR_UINT: r = INT2FIX( dcCallInt (cvm, fptr)); break;
|
269
|
+
case DC_SIGCHAR_LONG:
|
270
|
+
case DC_SIGCHAR_ULONG: r = INT2FIX( dcCallLong (cvm, fptr)); break;
|
271
|
+
case DC_SIGCHAR_LONGLONG:
|
272
|
+
case DC_SIGCHAR_ULONGLONG: r = INT2FIX( dcCallLongLong(cvm, fptr)); break;
|
273
|
+
case DC_SIGCHAR_FLOAT: r = rb_float_new(dcCallFloat (cvm, fptr)); break;
|
274
|
+
case DC_SIGCHAR_DOUBLE: r = rb_float_new(dcCallDouble (cvm, fptr)); break;
|
275
|
+
case DC_SIGCHAR_STRING: r = rb_str_new2( dcCallPointer (cvm, fptr)); break;
|
276
|
+
case DC_SIGCHAR_POINTER:
|
277
|
+
default:
|
278
|
+
rb_raise(rb_eRuntimeError, "unsupported return type or syntax error in signature");
|
279
|
+
}
|
280
|
+
|
281
|
+
return r;
|
282
|
+
}
|
283
|
+
|
284
|
+
|
285
|
+
/* Main initialization. */
|
286
|
+
void Init_rbdc()
|
287
|
+
{
|
288
|
+
rb_dcModule = rb_define_module("Dyncall");
|
289
|
+
|
290
|
+
/* Handle to the external dynamic library. */
|
291
|
+
rb_dcExtLib = rb_define_class_under(rb_dcModule, "ExtLib", rb_cObject);
|
292
|
+
|
293
|
+
/* Class allocators. */
|
294
|
+
rb_define_alloc_func(rb_dcExtLib, AllocExtLib);
|
295
|
+
|
296
|
+
/* Methods. */
|
297
|
+
rb_define_method(rb_dcExtLib, "load", &ExtLib_Load, 1);
|
298
|
+
rb_define_method(rb_dcExtLib, "exists?", &ExtLib_ExistsQ, 1);
|
299
|
+
rb_define_method(rb_dcExtLib, "syms_init", &ExtLib_SymsInit, 1);
|
300
|
+
rb_define_method(rb_dcExtLib, "syms_count", &ExtLib_SymsCount, 0);
|
301
|
+
rb_define_method(rb_dcExtLib, "syms_each", &ExtLib_SymsEach, -1);
|
302
|
+
rb_define_method(rb_dcExtLib, "call", &ExtLib_Call, -1);
|
303
|
+
}
|
304
|
+
|
data/dyncall/AUTHORS
ADDED
data/dyncall/BUGS
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
- add support for SELinux; object files need to be tagged with section '.section .note.GNU-stack,"",%progbits'
|
2
|
+
- dyncall sparc v7/v8: -xO3 on SunPro segfaults in tests.
|
3
|
+
- dyncall sparc64 port: works fine on Debian 6, but has issues on OpenBSD and Solaris regarding passing of float and double values.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Package: dyncall
|
2
|
+
# File: CMakeLists.txt
|
3
|
+
# Description: DynCall Project cmake files
|
4
|
+
# License:
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Daniel Adler <dadler@uni-goettingen.de>
|
7
|
+
#
|
8
|
+
# Permission to use, copy, modify, and distribute this software for any
|
9
|
+
# purpose with or without fee is hereby granted, provided that the above
|
10
|
+
# copyright notice and this permission notice appear in all copies.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
13
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
14
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
15
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
16
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
17
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
18
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
19
|
+
#
|
20
|
+
|
21
|
+
cmake_minimum_required (VERSION 2.6)
|
22
|
+
project(DynCall)
|
23
|
+
|
24
|
+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "dyncall enables dynamic invocation of machine-level function calls")
|
25
|
+
set(CPACK_PACKAGE_VENDOR "dyncall project")
|
26
|
+
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/doc/Description.txt")
|
27
|
+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/doc/License.txt")
|
28
|
+
if(APPLE)
|
29
|
+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/doc/Description.txt")
|
30
|
+
endif(APPLE)
|
31
|
+
set(CPACK_PACKAGE_NAME "dyncall")
|
32
|
+
include(CPack)
|
33
|
+
|
34
|
+
# add cmake modules shipped with the package to cmake's module path.
|
35
|
+
# currently we have no use for this, but maybe later..
|
36
|
+
#set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/buildsys/cmake/Modules" "${CMAKE_MODULE_PATH}")
|
37
|
+
|
38
|
+
|
39
|
+
if(MSVC)
|
40
|
+
enable_language(ASM_MASM)
|
41
|
+
#if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
42
|
+
# set(CMAKE_ASM_COMPILER "ml64")
|
43
|
+
#else()
|
44
|
+
# set(CMAKE_ASM_COMPILER "ml")
|
45
|
+
#endif()
|
46
|
+
#set(CMAKE_ASM_COMPILER_ARG1 "/c")
|
47
|
+
#set(CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS asm)
|
48
|
+
#set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> <FLAGS> /c /Fo <OBJECT> <SOURCE>")
|
49
|
+
elseif(CMAKE_COMPILER_IS_GNUCC)
|
50
|
+
# when used in shared libraries, -fPIC is required by several architectures
|
51
|
+
# and platforms (observed on AMD64, Solaris/Sparc).
|
52
|
+
# we enable it per default here.
|
53
|
+
add_definitions("-fPIC")
|
54
|
+
# enable gcc as front-end to assembler for .S files
|
55
|
+
set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}")
|
56
|
+
set(CMAKE_ASM_COMPILER_ARG1 "${CPPFLAGS} -c")
|
57
|
+
enable_language(ASM)
|
58
|
+
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro")
|
59
|
+
set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}")
|
60
|
+
set(CMAKE_ASM_COMPILER_ARG1 "${CPPFLAGS} -c")
|
61
|
+
enable_language(ASM)
|
62
|
+
endif()
|
63
|
+
|
64
|
+
|
65
|
+
add_subdirectory(dynload)
|
66
|
+
add_subdirectory(dyncall)
|
67
|
+
add_subdirectory(dyncallback)
|
68
|
+
add_subdirectory(doc/manual EXCLUDE_FROM_ALL)
|
69
|
+
add_subdirectory(test EXCLUDE_FROM_ALL)
|
70
|
+
|
71
|
+
# install cmake Find scripts (disabled per default)
|
72
|
+
|
73
|
+
option(INSTALL_CMAKE_MODULES "install cmake modules to locate dyncall" "NO")
|
74
|
+
|
75
|
+
if(INSTALL_CMAKE_MODULES)
|
76
|
+
file(GLOB INSTALL_CMAKE_MODULES_FILES buildsys/cmake/Modules/Find*.cmake)
|
77
|
+
install(FILES ${INSTALL_CMAKE_MODULES_FILES} DESTINATION ${CMAKE_ROOT}/Modules)
|
78
|
+
endif(INSTALL_CMAKE_MODULES)
|
79
|
+
|