Comparar commits
261 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 38ac62cedd | |||
| ce280731af | |||
| 751fb57f71 | |||
| be7d90abbf | |||
| d59585dd4f | |||
| 7a695707a2 | |||
| 4e590c9450 | |||
| b069d1c9e9 | |||
| 9fa1f7b981 | |||
| 4a68e4cd9d | |||
| 8320b6fd7c | |||
| e40cf0a1c4 | |||
| 19106985d7 | |||
| 3d817c54da | |||
| ca31877107 | |||
| f5f9afefb0 | |||
| d42863603e | |||
| 2c19cf3e31 | |||
| e7dc918c6a | |||
| 64c9e8212a | |||
| 499c39f13d | |||
| bccdae735b | |||
| 58120730a5 | |||
| 5b8db8a680 | |||
| 0acfd583c8 | |||
| 402b7ef67e | |||
| 6944871c42 | |||
| b60da35689 | |||
| 5204feddb1 | |||
| 68156df66b | |||
| a9e8b27285 | |||
| b8f470ddbd | |||
| 9d075dd1d1 | |||
| 4b802c6f60 | |||
| 8ce9344dd0 | |||
| cb2b386791 | |||
| 7ee4681c10 | |||
| 82c0ea9df2 | |||
| 9070d80880 | |||
| 45c53caf94 | |||
| c4947618c1 | |||
| 941ed59c37 | |||
| d76bbec1ab | |||
| f5a1d98cf9 | |||
| b0e6d837f0 | |||
| b1cfb1b733 | |||
| 26a1212546 | |||
| 03b05aaae9 | |||
| f41c87d7c9 | |||
| b74deb5e35 | |||
| 240e2db637 | |||
| 441947b6a4 | |||
| 194bdaffcd | |||
| db6e9ff4c6 | |||
| 57261a1164 | |||
| 0b116bb409 | |||
| a5ad2e5de2 | |||
| b6928ff6c0 | |||
| 4b03dd321c | |||
| f7eefbd3d7 | |||
| b23f7f9b27 | |||
| b95bc7e4c4 | |||
| 1593c0c347 | |||
| c154663455 | |||
| 13bc1901dc | |||
| 4f28322ac2 | |||
| 756e2ced8b | |||
| 1dc78b5209 | |||
| 3464093273 | |||
| 4487214494 | |||
| 6d7e222946 | |||
| d12a6a3178 | |||
| ed9d609c35 | |||
| b86f359d93 | |||
| 02080dfcf8 | |||
| 2768d25884 | |||
| 7bdf9896d2 | |||
| 3b4f84ded8 | |||
| 69abc52731 | |||
| 1671b1fb8b | |||
| 8735f4ef5c | |||
| 86967b5786 | |||
| ca8ceeb130 | |||
| 41d6f8eeea | |||
| 27b7805608 | |||
| fef39f7013 | |||
| b414b54c6b | |||
| ccdbb20ad0 | |||
| eb7e47bf29 | |||
| 53988c7184 | |||
| 9092b2bdc5 | |||
| 068353aa5b | |||
| 95a17ddbf0 | |||
| 6c8c455f5b | |||
| 282032e178 | |||
| af63e6a80d | |||
| a46ba0da29 | |||
| f7738bf65b | |||
| bb11d1fe37 | |||
| d02a2deb52 | |||
| 46105d849d | |||
| f16b6c3482 | |||
| a9cb497045 | |||
| d529a34ecb | |||
| 5394029dc5 | |||
| 28247737ca | |||
| 6448c2d8fb | |||
| 4460ccc8ec | |||
| 2b02a3c533 | |||
| 6705513b86 | |||
| 4bd8d12481 | |||
| ccaf3c283b | |||
| ce4276a0cb | |||
| 709e316e56 | |||
| e46635d6ab | |||
| 0af8677ba4 | |||
| 9ab13daf09 | |||
| 17977fbabc | |||
| 83854047b7 | |||
| 28e56fd587 | |||
| 29fc6308b8 | |||
| 14a7df128d | |||
| dd4ef89d0a | |||
| 830ec91cbf | |||
| aee2d55fab | |||
| 89ed7982e7 | |||
| 9f702c89ab | |||
| 2f76efd0f6 | |||
| fae18c72c3 | |||
| 1586f6ee2b | |||
| 4ce6214526 | |||
| e370e4b65e | |||
| 944de2d3f5 | |||
| f32146368d | |||
| 8d45e9b016 | |||
| 70227861ff | |||
| 20e542516b | |||
| 73ad21df73 | |||
| a67fe7e43d | |||
| a15ddd9f88 | |||
| b27f9bf930 | |||
| d5c28f98f1 | |||
| 16b283ed00 | |||
| 97b43889a1 | |||
| 05efa12411 | |||
| 3e60495232 | |||
| 45522b0710 | |||
| d67d25eb7b | |||
| 2538690fb4 | |||
| 4c23b2518e | |||
| 9daade9816 | |||
| 5f925f0070 | |||
| 38b0cd7780 | |||
| e46391042b | |||
| 553a03b05f | |||
| 24c1cc4efe | |||
| f6eabe7b58 | |||
| de2de1fdc7 | |||
| 8184ac8843 | |||
| a57d82d4cd | |||
| a266ef7337 | |||
| b30ca23180 | |||
| db5c8f00fc | |||
| d1bbacb06e | |||
| bff4e3b0fd | |||
| 14248ddbd9 | |||
| 391f39d291 | |||
| b4354efa8b | |||
| 686588a6e5 | |||
| 294267a605 | |||
| 7b53b9108b | |||
| 15be9ab501 | |||
| 7cfcd2daef | |||
| 6070429eec | |||
| b5f41ef6c7 | |||
| 716588a8fb | |||
| 95bc92f005 | |||
| 23425abe9d | |||
| 3bab5e1e78 | |||
| 79ed7e81b1 | |||
| a59e58cc94 | |||
| 72bd12e394 | |||
| 2c667ca016 | |||
| 209c4d724f | |||
| 95cf641f50 | |||
| 85750fd065 | |||
| 402b5c7f81 | |||
| be6f52b796 | |||
| f4e6c6ad94 | |||
| 99fe59cee9 | |||
| 0e80ba8b91 | |||
| 8965efdce1 | |||
| 1393a94804 | |||
| 52e558d877 | |||
| d9948105f1 | |||
| 87c91c1c04 | |||
| f15e471371 | |||
| fc0a83933d | |||
| f1cf2fe218 | |||
| 7a5679cb65 | |||
| 571b4604db | |||
| 29e15a40db | |||
| 6fb2286fa4 | |||
| ab2f78c7b4 | |||
| f9b918a05b | |||
| a46cde174a | |||
| 6eee0f8741 | |||
| 28d31bb9f6 | |||
| 23128be17f | |||
| 130885fda7 | |||
| c4fc42f8f4 | |||
| 21e73c5fb9 | |||
| b635bf5591 | |||
| be594bb1f6 | |||
| 543e3fca98 | |||
| b385d76dc6 | |||
| 2adc88fec3 | |||
| 2a9e2ceb61 | |||
| 47fa804469 | |||
| f70c01eee7 | |||
| eb4ea07a2d | |||
| 55cd72baaa | |||
| 940076d101 | |||
| 93ebb9f7a9 | |||
| 1a17ea52d8 | |||
| 68bc0c0c7c | |||
| 0e7dd6b350 | |||
| b3b0bf3845 | |||
| ddc32f1e43 | |||
| c9de508a2c | |||
| fac68bca4e | |||
| eaf250c3c6 | |||
| 8b99772d29 | |||
| 862a32e97e | |||
| 6cfb84d6ee | |||
| 2fda7ca6f6 | |||
| f2aecb53bc | |||
| 05fdc2f17a | |||
| b9868b993c | |||
| 573d8eefd1 | |||
| 51d64f29e6 | |||
| a39ab60ae5 | |||
| ba9671fae5 | |||
| a9340f354d | |||
| f9d6b069f7 | |||
| c363d5790d | |||
| 15a50d2a26 | |||
| bffc188151 | |||
| e78205430c | |||
| 4ef76d4f85 | |||
| 967da46793 | |||
| 46899503bd | |||
| 2dcf0f774c | |||
| d669db0cab | |||
| f8aabcc50a | |||
| 4bb3ece8dc | |||
| 495a7765d2 | |||
| 225296f253 | |||
| 52e6900e7a | |||
| 557bff1465 | |||
| add32ac107 |
+8
-8
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
|
||||
+62
-46
@@ -18,40 +18,42 @@
|
||||
* get system process information, basic process control
|
||||
* additional file utilities (meta info, free space, etc)
|
||||
* enforce window minimum/maximum size (workaround java bug)
|
||||
* OSX ObjC access
|
||||
* OSX ObjC access (see rococoa)
|
||||
|
||||
# TODO
|
||||
|
||||
* write structure to contiguous Java array, then write all at once to minimize
|
||||
native calls. Otherwise, structs with lots of fields take a big performance
|
||||
hit making a native call for each field.
|
||||
* make direct calls call back *once* to Java where conversion is required,
|
||||
and process all arguments from there (instead of potentially swapping back
|
||||
and forth multipel times). This also makes it easer to perform conversions
|
||||
(no native changes required).
|
||||
|
||||
* parser (gluegen? swig? others?) to auto-generate JNA interfaces from headers;
|
||||
ideally get the native library build system to output preprocessed headers,
|
||||
otherwise CPP crap is a nightmare to get right.
|
||||
o write SWIG transformer to auto-generate interfaces from header files
|
||||
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
|
||||
|
||||
* stdcall/w32 underscore prefix issue
|
||||
* ppc64 direct/raw failures (multiple)
|
||||
|
||||
* should structure offsets be "long"?
|
||||
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
|
||||
now
|
||||
|
||||
* allow return of W/String[] or Pointer[], if array is NULL-terminated?
|
||||
* combine direct and interface mapping calling code where possible
|
||||
|
||||
* Direct buffers should be used where
|
||||
hotspot inlining can improve performance.
|
||||
* make native dll extraction from jar public, to use with user dlls packaged
|
||||
in a jar
|
||||
|
||||
* Callback.PostCallWrite.write() cf PostCallRead; do Structure.write for any
|
||||
arguments as well
|
||||
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
|
||||
methods out of Structure, to be used by Function w/NativeMapped[] parameter
|
||||
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
|
||||
|
||||
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
|
||||
Can use annotations as shorthand to initialize a map, but basically set up a
|
||||
per-NativeLibrary (or per-Function?) map of methods to mappers.
|
||||
|
||||
Requires separate compilation of annotation handling.
|
||||
|
||||
* ditch type conversion context.
|
||||
|
||||
* packaging: 'types', 'convert/marshal' subpackages?
|
||||
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
|
||||
@@ -61,12 +63,6 @@
|
||||
Pointer into a types subpackage (which would leave just a few top-level
|
||||
classes). Javadoc is cluttered by example classes anyway.
|
||||
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc.
|
||||
|
||||
* support annotations of parameters and return values w/o breaking
|
||||
1.4 compatibility (retroweaver?), e.g.
|
||||
-- retroweaver (requires retroweaver runtime classes to provide annotation
|
||||
@@ -81,14 +77,6 @@
|
||||
this only really applies to NativeLong/IntegerType types that want to use a
|
||||
primitive value instead of creating an object instance.
|
||||
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* flag string(/wstring)-returning methods which need to free their result
|
||||
to avoid leaking memory whan auto-creating strings from the result
|
||||
(since normally we don't take explicit ownership of any returned pointers)
|
||||
@@ -105,9 +93,6 @@
|
||||
"pointer-requiring-free" (which is just Memory). For now, leave it up to
|
||||
the user to manage the pointer, since they have to define the free method
|
||||
anyway. use could always put a finalizer on a PointerType-derived type.
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* if method has "GetLastErrorException/ErrnoException" in its signature, use
|
||||
result codes + GetLastError/errno/errstr to auto-generate
|
||||
runtime exceptions? (cf P/Invoke; also useful for X11 return types)
|
||||
@@ -119,21 +104,22 @@
|
||||
if nonzero ?
|
||||
o otherwise, need an ExceptionOnZero, ExceptionOnNonZero runtime, from which
|
||||
derive GetLastError/ErrnoExceptionOnZero/NZ
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
* universal GCC build w/cross-compile (needs cross compilers...)
|
||||
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
|
||||
Long.SIZE, Integer.SIZE, et al.
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* verify get/set methods vs read/write for performance (Pointer)?
|
||||
* bitfields for structs (how?)
|
||||
|
||||
|
||||
|
||||
|
||||
# DONE
|
||||
* verify get/set methods vs read/write for performance (Pointer)?
|
||||
(see RawTest for performance comparisons)
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
|
||||
* embed version in DLL ('depends'-done)/so (symlink?)
|
||||
* use libffi closure allocation/deallocation
|
||||
|
||||
@@ -253,5 +239,35 @@ transient callbacks, and require callback+dispose for most callbacks?
|
||||
void setWindowMask(Window w, Shape clip);
|
||||
// needs:
|
||||
int findNativeWindow(Window w);
|
||||
|
||||
#MAYBE NOT
|
||||
* should structure offsets be 64-bit? technically yes, but in practice I don't
|
||||
think a structure that big actually works.
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
o when used as struct fields, could allow detection of field order by order
|
||||
of initialization (requires all-or-nothing usage, though)
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
|
||||
|
||||
|
||||
+77
-29
@@ -15,6 +15,7 @@
|
||||
<!-- (all build-related props should go in -dynamic-properties) -->
|
||||
<property name="name" value="jna"/>
|
||||
<property name="jar" value="${name}.jar"/>
|
||||
<property name="testjar" value="${name}-test.jar"/>
|
||||
<property name="debug" value="true"/>
|
||||
<property name="debug.native" value="false"/>
|
||||
<property name="cflags_extra.native" value=""/>
|
||||
@@ -28,21 +29,21 @@
|
||||
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
|
||||
<property name="vendor" value="JNA Development Team"/>
|
||||
<property name="copyright"
|
||||
value="Copyright &copy; 2007-2008 Timothy Wall. All Rights Reserved."/>
|
||||
value="Copyright &copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
|
||||
<buildnumber/>
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="0"/>
|
||||
<property name="jna.revision" value="5"/>
|
||||
<property name="jna.minor" value="2"/>
|
||||
<property name="jna.revision" value="2"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
<property name="jni.major" value="3"/>
|
||||
<property name="jni.minor" value="0"/>
|
||||
<property name="jni.revision" value="4"/>
|
||||
<property name="jni.minor" value="2"/>
|
||||
<property name="jni.revision" value="1"/>
|
||||
<property name="jni.build" value="${build.number}"/>
|
||||
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
|
||||
<property name="jni.md5" value="892beacd437514d23ed9b1cefeb2ead6"/>
|
||||
<property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
|
||||
<property name="spec.title" value="Java Native Access (JNA)"/>
|
||||
<property name="spec.vendor" value="${vendor}"/>
|
||||
<property name="spec.version" value="${jna.major}"/>
|
||||
@@ -64,8 +65,11 @@
|
||||
<target name="compile-single" depends="compile"/>
|
||||
|
||||
<target name="-dynamic-properties">
|
||||
<echo>Java version: ${java.version}, compatibility: ${compatibility}</echo>
|
||||
<echo>JNA version ${jna.version}, native API version ${jni.version}</echo>
|
||||
<echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
|
||||
<echo>JNA version ${jna.version}, native ${jni.version}</echo>
|
||||
<echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
|
||||
<echo>java.home=${java.home}</echo>
|
||||
<echo>java.library.path=${java.library.path}</echo>
|
||||
|
||||
<replaceregexp match="(<version>).*(</version>)"
|
||||
replace="\1${jna.version}\2"
|
||||
@@ -77,12 +81,19 @@
|
||||
<condition property="vm.arch" value="-d64" else="">
|
||||
<or>
|
||||
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
|
||||
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
|
||||
<os arch="x86_64"/>
|
||||
<os arch="ppc64"/>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="amd64"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
|
||||
<and>
|
||||
<os name="SunOS"/>
|
||||
<equals arg1="${vm.arch}" arg2="-d64"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="build" value="build${vm.arch}"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="eclipse.classes" location="build.eclipse/classes"/>
|
||||
@@ -90,20 +101,19 @@
|
||||
<property name="reports" value="${build}/reports"/>
|
||||
|
||||
<!-- Add other supported platforms here -->
|
||||
<condition property="jre.arch" value="i386">
|
||||
<equals arg1="x86" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<condition property="jre.arch" value="amd64">
|
||||
<equals arg1="x86_64" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<property name="jre.arch" value="${os.arch}"/>
|
||||
<condition property="os.prefix" value="linux-${jre.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="win32-${os.arch}">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="linux-i386">
|
||||
<!-- IBM's J9 reports 'x86' -->
|
||||
<and><os name="Linux"/><os arch="x86"/></and>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="linux-amd64">
|
||||
<!-- Debian reports 'x86_64' -->
|
||||
<and><os name="Linux"/><os arch="x86_64"/></and>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="linux-${os.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<!-- Darwin builds are universal, no arch required -->
|
||||
<condition property="os.prefix" value="darwin">
|
||||
<os family="mac"/>
|
||||
@@ -125,7 +135,10 @@
|
||||
<available file="${java.home}/../include"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
|
||||
|
||||
<condition property="libjsig"
|
||||
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
|
||||
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
|
||||
</condition>
|
||||
<property name="native.jar" value="${os.prefix}.jar"/>
|
||||
<property name="build.native" location="${build}/native"/>
|
||||
<property name="md5.file" location="${build.native}/sig"/>
|
||||
@@ -244,7 +257,10 @@
|
||||
<fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
|
||||
<checksum property="md5" file="${md5.file}" />
|
||||
<condition property="jni.valid" value="true">
|
||||
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
|
||||
<or>
|
||||
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
|
||||
<equals arg1="${jni.md5}" arg2=""/>
|
||||
</or>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
@@ -253,6 +269,7 @@
|
||||
<echo>Invalidating native code, new checksum is ${md5}</echo>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
|
||||
@@ -379,7 +396,7 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile,native"
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<javac classpathref="compile-test.path"
|
||||
source="${test.compatibility}"
|
||||
@@ -388,10 +405,26 @@
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${test.src}"/>
|
||||
</javac>
|
||||
<jar jarfile="${build}/${testjar}">
|
||||
<fileset dir="${test.classes}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<mkdir dir="${build}/jws"/>
|
||||
<copy todir="${build}/jws" file="${build}/${jar}"/>
|
||||
<copy todir="${build}/jws" file="${build}/${testjar}"/>
|
||||
<copy todir="${build}/jws" file="lib/junit.jar"/>
|
||||
<copy todir="${build}/jws" file="lib/clover.jar"/>
|
||||
<jar jarfile="${build}/jws/jnidispatch.jar">
|
||||
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
|
||||
</jar>
|
||||
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
|
||||
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
</signjar>
|
||||
</target>
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found. Also need to add -Ddir.build.suffix=-d64 for 64-bit JVMs. -->
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,examples,compile-tests"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
@@ -399,9 +432,13 @@
|
||||
<property name="results.junit" location="${build}/junit-results"/>
|
||||
<mkdir dir="${results.junit}"/>
|
||||
<echo>Saving test results in ${results.junit}</echo>
|
||||
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
|
||||
<condition property="tests.platform" value="**/win32/*Test.java">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
|
||||
<and><os family="windows"/><not><os arch="x86"/></not></and>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="**/unix/*Test.java">
|
||||
<and>
|
||||
<os family="unix"/>
|
||||
@@ -409,17 +446,21 @@
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="vmopt.arch" value="-d64" else="-Dignore">
|
||||
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
|
||||
</condition>
|
||||
<condition property="dir.build.suffix" value="-d64" else="">
|
||||
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
|
||||
<and>
|
||||
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
|
||||
<not><os family="windows"/></not>
|
||||
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="tests.platform" value=""/>
|
||||
<property name="tests.exclude" value=""/>
|
||||
<junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
|
||||
<!-- avoid VM conflicts with JNA protected mode -->
|
||||
<env key="${ld.preload}" file="${libjsig}"/>
|
||||
<jvmarg value="-Djna.library.path=${build.native}"/>
|
||||
<!-- Avoid VM crashes, if possible -->
|
||||
<jvmarg value="-Djna.protected=true"/>
|
||||
<jvmarg value="-Ddir.build.suffix=${dir.build.suffix}"/>
|
||||
<jvmarg value="-Djna.builddir=${build}"/>
|
||||
<jvmarg value="${vmopt.arch}"/>
|
||||
<classpath><path refid="test.runpath"/></classpath>
|
||||
<formatter type="xml"/>
|
||||
@@ -547,6 +588,9 @@
|
||||
<zipfileset src="${dist}/openbsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/openbsd-i386"/>
|
||||
<zipfileset src="${dist}/win32-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-amd64"/>
|
||||
</jar>
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${build}">
|
||||
@@ -559,7 +603,7 @@
|
||||
</zip>
|
||||
<!-- JNA sources only, for use in Linux build from source -->
|
||||
<zip zipfile="${dist}/src.zip">
|
||||
<zipfileset dir="." includes="build.xml"/>
|
||||
<zipfileset dir="." includes="build.xml,LICENSE.txt"/>
|
||||
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
|
||||
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
|
||||
@@ -572,6 +616,10 @@
|
||||
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
|
||||
<zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
|
||||
</zip>
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${dist}/src-mvn.zip">
|
||||
<zipfileset dir="${src}" includes="**/*.jar,**/*.html,**/*.png"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="-dynamic-properties">
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
Copyright (c) 2008 Stefan Endrullis, All Rights Reserved
|
||||
|
||||
Disclaimer:
|
||||
===========
|
||||
This code is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
Description:
|
||||
============
|
||||
|
||||
The intension of this contribution is to provide an object oriented
|
||||
interface to X11. It doesn't not cover all available X11 functions, but
|
||||
it supports major functions to manage the X11 desktop, windows and keys.
|
||||
|
||||
If you want to help to extend this API, you're welcome!
|
||||
|
||||
|
||||
Project structure:
|
||||
==================
|
||||
|
||||
The project has been divided into two parts:
|
||||
- jnacontrib.x11.api
|
||||
- jnacontrib.c11.demos
|
||||
|
||||
The first part contains the API files. The main class is the class X.
|
||||
The second part contains some demos showing you how you can use the API.
|
||||
|
||||
X.java:
|
||||
-------
|
||||
Object oriented interface to X11. It mainly contains methods related
|
||||
to window management but also some functions for keys.
|
||||
Static methods for getting information about Win32 accounts (users
|
||||
and groups).
|
||||
- list all domain users
|
||||
- list all domain groups
|
||||
- list all local or domain groups where a user belongs to
|
||||
- get account by SID
|
||||
- get SID of account
|
||||
- get domain controller name
|
||||
- get domain name
|
||||
|
||||
X11KeySymDef.java
|
||||
-----------------
|
||||
Class X11KeySymDef is a Java translation of keysymdef.h and contains all
|
||||
KeySym definitions of the X server.
|
||||
|
||||
XDesktopDemo.java
|
||||
-----------------
|
||||
Class XDesktopDemo is a small demonstration of the window management
|
||||
capabilities of X. It's a GUI which allows you to move windows to other
|
||||
desktops, switch to other desktops, hide all windows etc.
|
||||
|
||||
XTestDemo.java
|
||||
--------------
|
||||
This class demonstrates how you can use the "Test extension" of the X
|
||||
server, which allows you to simulate key and mouse events. Be careful
|
||||
when running the program, because it simulates keystrokes and "types"
|
||||
the words "hello world" in the active window.
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.x11" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.x11.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="src"/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-src" location="../../src"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/jnacontrib-x11.jar"/>
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../dist">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<!-- Run XDesktopDemo. -->
|
||||
<target name="runXDesktopDemo" depends="compile">
|
||||
<java classname="jnacontrib.x11.demos.XDesktopDemo" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Run XTestDemo. -->
|
||||
<target name="runXTestDemo" depends="compile">
|
||||
<java classname="jnacontrib.x11.demos.XTestDemo" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
<dirset dir="${jna-src}/com/sun/jna/examples/unix"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}">
|
||||
<fileset dir="src">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="jnacontrib.x11.demos.XDesktopDemo"/>
|
||||
<attribute name="Class-Path" value="${jna-dist}/jna.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,365 @@
|
||||
/* Copyright (c) 2008 Stefan Endrullis, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package jnacontrib.x11.demos;
|
||||
|
||||
import jnacontrib.x11.api.X;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Demonstrates some possibilities on your X Window System.
|
||||
*
|
||||
* @author Stefan Endrullis
|
||||
*/
|
||||
public class XDesktopDemo extends JFrame {
|
||||
public static void main(String[] args) throws X.X11Exception {
|
||||
new XDesktopDemo();
|
||||
}
|
||||
|
||||
private X.Display display = new X.Display();
|
||||
private JList desktopList;
|
||||
private JTable windowTable;
|
||||
private JButton refreshButton;
|
||||
private JButton moveWindowToDesktopButton;
|
||||
private JButton goToDesktopButton;
|
||||
private JButton moveWindowAndGoToDesktopButton;
|
||||
private JButton closeWindowButton;
|
||||
private JButton goToWindowButton;
|
||||
private JButton showDesktop;
|
||||
|
||||
public XDesktopDemo() throws X.X11Exception {
|
||||
super("XDesktopDemo");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
initGui();
|
||||
|
||||
refreshDesktopsAndWindows();
|
||||
|
||||
pack();
|
||||
addListeners();
|
||||
setVisible(true);
|
||||
|
||||
printWmInfo();
|
||||
}
|
||||
|
||||
private void printWmInfo() throws X.X11Exception {
|
||||
X.Window wm = display.getWindowManagerInfo();
|
||||
System.out.println("wm.getTitle() = " + wm.getTitle());
|
||||
System.out.println("wm.getWindowClass() = " + wm.getWindowClass());
|
||||
System.out.println("wm.getPID() = " + wm.getPID());
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
refreshButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
refreshDesktopsAndWindows();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
goToDesktopButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
int desktopNr = desktopList.getSelectedIndex();
|
||||
if (desktopNr >= 0) {
|
||||
try {
|
||||
display.switchDesktop(desktopNr);
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
goToWindowButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
X.Window window = getSelectedWindow();
|
||||
try {
|
||||
window.activate();
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
showDesktop.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
display.showingDesktop(true);
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
moveWindowToDesktopButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
X.Window window = getSelectedWindow();
|
||||
try {
|
||||
window.moveToDesktop(desktopList.getSelectedIndex());
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
moveWindowAndGoToDesktopButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
X.Window window = getSelectedWindow();
|
||||
try {
|
||||
window.moveToDesktop(desktopList.getSelectedIndex());
|
||||
window.activate();
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
closeWindowButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
X.Window window = getSelectedWindow();
|
||||
try {
|
||||
window.close();
|
||||
display.flush();
|
||||
} catch (X.X11Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private X.Window getSelectedWindow() {
|
||||
WindowTableModel tableModel = (WindowTableModel) windowTable.getModel();
|
||||
return tableModel.getWindow(windowTable.getSelectedRow());
|
||||
}
|
||||
|
||||
private void refreshDesktopsAndWindows() throws X.X11Exception {
|
||||
// update desktop list
|
||||
X.Desktop[] desktops = display.getDesktops();
|
||||
ArrayList list = new ArrayList(desktops.length);
|
||||
for (int i = 0; i < desktops.length; i++) {
|
||||
list.add(desktops[i].name);
|
||||
}
|
||||
desktopList.clearSelection();
|
||||
desktopList.setModel(new SimpleListModel(list));
|
||||
|
||||
// select active desktop
|
||||
int activeDesktop = display.getActiveDesktopNumber();
|
||||
desktopList.setSelectedIndex(activeDesktop);
|
||||
|
||||
// update window list
|
||||
int activeWindowId = display.getActiveWindow().getID();
|
||||
int activeWindowNumber = -1;
|
||||
X.Window[] windows = display.getWindows();
|
||||
String[] head = new String[]{
|
||||
"ID", "Desktop", "Title",
|
||||
"X", "Y", "Width", "Height"
|
||||
};
|
||||
String[][] data = new String[windows.length][head.length];
|
||||
for (int i = 0; i < windows.length; i++) {
|
||||
X.Window window = windows[i];
|
||||
X.Window.Geometry geo = window.getGeometry();
|
||||
int windowId = window.getID();
|
||||
data[i][0] = String.format("0x%08X", new Object[]{new Integer(windowId)});
|
||||
data[i][1] = "" + window.getDesktop();
|
||||
data[i][2] = window.getTitle();
|
||||
data[i][3] = "" + geo.x;
|
||||
data[i][4] = "" + geo.y;
|
||||
data[i][5] = "" + geo.width;
|
||||
data[i][6] = "" + geo.height;
|
||||
if (windowId == activeWindowId) {
|
||||
activeWindowNumber = i;
|
||||
}
|
||||
}
|
||||
windowTable.setModel(new WindowTableModel(head, data, windows));
|
||||
if (activeWindowNumber >= 0) {
|
||||
windowTable.getSelectionModel().setSelectionInterval(activeWindowNumber, activeWindowNumber);
|
||||
}
|
||||
}
|
||||
|
||||
private void initGui() {
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new GridBagLayout());
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc;
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.weightx = 0.8;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(panel1, gbc);
|
||||
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), "Desktops"));
|
||||
desktopList = new JList();
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
panel1.add(desktopList, gbc);
|
||||
final JPanel panel2 = new JPanel();
|
||||
panel2.setLayout(new GridBagLayout());
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 0;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(panel2, gbc);
|
||||
panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), "Windows"));
|
||||
final JScrollPane scrollPane1 = new JScrollPane();
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
panel2.add(scrollPane1, gbc);
|
||||
windowTable = new JTable();
|
||||
windowTable.setEnabled(true);
|
||||
scrollPane1.setViewportView(windowTable);
|
||||
final JPanel panel3 = new JPanel();
|
||||
panel3.setLayout(new GridBagLayout());
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
mainPanel.add(panel3, gbc);
|
||||
panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(), "Actions"));
|
||||
goToDesktopButton = new JButton();
|
||||
goToDesktopButton.setText("go to desktop");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(goToDesktopButton, gbc);
|
||||
refreshButton = new JButton();
|
||||
refreshButton.setText("refresh");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(refreshButton, gbc);
|
||||
goToWindowButton = new JButton();
|
||||
goToWindowButton.setText("go to window");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 2;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(goToWindowButton, gbc);
|
||||
moveWindowAndGoToDesktopButton = new JButton();
|
||||
moveWindowAndGoToDesktopButton.setText("move window and go to desktop");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 2;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(moveWindowAndGoToDesktopButton, gbc);
|
||||
closeWindowButton = new JButton();
|
||||
closeWindowButton.setText("close window");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 3;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(closeWindowButton, gbc);
|
||||
moveWindowToDesktopButton = new JButton();
|
||||
moveWindowToDesktopButton.setText("move window to desktop");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(moveWindowToDesktopButton, gbc);
|
||||
showDesktop = new JButton();
|
||||
showDesktop.setText("show desktop");
|
||||
gbc = new GridBagConstraints();
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel3.add(showDesktop, gbc);
|
||||
|
||||
// more attributes
|
||||
desktopList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
windowTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
setContentPane(mainPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple ListModel managing a list of objects.
|
||||
*/
|
||||
public static class SimpleListModel extends AbstractListModel {
|
||||
private ArrayList list;
|
||||
|
||||
public SimpleListModel(ArrayList list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public int getSize() { return list.size(); }
|
||||
public Object getElementAt(int i) { return list.get(i); }
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple TableModel managing an array of Strings.
|
||||
*/
|
||||
public static class WindowTableModel implements TableModel {
|
||||
private String[] head;
|
||||
private String[][] data;
|
||||
private X.Window[] windows;
|
||||
|
||||
public WindowTableModel(String[] head, String[][] data, X.Window[] windows) {
|
||||
this.head = head;
|
||||
this.data = data;
|
||||
this.windows = windows;
|
||||
}
|
||||
|
||||
public int getRowCount() {
|
||||
return data.length;
|
||||
}
|
||||
public int getColumnCount() {
|
||||
return head.length;
|
||||
}
|
||||
public String getColumnName(int columnIndex) {
|
||||
return head[columnIndex];
|
||||
}
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return String.class;
|
||||
}
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
}
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return data[rowIndex][columnIndex];
|
||||
}
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
}
|
||||
public void addTableModelListener(TableModelListener l) {
|
||||
}
|
||||
public void removeTableModelListener(TableModelListener l) {
|
||||
}
|
||||
|
||||
public X.Window getWindow(int rowIndex) {
|
||||
return windows[rowIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/* Copyright (c) 2008 Stefan Endrullis, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package jnacontrib.x11.demos;
|
||||
|
||||
import jnacontrib.x11.api.X;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.NativeLong;
|
||||
|
||||
/**
|
||||
* Demonstration of the X extension XTest.
|
||||
*/
|
||||
public class XTestDemo {
|
||||
private static final long DELAY = 20;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
new XTestDemo();
|
||||
}
|
||||
|
||||
private X.Display display = new X.Display();
|
||||
|
||||
public XTestDemo() throws InterruptedException {
|
||||
IntByReference event_basep = new IntByReference();
|
||||
IntByReference error_basep = new IntByReference();
|
||||
IntByReference majorp = new IntByReference();
|
||||
IntByReference minorp = new IntByReference();
|
||||
|
||||
if (X11.XTest.INSTANCE.XTestQueryExtension(
|
||||
display.getX11Display(),
|
||||
event_basep,
|
||||
error_basep,
|
||||
majorp,
|
||||
minorp)) {
|
||||
|
||||
System.out.println("event_basep.getValue() = " + event_basep.getValue());
|
||||
System.out.println("error_basep.getValue() = " + error_basep.getValue());
|
||||
System.out.println("majorp.getValue() = " + majorp.getValue());
|
||||
System.out.println("minorp.getValue() = " + minorp.getValue());
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
type("hello world");
|
||||
// typeKey("Return");
|
||||
// type("it works!");
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
private void type(String text) {
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char myChar = text.charAt(i);
|
||||
|
||||
// get keycode from character
|
||||
switch (myChar) {
|
||||
case ' ': typeKey(65); break;
|
||||
default: typeKey("" + myChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void typeKey(String keyName) {
|
||||
X11.KeySym keysym = X11.INSTANCE.XStringToKeysym(keyName);
|
||||
typeKey(X11.INSTANCE.XKeysymToKeycode(display.getX11Display(), keysym));
|
||||
}
|
||||
|
||||
private void typeKey(int keyCode) {
|
||||
if (keyCode == -1) return;
|
||||
|
||||
// press key
|
||||
X11.XTest.INSTANCE.XTestFakeKeyEvent(display.getX11Display(), keyCode, true, new NativeLong(DELAY));
|
||||
X11.INSTANCE.XFlush(display.getX11Display());
|
||||
// release key
|
||||
X11.XTest.INSTANCE.XTestFakeKeyEvent(display.getX11Display(), keyCode, false, new NativeLong(DELAY));
|
||||
X11.INSTANCE.XFlush(display.getX11Display());
|
||||
}
|
||||
}
|
||||
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
BIN
Arquivo binário não exibido.
externo
BIN
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -1,5 +1,5 @@
|
||||
nQMpVtdkeiLDhkfVhlebsGWVMnsDeqDAmHuaUJSRUxwraf
|
||||
mi2K4SaejnjOrPDIm3nJq8<b2Ke>wQwCu3>RYeCLGxFda>
|
||||
PRoQxwONRmmnMpmQRPQvuNmQoQpMQRMpOnSSTxXMvwWmvu
|
||||
VtqwVvXwqqRnmqmUUnnvuvvqqmmmmmUUnnvuvvqqmmmmmU
|
||||
UgkXkabskgXsXkkbqUUnmm
|
||||
qRNQnmsMoNMDGXUenVfHVPuFPrNBGUUdBvfgtIdgVQWSbAa
|
||||
mj2KW7Oo9ud83ZbEKfK2xx922L04T>gYjDdLjGld4Wa6MPW
|
||||
NrqPtxROppqOmmqROMPSTnMmRqNOMnMnoPVSXswPsVXQwXV
|
||||
SPVVUtUNQmnmqmUUnopmqsvommmmmUUnopmqsvommmmmUUg
|
||||
kXkabskgXsXkkbqUUnmm
|
||||
|
||||
+60
-41
@@ -27,13 +27,12 @@ OS=$(shell uname | sed -e 's/\(CYGWIN\|MINGW32\).*/win32/g' \
|
||||
-e 's/Darwin.*/darwin/g' \
|
||||
-e 's/Linux.*/linux/g')
|
||||
|
||||
VERSION=3.0.4 # auto-generated by ant
|
||||
CHECKSUM=892beacd437514d23ed9b1cefeb2ead6 # auto-generated by ant
|
||||
VERSION=3.2.1 # auto-generated by ant
|
||||
CHECKSUM=c870290c36c8d3fdf85db7c782febc3f # auto-generated by ant
|
||||
|
||||
JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \
|
||||
-I"$(JAVA_HOME)/include/$(OS)"
|
||||
|
||||
LIBDIR=$(JAVA_HOME)/jre/lib/$(ARCH)
|
||||
BUILD=../build/native
|
||||
JAVAH=$(BUILD)
|
||||
INSTALLDIR=../build/$(OS)
|
||||
@@ -42,22 +41,24 @@ RSRC=$(BUILD)/rsrc.o
|
||||
ifneq ($(DYNAMIC_LIBFFI),true)
|
||||
FFI_SRC=$(shell pwd)/libffi
|
||||
FFI_BUILD=$(BUILD)/libffi
|
||||
FFI_LIB=$(FFI_BUILD)/.libs/libffi_convenience.a
|
||||
FFI_CONFIG=--disable-static --with-pic=yes
|
||||
FFI_LIB=$(FFI_BUILD)/.libs/libffi$(ARSFX)
|
||||
FFI_ENV=CC="$(CC)" CFLAGS="$(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)"
|
||||
FFI_CONFIG=--enable-static --disable-shared --with-pic=yes
|
||||
endif
|
||||
LIBRARY=$(BUILD)/$(LIBPFX)jnidispatch$(JNISFX)
|
||||
TESTLIB=$(BUILD)/$(LIBPFX)testlib$(LIBSFX)
|
||||
TESTLIB2=$(BUILD)/$(LIBPFX)testlib2$(LIBSFX)
|
||||
|
||||
# Reasonable defaults based on GCC
|
||||
LIBPFX=lib
|
||||
LIBSFX=.so
|
||||
ARSFX=.a
|
||||
JNISFX=$(LIBSFX)
|
||||
CC=gcc
|
||||
LD=gcc
|
||||
LIBS=
|
||||
# Default to Sun recommendations for JNI compilation
|
||||
#COPT=-O2 -fomit-frame-pointer
|
||||
COPT=-fno-omit-frame-pointer -fno-strict-aliasing
|
||||
COPT=-O2 -fno-omit-frame-pointer -fno-strict-aliasing
|
||||
CASM=-S
|
||||
ifeq ($(DEBUG),true)
|
||||
CDEBUG=-g
|
||||
@@ -84,44 +85,51 @@ STRIP=strip -x
|
||||
# end defaults
|
||||
|
||||
ifeq ($(OS),win32)
|
||||
# Uncomment this line to use MSVC (doesn't yet work with libffi)
|
||||
#CC=cl
|
||||
ARCH=$(shell uname -m | sed 's/i.86/i386/g')
|
||||
CDEFINES=-DHAVE_PROTECTION
|
||||
|
||||
ifeq ($(CC),cl)
|
||||
LD=link
|
||||
COPT=-O1 -Op
|
||||
ifeq ($(DEBUG),true)
|
||||
COPT=-Od
|
||||
DBG=d
|
||||
CDEBUG=-D_DEBUG -GZ -Zi
|
||||
endif
|
||||
COUT=-Fo$@
|
||||
PCFLAGS=-nologo -MD$(DBG) -W3 -WX -GX -YX -Fd$(@D)/$* -Fp$(@D)/$*
|
||||
CASM=-FAs
|
||||
|
||||
LDFLAGS=/pdb:$(subst .dll,,$@).pdb /implib:$(subst .dll,,$@).lib /debug /machine:i386 /pdbtype:sept /dll /nologo /opt:REF /incremental:no /out:$@
|
||||
LIBDIR=/libpath:"$(JAVA_HOME)/lib"
|
||||
#LIBS=$(LIBDIR) jawt.lib
|
||||
CDEFINES=-DHAVE_PROTECTION -DPSAPI_VERSION=1
|
||||
LIBS=-lpsapi
|
||||
WINDRES=windres
|
||||
EXTRAOBJS=$(RSRC)
|
||||
STRIP=@echo
|
||||
else
|
||||
CC += -mno-cygwin
|
||||
LD += -mno-cygwin -Wl,--add-stdcall-alias
|
||||
LIBDIR="$(JAVA_HOME)/lib"
|
||||
#LIBS=$(LIBDIR)/jawt.lib
|
||||
endif
|
||||
|
||||
LIBPFX=
|
||||
LIBSFX=.dll
|
||||
EXTRAOBJS=$(RSRC)
|
||||
|
||||
ifeq ($(CC),gcc)
|
||||
CC += -mno-cygwin
|
||||
LD += -mno-cygwin -Wl,--add-stdcall-alias
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),amd64)
|
||||
|
||||
WINDRES=/usr/local/mingw64-cross/bin/x86_64-pc-mingw32-windres
|
||||
|
||||
# Uncomment to enable MINGW64 cross compiler
|
||||
# Should build properly as of 090601, but lacks SEH, so MSVC build is preferred
|
||||
#MINGW = x86_64-pc-mingw32-gcc
|
||||
ifneq ($(MINGW),)
|
||||
CC = $(MINGW) -m64 -mno-cygwin
|
||||
LD = $(CC)
|
||||
LDFLAGS=-o $@ -shared
|
||||
LIBS= -lmingwex -lpsapi -lkernel32 -lmsvcrt
|
||||
FFI_CONFIG += --host=x86_64-pc-mingw32
|
||||
else
|
||||
# MSVC (wrapper scripts)
|
||||
CC=$(FFI_SRC)/../cc.sh -m64
|
||||
LD=$(FFI_SRC)/../ld.sh -m64
|
||||
COPT=
|
||||
LIBS=psapi.lib
|
||||
ARSFX=.lib
|
||||
FFI_CONFIG += --host=x86_64-pc-mingw32 && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
|
||||
FFI_ENV += LD="$(LD)" CPP=cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS),linux)
|
||||
ARCH=$(shell uname -m | sed 's/i.86/i386/g')
|
||||
PCFLAGS+=-fPIC
|
||||
CDEFINES+=-DHAVE_PROTECTION
|
||||
LDFLAGS+=-Wl,-soname,$@
|
||||
LDFLAGS+=-Wl,-soname,$@
|
||||
endif
|
||||
|
||||
ifeq ($(OS),freebsd)
|
||||
@@ -156,10 +164,12 @@ endif
|
||||
endif
|
||||
|
||||
# Enable 64-bit builds if the arch demands it
|
||||
ifeq ($(CC),gcc)
|
||||
ifeq ($(ARCH),amd64)
|
||||
CC += -m64
|
||||
LD += -m64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS),darwin)
|
||||
ARCH=$(shell arch)
|
||||
@@ -175,8 +185,8 @@ SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT)
|
||||
ISYSROOT=-isysroot $(SDKROOT)
|
||||
ARCHFLAGS=-arch ppc -arch i386
|
||||
ifneq ($(findstring 10.5,$(SDKROOT)),)
|
||||
ALT_ARCHS+=x86_64 #ppc64
|
||||
ARCHFLAGS+=-arch x86_64 #-arch ppc64
|
||||
ALT_ARCHS+=x86_64
|
||||
ARCHFLAGS+=-arch x86_64
|
||||
endif
|
||||
endif
|
||||
PCFLAGS+=$(ISYSROOT) -x objective-c
|
||||
@@ -206,20 +216,29 @@ else
|
||||
$(CC) $(CFLAGS) -c $< $(COUT)
|
||||
endif
|
||||
|
||||
all: $(LIBRARY) $(TESTLIB)
|
||||
all: $(LIBRARY) $(TESTLIB) $(TESTLIB2)
|
||||
|
||||
install:
|
||||
mkdir $(INSTALLDIR)
|
||||
cp $(LIBRARY) $(INSTALLDIR)
|
||||
|
||||
$(RSRC): $(BUILD)/jnidispatch.rc
|
||||
windres -i $< -o $@
|
||||
$(WINDRES) -i $< -o $@ \
|
||||
|| (echo > $@.c && $(CC) $(CFLAGS) -c $@.c $(COUT))
|
||||
|
||||
$(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB)
|
||||
$(LD) $(LDFLAGS) $(JNIDISPATCH_OBJS) $(FFI_LIB) $(LIBS)
|
||||
|
||||
$(TESTLIB): $(BUILD)/testlib.o
|
||||
$(LD) $(LDFLAGS) $< $(TESTDEF)
|
||||
$(LD) $(LDFLAGS) $<
|
||||
|
||||
ifeq ($(ARSFX),.lib)
|
||||
TESTDEP=$(TESTLIB:.dll=.lib)
|
||||
else
|
||||
TESTDEP=$(TESTLIB)
|
||||
endif
|
||||
$(TESTLIB2): $(BUILD)/testlib2.o
|
||||
$(LD) $(LDFLAGS) $< $(TESTDEP)
|
||||
|
||||
ifneq ($(DYNAMIC_LIBFFI),true)
|
||||
$(FFI_LIB):
|
||||
@@ -227,7 +246,7 @@ $(FFI_LIB):
|
||||
@if [ ! -f $(FFI_BUILD)/Makefile ]; then \
|
||||
echo "Configuring libffi ($(ARCH))"; \
|
||||
(cd $(FFI_BUILD) \
|
||||
&& CC="$(CC)" CFLAGS="$(CDEBUG)" CPPFLAGS="$(CDEFINES)" $(FFI_SRC)/configure $(FFI_CONFIG)); \
|
||||
&& $(FFI_ENV) $(FFI_SRC)/configure $(FFI_CONFIG)); \
|
||||
fi
|
||||
$(MAKE) -C $(FFI_BUILD)
|
||||
ifneq ($(SDKROOT),)
|
||||
|
||||
+316
-58
@@ -37,92 +37,363 @@ static jclass classObject;
|
||||
callback*
|
||||
create_callback(JNIEnv* env, jobject obj, jobject method,
|
||||
jobjectArray param_types, jclass return_type,
|
||||
callconv_t calling_convention) {
|
||||
callconv_t calling_convention, jboolean direct) {
|
||||
callback* cb;
|
||||
ffi_abi abi = FFI_DEFAULT_ABI;
|
||||
ffi_abi java_abi = FFI_DEFAULT_ABI;
|
||||
ffi_type* ffi_rtype;
|
||||
ffi_status status;
|
||||
int args_size = 0;
|
||||
jsize argc;
|
||||
JavaVM* vm;
|
||||
char rtype;
|
||||
int rtype;
|
||||
char msg[64];
|
||||
int i;
|
||||
int cvt = 0;
|
||||
const char* throw_type = NULL;
|
||||
const char* throw_msg = NULL;
|
||||
|
||||
if ((*env)->GetJavaVM(env, &vm) != JNI_OK) {
|
||||
throwByName(env, EUnsatisfiedLink, "Can't get Java VM");
|
||||
return NULL;
|
||||
}
|
||||
argc = (*env)->GetArrayLength(env, param_types);
|
||||
|
||||
cb = (callback *)malloc(sizeof(callback));
|
||||
cb->ffi_closure = ffi_closure_alloc(sizeof(ffi_closure), &cb->x_closure);
|
||||
cb->closure = ffi_closure_alloc(sizeof(ffi_closure), &cb->x_closure);
|
||||
cb->object = (*env)->NewWeakGlobalRef(env, obj);
|
||||
cb->methodID = (*env)->FromReflectedMethod(env, method);
|
||||
cb->vm = vm;
|
||||
cb->arg_types = (ffi_type**)malloc(sizeof(ffi_type*) * argc);
|
||||
cb->java_arg_types = (ffi_type**)malloc(sizeof(ffi_type*) * (argc + 3));
|
||||
cb->arg_jtypes = (char*)malloc(sizeof(char) * argc);
|
||||
cb->flags = (int *)malloc(sizeof(int) * argc);
|
||||
cb->rflag = CVT_DEFAULT;
|
||||
cb->arg_classes = (jobject*)malloc(sizeof(jobject) * argc);
|
||||
|
||||
cb->direct = direct;
|
||||
cb->java_arg_types[0] = cb->java_arg_types[1] = cb->java_arg_types[2] = &ffi_type_pointer;
|
||||
|
||||
for (i=0;i < argc;i++) {
|
||||
int jtype;
|
||||
jclass cls = (*env)->GetObjectArrayElement(env, param_types, i);
|
||||
cb->param_jtypes[i] = get_jtype(env, cls);
|
||||
cb->ffi_args[i] = get_ffi_type(env, cls, cb->param_jtypes[i]);
|
||||
if (!cb->param_jtypes[i]) {
|
||||
sprintf(msg, "Unsupported type at parameter %d", i);
|
||||
throwByName(env, EIllegalArgument, msg);
|
||||
if ((cb->flags[i] = get_conversion_flag(env, cls)) != CVT_DEFAULT) {
|
||||
cb->arg_classes[i] = (*env)->NewWeakGlobalRef(env, cls);
|
||||
cvt = 1;
|
||||
}
|
||||
|
||||
jtype = get_jtype(env, cls);
|
||||
if (jtype == -1) {
|
||||
snprintf(msg, sizeof(msg), "Unsupported argument at index %d", i);
|
||||
throw_type = EIllegalArgument;
|
||||
throw_msg = msg;
|
||||
goto failure_cleanup;
|
||||
}
|
||||
cb->arg_jtypes[i] = (char)jtype;
|
||||
cb->java_arg_types[i+3] = cb->arg_types[i] = get_ffi_type(env, cls, cb->arg_jtypes[i]);
|
||||
if (cb->flags[i] == CVT_NATIVE_MAPPED
|
||||
|| cb->flags[i] == CVT_POINTER_TYPE
|
||||
|| cb->flags[i] == CVT_INTEGER_TYPE) {
|
||||
jclass ncls;
|
||||
ncls = getNativeType(env, cls);
|
||||
jtype = get_jtype(env, ncls);
|
||||
if (jtype == -1) {
|
||||
snprintf(msg, sizeof(msg), "Unsupported NativeMapped argument native type at argument %d", i);
|
||||
throw_type = EIllegalArgument;
|
||||
throw_msg = msg;
|
||||
goto failure_cleanup;
|
||||
}
|
||||
cb->arg_jtypes[i] = (char)jtype;
|
||||
cb->java_arg_types[i+3] = &ffi_type_pointer;
|
||||
cb->arg_types[i] = get_ffi_type(env, ncls, cb->arg_jtypes[i]);
|
||||
}
|
||||
|
||||
if (cb->arg_types[i]->type == FFI_TYPE_FLOAT) {
|
||||
// Java method is varargs, so promote floats to double
|
||||
cb->java_arg_types[i+3] = &ffi_type_double;
|
||||
cb->flags[i] = CVT_FLOAT;
|
||||
cvt = 1;
|
||||
}
|
||||
else if (cb->java_arg_types[i+3]->type == FFI_TYPE_STRUCT) {
|
||||
// All callback structure arguments are passed as a jobject
|
||||
cb->java_arg_types[i+3] = &ffi_type_pointer;
|
||||
}
|
||||
}
|
||||
if (!direct || !cvt) {
|
||||
free(cb->flags);
|
||||
cb->flags = NULL;
|
||||
free(cb->arg_classes);
|
||||
cb->arg_classes = NULL;
|
||||
}
|
||||
if (direct) {
|
||||
cb->rflag = get_conversion_flag(env, return_type);
|
||||
if (cb->rflag == CVT_NATIVE_MAPPED
|
||||
|| cb->rflag == CVT_INTEGER_TYPE
|
||||
|| cb->rflag == CVT_POINTER_TYPE) {
|
||||
return_type = getNativeType(env, return_type);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(_WIN64)
|
||||
if (calling_convention == CALLCONV_STDCALL) {
|
||||
abi = FFI_STDCALL;
|
||||
}
|
||||
java_abi = FFI_STDCALL;
|
||||
#endif // _WIN32
|
||||
|
||||
rtype = get_jtype(env, return_type);
|
||||
if (!rtype) {
|
||||
throwByName(env, EIllegalArgument, "Unsupported return type");
|
||||
if (rtype == -1) {
|
||||
throw_type = EIllegalArgument;
|
||||
throw_msg = "Unsupported return type";
|
||||
goto failure_cleanup;
|
||||
}
|
||||
status = ffi_prep_cif(&cb->ffi_cif, abi, argc,
|
||||
get_ffi_rtype(env, return_type, rtype),
|
||||
&cb->ffi_args[0]);
|
||||
switch(status) {
|
||||
case FFI_BAD_ABI:
|
||||
sprintf(msg, "Invalid calling convention: %d", (int)calling_convention);
|
||||
throwByName(env, EIllegalArgument, msg);
|
||||
break;
|
||||
case FFI_BAD_TYPEDEF:
|
||||
sprintf(msg, "Invalid structure definition (native typedef error)");
|
||||
throwByName(env, EIllegalArgument, msg);
|
||||
break;
|
||||
case FFI_OK:
|
||||
ffi_prep_closure_loc(cb->ffi_closure, &cb->ffi_cif, callback_dispatch, cb,
|
||||
cb->x_closure);
|
||||
return cb;
|
||||
default:
|
||||
sprintf(msg, "Native callback setup failure: error code %d", status);
|
||||
throwByName(env, EIllegalArgument, msg);
|
||||
break;
|
||||
ffi_rtype = get_ffi_rtype(env, return_type, (char)rtype);
|
||||
if (!ffi_rtype) {
|
||||
throw_type = EIllegalArgument;
|
||||
throw_msg = "Error in return type";
|
||||
goto failure_cleanup;
|
||||
}
|
||||
status = ffi_prep_cif(&cb->cif, abi, argc, ffi_rtype, cb->arg_types);
|
||||
if (!ffi_error(env, "callback setup", status)) {
|
||||
ffi_type* java_ffi_rtype = ffi_rtype;
|
||||
|
||||
if (cb->rflag == CVT_STRUCTURE_BYVAL
|
||||
|| cb->rflag == CVT_NATIVE_MAPPED
|
||||
|| cb->rflag == CVT_POINTER_TYPE
|
||||
|| cb->rflag == CVT_INTEGER_TYPE) {
|
||||
// Java method returns a jobject, not a struct
|
||||
java_ffi_rtype = &ffi_type_pointer;
|
||||
rtype = '*';
|
||||
}
|
||||
switch(rtype) {
|
||||
case 'V': cb->fptr = (*env)->CallVoidMethod; break;
|
||||
case 'Z': cb->fptr = (*env)->CallBooleanMethod; break;
|
||||
case 'B': cb->fptr = (*env)->CallByteMethod; break;
|
||||
case 'S': cb->fptr = (*env)->CallShortMethod; break;
|
||||
case 'C': cb->fptr = (*env)->CallCharMethod; break;
|
||||
case 'I': cb->fptr = (*env)->CallIntMethod; break;
|
||||
case 'J': cb->fptr = (*env)->CallLongMethod; break;
|
||||
case 'F': cb->fptr = (*env)->CallFloatMethod; break;
|
||||
case 'D': cb->fptr = (*env)->CallDoubleMethod; break;
|
||||
default: cb->fptr = (*env)->CallObjectMethod; break;
|
||||
}
|
||||
status = ffi_prep_cif(&cb->java_cif, java_abi, argc+3, java_ffi_rtype, cb->java_arg_types);
|
||||
if (!ffi_error(env, "callback setup (2)", status)) {
|
||||
ffi_prep_closure_loc(cb->closure, &cb->cif, callback_dispatch, cb,
|
||||
cb->x_closure);
|
||||
return cb;
|
||||
}
|
||||
}
|
||||
|
||||
failure_cleanup:
|
||||
free_callback(env, cb);
|
||||
if (throw_type) {
|
||||
throwByName(env, throw_type, msg);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void
|
||||
free_callback(JNIEnv* env, callback *cb) {
|
||||
(*env)->DeleteWeakGlobalRef(env, cb->object);
|
||||
ffi_closure_free(cb->ffi_closure);
|
||||
ffi_closure_free(cb->closure);
|
||||
free(cb->arg_types);
|
||||
if (cb->arg_classes) {
|
||||
unsigned i;
|
||||
for (i=0;i < cb->cif.nargs;i++) {
|
||||
(*env)->DeleteWeakGlobalRef(env, cb->arg_classes[i]);
|
||||
}
|
||||
free(cb->arg_classes);
|
||||
}
|
||||
free(cb->java_arg_types);
|
||||
if (cb->flags)
|
||||
free(cb->flags);
|
||||
free(cb->arg_jtypes);
|
||||
free(cb);
|
||||
}
|
||||
|
||||
static int
|
||||
handle_exception(JNIEnv* env, jobject cb, jthrowable throwable) {
|
||||
#define HANDLER_TYPE "com/sun/jna/Callback$UncaughtExceptionHandler"
|
||||
#define HANDLER_SIG "Lcom/sun/jna/Callback$UncaughtExceptionHandler;"
|
||||
jclass classHandler = (*env)->FindClass(env, HANDLER_TYPE);
|
||||
if (classHandler) {
|
||||
jclass classNative = (*env)->FindClass(env, "com/sun/jna/Native");
|
||||
if (classNative) {
|
||||
jfieldID fid = (*env)->GetStaticFieldID(env, classNative, "callbackExceptionHandler", HANDLER_SIG);
|
||||
if (fid) {
|
||||
jobject handler = (*env)->GetStaticObjectField(env, classNative, fid);
|
||||
if (handler) {
|
||||
jmethodID mid = (*env)->GetMethodID(env, classHandler, "uncaughtException", "(Lcom/sun/jna/Callback;Ljava/lang/Throwable;)V");
|
||||
if (mid) {
|
||||
if (!(*env)->IsSameObject(env, handler, NULL)) {
|
||||
(*env)->CallVoidMethod(env, handler, mid, cb, throwable);
|
||||
}
|
||||
if ((*env)->ExceptionCheck(env) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(*env)->ExceptionDescribe(env);
|
||||
(*env)->ExceptionClear(env);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbargs) {
|
||||
jobject self;
|
||||
void *oldresp = resp;
|
||||
|
||||
self = (*env)->NewLocalRef(env, cb->object);
|
||||
// Avoid calling back to a GC'd object
|
||||
if ((*env)->IsSameObject(env, self, NULL)) {
|
||||
fprintf(stderr, "JNA: callback object has been garbage collected\n");
|
||||
if (cif->rtype->type != FFI_TYPE_VOID)
|
||||
memset(resp, 0, cif->rtype->size);
|
||||
}
|
||||
else if (cb->direct) {
|
||||
unsigned int i;
|
||||
void **args = alloca((cif->nargs + 3) * sizeof(void *));
|
||||
args[0] = (void *)&env;
|
||||
args[1] = &self;
|
||||
args[2] = &cb->methodID;
|
||||
memcpy(&args[3], cbargs, cif->nargs * sizeof(void *));
|
||||
|
||||
if (cb->flags) {
|
||||
for (i=0;i < cif->nargs;i++) {
|
||||
switch(cb->flags[i]) {
|
||||
case CVT_INTEGER_TYPE:
|
||||
case CVT_POINTER_TYPE:
|
||||
case CVT_NATIVE_MAPPED:
|
||||
*((void **)args[i+3]) = fromNative(env, cb->arg_classes[i], cif->arg_types[i], args[i+3], JNI_FALSE);
|
||||
break;
|
||||
case CVT_POINTER:
|
||||
*((void **)args[i+3]) = newJavaPointer(env, *(void **)args[i+3]);
|
||||
break;
|
||||
case CVT_STRING:
|
||||
*((void **)args[i+3]) = newJavaString(env, *(void **)args[i+3], JNI_FALSE);
|
||||
break;
|
||||
case CVT_WSTRING:
|
||||
*((void **)args[i+3]) = newJavaWString(env, *(void **)args[i+3]);
|
||||
break;
|
||||
case CVT_STRUCTURE:
|
||||
*((void **)args[i+3]) = newJavaStructure(env, *(void **)args[i+3], cb->arg_classes[i], JNI_FALSE);
|
||||
break;
|
||||
case CVT_STRUCTURE_BYVAL:
|
||||
{
|
||||
void *ptr = args[i+3];
|
||||
args[i+3] = alloca(sizeof(void *));
|
||||
*((void **)args[i+3]) = newJavaStructure(env, ptr, cb->arg_classes[i], JNI_TRUE);
|
||||
}
|
||||
break;
|
||||
case CVT_CALLBACK:
|
||||
*((void **)args[i+3]) = newJavaCallback(env, *(void **)args[i+3], cb->arg_classes[i]);
|
||||
break;
|
||||
case CVT_FLOAT:
|
||||
{
|
||||
void *ptr = alloca(sizeof(double));
|
||||
*(double *)ptr = *(float*)args[i+3];
|
||||
args[i+3] = ptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cb->rflag == CVT_STRUCTURE_BYVAL) {
|
||||
resp = alloca(sizeof(jobject));
|
||||
}
|
||||
else if (cb->cif.rtype->size > cif->rtype->size) {
|
||||
resp = alloca(cb->cif.rtype->size);
|
||||
}
|
||||
ffi_call(&cb->java_cif, FFI_FN(cb->fptr), resp, args);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
jthrowable throwable = (*env)->ExceptionOccurred(env);
|
||||
(*env)->ExceptionClear(env);
|
||||
if (!handle_exception(env, self, throwable)) {
|
||||
fprintf(stderr, "JNA: error handling callback exception, continuing\n");
|
||||
}
|
||||
if (cif->rtype->type != FFI_TYPE_VOID)
|
||||
memset(oldresp, 0, cif->rtype->size);
|
||||
}
|
||||
else switch(cb->rflag) {
|
||||
case CVT_INTEGER_TYPE:
|
||||
if (cb->cif.rtype->size > sizeof(ffi_arg)) {
|
||||
*(jlong *)oldresp = getIntegerTypeValue(env, *(void **)resp);
|
||||
}
|
||||
else {
|
||||
*(ffi_arg *)oldresp = (ffi_arg)getIntegerTypeValue(env, *(void **)resp);
|
||||
}
|
||||
break;
|
||||
case CVT_POINTER_TYPE:
|
||||
*(void **)resp = getPointerTypeAddress(env, *(void **)resp);
|
||||
break;
|
||||
case CVT_NATIVE_MAPPED:
|
||||
toNative(env, *(void **)resp, oldresp, cb->cif.rtype->size, JNI_TRUE);
|
||||
break;
|
||||
case CVT_POINTER:
|
||||
*(void **)resp = getNativeAddress(env, *(void **)resp);
|
||||
break;
|
||||
case CVT_STRING:
|
||||
*(void **)resp = getNativeString(env, *(void **)resp, JNI_FALSE);
|
||||
break;
|
||||
case CVT_WSTRING:
|
||||
*(void **)resp = getNativeString(env, *(void **)resp, JNI_TRUE);
|
||||
break;
|
||||
case CVT_STRUCTURE:
|
||||
writeStructure(env, *(void **)resp);
|
||||
*(void **)resp = getStructureAddress(env, *(void **)resp);
|
||||
break;
|
||||
case CVT_STRUCTURE_BYVAL:
|
||||
writeStructure(env, *(void **)resp);
|
||||
memcpy(oldresp, getStructureAddress(env, *(void **)resp), cb->cif.rtype->size);
|
||||
break;
|
||||
case CVT_CALLBACK:
|
||||
*(void **)resp = getCallbackAddress(env, *(void **)resp);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
if (cb->flags) {
|
||||
for (i=0;i < cif->nargs;i++) {
|
||||
if (cb->flags[i] == CVT_STRUCTURE) {
|
||||
writeStructure(env, *(void **)args[i+3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
jobject result;
|
||||
jobjectArray array =
|
||||
(*env)->NewObjectArray(env, cif->nargs, classObject, NULL);
|
||||
unsigned int i;
|
||||
|
||||
for (i=0;i < cif->nargs;i++) {
|
||||
jobject arg = new_object(env, cb->arg_jtypes[i], cbargs[i], JNI_FALSE);
|
||||
(*env)->SetObjectArrayElement(env, array, i, arg);
|
||||
}
|
||||
result = (*env)->CallObjectMethod(env, self, cb->methodID, array);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
jthrowable throwable = (*env)->ExceptionOccurred(env);
|
||||
(*env)->ExceptionClear(env);
|
||||
if (!handle_exception(env, self, throwable)) {
|
||||
fprintf(stderr, "JNA: error handling callback exception, continuing\n");
|
||||
}
|
||||
if (cif->rtype->type != FFI_TYPE_VOID)
|
||||
memset(resp, 0, cif->rtype->size);
|
||||
}
|
||||
else {
|
||||
extract_value(env, result, resp, cif->rtype->size, JNI_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
|
||||
callback* cb = (callback *) user_data;
|
||||
JavaVM* jvm = cb->vm;
|
||||
jobject self;
|
||||
JavaVM* jvm = ((callback *)user_data)->vm;
|
||||
JNIEnv* env;
|
||||
int attached;
|
||||
unsigned int i;
|
||||
jobjectArray array;
|
||||
|
||||
attached = (*jvm)->GetEnv(jvm, (void *)&env, JNI_VERSION_1_4) == JNI_OK;
|
||||
if (!attached) {
|
||||
@@ -132,29 +403,16 @@ callback_dispatch(ffi_cif* cif, void* resp, void** cbargs, void* user_data) {
|
||||
}
|
||||
}
|
||||
|
||||
self = (*env)->NewLocalRef(env, cb->object);
|
||||
// Avoid calling back to a GC'd object
|
||||
if ((*env)->IsSameObject(env, self, NULL)) {
|
||||
fprintf(stderr, "JNA: callback object has been garbage collected\n");
|
||||
memset(resp, 0, cif->rtype->size);
|
||||
// Give the callback its own local frame to ensure all local references
|
||||
// are properly disposed
|
||||
if ((*env)->PushLocalFrame(env, 16) < 0) {
|
||||
fprintf(stderr, "JNA: Out of memory: Can't allocate local frame");
|
||||
}
|
||||
else {
|
||||
jobject result;
|
||||
array = (*env)->NewObjectArray(env, cif->nargs, classObject, NULL);
|
||||
for (i=0;i < cif->nargs;i++) {
|
||||
jobject arg = new_object(env, cb->param_jtypes[i], cbargs[i]);
|
||||
(*env)->SetObjectArrayElement(env, array, i, arg);
|
||||
}
|
||||
result = (*env)->CallObjectMethod(env, self, cb->methodID, array);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
fprintf(stderr, "JNA: uncaught exception in callback, continuing\n");
|
||||
memset(resp, 0, cif->rtype->size);
|
||||
}
|
||||
else {
|
||||
extract_value(env, result, resp, cif->rtype->size);
|
||||
}
|
||||
callback_invoke(env, (callback *)user_data, cif, resp, cbargs);
|
||||
(*env)->PopLocalFrame(env, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (!attached) {
|
||||
(*jvm)->DetachCurrentThread(jvm);
|
||||
}
|
||||
|
||||
Arquivo executável
+147
@@ -0,0 +1,147 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# GCC-compatible wrapper for cl.exe
|
||||
#
|
||||
MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin"
|
||||
nowarn="/wd4127 /wd4820 /wd4706 /wd4100 /wd4255 /wd4668"
|
||||
args="/nologo /EHac /W3 /LD $nowarn" # /WX
|
||||
# FIXME is this equivalent to --static-libgcc? links to msvcrt.lib
|
||||
# I've forgotten why it was originally added
|
||||
# /MD causes link problems
|
||||
#md=/MD
|
||||
cl="$MSVC/cl"
|
||||
ml="$MSVC/ml"
|
||||
output=
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case $1
|
||||
in
|
||||
-fexceptions)
|
||||
shift 1
|
||||
;;
|
||||
-fno-omit-frame-pointer)
|
||||
# TODO: does this have an equivalent?
|
||||
shift 1
|
||||
;;
|
||||
-fno-strict-aliasing)
|
||||
# TODO: does this have an equivalent?
|
||||
shift 1
|
||||
;;
|
||||
-mno-cygwin)
|
||||
shift 1
|
||||
;;
|
||||
-m32)
|
||||
cl="$MSVC/cl"
|
||||
ml="$MSVC/ml"
|
||||
shift 1
|
||||
;;
|
||||
-m64)
|
||||
cl="$MSVC/x86_amd64/cl"
|
||||
ml="$MSVC/x86_amd64/ml64"
|
||||
shift 1
|
||||
;;
|
||||
-O*)
|
||||
args="$args $i"
|
||||
shift 1
|
||||
;;
|
||||
-g)
|
||||
# using /RTC1 instead of /GZ
|
||||
args="$args /Od /D_DEBUG /RTC1 /Zi"
|
||||
md=/MDd
|
||||
shift 1
|
||||
;;
|
||||
-c)
|
||||
args="$args /c"
|
||||
args="$(echo $args | sed 's%/Fe%/Fo%g')"
|
||||
single="/c"
|
||||
shift 1
|
||||
;;
|
||||
-D*=*)
|
||||
name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
|
||||
value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
|
||||
args="$args -D${name}='$value'"
|
||||
defines="$defines -D${name}='$value'"
|
||||
shift 1
|
||||
;;
|
||||
-D*)
|
||||
args="$args $1"
|
||||
defines="$defines $1"
|
||||
shift 1
|
||||
;;
|
||||
-I)
|
||||
args="$args /I\"$2\""
|
||||
includes="$includes /I\"$2\""
|
||||
shift 2
|
||||
;;
|
||||
-I*)
|
||||
args="$args /I\"$(echo $1|sed -e 's/-I//g')\""
|
||||
includes="$includes /I\"$(echo $1|sed -e 's/-I//g')\""
|
||||
shift 1
|
||||
;;
|
||||
-W|-Wextra)
|
||||
# TODO map extra warnings
|
||||
shift 1
|
||||
;;
|
||||
-Wall)
|
||||
args="$args /Wall"
|
||||
shift 1
|
||||
;;
|
||||
-Werror)
|
||||
args="$args /WX"
|
||||
shift 1
|
||||
;;
|
||||
-W*)
|
||||
# TODO map specific warnings
|
||||
shift 1
|
||||
;;
|
||||
-S)
|
||||
args="$args /FAs"
|
||||
shift 1
|
||||
;;
|
||||
-o)
|
||||
outdir="$(dirname $2)"
|
||||
base="$(basename $2|sed 's/\.[^.]*//g')"
|
||||
if [ -n "$single" ]; then
|
||||
output="/Fo$2"
|
||||
else
|
||||
output="/Fe$2"
|
||||
fi
|
||||
if [ -n "$assembly" ]; then
|
||||
args="$args $output"
|
||||
else
|
||||
args="$args $output /Fd$outdir/$base /Fp$outdir/$base /Fa$outdir/$base"
|
||||
fi
|
||||
shift 2
|
||||
;;
|
||||
*.S)
|
||||
src="$(echo $1|sed -e 's/.S$/.asm/g' -e 's%\\%/%g')"
|
||||
echo "$cl /EP $includes $defines $1 > $src"
|
||||
"$cl" /nologo /EP $includes $defines $1 > $src || exit $?
|
||||
md=""
|
||||
cl="$ml"
|
||||
output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
|
||||
args="/nologo $single $src $output"
|
||||
assembly="true"
|
||||
shift 1
|
||||
;;
|
||||
*.c)
|
||||
args="$args $(echo $1|sed -e 's%\\%/%g')"
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported argument '$1'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
args="$md $args"
|
||||
echo "$cl $args"
|
||||
eval "\"$cl\" $args"
|
||||
result=$?
|
||||
# @#!%@!# ml64 broken output
|
||||
if [ -n "$assembly" ]; then
|
||||
mv $src $outdir
|
||||
mv *.obj $outdir
|
||||
fi
|
||||
exit $result
|
||||
+1224
-294
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+94
-13
@@ -15,6 +15,22 @@
|
||||
|
||||
#include "ffi.h"
|
||||
#include "com_sun_jna_Function.h"
|
||||
#include "com_sun_jna_Native.h"
|
||||
#ifdef sun
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#define alloca _alloca
|
||||
#pragma warning( disable : 4152 ) /* function/data conversion */
|
||||
#pragma warning( disable : 4054 ) /* cast function pointer to data pointer */
|
||||
#pragma warning( disable : 4055 ) /* cast data pointer to function pointer */
|
||||
#pragma warning( disable : 4204 ) /* structure initializer */
|
||||
#pragma warning( disable : 4710 ) /* swprintf not inlined */
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -23,7 +39,7 @@ extern "C" {
|
||||
/* These are the calling conventions an invocation can handle. */
|
||||
typedef enum _callconv {
|
||||
CALLCONV_C = com_sun_jna_Function_C_CONVENTION,
|
||||
#if defined(_WIN32)
|
||||
#ifdef _WIN32
|
||||
CALLCONV_STDCALL = com_sun_jna_Function_ALT_CONVENTION,
|
||||
#endif
|
||||
} callconv_t;
|
||||
@@ -31,29 +47,64 @@ typedef enum _callconv {
|
||||
/* Maximum number of allowed arguments in libffi. */
|
||||
#define MAX_NARGS com_sun_jna_Function_MAX_NARGS
|
||||
|
||||
enum {
|
||||
CVT_DEFAULT = com_sun_jna_Native_CVT_DEFAULT,
|
||||
CVT_POINTER = com_sun_jna_Native_CVT_POINTER,
|
||||
CVT_STRING = com_sun_jna_Native_CVT_STRING,
|
||||
CVT_STRUCTURE = com_sun_jna_Native_CVT_STRUCTURE,
|
||||
CVT_STRUCTURE_BYVAL = com_sun_jna_Native_CVT_STRUCTURE_BYVAL,
|
||||
CVT_BUFFER = com_sun_jna_Native_CVT_BUFFER,
|
||||
CVT_ARRAY_BYTE = com_sun_jna_Native_CVT_ARRAY_BYTE,
|
||||
CVT_ARRAY_SHORT = com_sun_jna_Native_CVT_ARRAY_SHORT,
|
||||
CVT_ARRAY_CHAR = com_sun_jna_Native_CVT_ARRAY_CHAR,
|
||||
CVT_ARRAY_INT = com_sun_jna_Native_CVT_ARRAY_INT,
|
||||
CVT_ARRAY_LONG = com_sun_jna_Native_CVT_ARRAY_LONG,
|
||||
CVT_ARRAY_FLOAT = com_sun_jna_Native_CVT_ARRAY_FLOAT,
|
||||
CVT_ARRAY_DOUBLE = com_sun_jna_Native_CVT_ARRAY_DOUBLE,
|
||||
CVT_ARRAY_BOOLEAN = com_sun_jna_Native_CVT_ARRAY_BOOLEAN,
|
||||
CVT_BOOLEAN = com_sun_jna_Native_CVT_BOOLEAN,
|
||||
CVT_CALLBACK = com_sun_jna_Native_CVT_CALLBACK,
|
||||
CVT_FLOAT = com_sun_jna_Native_CVT_FLOAT,
|
||||
CVT_NATIVE_MAPPED = com_sun_jna_Native_CVT_NATIVE_MAPPED,
|
||||
CVT_WSTRING = com_sun_jna_Native_CVT_WSTRING,
|
||||
CVT_INTEGER_TYPE = com_sun_jna_Native_CVT_INTEGER_TYPE,
|
||||
CVT_POINTER_TYPE = com_sun_jna_Native_CVT_POINTER_TYPE,
|
||||
CVT_TYPE_MAPPER = com_sun_jna_Native_CVT_TYPE_MAPPER,
|
||||
};
|
||||
|
||||
typedef struct _callback {
|
||||
// Location of this field must agree with CallbackReference.getTrampoline()
|
||||
void* x_closure;
|
||||
ffi_closure* ffi_closure;
|
||||
ffi_cif ffi_cif;
|
||||
ffi_type* ffi_args[MAX_NARGS];
|
||||
ffi_closure* closure;
|
||||
ffi_cif cif;
|
||||
ffi_cif java_cif;
|
||||
ffi_type** arg_types;
|
||||
ffi_type** java_arg_types;
|
||||
jobject* arg_classes;
|
||||
int* flags;
|
||||
int rflag;
|
||||
JavaVM* vm;
|
||||
jobject object;
|
||||
jmethodID methodID;
|
||||
char param_jtypes[MAX_NARGS];
|
||||
char* arg_jtypes;
|
||||
jboolean direct;
|
||||
void* fptr;
|
||||
} callback;
|
||||
|
||||
// Size of a register
|
||||
typedef long word_t;
|
||||
|
||||
#if defined(SOLARIS2) || defined(__GNUC__)
|
||||
#if defined(_WIN64)
|
||||
#define L2A(X) ((void *)(long long)(X))
|
||||
#define A2L(X) ((jlong)(long long)(X))
|
||||
#else
|
||||
#define L2A(X) ((void *)(unsigned long)(X))
|
||||
#define A2L(X) ((jlong)(unsigned long)(X))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define L2A(X) ((void *)(X))
|
||||
#define A2L(X) ((jlong)(X))
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
/* Convenience macros */
|
||||
@@ -81,21 +132,51 @@ typedef long word_t;
|
||||
#define EUnsatisfiedLink "java/lang/UnsatisfiedLinkError"
|
||||
#define EIllegalState "java/lang/IllegalStateException"
|
||||
#define EUnsupportedOperation "java/lang/UnsupportedOperationException"
|
||||
#define ERuntime "java/lang/RuntimeException"
|
||||
#define EError "java/lang/Error"
|
||||
#define ELastError "com/sun/jna/LastErrorException"
|
||||
|
||||
extern void throwByName(JNIEnv *env, const char *name, const char *msg);
|
||||
extern jobject newJavaPointer(JNIEnv *, void *);
|
||||
extern char get_jtype(JNIEnv*, jclass);
|
||||
extern int get_jtype(JNIEnv*, jclass);
|
||||
extern ffi_type* get_ffi_type(JNIEnv*, jclass, char);
|
||||
extern ffi_type* get_ffi_rtype(JNIEnv*, jclass, char);
|
||||
extern const char* jnidispatch_callback_init(JNIEnv*);
|
||||
extern void jnidispatch_callback_dispose(JNIEnv*);
|
||||
extern callback* create_callback(JNIEnv*, jobject, jobject,
|
||||
jobjectArray, jclass,
|
||||
callconv_t);
|
||||
callconv_t, jboolean);
|
||||
extern void free_callback(JNIEnv*, callback*);
|
||||
extern void extract_value(JNIEnv*, jobject, void*, size_t size);
|
||||
extern jobject new_object(JNIEnv*, char, void*);
|
||||
extern void extract_value(JNIEnv*, jobject, void*, size_t, jboolean);
|
||||
extern jobject new_object(JNIEnv*, char, void*, jboolean);
|
||||
extern jboolean is_protected();
|
||||
extern int get_conversion_flag(JNIEnv*, jclass);
|
||||
extern jboolean ffi_error(JNIEnv*,const char*,ffi_status);
|
||||
|
||||
extern jobject newJavaPointer(JNIEnv*, void*);
|
||||
extern jstring newJavaString(JNIEnv*, const char*, jboolean);
|
||||
extern jobject newJavaWString(JNIEnv*, const wchar_t*);
|
||||
extern jobject newJavaStructure(JNIEnv*, void*, jclass, jboolean);
|
||||
extern jobject newJavaCallback(JNIEnv*, void*, jclass);
|
||||
extern void* getNativeString(JNIEnv*, jstring, jboolean);
|
||||
extern void* getNativeAddress(JNIEnv*, jobject);
|
||||
extern void* getStructureAddress(JNIEnv*, jobject);
|
||||
extern void* getCallbackAddress(JNIEnv*, jobject);
|
||||
extern jlong getIntegerTypeValue(JNIEnv*, jobject);
|
||||
extern void* getPointerTypeAddress(JNIEnv*, jobject);
|
||||
extern void writeStructure(JNIEnv*, jobject);
|
||||
extern jclass getNativeType(JNIEnv*, jclass);
|
||||
extern void toNative(JNIEnv*, jobject, void*, size_t, jboolean);
|
||||
extern jclass fromNative(JNIEnv*, jclass, ffi_type*, void*, jboolean);
|
||||
|
||||
/* Native memory fault protection */
|
||||
#ifdef HAVE_PROTECTION
|
||||
#define PROTECT is_protected()
|
||||
#endif
|
||||
#include "protect.h"
|
||||
#define ON_ERROR() throwByName(env, EError, "Invalid memory access")
|
||||
#define PSTART() PROTECTED_START()
|
||||
#define PEND() PROTECTED_END(ON_ERROR())
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Arquivo executável
+56
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# ld-compatible wrapper for link.exe
|
||||
#
|
||||
#args="/pdbtype:sept"
|
||||
MSVC="/c/Program Files (x86)/Microsoft Visual Studio 9.0/vc/bin"
|
||||
args="/nologo /opt:REF /incremental:no /subsystem:console /nodefaultlib:msvcrtd"
|
||||
link="$MSVC/link"
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case $1
|
||||
in
|
||||
-m32)
|
||||
link="$MSVC/link"
|
||||
args="$args /machine:X86"
|
||||
shift 1
|
||||
;;
|
||||
-m64)
|
||||
link="$MSVC/x86_amd64/link"
|
||||
args="$args /machine:X64"
|
||||
shift 1
|
||||
;;
|
||||
-g)
|
||||
args="$args /debug"
|
||||
shift 1
|
||||
;;
|
||||
-o)
|
||||
dir="$(dirname $2)"
|
||||
base="$(basename $2|sed 's/\.[^.]*//g')"
|
||||
args="$args /out:\"$2\" /pdb:$dir/$base.pdb /implib:$dir/$base.lib"
|
||||
shift 2
|
||||
;;
|
||||
-shared)
|
||||
args="$args /DLL"
|
||||
shift 1
|
||||
;;
|
||||
-static-libgcc)
|
||||
shift 1
|
||||
;;
|
||||
*.dll)
|
||||
args="$args $(echo $1|sed -e 's/.dll/.lib/g')"
|
||||
shift 1
|
||||
;;
|
||||
*.o|*.lib|*.a)
|
||||
args="$args $(echo $1|sed -e 's%\\%/%g')"
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported argument '$1'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "\"$link\" $args"
|
||||
eval "\"$link\" $args"
|
||||
@@ -1,12 +1,229 @@
|
||||
2007-11-26 Timothy Wall <twall@users.sf.net>
|
||||
2009-06-16 Wim Lewis <wiml@hhhh.org>
|
||||
|
||||
* src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are
|
||||
supposed to be callee-saved.
|
||||
* src/powerpc/sysv.S (small_struct_return_value): Fix overrun of
|
||||
return buffer for odd-size structs.
|
||||
|
||||
2009-06-16 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
PR libffi/40444
|
||||
* testsuite/lib/libffi-dg.exp (libffi_target_compile): Add
|
||||
allow_stack_execute for Darwin.
|
||||
|
||||
2009-06-16 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* configure.ac (TARGETDIR): Add missing blank lines.
|
||||
* configure: Regenerate.
|
||||
|
||||
2009-06-16 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/err_bad_typedef.c: xfail everywhere.
|
||||
* testsuite/libffi.call/err_bad_abi.c: Likewise.
|
||||
|
||||
2009-06-11 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*.
|
||||
* testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*.
|
||||
* testsuite/libffi.call/err_bad_typedef.c: Likewise.
|
||||
|
||||
2009-06-08 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/err_bad_abi.c: Add xfails.
|
||||
* testsuite/libffi.call/cls_longdouble_va.c: Add xfails.
|
||||
* testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*.
|
||||
* testsuite/libffi.call/err_bad_typedef.c: Add xfails.
|
||||
|
||||
* testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args.
|
||||
* testsuite/libffi.call/stret_medium.c: Likewise.
|
||||
* testsuite/libffi.call/stret_large2.c: Likewise.
|
||||
* testsuite/libffi.call/stret_large.c: Likewise.
|
||||
|
||||
2009-06-05 Andrew Haley <aph@redhat.com>
|
||||
|
||||
* src/x86/win32.S (_ffi_closure_STDCALL): Import from gcc.
|
||||
|
||||
2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
|
||||
|
||||
* src/x86/win32.S (_ffi_closure_STDCALL): New function.
|
||||
(.eh_frame): Add FDE for it.
|
||||
|
||||
2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
|
||||
|
||||
* configure.ac: Also check if assembler supports pc-relative
|
||||
relocs on X86_WIN32 targets.
|
||||
* configure: Regenerate.
|
||||
* src/x86/win32.S (ffi_prep_args): Declare extern, not global.
|
||||
(_ffi_call_SYSV): Add missing function type symbol .def and
|
||||
add EH markup labels.
|
||||
(_ffi_call_STDCALL): Likewise.
|
||||
(_ffi_closure_SYSV): Likewise.
|
||||
(_ffi_closure_raw_SYSV): Likewise.
|
||||
(.eh_frame): Add hand-crafted EH data.
|
||||
|
||||
2008-12-18 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||
|
||||
PR libffi/26048
|
||||
* configure.ac (HAVE_AS_X86_PCREL): New test.
|
||||
* configure: Regenerate.
|
||||
* fficonfig.h.in: Regenerate.
|
||||
* src/x86/sysv.S [!FFI_NO_RAW_API]: Precalculate
|
||||
RAW_CLOSURE_CIF_OFFSET, RAW_CLOSURE_FUN_OFFSET,
|
||||
RAW_CLOSURE_USER_DATA_OFFSET for the Solaris 10/x86 assembler.
|
||||
(.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL.
|
||||
* src/x86/unix64.S (.Lstore_table): Move to .text section.
|
||||
(.Lload_table): Likewise.
|
||||
(.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL.
|
||||
|
||||
2008-11-21 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for
|
||||
signed/unsigned int8/16 return values.
|
||||
* src/sparc/v8.S (ffi_call_v8): Likewise.
|
||||
(ffi_closure_v8): Likewise.
|
||||
|
||||
2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
|
||||
FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
|
||||
Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
|
||||
Adjust copyright notice.
|
||||
* src/powerpc/ffi.c: Add two new flags to indicate if we have one
|
||||
register or two register to use for FFI_SYSV structs.
|
||||
(ffi_prep_cif_machdep): Pass the right register flag introduced above.
|
||||
(ffi_closure_helper_SYSV): Fix the return type for
|
||||
FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
|
||||
Adjust copyright notice.
|
||||
|
||||
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
|
||||
int.
|
||||
|
||||
2008-03-26 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/sysv.S: Add .note.GNU-stack on Linux.
|
||||
* src/sh64/sysv.S: Likewise.
|
||||
|
||||
2008-03-26 Daniel Jacobowitz <dan@debian.org>
|
||||
|
||||
* src/arm/sysv.S: Fix ARM comment marker.
|
||||
|
||||
2008-03-26 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* src/alpha/osf.S: Add .note.GNU-stack on Linux.
|
||||
* src/s390/sysv.S: Likewise.
|
||||
* src/powerpc/ppc_closure.S: Likewise.
|
||||
* src/powerpc/sysv.S: Likewise.
|
||||
* src/x86/unix64.S: Likewise.
|
||||
* src/x86/sysv.S: Likewise.
|
||||
* src/sparc/v8.S: Likewise.
|
||||
* src/sparc/v9.S: Likewise.
|
||||
* src/m68k/sysv.S: Likewise.
|
||||
* src/arm/sysv.S: Likewise.
|
||||
|
||||
2008-02-12 Bjoern Koenig <bkoenig@alpha-tierchen.de>
|
||||
Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* configure.ac: Add amd64-*-freebsd* target.
|
||||
* configure: Regenerate.
|
||||
|
||||
2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR libffi/34612
|
||||
* src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
|
||||
returning struct.
|
||||
|
||||
* testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
|
||||
tests.
|
||||
|
||||
2008-01-24 David Edelsohn <edelsohn@gnu.org>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
||||
2008-01-06 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* src/x86/ffi.c (ffi_prep_cif_machdep): Fix thinko.
|
||||
|
||||
2008-01-05 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
PR testsuite/32843
|
||||
* src/x86/ffi.c (ffi_prep_cif_machdep): Add code for
|
||||
signed/unsigned int8/16 for X86_DARWIN.
|
||||
Updated copyright info.
|
||||
Handle one and two byte structs with special cif->flags.
|
||||
* src/x86/ffitarget.h: Add special types for one and two byte structs.
|
||||
Updated copyright info.
|
||||
* src/x86/darwin.S (ffi_call_SYSV): Rewrite to use a jump table like
|
||||
sysv.S
|
||||
Remove code to pop args from the stack after call.
|
||||
Special-case signed/unsigned for int8/16, one and two byte structs.
|
||||
(ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8,
|
||||
FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32,
|
||||
FFI_TYPE_SINT32.
|
||||
Updated copyright info.
|
||||
|
||||
2007-12-08 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/n32.S (ffi_call_N32): Replace dadd with ADDU, dsub with
|
||||
SUBU, add with ADDU and use smaller code sequences.
|
||||
|
||||
2007-12-07 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/ffi.c (ffi_prep_cif_machdep): Handle long double return
|
||||
type.
|
||||
|
||||
2007-12-06 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* include/ffi.h.in (FFI_SIZEOF_JAVA_RAW): Define if not already
|
||||
defined.
|
||||
(ffi_java_raw): New typedef.
|
||||
(ffi_java_raw_call, ffi_java_ptrarray_to_raw,
|
||||
ffi_java_raw_to_ptrarray): Change parameter types from ffi_raw to
|
||||
ffi_java_raw.
|
||||
(ffi_java_raw_closure) : Same.
|
||||
(ffi_prep_java_raw_closure, ffi_prep_java_raw_closure_loc): Change
|
||||
parameter types.
|
||||
* src/java_raw_api.c (ffi_java_raw_size): Replace FFI_SIZEOF_ARG with
|
||||
FFI_SIZEOF_JAVA_RAW.
|
||||
(ffi_java_raw_to_ptrarray): Change type of raw to ffi_java_raw.
|
||||
Replace FFI_SIZEOF_ARG with FFI_SIZEOF_JAVA_RAW. Use
|
||||
sizeof(ffi_java_raw) for alignment calculations.
|
||||
(ffi_java_ptrarray_to_raw): Same.
|
||||
(ffi_java_rvalue_to_raw): Add special handling for FFI_TYPE_POINTER
|
||||
if FFI_SIZEOF_JAVA_RAW == 4.
|
||||
(ffi_java_raw_to_rvalue): Same.
|
||||
(ffi_java_raw_call): Change type of raw to ffi_java_raw.
|
||||
(ffi_java_translate_args): Same.
|
||||
(ffi_prep_java_raw_closure_loc, ffi_prep_java_raw_closure): Change
|
||||
parameter types.
|
||||
* src/mips/ffitarget.h (FFI_SIZEOF_JAVA_RAW): Define for N32 ABI.
|
||||
|
||||
2007-12-06 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/n32.S (ffi_closure_N32): Use 64-bit add instruction on
|
||||
pointer values.
|
||||
|
||||
2007-12-01 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
PR libffi/31937
|
||||
* src/powerpc/ffitarget.h: Introduce new ABI FFI_LINUX_SOFT_FLOAT.
|
||||
Add local FFI_TYPE_UINT128 to handle soft-float long-double-128.
|
||||
* src/powerpc/ffi.c: Distinguish between __NO_FPRS__ and not and
|
||||
set the NUM_FPR_ARG_REGISTERS according to.
|
||||
Add support for potential soft-float support under hard-float
|
||||
architecture.
|
||||
(ffi_prep_args_SYSV): Set NUM_FPR_ARG_REGISTERS to 0 in case of
|
||||
FFI_LINUX_SOFT_FLOAT, handle float, doubles and long-doubles according
|
||||
to the FFI_LINUX_SOFT_FLOAT ABI.
|
||||
(ffi_prep_cif_machdep): Likewise.
|
||||
(ffi_closure_helper_SYSV): Likewise.
|
||||
* src/powerpc/ppc_closure.S: Make sure not to store float/double
|
||||
on archs where __NO_FPRS__ is true.
|
||||
Add FFI_TYPE_UINT128 support.
|
||||
* src/powerpc/sysv.S: Add support for soft-float long-double-128.
|
||||
Adjust copyright notice.
|
||||
|
||||
* testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
|
||||
closures.
|
||||
* src/x86/ffitarget.h: Increase size of trampoline for stdcall
|
||||
closures.
|
||||
* src/x86/win32.S: Add assembly for stdcall closure.
|
||||
* src/x86/ffi.c: Initialize stdcall closure trampoline.
|
||||
|
||||
2007-11-25 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* src/closures.c: Move defintion of MAYBE_UNUSED from here to ...
|
||||
|
||||
@@ -0,0 +1,524 @@
|
||||
2009-05-12 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* Makefile.am,
|
||||
configure.ac,
|
||||
include/ffi.h.in,
|
||||
include/ffi_common.h,
|
||||
src/closures.c,
|
||||
src/dlmalloc.c,
|
||||
src/x86/ffi.c,
|
||||
src/x86/ffitarget.h,
|
||||
src/x86/win64.S (new),
|
||||
README: Added win64 support (mingw or MSVC)
|
||||
* Makefile.in,
|
||||
include/Makefile.in,
|
||||
man/Makefile.in,
|
||||
testsuite/Makefile.in,
|
||||
configure,
|
||||
aclocal.m4: Regenerated
|
||||
* ltcf-c.sh: properly escape cygwin/w32 path
|
||||
* man/ffi_call.3: Clarify size requirements for return value.
|
||||
* src/x86/ffi64.c: Fix filename in comment.
|
||||
* src/x86/win32.S: Remove global reference which causes undefined
|
||||
symbol warning.
|
||||
* testsuite/libffi.call/closure_fn0.c,
|
||||
testsuite/libffi.call/closure_fn1.c,
|
||||
testsuite/libffi.call/closure_fn2.c,
|
||||
testsuite/libffi.call/closure_fn3.c,
|
||||
testsuite/libffi.call/closure_fn4.c,
|
||||
testsuite/libffi.call/closure_fn5.c,
|
||||
testsuite/libffi.call/closure_fn6.c,
|
||||
testsuite/libffi.call/closure_stdcall.c,
|
||||
testsuite/libffi.call/cls_12byte.c,
|
||||
testsuite/libffi.call/cls_16byte.c,
|
||||
testsuite/libffi.call/cls_18byte.c,
|
||||
testsuite/libffi.call/cls_19byte.c,
|
||||
testsuite/libffi.call/cls_1_1byte.c,
|
||||
testsuite/libffi.call/cls_20byte.c,
|
||||
testsuite/libffi.call/cls_20byte1.c,
|
||||
testsuite/libffi.call/cls_24byte.c,
|
||||
testsuite/libffi.call/cls_2byte.c,
|
||||
testsuite/libffi.call/cls_3_1byte.c,
|
||||
testsuite/libffi.call/cls_3byte1.c,
|
||||
testsuite/libffi.call/cls_3byte2.c,
|
||||
testsuite/libffi.call/cls_4_1byte.c,
|
||||
testsuite/libffi.call/cls_4byte.c,
|
||||
testsuite/libffi.call/cls_5_1_byte.c,
|
||||
testsuite/libffi.call/cls_5byte.c,
|
||||
testsuite/libffi.call/cls_64byte.c,
|
||||
testsuite/libffi.call/cls_6_1_byte.c,
|
||||
testsuite/libffi.call/cls_6byte.c,
|
||||
testsuite/libffi.call/cls_7_1_byte.c,
|
||||
testsuite/libffi.call/cls_7byte.c,
|
||||
testsuite/libffi.call/cls_8byte.c,
|
||||
testsuite/libffi.call/cls_9byte1.c,
|
||||
testsuite/libffi.call/cls_9byte2.c,
|
||||
testsuite/libffi.call/cls_align_double.c,
|
||||
testsuite/libffi.call/cls_align_float.c,
|
||||
testsuite/libffi.call/cls_align_longdouble.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split2.c,
|
||||
testsuite/libffi.call/cls_align_pointer.c,
|
||||
testsuite/libffi.call/cls_align_sint16.c,
|
||||
testsuite/libffi.call/cls_align_sint32.c,
|
||||
testsuite/libffi.call/cls_align_sint64.c,
|
||||
testsuite/libffi.call/cls_align_uint16.c,
|
||||
testsuite/libffi.call/cls_align_uint32.c,
|
||||
testsuite/libffi.call/cls_align_uint64.c,
|
||||
testsuite/libffi.call/cls_dbls_struct.c,
|
||||
testsuite/libffi.call/cls_double.c,
|
||||
testsuite/libffi.call/cls_double_va.c,
|
||||
testsuite/libffi.call/cls_float.c,
|
||||
testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_multi_schar.c,
|
||||
testsuite/libffi.call/cls_multi_sshort.c,
|
||||
testsuite/libffi.call/cls_multi_sshortchar.c,
|
||||
testsuite/libffi.call/cls_multi_uchar.c,
|
||||
testsuite/libffi.call/cls_multi_ushort.c,
|
||||
testsuite/libffi.call/cls_multi_ushortchar.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c,
|
||||
testsuite/libffi.call/cls_schar.c,
|
||||
testsuite/libffi.call/cls_sint.c,
|
||||
testsuite/libffi.call/cls_sshort.c,
|
||||
testsuite/libffi.call/cls_uchar.c,
|
||||
testsuite/libffi.call/cls_uint.c,
|
||||
testsuite/libffi.call/cls_ulonglong.c,
|
||||
testsuite/libffi.call/cls_ushort.c,
|
||||
testsuite/libffi.call/err_bad_abi.c,
|
||||
testsuite/libffi.call/err_bad_typedef.c,
|
||||
testsuite/libffi.call/float2.c,
|
||||
testsuite/libffi.call/huge_struct.c,
|
||||
testsuite/libffi.call/nested_struct.c,
|
||||
testsuite/libffi.call/nested_struct1.c,
|
||||
testsuite/libffi.call/nested_struct10.c,
|
||||
testsuite/libffi.call/nested_struct2.c,
|
||||
testsuite/libffi.call/nested_struct3.c,
|
||||
testsuite/libffi.call/nested_struct4.c,
|
||||
testsuite/libffi.call/nested_struct5.c,
|
||||
testsuite/libffi.call/nested_struct6.c,
|
||||
testsuite/libffi.call/nested_struct7.c,
|
||||
testsuite/libffi.call/nested_struct8.c,
|
||||
testsuite/libffi.call/nested_struct9.c,
|
||||
testsuite/libffi.call/problem1.c,
|
||||
testsuite/libffi.call/return_ldl.c,
|
||||
testsuite/libffi.call/return_ll1.c,
|
||||
testsuite/libffi.call/stret_large.c,
|
||||
testsuite/libffi.call/stret_large2.c,
|
||||
testsuite/libffi.call/stret_medium.c,
|
||||
testsuite/libffi.call/stret_medium2.c,
|
||||
testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
|
||||
of checking for MMAP. Use intptr_t instead of long casts.
|
||||
|
||||
2008-12-26 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_align_longdouble.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c,
|
||||
testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected
|
||||
failures on x86_64 cygwin/mingw.
|
||||
|
||||
2008-12-22 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/closure_fn0.c,
|
||||
testsuite/libffi.call/closure_fn1.c,
|
||||
testsuite/libffi.call/closure_fn2.c,
|
||||
testsuite/libffi.call/closure_fn3.c,
|
||||
testsuite/libffi.call/closure_fn4.c,
|
||||
testsuite/libffi.call/closure_fn5.c,
|
||||
testsuite/libffi.call/closure_fn6.c,
|
||||
testsuite/libffi.call/closure_loc_fn0.c,
|
||||
testsuite/libffi.call/closure_stdcall.c,
|
||||
testsuite/libffi.call/cls_align_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
|
||||
pointer to integer (intptr_t).
|
||||
* testsuite/libffi.call/cls_longdouble.c: disable for win64.
|
||||
|
||||
2008-12-19 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.8.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-11-11 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.7.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
|
||||
FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
|
||||
Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
|
||||
Adjust copyright notice.
|
||||
* src/powerpc/ffi.c: Add two new flags to indicate if we have one
|
||||
register or two register to use for FFI_SYSV structs.
|
||||
(ffi_prep_cif_machdep): Pass the right register flag introduced above.
|
||||
(ffi_closure_helper_SYSV): Fix the return type for
|
||||
FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
|
||||
Adjust copyright notice.
|
||||
|
||||
2008-07-24 Anthony Green <green@redhat.com>
|
||||
|
||||
* testsuite/libffi.call/cls_dbls_struct.c,
|
||||
testsuite/libffi.call/cls_double_va.c,
|
||||
testsuite/libffi.call/cls_longdouble.c,
|
||||
testsuite/libffi.call/cls_longdouble_va.c,
|
||||
testsuite/libffi.call/cls_pointer.c,
|
||||
testsuite/libffi.call/cls_pointer_stack.c,
|
||||
testsuite/libffi.call/err_bad_abi.c: Clean up failures from
|
||||
compiler warnings.
|
||||
|
||||
2008-07-17 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.6.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision. Add documentation.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
|
||||
int.
|
||||
|
||||
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/sysv.S: Add .note.GNU-stack on Linux.
|
||||
* src/sh64/sysv.S: Likewise.
|
||||
|
||||
2008-04-03 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in (Libs): Add -L${libdir}.
|
||||
* configure.ac: Bump version to 3.0.5.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-04-03 Anthony Green <green@redhat.com>
|
||||
Xerces Ranby <xerxes@zafena.se>
|
||||
|
||||
* include/ffi.h.in: Wrap definition of target architecture to
|
||||
protect from double definitions.
|
||||
|
||||
2008-03-22 Moriyoshi Koizumi <moriyoshi@gmail.com>
|
||||
|
||||
* src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in
|
||||
closure_loc_fn0.c.
|
||||
* testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0):
|
||||
New test.
|
||||
|
||||
2008-03-04 Anthony Green <green@redhat.com>
|
||||
Blake Chaffin
|
||||
hos@tamanegi.org
|
||||
|
||||
* testsuite/libffi.call/cls_align_longdouble_split2.c
|
||||
testsuite/libffi.call/cls_align_longdouble_split.c
|
||||
testsuite/libffi.call/cls_dbls_struct.c
|
||||
testsuite/libffi.call/cls_double_va.c
|
||||
testsuite/libffi.call/cls_longdouble.c
|
||||
testsuite/libffi.call/cls_longdouble_va.c
|
||||
testsuite/libffi.call/cls_pointer.c
|
||||
testsuite/libffi.call/cls_pointer_stack.c
|
||||
testsuite/libffi.call/err_bad_abi.c
|
||||
testsuite/libffi.call/err_bad_typedef.c
|
||||
testsuite/libffi.call/huge_struct.c
|
||||
testsuite/libffi.call/stret_large2.c
|
||||
testsuite/libffi.call/stret_large.c
|
||||
testsuite/libffi.call/stret_medium2.c
|
||||
testsuite/libffi.call/stret_medium.c: New tests from Apple.
|
||||
|
||||
2008-02-26 Jakub Jelinek <jakub@redhat.com>
|
||||
Anthony Green <green@redhat.com>
|
||||
|
||||
* src/alpha/osf.S: Add .note.GNU-stack on Linux.
|
||||
* src/s390/sysv.S: Likewise.
|
||||
* src/powerpc/linux64.S: Likewise.
|
||||
* src/powerpc/linux64_closure.S: Likewise.
|
||||
* src/powerpc/ppc_closure.S: Likewise.
|
||||
* src/powerpc/sysv.S: Likewise.
|
||||
* src/x86/unix64.S: Likewise.
|
||||
* src/x86/sysv.S: Likewise.
|
||||
* src/sparc/v8.S: Likewise.
|
||||
* src/sparc/v9.S: Likewise.
|
||||
* src/m68k/sysv.S: Likewise.
|
||||
* src/ia64/unix.S: Likewise.
|
||||
* src/arm/sysv.S: Likewise.
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.com>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
|
||||
comment.
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.org>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* include/ffi.h.in: Change void (*)() to void (*)(void).
|
||||
|
||||
2008-02-26 Anthony Green <green@redhat.org>
|
||||
Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* src/alpha/ffi.c: Change void (*)() to void (*)(void).
|
||||
src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
|
||||
src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
|
||||
src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
|
||||
src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
|
||||
src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
|
||||
src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,
|
||||
src/x86/ffi64.c: Ditto.
|
||||
|
||||
2008-02-24 Anthony Green <green@redhat.org>
|
||||
|
||||
* configure.ac: Accept openbsd*, not just openbsd.
|
||||
Bump version to 3.0.4.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-22 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Clean up list of tested platforms.
|
||||
|
||||
2008-02-22 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.3.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release. Clean up test docs.
|
||||
|
||||
2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
|
||||
Andreas Tobler <a.tobler@schweiz.org>
|
||||
|
||||
* configure.ac: Add amd64-*-freebsd* target.
|
||||
* configure: Regenerate.
|
||||
|
||||
2008-02-22 Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* configure.ac: Add x86 OpenBSD support.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-21 Thomas Heller <theller@ctypes.org>
|
||||
|
||||
* README: Change "make test" to "make check".
|
||||
|
||||
2008-02-21 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.2.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-21 Björn König <bkoenig@alpha-tierchen.de>
|
||||
|
||||
* src/x86/freebsd.S: New file.
|
||||
* configure.ac: Add x86 FreeBSD support.
|
||||
* Makefile.am: Ditto.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.1.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* libtool-version: Increment revision.
|
||||
* README: Update for new release.
|
||||
|
||||
2008-02-15 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/ffi.c: Remove extra '>' from include directive.
|
||||
(ffi_prep_closure_loc): Use clear_location instead of tramp.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 3.0.0.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-15 David Daney <ddaney@avtrex.com>
|
||||
|
||||
* src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
|
||||
Define (conditionally), and use it to include cachectl.h.
|
||||
(ffi_prep_closure_loc): Fix cache flushing.
|
||||
* src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
|
||||
Update dates and remove all references to ffi_prep_closure.
|
||||
* configure.ac: Bump version to 2.99.9.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-15 Anthony Green <green@redhat.com>
|
||||
|
||||
* man/ffi_prep_closure.3: Delete.
|
||||
* man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
|
||||
(man_MANS): Ditto.
|
||||
* man/Makefile.in: Rebuilt.
|
||||
* configure.ac: Bump version to 2.99.8.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 2.99.7.
|
||||
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
|
||||
* include/ffi.h.in LICENSE src/debug.c src/closures.c
|
||||
src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
|
||||
src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
|
||||
src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
|
||||
src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
|
||||
src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
|
||||
src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
|
||||
src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
|
||||
src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
|
||||
src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
|
||||
src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
|
||||
src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
|
||||
src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
|
||||
src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
|
||||
src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
|
||||
src/arm/ffitarget.h src/prep_cif.c: Update license text.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Update tested platforms.
|
||||
* configure.ac: Bump version to 2.99.6.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* configure.ac: Bump version to 2.99.5.
|
||||
* configure: Rebuilt.
|
||||
* Makefile.am (EXTRA_DIST): Add darwin64.S
|
||||
* Makefile.in: Rebuilt.
|
||||
* testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
|
||||
* LICENSE: Update WARRANTY.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in (libdir): Fix libdir definition.
|
||||
* configure.ac: Bump version to 2.99.4.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* README: Update.
|
||||
* libffi.info: New file.
|
||||
* doc/stamp-vti: New file.
|
||||
* configure.ac: Bump version to 2.99.3.
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (SUBDIRS): Add man dir.
|
||||
* Makefile.in: Rebuilt.
|
||||
* configure.ac: Create Makefile.
|
||||
* configure: Rebuilt.
|
||||
* man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3
|
||||
man/Makefile.am man/Makefile.in: New files.
|
||||
|
||||
2008-02-14 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
|
||||
* mdate-sh, texinfo.tex: New files.
|
||||
* Makefile.am (info_TEXINFOS): New variable.
|
||||
* doc/libffi.texi: New file.
|
||||
* doc/version.texi: Likewise.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET).
|
||||
(lib_LTLIBRARIES): Define.
|
||||
(toolexeclib_LIBRARIES): Undefine.
|
||||
* Makefile.in: Rebuilt.
|
||||
* configure.ac: Reset version to 2.99.1.
|
||||
* configure.in: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@.
|
||||
* configure.ac: Reset version to 2.99.1.
|
||||
* configure.in: Rebuilt.
|
||||
* Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
|
||||
* Makefile.in: Rebuilt.
|
||||
* LICENSE: Update copyright notice.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (nodist_includes_HEADERS): Define. Don't
|
||||
distribute ffitarget.h or ffi.h from the build include dir.
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
2008-02-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (includesdir): Install headers under libdir.
|
||||
(pkgconfigdir): Define. Install libffi.pc.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
* libffi.pc.in: Create.
|
||||
* libtool-version: Increment CURRENT
|
||||
* configure.ac: Add libffi.pc.in
|
||||
* configure: Rebuilt.
|
||||
|
||||
2008-02-03 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am (includesdir): Fix header install with
|
||||
DESTDIR.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
|
||||
2008-02-03 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
|
||||
offset based on code pointer, not data pointer.
|
||||
|
||||
2008-02-01 Anthony Green <green@redhat.com>
|
||||
|
||||
* include/Makefile.am: Fix header installs.
|
||||
* Makefile.am: Ditto.
|
||||
* include/Makefile.in: Rebuilt.
|
||||
* Makefile.in: Ditto.
|
||||
|
||||
2008-02-01 Anthony Green <green@redhat.com>
|
||||
|
||||
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL,
|
||||
FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last
|
||||
patch.
|
||||
|
||||
2008-01-31 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Add missing files.
|
||||
* testsuite/Makefile.am: Ditto.
|
||||
* Makefile.in, testsuite/Makefile.in: Rebuilt.
|
||||
|
||||
2008-01-31 Timothy Wall <twall@users.sf.net>
|
||||
|
||||
* testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
|
||||
closures.
|
||||
* src/x86/ffitarget.h: Increase size of trampoline for stdcall
|
||||
closures.
|
||||
* src/x86/win32.S: Add assembly for stdcall closure.
|
||||
* src/x86/ffi.c: Initialize stdcall closure trampoline.
|
||||
|
||||
2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR libffi/34612
|
||||
* src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
|
||||
returning struct.
|
||||
|
||||
* testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
|
||||
tests.
|
||||
|
||||
2008-01-30 Anthony Green <green@redhat.com>
|
||||
|
||||
* Makefile.am, include/Makefile.am: Move headers to
|
||||
libffi_la_SOURCES for new automake.
|
||||
* Makefile.in, include/Makefile.in: Rebuilt.
|
||||
|
||||
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
|
||||
execution outside of gcc tree.
|
||||
* testsuite/lib/target-libpath.exp: Ditto.
|
||||
|
||||
* testsuite/lib/libffi-dg.exp: Many changes to allow for execution
|
||||
outside of gcc tree.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
libffi - Copyright (c) 1996-2003 Red Hat, Inc.
|
||||
libffi - Copyright (c) 1996-2008 Red Hat, Inc and others.
|
||||
See source files for details.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -11,10 +12,10 @@ the following conditions:
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
## Process this with automake to create Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
|
||||
SUBDIRS = include testsuite
|
||||
SUBDIRS = include testsuite man
|
||||
|
||||
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
|
||||
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
|
||||
@@ -25,11 +24,15 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
|
||||
src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \
|
||||
src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
|
||||
src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \
|
||||
src/sparc/ffi.c \
|
||||
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/darwin.S \
|
||||
src/sparc/ffi.c src/x86/darwin64.S \
|
||||
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \
|
||||
src/x86/darwin.S src/x86/freebsd.S \
|
||||
src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \
|
||||
src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \
|
||||
src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h
|
||||
src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \
|
||||
libtool-version ChangeLog.libffi
|
||||
|
||||
info_TEXINFOS = doc/libffi.texi
|
||||
|
||||
## ################################################################
|
||||
|
||||
@@ -76,12 +79,15 @@ AM_MAKEFLAGS = \
|
||||
|
||||
MAKEOVERRIDES=
|
||||
|
||||
toolexeclib_LTLIBRARIES = libffi.la
|
||||
lib_LTLIBRARIES = libffi.la
|
||||
noinst_LTLIBRARIES = libffi_convenience.la
|
||||
|
||||
libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c \
|
||||
src/raw_api.c src/java_raw_api.c src/closures.c
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libffi.pc
|
||||
|
||||
nodist_libffi_la_SOURCES =
|
||||
|
||||
if MIPS
|
||||
@@ -90,9 +96,15 @@ endif
|
||||
if X86
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S
|
||||
endif
|
||||
if X86_FREEBSD
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/freebsd.S
|
||||
endif
|
||||
if X86_WIN32
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
|
||||
endif
|
||||
if X86_WIN64
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
|
||||
endif
|
||||
if X86_DARWIN
|
||||
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
|
||||
endif
|
||||
@@ -166,10 +178,3 @@ AM_CCASFLAGS = $(AM_CPPFLAGS)
|
||||
install-html:
|
||||
install-pdf:
|
||||
|
||||
# Multilib support. Automake should provide these on its own.
|
||||
all-recursive: all-multi
|
||||
install-recursive: install-multi
|
||||
mostlyclean-recursive: mostlyclean-multi
|
||||
clean-recursive: clean-multi
|
||||
distclean-recursive: distclean-multi
|
||||
maintainer-clean-recursive: maintainer-clean-multi
|
||||
|
||||
+610
-325
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+120
-274
@@ -1,78 +1,72 @@
|
||||
This directory contains the libffi package, which is not part of GCC but
|
||||
shipped with GCC as convenience.
|
||||
|
||||
Status
|
||||
======
|
||||
|
||||
libffi-2.00 has not been released yet! This is a development snapshot!
|
||||
|
||||
libffi-1.20 was released on October 5, 1998. Check the libffi web
|
||||
page for updates: <URL:http://sources.redhat.com/libffi/>.
|
||||
libffi-3.0.8 was released on December 19, 2008. Check the libffi web
|
||||
page for updates: <URL:http://sourceware.org/libffi/>.
|
||||
|
||||
|
||||
What is libffi?
|
||||
===============
|
||||
|
||||
Compilers for high level languages generate code that follow certain
|
||||
conventions. These conventions are necessary, in part, for separate
|
||||
compilation to work. One such convention is the "calling
|
||||
convention". The "calling convention" is essentially a set of
|
||||
assumptions made by the compiler about where function arguments will
|
||||
be found on entry to a function. A "calling convention" also specifies
|
||||
where the return value for a function is found.
|
||||
conventions. These conventions are necessary, in part, for separate
|
||||
compilation to work. One such convention is the "calling convention".
|
||||
The "calling convention" is a set of assumptions made by the compiler
|
||||
about where function arguments will be found on entry to a function.
|
||||
A "calling convention" also specifies where the return value for a
|
||||
function is found.
|
||||
|
||||
Some programs may not know at the time of compilation what arguments
|
||||
are to be passed to a function. For instance, an interpreter may be
|
||||
are to be passed to a function. For instance, an interpreter may be
|
||||
told at run-time about the number and types of arguments used to call
|
||||
a given function. Libffi can be used in such programs to provide a
|
||||
a given function. Libffi can be used in such programs to provide a
|
||||
bridge from the interpreter program to compiled code.
|
||||
|
||||
The libffi library provides a portable, high level programming
|
||||
interface to various calling conventions. This allows a programmer to
|
||||
interface to various calling conventions. This allows a programmer to
|
||||
call any function specified by a call interface description at run
|
||||
time.
|
||||
time.
|
||||
|
||||
Ffi stands for Foreign Function Interface. A foreign function
|
||||
FFI stands for Foreign Function Interface. A foreign function
|
||||
interface is the popular name for the interface that allows code
|
||||
written in one language to call code written in another language. The
|
||||
written in one language to call code written in another language. The
|
||||
libffi library really only provides the lowest, machine dependent
|
||||
layer of a fully featured foreign function interface. A layer must
|
||||
exist above libffi that handles type conversions for values passed
|
||||
between the two languages.
|
||||
|
||||
|
||||
Supported Platforms and Prerequisites
|
||||
=====================================
|
||||
Supported Platforms
|
||||
===================
|
||||
|
||||
Libffi has been ported to:
|
||||
|
||||
SunOS 4.1.3 & Solaris 2.x (SPARC-V8, SPARC-V9)
|
||||
|
||||
Irix 5.3 & 6.2 (System V/o32 & n32)
|
||||
|
||||
Intel x86 - Linux (System V ABI)
|
||||
|
||||
Alpha - Linux and OSF/1
|
||||
|
||||
m68k - Linux (System V ABI)
|
||||
|
||||
PowerPC - Linux (System V ABI, Darwin, AIX)
|
||||
|
||||
ARM - Linux (System V ABI)
|
||||
|
||||
Libffi has been tested with the egcs 1.0.2 gcc compiler. Chances are
|
||||
that other versions will work. Libffi has also been built and tested
|
||||
with the SGI compiler tools.
|
||||
|
||||
On PowerPC, the tests failed (see the note below).
|
||||
|
||||
You must use GNU make to build libffi. SGI's make will not work.
|
||||
Sun's probably won't either.
|
||||
|
||||
If you port libffi to another platform, please let me know! I assume
|
||||
that some will be easy (x86 NetBSD), and others will be more difficult
|
||||
(HP).
|
||||
Libffi has been ported to many different platforms, although this
|
||||
release was only tested on:
|
||||
|
||||
arm oabi linux
|
||||
arm eabi linux
|
||||
hppa linux
|
||||
mips o32 linux (little endian)
|
||||
powerpc darwin
|
||||
powerpc freebsd
|
||||
powerpc64 linux
|
||||
sparc solaris
|
||||
sparc64 freebsd
|
||||
sparc64 solaris
|
||||
x86 cygwin
|
||||
x86 darwin
|
||||
x86 freebsd
|
||||
x86 linux
|
||||
x86 openbsd
|
||||
x86 solaris
|
||||
x86-64 mingw
|
||||
x86-64 darwin
|
||||
x86-64 linux
|
||||
x86-64 OS X
|
||||
x86-64 freebsd
|
||||
x86-64 solaris
|
||||
|
||||
Please send additional platform test results to
|
||||
libffi-discuss@sourceware.org.
|
||||
|
||||
Installing libffi
|
||||
=================
|
||||
@@ -101,216 +95,17 @@ Purify, as it will slow down the library.
|
||||
Configure has many other options. Use "configure --help" to see them all.
|
||||
|
||||
Once configure has finished, type "make". Note that you must be using
|
||||
GNU make. SGI's make will not work. Sun's probably won't either.
|
||||
You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
|
||||
GNU make. You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
|
||||
|
||||
To ensure that libffi is working as advertised, type "make test".
|
||||
To ensure that libffi is working as advertised, type "make check".
|
||||
This will require that you have DejaGNU installed.
|
||||
|
||||
To install the library and header files, type "make install".
|
||||
|
||||
|
||||
Using libffi
|
||||
============
|
||||
|
||||
The Basics
|
||||
----------
|
||||
|
||||
Libffi assumes that you have a pointer to the function you wish to
|
||||
call and that you know the number and types of arguments to pass it,
|
||||
as well as the return type of the function.
|
||||
|
||||
The first thing you must do is create an ffi_cif object that matches
|
||||
the signature of the function you wish to call. The cif in ffi_cif
|
||||
stands for Call InterFace. To prepare a call interface object, use the
|
||||
following function:
|
||||
|
||||
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi,
|
||||
unsigned int nargs,
|
||||
ffi_type *rtype, ffi_type **atypes);
|
||||
|
||||
CIF is a pointer to the call interface object you wish
|
||||
to initialize.
|
||||
|
||||
ABI is an enum that specifies the calling convention
|
||||
to use for the call. FFI_DEFAULT_ABI defaults
|
||||
to the system's native calling convention. Other
|
||||
ABI's may be used with care. They are system
|
||||
specific.
|
||||
|
||||
NARGS is the number of arguments this function accepts.
|
||||
libffi does not yet support vararg functions.
|
||||
|
||||
RTYPE is a pointer to an ffi_type structure that represents
|
||||
the return type of the function. Ffi_type objects
|
||||
describe the types of values. libffi provides
|
||||
ffi_type objects for many of the native C types:
|
||||
signed int, unsigned int, signed char, unsigned char,
|
||||
etc. There is also a pointer ffi_type object and
|
||||
a void ffi_type. Use &ffi_type_void for functions that
|
||||
don't return values.
|
||||
|
||||
ATYPES is a vector of ffi_type pointers. ARGS must be NARGS long.
|
||||
If NARGS is 0, this is ignored.
|
||||
|
||||
|
||||
ffi_prep_cif will return a status code that you are responsible
|
||||
for checking. It will be one of the following:
|
||||
|
||||
FFI_OK - All is good.
|
||||
|
||||
FFI_BAD_TYPEDEF - One of the ffi_type objects that ffi_prep_cif
|
||||
came across is bad.
|
||||
|
||||
|
||||
Before making the call, the VALUES vector should be initialized
|
||||
with pointers to the appropriate argument values.
|
||||
|
||||
To call the the function using the initialized ffi_cif, use the
|
||||
ffi_call function:
|
||||
|
||||
void ffi_call(ffi_cif *cif, void *fn, void *rvalue, void **avalues);
|
||||
|
||||
CIF is a pointer to the ffi_cif initialized specifically
|
||||
for this function.
|
||||
|
||||
FN is a pointer to the function you want to call.
|
||||
|
||||
RVALUE is a pointer to a chunk of memory that is to hold the
|
||||
result of the function call. Currently, it must be
|
||||
at least one word in size (except for the n32 version
|
||||
under Irix 6.x, which must be a pointer to an 8 byte
|
||||
aligned value (a long long). It must also be at least
|
||||
word aligned (depending on the return type, and the
|
||||
system's alignment requirements). If RTYPE is
|
||||
&ffi_type_void, this is ignored. If RVALUE is NULL,
|
||||
the return value is discarded.
|
||||
|
||||
AVALUES is a vector of void* that point to the memory locations
|
||||
holding the argument values for a call.
|
||||
If NARGS is 0, this is ignored.
|
||||
|
||||
|
||||
If you are expecting a return value from FN it will have been stored
|
||||
at RVALUE.
|
||||
|
||||
|
||||
|
||||
An Example
|
||||
----------
|
||||
|
||||
Here is a trivial example that calls puts() a few times.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ffi.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
ffi_cif cif;
|
||||
ffi_type *args[1];
|
||||
void *values[1];
|
||||
char *s;
|
||||
int rc;
|
||||
|
||||
/* Initialize the argument info vectors */
|
||||
args[0] = &ffi_type_pointer;
|
||||
values[0] = &s;
|
||||
|
||||
/* Initialize the cif */
|
||||
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
&ffi_type_uint, args) == FFI_OK)
|
||||
{
|
||||
s = "Hello World!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
/* rc now holds the result of the call to puts */
|
||||
|
||||
/* values holds a pointer to the function's arg, so to
|
||||
call puts() again all we need to do is change the
|
||||
value of s */
|
||||
s = "This is cool!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Aggregate Types
|
||||
---------------
|
||||
|
||||
Although libffi has no special support for unions or bit-fields, it is
|
||||
perfectly happy passing structures back and forth. You must first
|
||||
describe the structure to libffi by creating a new ffi_type object
|
||||
for it. Here is the definition of ffi_type:
|
||||
|
||||
typedef struct _ffi_type
|
||||
{
|
||||
unsigned size;
|
||||
short alignment;
|
||||
short type;
|
||||
struct _ffi_type **elements;
|
||||
} ffi_type;
|
||||
|
||||
All structures must have type set to FFI_TYPE_STRUCT. You may set
|
||||
size and alignment to 0. These will be calculated and reset to the
|
||||
appropriate values by ffi_prep_cif().
|
||||
|
||||
elements is a NULL terminated array of pointers to ffi_type objects
|
||||
that describe the type of the structure elements. These may, in turn,
|
||||
be structure elements.
|
||||
|
||||
The following example initializes a ffi_type object representing the
|
||||
tm struct from Linux's time.h:
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
/* Those are for future use. */
|
||||
long int __tm_gmtoff__;
|
||||
__const char *__tm_zone__;
|
||||
};
|
||||
|
||||
{
|
||||
ffi_type tm_type;
|
||||
ffi_type *tm_type_elements[12];
|
||||
int i;
|
||||
|
||||
tm_type.size = tm_type.alignment = 0;
|
||||
tm_type.elements = &tm_type_elements;
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
tm_type_elements[i] = &ffi_type_sint;
|
||||
|
||||
tm_type_elements[9] = &ffi_type_slong;
|
||||
tm_type_elements[10] = &ffi_type_pointer;
|
||||
tm_type_elements[11] = NULL;
|
||||
|
||||
/* tm_type can now be used to represent tm argument types and
|
||||
return types for ffi_prep_cif() */
|
||||
}
|
||||
|
||||
|
||||
|
||||
Platform Specific Notes
|
||||
=======================
|
||||
|
||||
Intel x86
|
||||
---------
|
||||
|
||||
There are no known problems with the x86 port.
|
||||
|
||||
Sun SPARC - SunOS 4.1.3 & Solaris 2.x
|
||||
-------------------------------------
|
||||
|
||||
You must use GNU Make to build libffi on Sun platforms.
|
||||
|
||||
MIPS - Irix 5.3 & 6.x
|
||||
---------------------
|
||||
|
||||
@@ -339,13 +134,6 @@ If you don't do this you are liable to get spurious bus errors.
|
||||
|
||||
You must use GNU Make to build libffi on SGI platforms.
|
||||
|
||||
ARM - System V ABI
|
||||
------------------
|
||||
|
||||
The ARM port was performed on a NetWinder running ARM Linux ELF
|
||||
(2.0.31) and gcc 2.8.1.
|
||||
|
||||
|
||||
|
||||
PowerPC System V ABI
|
||||
--------------------
|
||||
@@ -375,6 +163,42 @@ arguments' test).
|
||||
History
|
||||
=======
|
||||
|
||||
3.0.7 Nov-11-08
|
||||
Fix for ppc FreeBSD.
|
||||
(thanks to Andreas Tobler)
|
||||
|
||||
3.0.6 Jul-17-08
|
||||
Fix for closures on sh.
|
||||
Mark the sh/sh64 stack as non-executable.
|
||||
(both thanks to Kaz Kojima)
|
||||
|
||||
3.0.5 Apr-3-08
|
||||
Fix libffi.pc file.
|
||||
Fix #define ARM for IcedTea users.
|
||||
Fix x86 closure bug.
|
||||
|
||||
3.0.4 Feb-24-08
|
||||
Fix x86 OpenBSD configury.
|
||||
|
||||
3.0.3 Feb-22-08
|
||||
Enable x86 OpenBSD thanks to Thomas Heller, and
|
||||
x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
|
||||
Clean up test instruction in README.
|
||||
|
||||
3.0.2 Feb-21-08
|
||||
Improved x86 FreeBSD support.
|
||||
Thanks to Björn König.
|
||||
|
||||
3.0.1 Feb-15-08
|
||||
Fix instruction cache flushing bug on MIPS.
|
||||
Thanks to David Daney.
|
||||
|
||||
3.0.0 Feb-15-08
|
||||
Many changes, mostly thanks to the GCC project.
|
||||
Cygnus Solutions is now Red Hat.
|
||||
|
||||
[10 years go by...]
|
||||
|
||||
1.20 Oct-5-98
|
||||
Raffaele Sena produces ARM port.
|
||||
|
||||
@@ -458,34 +282,56 @@ History
|
||||
Authors & Credits
|
||||
=================
|
||||
|
||||
libffi was written by Anthony Green <green@cygnus.com>.
|
||||
libffi was originally written by Anthony Green <green@redhat.com>.
|
||||
|
||||
Portions of libffi were derived from Gianni Mariani's free gencall
|
||||
library for Silicon Graphics machines.
|
||||
The developers of the GNU Compiler Collection project have made
|
||||
innumerable valuable contributions. See the ChangeLog file for
|
||||
details.
|
||||
|
||||
Some of the ideas behind libffi were inspired by Gianni Mariani's free
|
||||
gencall library for Silicon Graphics machines.
|
||||
|
||||
The closure mechanism was designed and implemented by Kresten Krab
|
||||
Thorup.
|
||||
|
||||
The Sparc port was derived from code contributed by the fine folks at
|
||||
Visible Decisions Inc <http://www.vdi.com>. Further enhancements were
|
||||
made by Gordon Irlam at Cygnus Solutions <http://www.cygnus.com>.
|
||||
Major processor architecture ports were contributed by the following
|
||||
developers:
|
||||
|
||||
The Alpha port was written by Richard Henderson at Cygnus Solutions.
|
||||
|
||||
Andreas Schwab ported libffi to m68k Linux and provided a number of
|
||||
bug fixes.
|
||||
|
||||
Geoffrey Keating ported libffi to the PowerPC.
|
||||
|
||||
Raffaele Sena ported libffi to the ARM.
|
||||
alpha Richard Henderson
|
||||
arm Raffaele Sena
|
||||
cris Simon Posnjak, Hans-Peter Nilsson
|
||||
frv Anthony Green
|
||||
ia64 Hans Boehm
|
||||
m32r Kazuhiro Inaoka
|
||||
m68k Andreas Schwab
|
||||
mips Anthony Green, Casey Marshall
|
||||
mips64 David Daney
|
||||
pa Randolph Chung, Dave Anglin, Andreas Tobler
|
||||
powerpc Geoffrey Keating, Andreas Tobler,
|
||||
David Edelsohn, John Hornkvist
|
||||
powerpc64 Jakub Jelinek
|
||||
s390 Gerhard Tonn, Ulrich Weigand
|
||||
sh Kaz Kojima
|
||||
sh64 Kaz Kojima
|
||||
sparc Anthony Green, Gordon Irlam
|
||||
x86 Anthony Green, Jon Beniston
|
||||
x86-64 Bo Thorsen
|
||||
|
||||
Jesper Skov and Andrew Haley both did more than their fair share of
|
||||
stepping through the code and tracking down bugs.
|
||||
|
||||
Thanks also to Tom Tromey for bug fixes and configuration help.
|
||||
Thanks also to Tom Tromey for bug fixes, documentation and
|
||||
configuration help.
|
||||
|
||||
Thanks to Jim Blandy, who provided some useful feedback on the libffi
|
||||
interface.
|
||||
|
||||
Andreas Tobler has done a tremendous amount of work on the testsuite.
|
||||
|
||||
Alex Oliva solved the executable page problem for SElinux.
|
||||
|
||||
The list above is almost certainly incomplete and inaccurate. I'm
|
||||
happy to make corrections or additions upon request.
|
||||
|
||||
If you have a problem, or have found a bug, please send a note to
|
||||
green@cygnus.com.
|
||||
green@redhat.com.
|
||||
|
||||
Arquivo executável
+3
@@ -0,0 +1,3 @@
|
||||
To run the testsuite on win64, make your mingw compiler available in the path
|
||||
as "gcc". This could probably be avoided via additional dejagnu configuration,
|
||||
but I haven't figured out how.
|
||||
externo
+6771
-104
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Arquivo executável
+142
@@ -0,0 +1,142 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand `-c -o'.
|
||||
|
||||
scriptversion=2005-05-14.22
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand `-c -o'.
|
||||
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file `INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
eat=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
||||
# So we strip `-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no `-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# `.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use `[/.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
||||
@@ -16,8 +16,8 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -551,7 +551,6 @@ multi-do:
|
||||
flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
|
||||
if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
|
||||
CFLAGS="$(CFLAGS) $${flags}" \
|
||||
CCASFLAGS="$(CCASFLAGS) $${flags}" \
|
||||
FCFLAGS="$(FCFLAGS) $${flags}" \
|
||||
FFLAGS="$(FFLAGS) $${flags}" \
|
||||
ADAFLAGS="$(ADAFLAGS) $${flags}" \
|
||||
@@ -586,8 +585,8 @@ multi-clean:
|
||||
true; \
|
||||
else \
|
||||
lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
|
||||
for dir in ${Makefile} $(MULTIDIRS); do \
|
||||
if [ -f ../$${dir}/$${lib}/${Makefile} ]; then \
|
||||
for dir in Makefile $(MULTIDIRS); do \
|
||||
if [ -f ../$${dir}/$${lib}/Makefile ]; then \
|
||||
if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
|
||||
then true; \
|
||||
else exit 1; \
|
||||
@@ -605,7 +604,7 @@ mv Makefile.tem ${Makefile}
|
||||
fi # ${ml_toplevel_p} = yes
|
||||
|
||||
if [ "${ml_verbose}" = --verbose ]; then
|
||||
echo "Adding multilib support to ${Makefile} in ${ml_realsrcdir}"
|
||||
echo "Adding multilib support to Makefile in ${ml_realsrcdir}"
|
||||
if [ "${ml_toplevel_p}" = yes ]; then
|
||||
echo "multidirs=${multidirs}"
|
||||
fi
|
||||
@@ -740,7 +739,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
|
||||
fi
|
||||
(cd ${ml_dir}/${ml_libdir};
|
||||
../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
|
||||
if [ -f ${ml_dir}/${ml_libdir}/${Makefile} ]; then
|
||||
if [ -f ${ml_dir}/${ml_libdir}/Makefile ]; then
|
||||
if [ x"${MAKE}" = x ]; then
|
||||
(cd ${ml_dir}/${ml_libdir}; make distclean)
|
||||
else
|
||||
@@ -895,7 +894,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
|
||||
|
||||
if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
|
||||
--with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
|
||||
${ac_configure_args} ${ml_config_env} ${ml_srcdiroption} ; then
|
||||
${ac_configure_args} ${ml_srcdiroption} ; then
|
||||
true
|
||||
else
|
||||
exit 1
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
timestamp='2007-07-22'
|
||||
timestamp='2007-05-17'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -330,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
|
||||
i86pc:SunOS:5.*:* | ix86xen:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
@@ -793,7 +793,7 @@ EOF
|
||||
exit ;;
|
||||
*:Interix*:[3456]*)
|
||||
case ${UNAME_MACHINE} in
|
||||
x86)
|
||||
x86)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
EM64T | authenticamd)
|
||||
|
||||
externo
+3
-3
@@ -4,7 +4,7 @@
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
timestamp='2007-06-28'
|
||||
timestamp='2007-04-29'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -475,8 +475,8 @@ case $basic_machine in
|
||||
basic_machine=craynv-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
cr16)
|
||||
basic_machine=cr16-unknown
|
||||
cr16c)
|
||||
basic_machine=cr16c-unknown
|
||||
os=-elf
|
||||
;;
|
||||
crds | unos)
|
||||
|
||||
externo
+17480
-7677
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -2,11 +2,9 @@ dnl Process this with autoconf to create configure
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([libffi], [2.1], [http://gcc.gnu.org/bugs.html])
|
||||
AC_INIT([libffi], [3.0.8], [http://gcc.gnu.org/bugs.html])
|
||||
AC_CONFIG_HEADERS([fficonfig.h])
|
||||
|
||||
AM_ENABLE_MULTILIB(, ..)
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
target_alias=${target_alias-$host_alias}
|
||||
|
||||
@@ -51,6 +49,10 @@ case "$host" in
|
||||
TARGET=ARM; TARGETDIR=arm
|
||||
;;
|
||||
|
||||
amd64-*-freebsd*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
;;
|
||||
|
||||
cris-*-*)
|
||||
TARGET=LIBFFI_CRIS; TARGETDIR=cris
|
||||
;;
|
||||
@@ -69,6 +71,9 @@ case "$host" in
|
||||
TARGET=PA_HPUX; TARGETDIR=pa
|
||||
;;
|
||||
|
||||
i386-*-freebsd* | i386-*-openbsd*)
|
||||
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||
;;
|
||||
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
|
||||
TARGET=X86_WIN32; TARGETDIR=x86
|
||||
;;
|
||||
@@ -139,6 +144,7 @@ case "$host" in
|
||||
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||
;;
|
||||
x86_64-*-cygwin* | x86_64-*-mingw*)
|
||||
TARGET=X86_WIN64; TARGETDIR=x86
|
||||
;;
|
||||
x86_64-*-*)
|
||||
TARGET=X86_64; TARGETDIR=x86
|
||||
@@ -154,7 +160,9 @@ fi
|
||||
AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
|
||||
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
|
||||
AM_CONDITIONAL(X86, test x$TARGET = xX86)
|
||||
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
|
||||
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
|
||||
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
|
||||
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
|
||||
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
|
||||
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
|
||||
@@ -239,6 +247,21 @@ if test x$TARGET = xSPARC; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$TARGET = xX86 || test x$TARGET = xX86_64; then
|
||||
AC_CACHE_CHECK([assembler supports pc related relocs],
|
||||
libffi_cv_as_x86_pcrel, [
|
||||
libffi_cv_as_x86_pcrel=yes
|
||||
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
|
||||
if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
|
||||
libffi_cv_as_x86_pcrel=no
|
||||
fi
|
||||
])
|
||||
if test "x$libffi_cv_as_x86_pcrel" = xyes; then
|
||||
AC_DEFINE(HAVE_AS_X86_PCREL, 1,
|
||||
[Define if your assembler supports PC relative relocs.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether .eh_frame section should be read-only],
|
||||
libffi_cv_ro_eh_frame, [
|
||||
libffi_cv_ro_eh_frame=no
|
||||
@@ -354,6 +377,6 @@ test -d src/$TARGETDIR || mkdir src/$TARGETDIR
|
||||
|
||||
AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
|
||||
|
||||
AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile)
|
||||
AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2005-05-16.16
|
||||
scriptversion=2006-10-15.18
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -91,7 +92,20 @@ gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
@@ -276,27 +290,44 @@ icc)
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
ia64hp)
|
||||
# The "hp" stanza above does not work with HP's ia64 compilers,
|
||||
# which have integrated preprocessors. The correct option to use
|
||||
# with these is +Maked; it writes dependencies to a file named
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
tmpdepfile=`echo "$object" | sed -e 's/\.o$/.d/'`
|
||||
"$@" +Maked
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
# The object file name is correct already.
|
||||
cat "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ //; s/ \\*$//; s/$/:/; p; }' "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
@@ -311,13 +342,13 @@ tru64)
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mecanism is used in libtool 1.4 series to
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in in $dir.libs/$base.o.d and
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
This is doc/libffi.info, produced by makeinfo version 4.12 from
|
||||
./doc/libffi.texi.
|
||||
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
Copyright (C) 2008 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version. A copy of the license is
|
||||
included in the section entitled "GNU General Public License".
|
||||
|
||||
|
||||
INFO-DIR-SECTION
|
||||
START-INFO-DIR-ENTRY
|
||||
* libffi: (libffi). Portable foreign-function interface library.
|
||||
END-INFO-DIR-ENTRY
|
||||
|
||||
|
||||
File: libffi.info, Node: Top, Next: Introduction, Up: (dir)
|
||||
|
||||
libffi
|
||||
******
|
||||
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
Copyright (C) 2008 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version. A copy of the license is
|
||||
included in the section entitled "GNU General Public License".
|
||||
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction:: What is libffi?
|
||||
* Using libffi:: How to use libffi.
|
||||
* Missing Features:: Things libffi can't do.
|
||||
* Index:: Index.
|
||||
|
||||
|
||||
File: libffi.info, Node: Introduction, Next: Using libffi, Prev: Top, Up: Top
|
||||
|
||||
1 What is libffi?
|
||||
*****************
|
||||
|
||||
Compilers for high level languages generate code that follow certain
|
||||
conventions. These conventions are necessary, in part, for separate
|
||||
compilation to work. One such convention is the "calling convention".
|
||||
The calling convention is a set of assumptions made by the compiler
|
||||
about where function arguments will be found on entry to a function. A
|
||||
calling convention also specifies where the return value for a function
|
||||
is found. The calling convention is also sometimes called the "ABI" or
|
||||
"Application Binary Interface".
|
||||
|
||||
Some programs may not know at the time of compilation what arguments
|
||||
are to be passed to a function. For instance, an interpreter may be
|
||||
told at run-time about the number and types of arguments used to call a
|
||||
given function. `Libffi' can be used in such programs to provide a
|
||||
bridge from the interpreter program to compiled code.
|
||||
|
||||
The `libffi' library provides a portable, high level programming
|
||||
interface to various calling conventions. This allows a programmer to
|
||||
call any function specified by a call interface description at run time.
|
||||
|
||||
FFI stands for Foreign Function Interface. A foreign function
|
||||
interface is the popular name for the interface that allows code
|
||||
written in one language to call code written in another language. The
|
||||
`libffi' library really only provides the lowest, machine dependent
|
||||
layer of a fully featured foreign function interface. A layer must
|
||||
exist above `libffi' that handles type conversions for values passed
|
||||
between the two languages.
|
||||
|
||||
|
||||
File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
|
||||
|
||||
2 Using libffi
|
||||
**************
|
||||
|
||||
* Menu:
|
||||
|
||||
* The Basics:: The basic libffi API.
|
||||
* Simple Example:: A simple example.
|
||||
* Types:: libffi type descriptions.
|
||||
* Multiple ABIs:: Different passing styles on one platform.
|
||||
* The Closure API:: Writing a generic function.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
|
||||
|
||||
2.1 The Basics
|
||||
==============
|
||||
|
||||
`Libffi' assumes that you have a pointer to the function you wish to
|
||||
call and that you know the number and types of arguments to pass it, as
|
||||
well as the return type of the function.
|
||||
|
||||
The first thing you must do is create an `ffi_cif' object that
|
||||
matches the signature of the function you wish to call. This is a
|
||||
separate step because it is common to make multiple calls using a
|
||||
single `ffi_cif'. The "cif" in `ffi_cif' stands for Call InterFace.
|
||||
To prepare a call interface object, use the function `ffi_prep_cif'.
|
||||
|
||||
-- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
|
||||
unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
|
||||
This initializes CIF according to the given parameters.
|
||||
|
||||
ABI is the ABI to use; normally `FFI_DEFAULT_ABI' is what you
|
||||
want. *note Multiple ABIs:: for more information.
|
||||
|
||||
NARGS is the number of arguments that this function accepts.
|
||||
`libffi' does not yet handle varargs functions; see *note Missing
|
||||
Features:: for more information.
|
||||
|
||||
RTYPE is a pointer to an `ffi_type' structure that describes the
|
||||
return type of the function. *Note Types::.
|
||||
|
||||
ARGTYPES is a vector of `ffi_type' pointers. ARGTYPES must have
|
||||
NARGS elements. If NARGS is 0, this argument is ignored.
|
||||
|
||||
`ffi_prep_cif' returns a `libffi' status code, of type
|
||||
`ffi_status'. This will be either `FFI_OK' if everything worked
|
||||
properly; `FFI_BAD_TYPEDEF' if one of the `ffi_type' objects is
|
||||
incorrect; or `FFI_BAD_ABI' if the ABI parameter is invalid.
|
||||
|
||||
To call a function using an initialized `ffi_cif', use the
|
||||
`ffi_call' function:
|
||||
|
||||
-- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void
|
||||
**AVALUES)
|
||||
This calls the function FN according to the description given in
|
||||
CIF. CIF must have already been prepared using `ffi_prep_cif'.
|
||||
|
||||
RVALUE is a pointer to a chunk of memory that will hold the result
|
||||
of the function call. This must be large enough to hold the
|
||||
result and must be suitably aligned; it is the caller's
|
||||
responsibility to ensure this. If CIF declares that the function
|
||||
returns `void' (using `ffi_type_void'), then RVALUE is ignored.
|
||||
If RVALUE is `NULL', then the return value is discarded.
|
||||
|
||||
AVALUES is a vector of `void *' pointers that point to the memory
|
||||
locations holding the argument values for a call. If CIF declares
|
||||
that the function has no arguments (i.e., NARGS was 0), then
|
||||
AVALUES is ignored.
|
||||
|
||||
|
||||
File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
|
||||
|
||||
2.2 Simple Example
|
||||
==================
|
||||
|
||||
Here is a trivial example that calls `puts' a few times.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ffi.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
ffi_cif cif;
|
||||
ffi_type *args[1];
|
||||
void *values[1];
|
||||
char *s;
|
||||
int rc;
|
||||
|
||||
/* Initialize the argument info vectors */
|
||||
args[0] = &ffi_type_pointer;
|
||||
values[0] = &s;
|
||||
|
||||
/* Initialize the cif */
|
||||
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
&ffi_type_uint, args) == FFI_OK)
|
||||
{
|
||||
s = "Hello World!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
/* rc now holds the result of the call to puts */
|
||||
|
||||
/* values holds a pointer to the function's arg, so to
|
||||
call puts() again all we need to do is change the
|
||||
value of s */
|
||||
s = "This is cool!";
|
||||
ffi_call(&cif, puts, &rc, values);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
File: libffi.info, Node: Types, Next: Multiple ABIs, Prev: Simple Example, Up: Using libffi
|
||||
|
||||
2.3 Types
|
||||
=========
|
||||
|
||||
* Menu:
|
||||
|
||||
* Primitive Types:: Built-in types.
|
||||
* Structures:: Structure types.
|
||||
* Type Example:: Structure type example.
|
||||
|
||||
|
||||
File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
|
||||
|
||||
2.3.1 Primitive Types
|
||||
---------------------
|
||||
|
||||
`Libffi' provides a number of built-in type descriptors that can be
|
||||
used to describe argument and return types:
|
||||
|
||||
`ffi_type_void'
|
||||
The type `void'. This cannot be used for argument types, only for
|
||||
return values.
|
||||
|
||||
`ffi_type_uint8'
|
||||
An unsigned, 8-bit integer type.
|
||||
|
||||
`ffi_type_sint8'
|
||||
A signed, 8-bit integer type.
|
||||
|
||||
`ffi_type_uint16'
|
||||
An unsigned, 16-bit integer type.
|
||||
|
||||
`ffi_type_sint16'
|
||||
A signed, 16-bit integer type.
|
||||
|
||||
`ffi_type_uint32'
|
||||
An unsigned, 32-bit integer type.
|
||||
|
||||
`ffi_type_sint32'
|
||||
A signed, 32-bit integer type.
|
||||
|
||||
`ffi_type_uint64'
|
||||
An unsigned, 64-bit integer type.
|
||||
|
||||
`ffi_type_sint64'
|
||||
A signed, 64-bit integer type.
|
||||
|
||||
`ffi_type_float'
|
||||
The C `float' type.
|
||||
|
||||
`ffi_type_double'
|
||||
The C `double' type.
|
||||
|
||||
`ffi_type_uchar'
|
||||
The C `unsigned char' type.
|
||||
|
||||
`ffi_type_schar'
|
||||
The C `signed char' type. (Note that there is not an exact
|
||||
equivalent to the C `char' type in `libffi'; ordinarily you should
|
||||
either use `ffi_type_schar' or `ffi_type_uchar' depending on
|
||||
whether `char' is signed.)
|
||||
|
||||
`ffi_type_ushort'
|
||||
The C `unsigned short' type.
|
||||
|
||||
`ffi_type_sshort'
|
||||
The C `short' type.
|
||||
|
||||
`ffi_type_uint'
|
||||
The C `unsigned int' type.
|
||||
|
||||
`ffi_type_sint'
|
||||
The C `int' type.
|
||||
|
||||
`ffi_type_ulong'
|
||||
The C `unsigned long' type.
|
||||
|
||||
`ffi_type_slong'
|
||||
The C `long' type.
|
||||
|
||||
`ffi_type_longdouble'
|
||||
On platforms that have a C `long double' type, this is defined.
|
||||
On other platforms, it is not.
|
||||
|
||||
`ffi_type_pointer'
|
||||
A generic `void *' pointer. You should use this for all pointers,
|
||||
regardless of their real type.
|
||||
|
||||
Each of these is of type `ffi_type', so you must take the address
|
||||
when passing to `ffi_prep_cif'.
|
||||
|
||||
|
||||
File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
|
||||
|
||||
2.3.2 Structures
|
||||
----------------
|
||||
|
||||
Although `libffi' has no special support for unions or bit-fields, it
|
||||
is perfectly happy passing structures back and forth. You must first
|
||||
describe the structure to `libffi' by creating a new `ffi_type' object
|
||||
for it.
|
||||
|
||||
-- ffi_type:
|
||||
The `ffi_type' has the following members:
|
||||
`size_t size'
|
||||
This is set by `libffi'; you should initialize it to zero.
|
||||
|
||||
`unsigned short alignment'
|
||||
This is set by `libffi'; you should initialize it to zero.
|
||||
|
||||
`unsigned short type'
|
||||
For a structure, this should be set to `FFI_TYPE_STRUCT'.
|
||||
|
||||
`ffi_type **elements'
|
||||
This is a `NULL'-terminated array of pointers to `ffi_type'
|
||||
objects. There is one element per field of the struct.
|
||||
|
||||
|
||||
File: libffi.info, Node: Type Example, Prev: Structures, Up: Types
|
||||
|
||||
2.3.3 Type Example
|
||||
------------------
|
||||
|
||||
The following example initializes a `ffi_type' object representing the
|
||||
`tm' struct from Linux's `time.h'.
|
||||
|
||||
Here is how the struct is defined:
|
||||
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
/* Those are for future use. */
|
||||
long int __tm_gmtoff__;
|
||||
__const char *__tm_zone__;
|
||||
};
|
||||
|
||||
Here is the corresponding code to describe this struct to `libffi':
|
||||
|
||||
{
|
||||
ffi_type tm_type;
|
||||
ffi_type *tm_type_elements[12];
|
||||
int i;
|
||||
|
||||
tm_type.size = tm_type.alignment = 0;
|
||||
tm_type.elements = &tm_type_elements;
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
tm_type_elements[i] = &ffi_type_sint;
|
||||
|
||||
tm_type_elements[9] = &ffi_type_slong;
|
||||
tm_type_elements[10] = &ffi_type_pointer;
|
||||
tm_type_elements[11] = NULL;
|
||||
|
||||
/* tm_type can now be used to represent tm argument types and
|
||||
return types for ffi_prep_cif() */
|
||||
}
|
||||
|
||||
|
||||
File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types, Up: Using libffi
|
||||
|
||||
2.4 Multiple ABIs
|
||||
=================
|
||||
|
||||
A given platform may provide multiple different ABIs at once. For
|
||||
instance, the x86 platform has both `stdcall' and `fastcall' functions.
|
||||
|
||||
`libffi' provides some support for this. However, this is
|
||||
necessarily platform-specific.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
|
||||
|
||||
2.5 The Closure API
|
||||
===================
|
||||
|
||||
`libffi' also provides a way to write a generic function - a function
|
||||
that can accept and decode any combination of arguments. This can be
|
||||
useful when writing an interpreter, or to provide wrappers for
|
||||
arbitrary functions.
|
||||
|
||||
This facility is called the "closure API". Closures are not
|
||||
supported on all platforms; you can check the `FFI_CLOSURES' define to
|
||||
determine whether they are supported on the current platform.
|
||||
|
||||
Because closures work by assembling a tiny function at runtime, they
|
||||
require special allocation on platforms that have a non-executable
|
||||
heap. Memory management for closures is handled by a pair of functions:
|
||||
|
||||
-- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
|
||||
Allocate a chunk of memory holding SIZE bytes. This returns a
|
||||
pointer to the writable address, and sets *CODE to the
|
||||
corresponding executable address.
|
||||
|
||||
SIZE should be sufficient to hold a `ffi_closure' object.
|
||||
|
||||
-- Function: void ffi_closure_free (void *WRITABLE)
|
||||
Free memory allocated using `ffi_closure_alloc'. The argument is
|
||||
the writable address that was returned.
|
||||
|
||||
Once you have allocated the memory for a closure, you must construct
|
||||
a `ffi_cif' describing the function call. Finally you can prepare the
|
||||
closure function:
|
||||
|
||||
-- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
|
||||
ffi_cif *CIF, void (*FUN) (ffi_cif *CIF, void *RET, void
|
||||
**ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
|
||||
Prepare a closure function.
|
||||
|
||||
CLOSURE is the address of a `ffi_closure' object; this is the
|
||||
writable address returned by `ffi_closure_alloc'.
|
||||
|
||||
CIF is the `ffi_cif' describing the function parameters.
|
||||
|
||||
USER_DATA is an arbitrary datum that is passed, uninterpreted, to
|
||||
your closure function.
|
||||
|
||||
CODELOC is the executable address returned by `ffi_closure_alloc'.
|
||||
|
||||
FUN is the function which will be called when the closure is
|
||||
invoked. It is called with the arguments:
|
||||
CIF
|
||||
The `ffi_cif' passed to `ffi_prep_closure_loc'.
|
||||
|
||||
RET
|
||||
A pointer to the memory used for the function's return value.
|
||||
FUN must fill this, unless the function is declared as
|
||||
returning `void'.
|
||||
|
||||
ARGS
|
||||
A vector of pointers to memory holding the arguments to the
|
||||
function.
|
||||
|
||||
USER_DATA
|
||||
The same USER_DATA that was passed to `ffi_prep_closure_loc'.
|
||||
|
||||
`ffi_prep_closure_loc' will return `FFI_OK' if everything went ok,
|
||||
and something else on error.
|
||||
|
||||
After calling `ffi_prep_closure_loc', you can cast CODELOC to the
|
||||
appropriate pointer-to-function type.
|
||||
|
||||
You may see old code referring to `ffi_prep_closure'. This function
|
||||
is deprecated, as it cannot handle the need for separate writable and
|
||||
executable addresses.
|
||||
|
||||
|
||||
File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
|
||||
|
||||
3 Missing Features
|
||||
******************
|
||||
|
||||
`libffi' is missing a few features. We welcome patches to add support
|
||||
for these.
|
||||
|
||||
* There is no support for calling varargs functions. This may work
|
||||
on some platforms, depending on how the ABI is defined, but it is
|
||||
not reliable.
|
||||
|
||||
* There is no support for bit fields in structures.
|
||||
|
||||
* The closure API is
|
||||
|
||||
* The "raw" API is undocumented.
|
||||
|
||||
|
||||
File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
|
||||
|
||||
Index
|
||||
*****
|
||||
|
||||
| ||||