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,75 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_callvm_x86.h
|
6
|
+
Description: Call virtual machine for x86 architecture header
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
#ifndef DYNCALL_CALLVM_X86_H
|
28
|
+
#define DYNCALL_CALLVM_X86_H
|
29
|
+
|
30
|
+
/*
|
31
|
+
|
32
|
+
dyncall callvm for 32bit X86 architectures
|
33
|
+
Copyright 2007 Daniel Adler.
|
34
|
+
|
35
|
+
SUPPORTED CALLING CONVENTIONS
|
36
|
+
cdecl,stdcall,fastcall,thiscall,msthiscall
|
37
|
+
|
38
|
+
REVISION
|
39
|
+
2007/12/10 initial
|
40
|
+
|
41
|
+
*/
|
42
|
+
|
43
|
+
|
44
|
+
#include "dyncall_call_x86.h"
|
45
|
+
#include "dyncall_callvm.h"
|
46
|
+
#include "dyncall_vector.h"
|
47
|
+
|
48
|
+
typedef struct DCCallVM_x86_ DCCallVM_x86;
|
49
|
+
|
50
|
+
struct DCCallVM_x86_
|
51
|
+
{
|
52
|
+
DCCallVM mInterface;
|
53
|
+
DCpointer mpCallFunc;
|
54
|
+
int mIntRegs; /* used by fastcall implementation */
|
55
|
+
DCVecHead mVecHead;
|
56
|
+
};
|
57
|
+
|
58
|
+
/* Plan9 has no support for OS foreign calling conventions at
|
59
|
+
the time, and vice-versa. */
|
60
|
+
#if defined(DC__OS_Plan9)
|
61
|
+
|
62
|
+
DCCallVM* dcNewCallVM_x86_plan9(DCsize size);
|
63
|
+
|
64
|
+
#else
|
65
|
+
|
66
|
+
DCCallVM* dcNewCallVM_x86_cdecl(DCsize size);
|
67
|
+
DCCallVM* dcNewCallVM_x86_win32_std(DCsize size);
|
68
|
+
DCCallVM* dcNewCallVM_x86_win32_fast_ms(DCsize size);
|
69
|
+
DCCallVM* dcNewCallVM_x86_win32_fast_gnu(DCsize size);
|
70
|
+
DCCallVM* dcNewCallVM_x86_win32_this_ms(DCsize size);
|
71
|
+
|
72
|
+
#endif
|
73
|
+
|
74
|
+
#endif /* DYNCALL_CALLVM_X86_H */
|
75
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_config.h
|
6
|
+
Description: Macro configuration file for non-standard C types
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
/*
|
28
|
+
|
29
|
+
dyncall type configuration
|
30
|
+
|
31
|
+
REVISION
|
32
|
+
2007/12/11 initial
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
#ifndef DYNCALL_CONFIG_H
|
37
|
+
#define DYNCALL_CONFIG_H
|
38
|
+
|
39
|
+
#include "dyncall_macros.h"
|
40
|
+
|
41
|
+
#define DC_BOOL int
|
42
|
+
#define DC_LONG_LONG long long
|
43
|
+
#define DC_POINTER void*
|
44
|
+
|
45
|
+
#endif /* DYNCALL_CONFIG_H */
|
46
|
+
|
@@ -0,0 +1,248 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_macros.h
|
6
|
+
Description: Platform detection macros
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
/*
|
28
|
+
|
29
|
+
dyncall macros
|
30
|
+
|
31
|
+
Platform detection, specific defines and configuration.
|
32
|
+
The purpose of this file is to provide coherent platform and compiler
|
33
|
+
specific defines. So instead of defines like WIN32, _OpenBSD_ or
|
34
|
+
__GNUC__, one should use DC__OS_Win32, DC__OS_OpenBSD or DC__C_GNU,
|
35
|
+
respectively.
|
36
|
+
|
37
|
+
REVISION
|
38
|
+
2007/12/11 initial
|
39
|
+
|
40
|
+
*/
|
41
|
+
|
42
|
+
|
43
|
+
#ifndef DYNCALL_MACROS_H
|
44
|
+
#define DYNCALL_MACROS_H
|
45
|
+
|
46
|
+
|
47
|
+
/* Platform specific defines. */
|
48
|
+
|
49
|
+
/* MS Windows XP x64/Vista64 or later. */
|
50
|
+
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
|
51
|
+
#define DC__OS_Win64
|
52
|
+
|
53
|
+
/* MS Windows NT/95/98/ME/2000/XP/Vista32. */
|
54
|
+
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(__WINDOWS__) || defined(_WINDOWS)
|
55
|
+
#define DC__OS_Win32
|
56
|
+
|
57
|
+
/* All the OS' based on Darwin OS (MacOS X, OpenDarwin). Note that '__APPLE__' may be defined for classic MacOS, too. */
|
58
|
+
/* __MACOSX__ is not defined in gcc assembler mode (switch: -S) */
|
59
|
+
/* @@@ TODO: Check for Classic OS */
|
60
|
+
|
61
|
+
#elif defined(__APPLE__) || defined(__Darwin__)
|
62
|
+
# define DC__OS_Darwin
|
63
|
+
# if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
|
64
|
+
# define DC__OS_IPhone
|
65
|
+
# else /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */
|
66
|
+
# define DC__OS_MacOSX
|
67
|
+
# endif
|
68
|
+
|
69
|
+
/* The most popular open source Unix-like OS - Linux. */
|
70
|
+
#elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
|
71
|
+
#define DC__OS_Linux
|
72
|
+
|
73
|
+
/* The most powerful open source Unix-like OS - FreeBSD. */
|
74
|
+
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
75
|
+
#define DC__OS_FreeBSD
|
76
|
+
|
77
|
+
/* The most secure open source Unix-like OS - OpenBSD. */
|
78
|
+
#elif defined(__OpenBSD__)
|
79
|
+
#define DC__OS_OpenBSD
|
80
|
+
|
81
|
+
/* The most portable open source Unix-like OS - NetBSD. */
|
82
|
+
#elif defined(__NetBSD__)
|
83
|
+
#define DC__OS_NetBSD
|
84
|
+
|
85
|
+
/* The FreeBSD fork having heavy clusterization in mind - DragonFlyBSD. */
|
86
|
+
#elif defined(__DragonFly__)
|
87
|
+
#define DC__OS_DragonFlyBSD
|
88
|
+
|
89
|
+
/* Sun's Unix-like OS - SunOS / Solaris. */
|
90
|
+
#elif defined(__sun__) || defined(__sun) || defined(sun)
|
91
|
+
#define DC__OS_SunOS
|
92
|
+
|
93
|
+
/* The "Linux-like environment for Windows" - Cygwin. */
|
94
|
+
#elif defined(__CYGWIN__)
|
95
|
+
#define DC__OS_Cygwin
|
96
|
+
|
97
|
+
/* The "Minimalist GNU for Windows" - MinGW. */
|
98
|
+
#elif defined(__MINGW__)/*@@@*/
|
99
|
+
#define DC__OS_MinGW
|
100
|
+
|
101
|
+
/* The Nintendo DS (homebrew) using devkitpro. */
|
102
|
+
#elif defined(__nds__)
|
103
|
+
#define DC__OS_NDS
|
104
|
+
|
105
|
+
/* The PlayStation Portable (homebrew) SDK. */
|
106
|
+
#elif defined(__psp__) || defined(PSP)
|
107
|
+
#define DC__OS_PSP
|
108
|
+
|
109
|
+
/* Haiku (BeOS alike). */
|
110
|
+
#elif defined(__HAIKU__)
|
111
|
+
#define DC__OS_BeOS
|
112
|
+
|
113
|
+
/* The Unix successor - Plan9 from Bell Labs */
|
114
|
+
#elif defined(Plan9) || defined(__Plan9__)
|
115
|
+
#define DC__OS_Plan9
|
116
|
+
|
117
|
+
/* Digital's Unix-like OS - VMS */
|
118
|
+
#elif defined(__vms)
|
119
|
+
#define DC__OS_VMS
|
120
|
+
|
121
|
+
#elif defined(__minix)
|
122
|
+
#define DC__OS_Minix
|
123
|
+
|
124
|
+
#else
|
125
|
+
#error Unsupported OS.
|
126
|
+
#endif
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
/* Compiler specific defines. Do not change the order, because */
|
131
|
+
/* some of the compilers define flags for compatible ones, too. */
|
132
|
+
|
133
|
+
/* Intel's C/C++ compiler. */
|
134
|
+
#if defined(__INTEL_COMPILER)
|
135
|
+
#define DC__C_Intel
|
136
|
+
|
137
|
+
/* MS C/C++ compiler. */
|
138
|
+
#elif defined(_MSC_VER)
|
139
|
+
#define DC__C_MSVC
|
140
|
+
|
141
|
+
/* The GNU Compiler Collection - GCC. */
|
142
|
+
#elif defined(__GNUC__)
|
143
|
+
#define DC__C_GNU
|
144
|
+
|
145
|
+
/* Watcom compiler. */
|
146
|
+
#elif defined(__WATCOMC__)
|
147
|
+
#define DC__C_WATCOM
|
148
|
+
|
149
|
+
/* Portable C Compiler. */
|
150
|
+
#elif defined(__PCC__)
|
151
|
+
#define DC__C_PCC
|
152
|
+
|
153
|
+
/* Sun Pro C. */
|
154
|
+
#elif defined(__SUNPRO_C)
|
155
|
+
#define DC__C_SUNPRO
|
156
|
+
|
157
|
+
/* Undetected C Compiler. */
|
158
|
+
#else
|
159
|
+
#define DC__C_UNKNOWN
|
160
|
+
#endif
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
/* Architecture. */
|
165
|
+
|
166
|
+
/* Check architecture. */
|
167
|
+
#if defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__386__) || defined(__i386)
|
168
|
+
# define DC__Arch_Intel_x86
|
169
|
+
#elif defined(_M_X64_) || defined(_M_AMD64) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
170
|
+
# define DC__Arch_AMD64
|
171
|
+
#elif defined(_M_IA64) || defined(__ia64__)
|
172
|
+
# define DC__Arch_Itanium
|
173
|
+
#elif defined(_M_PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__ppc__) || defined(__power__)
|
174
|
+
# define DC__Arch_PowerPC
|
175
|
+
#elif defined(__ppc64__) || defined(_ARCH_PPC64) || defined(__power64__)
|
176
|
+
# define DC__Arch_PPC64
|
177
|
+
#elif defined(__mips64__) || defined(__mips64)
|
178
|
+
# define DC__Arch_MIPS64
|
179
|
+
#elif defined(_M_MRX000) || defined(__mips__) || defined(__mips) || defined(_mips)
|
180
|
+
# define DC__Arch_MIPS
|
181
|
+
#elif defined(__arm__)
|
182
|
+
# define DC__Arch_ARM
|
183
|
+
#elif defined(__sh__)
|
184
|
+
# define DC__Arch_SuperH
|
185
|
+
#elif defined(__sparcv9) || defined(__sparc64__) || ( defined(__sparc) && defined(__arch64__) )
|
186
|
+
/* this could be needed on Linux/GNU sparc64 in the future: || ( defined(__sparc) && defined(__arch64__) ) */
|
187
|
+
# define DC__Arch_Sparcv9
|
188
|
+
#elif defined(__sparc)
|
189
|
+
# define DC__Arch_Sparc
|
190
|
+
#endif
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
/* Rough OS classification. */
|
195
|
+
|
196
|
+
#if defined(DC__OS_Win32) || defined(DC__OS_Win64)
|
197
|
+
# define DC_WINDOWS
|
198
|
+
#elif defined(DC__OS_Plan9)
|
199
|
+
# define DC_PLAN9
|
200
|
+
#elif defined(DC__OS_NDS) || defined(DC__OS_PSP)
|
201
|
+
# define DC_OTHER
|
202
|
+
#else
|
203
|
+
# define DC_UNIX
|
204
|
+
#endif
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
/* Misc machine-dependent quirks. */
|
209
|
+
|
210
|
+
#if defined(__arm__) && !defined(__thumb__)
|
211
|
+
# define DC__Arch_ARM_ARM
|
212
|
+
#elif defined(__arm__) && defined(__thumb__)
|
213
|
+
# define DC__Arch_ARM_THUMB
|
214
|
+
#endif
|
215
|
+
|
216
|
+
#if defined(DC__Arch_ARM_ARM) || defined(DC__Arch_ARM_THUMB)
|
217
|
+
# if defined(__ARM_EABI__) || defined(DC__OS_NDS)
|
218
|
+
# if defined (__ARM_PCS_VFP) && (__ARM_PCS_VFP == 1)
|
219
|
+
# define DC__ABI_ARM_HF
|
220
|
+
# else
|
221
|
+
# define DC__ABI_ARM_EABI
|
222
|
+
# endif
|
223
|
+
# elif defined(__APCS_32__)
|
224
|
+
# define DC__ABI_ARM_OABI
|
225
|
+
# endif
|
226
|
+
#endif /* ARM */
|
227
|
+
|
228
|
+
#if defined(DC__Arch_MIPS) || defined(DC__Arch_MIPS64)
|
229
|
+
# if defined(_ABIO32) || defined(_MIPS_ARCH_MIPS1) || defined(_MIPS_ARCH_MIPS2)
|
230
|
+
# define DC__ABI_MIPS_O32
|
231
|
+
# elif defined(_ABIN32)
|
232
|
+
# define DC__ABI_MIPS_N32
|
233
|
+
# elif defined(_ABI64)
|
234
|
+
# define DC__ABI_MIPS_N64
|
235
|
+
# else
|
236
|
+
# define DC__ABI_MIPS_EABI
|
237
|
+
# endif
|
238
|
+
#endif /* MIPS */
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
/* Internal macro/tag. */
|
243
|
+
#if !defined(DC_API)
|
244
|
+
#define DC_API
|
245
|
+
#endif
|
246
|
+
|
247
|
+
#endif /* DYNCALL_MACROS_H */
|
248
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_signature.h
|
6
|
+
Description: Type and calling-convention signature character defines
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2007-2011 Daniel Adler <dadler@uni-goettingen.de>,
|
10
|
+
Tassilo Philipp <tphilipp@potion-studios.com>
|
11
|
+
|
12
|
+
Permission to use, copy, modify, and distribute this software for any
|
13
|
+
purpose with or without fee is hereby granted, provided that the above
|
14
|
+
copyright notice and this permission notice appear in all copies.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
17
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
18
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
19
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
20
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
21
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
22
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
/*
|
28
|
+
|
29
|
+
dyncall signature characters
|
30
|
+
|
31
|
+
REVISION
|
32
|
+
2007/12/11 initial
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
|
37
|
+
#ifndef DYNCALL_SIGNATURE_H
|
38
|
+
#define DYNCALL_SIGNATURE_H
|
39
|
+
|
40
|
+
typedef char DCsigchar;
|
41
|
+
|
42
|
+
#define DC_SIGCHAR_VOID 'v'
|
43
|
+
#define DC_SIGCHAR_BOOL 'B'
|
44
|
+
#define DC_SIGCHAR_CHAR 'c'
|
45
|
+
#define DC_SIGCHAR_UCHAR 'C'
|
46
|
+
#define DC_SIGCHAR_SHORT 's'
|
47
|
+
#define DC_SIGCHAR_USHORT 'S'
|
48
|
+
#define DC_SIGCHAR_INT 'i'
|
49
|
+
#define DC_SIGCHAR_UINT 'I'
|
50
|
+
#define DC_SIGCHAR_LONG 'j'
|
51
|
+
#define DC_SIGCHAR_ULONG 'J'
|
52
|
+
#define DC_SIGCHAR_LONGLONG 'l'
|
53
|
+
#define DC_SIGCHAR_ULONGLONG 'L'
|
54
|
+
#define DC_SIGCHAR_FLOAT 'f'
|
55
|
+
#define DC_SIGCHAR_DOUBLE 'd'
|
56
|
+
#define DC_SIGCHAR_POINTER 'p'
|
57
|
+
#define DC_SIGCHAR_STRING 'Z'
|
58
|
+
#define DC_SIGCHAR_STRUCT 'T'
|
59
|
+
#define DC_SIGCHAR_ENDARG ')' /* also works for end struct */
|
60
|
+
|
61
|
+
/* callback signatures */
|
62
|
+
|
63
|
+
#define DC_SIGCHAR_CC_PREFIX '_'
|
64
|
+
#define DC_SIGCHAR_CC_ELLIPSIS 'e'
|
65
|
+
#define DC_SIGCHAR_CC_STDCALL 's'
|
66
|
+
#define DC_SIGCHAR_CC_FASTCALL_GNU 'f'
|
67
|
+
#define DC_SIGCHAR_CC_FASTCALL_MS 'F'
|
68
|
+
#define DC_SIGCHAR_CC_THISCALL_MS '+'
|
69
|
+
|
70
|
+
#endif /* DYNCALL_SIGNATURE_H */
|
71
|
+
|
@@ -0,0 +1,255 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Package: dyncall
|
4
|
+
Library: dyncall
|
5
|
+
File: dyncall/dyncall_struct.c
|
6
|
+
Description: C interface to compute struct size
|
7
|
+
License:
|
8
|
+
|
9
|
+
Copyright (c) 2010-2011 Olivier Chafik <olivier.chafik@centraliens.net>
|
10
|
+
|
11
|
+
Permission to use, copy, modify, and distribute this software for any
|
12
|
+
purpose with or without fee is hereby granted, provided that the above
|
13
|
+
copyright notice and this permission notice appear in all copies.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
16
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
17
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
18
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
19
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
20
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
21
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
22
|
+
|
23
|
+
*/
|
24
|
+
|
25
|
+
|
26
|
+
#include "dyncall.h"
|
27
|
+
#include "dyncall_signature.h"
|
28
|
+
#include "dyncall_struct.h"
|
29
|
+
#include "dyncall_alloc.h"
|
30
|
+
#include <stdio.h>
|
31
|
+
#include <assert.h>
|
32
|
+
|
33
|
+
|
34
|
+
DCstruct* dcNewStruct(DCsize fieldCount, DCint alignment)
|
35
|
+
{
|
36
|
+
DCstruct* s = (DCstruct*)dcAllocMem(sizeof(DCstruct));
|
37
|
+
s->pCurrentStruct = s;
|
38
|
+
s->pLastStruct = NULL;
|
39
|
+
s->nextField = 0;
|
40
|
+
s->fieldCount = fieldCount;
|
41
|
+
s->alignment = alignment;
|
42
|
+
s->size = 0;
|
43
|
+
s->pFields = (DCfield*)dcAllocMem(fieldCount * sizeof(DCfield));
|
44
|
+
return s;
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
void dcStructField(DCstruct* s, DCint type, DCint alignment, DCsize arrayLength)
|
49
|
+
{
|
50
|
+
DCfield *f;
|
51
|
+
if (type == DC_SIGCHAR_STRING) {
|
52
|
+
assert(!"Use dcSubStruct instead !!!");
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
assert(s && s->pCurrentStruct);
|
56
|
+
assert(s->pCurrentStruct->nextField <= (DCint)s->pCurrentStruct->fieldCount - 1);
|
57
|
+
f = s->pCurrentStruct->pFields + (s->pCurrentStruct->nextField++);
|
58
|
+
f->type = type;
|
59
|
+
f->alignment = alignment;
|
60
|
+
f->arrayLength = arrayLength;
|
61
|
+
f->pSubStruct = NULL;
|
62
|
+
switch (type) {
|
63
|
+
case DC_SIGCHAR_BOOL: f->size = sizeof(DCbool); break;
|
64
|
+
case DC_SIGCHAR_CHAR:
|
65
|
+
case DC_SIGCHAR_UCHAR: f->size = sizeof(DCchar); break;
|
66
|
+
case DC_SIGCHAR_SHORT:
|
67
|
+
case DC_SIGCHAR_USHORT: f->size = sizeof(DCshort); break;
|
68
|
+
case DC_SIGCHAR_INT:
|
69
|
+
case DC_SIGCHAR_UINT: f->size = sizeof(DCint); break;
|
70
|
+
case DC_SIGCHAR_LONG:
|
71
|
+
case DC_SIGCHAR_ULONG: f->size = sizeof(DClong); break;
|
72
|
+
case DC_SIGCHAR_LONGLONG:
|
73
|
+
case DC_SIGCHAR_ULONGLONG: f->size = sizeof(DClonglong); break;
|
74
|
+
case DC_SIGCHAR_FLOAT: f->size = sizeof(DCfloat); break;
|
75
|
+
case DC_SIGCHAR_DOUBLE: f->size = sizeof(DCdouble); break;
|
76
|
+
case DC_SIGCHAR_POINTER:
|
77
|
+
case DC_SIGCHAR_STRING: f->size = sizeof(DCpointer); break;
|
78
|
+
default: assert(0);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
void dcSubStruct(DCstruct* s, DCsize fieldCount, DCint alignment, DCsize arrayLength)
|
84
|
+
{
|
85
|
+
DCfield *f = s->pCurrentStruct->pFields + (s->pCurrentStruct->nextField++);
|
86
|
+
f->type = DC_SIGCHAR_STRUCT;
|
87
|
+
f->arrayLength = arrayLength;
|
88
|
+
f->alignment = alignment;
|
89
|
+
f->pSubStruct = dcNewStruct(fieldCount, alignment);
|
90
|
+
f->pSubStruct->pLastStruct = s->pCurrentStruct;
|
91
|
+
s->pCurrentStruct = f->pSubStruct;
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
static void dcAlign(DCsize *size, DCsize alignment)
|
96
|
+
{
|
97
|
+
DCsize mod = (*size) % alignment;
|
98
|
+
if (mod) {
|
99
|
+
DCsize rest = alignment - mod;
|
100
|
+
(*size) += rest;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
|
105
|
+
static void dcComputeStructSize(DCstruct* s)
|
106
|
+
{
|
107
|
+
DCsize i;
|
108
|
+
assert(s);
|
109
|
+
for (i = 0; i < s->fieldCount; i++) {
|
110
|
+
DCfield *f = s->pFields + i;
|
111
|
+
DCsize fieldAlignment;
|
112
|
+
if (f->type == DC_SIGCHAR_STRUCT) {
|
113
|
+
dcComputeStructSize(f->pSubStruct);
|
114
|
+
f->size = f->pSubStruct->size;
|
115
|
+
fieldAlignment = f->pSubStruct->alignment;
|
116
|
+
} else {
|
117
|
+
fieldAlignment = f->size;
|
118
|
+
}
|
119
|
+
if (!f->alignment)
|
120
|
+
f->alignment = fieldAlignment;
|
121
|
+
|
122
|
+
if (f->alignment > s->alignment)
|
123
|
+
s->alignment = f->alignment;
|
124
|
+
|
125
|
+
f->size *= f->arrayLength;
|
126
|
+
|
127
|
+
/*printf("FIELD %d, size = %d, alignment = %d\n", (int)i, (int)f->size, (int)f->alignment);@@@*/
|
128
|
+
}
|
129
|
+
for (i = 0; i < s->fieldCount; i++) {
|
130
|
+
DCfield *f = s->pFields + i;
|
131
|
+
dcAlign(&s->size, f->alignment);
|
132
|
+
s->size += f->size;
|
133
|
+
}
|
134
|
+
dcAlign(&s->size, s->alignment);
|
135
|
+
|
136
|
+
/*printf("STRUCT size = %d, alignment = %d\n", (int)s->size, (int)s->alignment);@@@*/
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
void dcCloseStruct(DCstruct* s)
|
141
|
+
{
|
142
|
+
assert(s);
|
143
|
+
assert(s->pCurrentStruct);
|
144
|
+
assert(s->pCurrentStruct->nextField == s->pCurrentStruct->fieldCount);
|
145
|
+
if (!s->pCurrentStruct->pLastStruct) {
|
146
|
+
dcComputeStructSize(s->pCurrentStruct);
|
147
|
+
}
|
148
|
+
s->pCurrentStruct = s->pCurrentStruct->pLastStruct;
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
void dcFreeStruct(DCstruct* s)
|
153
|
+
{
|
154
|
+
DCsize i;
|
155
|
+
assert(s);
|
156
|
+
for (i = 0; i < s->fieldCount; i++) {
|
157
|
+
DCfield *f = s->pFields + i;
|
158
|
+
if (f->type == DC_SIGCHAR_STRUCT)
|
159
|
+
dcFreeStruct(f->pSubStruct);
|
160
|
+
}
|
161
|
+
free(s->pFields);
|
162
|
+
free(s);
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
DCsize dcStructSize(DCstruct* s)
|
167
|
+
{
|
168
|
+
assert(!s->pCurrentStruct && "Struct was not closed");
|
169
|
+
return s->size;
|
170
|
+
}
|
171
|
+
|
172
|
+
DCsize dcStructAlignment(DCstruct* s)
|
173
|
+
{
|
174
|
+
assert(!s->pCurrentStruct && "Struct was not closed");
|
175
|
+
return s->alignment;
|
176
|
+
}
|
177
|
+
|
178
|
+
|
179
|
+
void dcArgStructUnroll(DCCallVM* vm, DCstruct* s, DCpointer value)
|
180
|
+
{
|
181
|
+
DCsize i;
|
182
|
+
/*printf("UNROLLING STRUCT !\n");@@@*/
|
183
|
+
assert(s && value);
|
184
|
+
for (i = 0; i < s->fieldCount; i++) {
|
185
|
+
DCfield *f = s->pFields + i;
|
186
|
+
DCpointer p = (char*)value + f->offset;
|
187
|
+
switch(f->type) {
|
188
|
+
case DC_SIGCHAR_STRUCT:
|
189
|
+
dcArgStruct(vm, f->pSubStruct, p);
|
190
|
+
break;
|
191
|
+
case DC_SIGCHAR_BOOL:
|
192
|
+
dcArgBool (vm, *(DCbool*)p);
|
193
|
+
break;
|
194
|
+
case DC_SIGCHAR_CHAR:
|
195
|
+
case DC_SIGCHAR_UCHAR:
|
196
|
+
dcArgChar (vm, *(DCchar*)p);
|
197
|
+
break;
|
198
|
+
case DC_SIGCHAR_SHORT:
|
199
|
+
case DC_SIGCHAR_USHORT:
|
200
|
+
dcArgShort (vm, *(DCshort*)p);
|
201
|
+
break;
|
202
|
+
case DC_SIGCHAR_INT:
|
203
|
+
case DC_SIGCHAR_UINT:
|
204
|
+
dcArgInt (vm, *(DCint*)p);
|
205
|
+
break;
|
206
|
+
case DC_SIGCHAR_LONG:
|
207
|
+
case DC_SIGCHAR_ULONG:
|
208
|
+
dcArgLong (vm, *(DCulong*)p);
|
209
|
+
break;
|
210
|
+
case DC_SIGCHAR_LONGLONG:
|
211
|
+
case DC_SIGCHAR_ULONGLONG:
|
212
|
+
dcArgLongLong (vm, *(DCulonglong*)p);
|
213
|
+
break;
|
214
|
+
case DC_SIGCHAR_FLOAT:
|
215
|
+
dcArgFloat (vm, *(DCfloat*)p);
|
216
|
+
break;
|
217
|
+
case DC_SIGCHAR_DOUBLE:
|
218
|
+
dcArgDouble (vm, *(DCdouble*)p);
|
219
|
+
break;
|
220
|
+
case DC_SIGCHAR_POINTER:
|
221
|
+
case DC_SIGCHAR_STRING:
|
222
|
+
dcArgPointer (vm, *(DCpointer**)p);
|
223
|
+
break;
|
224
|
+
default:
|
225
|
+
assert(0);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
static DCint readInt(const char** ptr)
|
232
|
+
{
|
233
|
+
return strtol(*ptr, (char**)ptr, 10);/*@@@ enough*/
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
DCstruct* dcDefineStruct(const char* signature)
|
238
|
+
{
|
239
|
+
DCstruct* s;
|
240
|
+
const char* ptr = signature;
|
241
|
+
DCint fieldCount = readInt(&ptr);
|
242
|
+
s = dcNewStruct(fieldCount, DEFAULT_ALIGNMENT);
|
243
|
+
|
244
|
+
while (*ptr) {
|
245
|
+
char type = *(ptr++);
|
246
|
+
if (type == DC_SIGCHAR_STRUCT) {
|
247
|
+
/*dcSubStruct( @@@*/
|
248
|
+
} else {
|
249
|
+
dcStructField(s, type, DEFAULT_ALIGNMENT, readInt(&ptr));
|
250
|
+
}
|
251
|
+
}
|
252
|
+
dcCloseStruct(s);
|
253
|
+
return s;
|
254
|
+
}
|
255
|
+
|