mirror of
https://github.com/partic2/libffi
synced 2026-11-11 02:27:19 +00:00
Rebase
This commit is contained in:
@@ -1,214 +0,0 @@
|
||||
Index: libffi/doc/libffi.info
|
||||
===================================================================
|
||||
--- libffi.orig/doc/libffi.info
|
||||
+++ libffi/doc/libffi.info
|
||||
@@ -4,7 +4,7 @@ This is doc/libffi.info, produced by mak
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
- Copyright (C) 2008 Red Hat, Inc.
|
||||
+ Copyright (C) 2008, 2010 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
@@ -27,7 +27,7 @@ libffi
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
- Copyright (C) 2008 Red Hat, Inc.
|
||||
+ Copyright (C) 2008, 2010 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
@@ -89,6 +89,7 @@ File: libffi.info, Node: Using libffi,
|
||||
* Types:: libffi type descriptions.
|
||||
* Multiple ABIs:: Different passing styles on one platform.
|
||||
* The Closure API:: Writing a generic function.
|
||||
+* Closure Example:: A closure example.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
|
||||
@@ -368,7 +369,7 @@ instance, the x86 platform has both `std
|
||||
necessarily platform-specific.
|
||||
|
||||
|
||||
-File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
|
||||
+File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
|
||||
|
||||
2.5 The Closure API
|
||||
===================
|
||||
@@ -444,6 +445,62 @@ is deprecated, as it cannot handle the n
|
||||
executable addresses.
|
||||
|
||||
|
||||
+File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
|
||||
+
|
||||
+2.6 Closure Example
|
||||
+===================
|
||||
+
|
||||
+A trivial example that creates a new `puts' by binding `fputs' with
|
||||
+`stdin'.
|
||||
+
|
||||
+ #include <stdio.h>
|
||||
+ #include <ffi.h>
|
||||
+
|
||||
+ /* Acts like puts with the file given at time of enclosure. */
|
||||
+ void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
|
||||
+ FILE *stream)
|
||||
+ {
|
||||
+ *ret = fputs(*(char **)args[0], stream);
|
||||
+ }
|
||||
+
|
||||
+ int main()
|
||||
+ {
|
||||
+ ffi_cif cif;
|
||||
+ ffi_type *args[1];
|
||||
+ ffi_closure *closure;
|
||||
+
|
||||
+ int (*bound_puts)(char *);
|
||||
+ int rc;
|
||||
+
|
||||
+ /* Allocate closure and bound_puts */
|
||||
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
|
||||
+
|
||||
+ if (closure)
|
||||
+ {
|
||||
+ /* Initialize the argument info vectors */
|
||||
+ args[0] = &ffi_type_pointer;
|
||||
+
|
||||
+ /* Initialize the cif */
|
||||
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
+ &ffi_type_uint, args) == FFI_OK)
|
||||
+ {
|
||||
+ /* Initialize the closure, setting stream to stdout */
|
||||
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
||||
+ stdout, bound_puts) == FFI_OK)
|
||||
+ {
|
||||
+ rc = bound_puts("Hello World!");
|
||||
+ /* rc now holds the result of the call to fputs */
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Deallocate both closure, and bound_puts */
|
||||
+ ffi_closure_free(closure);
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
|
||||
|
||||
3 Missing Features
|
||||
Index: libffi/doc/libffi.texi
|
||||
===================================================================
|
||||
--- libffi.orig/doc/libffi.texi
|
||||
+++ libffi/doc/libffi.texi
|
||||
@@ -19,7 +19,7 @@
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
-Copyright @copyright{} 2008 Red Hat, Inc.
|
||||
+Copyright @copyright{} 2008, 2010 Red Hat, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
@@ -106,6 +106,7 @@ values passed between the two languages.
|
||||
* Types:: libffi type descriptions.
|
||||
* Multiple ABIs:: Different passing styles on one platform.
|
||||
* The Closure API:: Writing a generic function.
|
||||
+* Closure Example:: A closure example.
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -500,12 +501,66 @@ After calling @code{ffi_prep_closure_loc
|
||||
to the appropriate pointer-to-function type.
|
||||
@end defun
|
||||
|
||||
-@c FIXME: example
|
||||
-
|
||||
You may see old code referring to @code{ffi_prep_closure}. This
|
||||
function is deprecated, as it cannot handle the need for separate
|
||||
writable and executable addresses.
|
||||
|
||||
+@node Closure Example
|
||||
+@section Closure Example
|
||||
+
|
||||
+A trivial example that creates a new @code{puts} by binding
|
||||
+@code{fputs} with @code{stdin}.
|
||||
+
|
||||
+@example
|
||||
+#include <stdio.h>
|
||||
+#include <ffi.h>
|
||||
+
|
||||
+/* Acts like puts with the file given at time of enclosure. */
|
||||
+void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
|
||||
+ FILE *stream)
|
||||
+@{
|
||||
+ *ret = fputs(*(char **)args[0], stream);
|
||||
+@}
|
||||
+
|
||||
+int main()
|
||||
+@{
|
||||
+ ffi_cif cif;
|
||||
+ ffi_type *args[1];
|
||||
+ ffi_closure *closure;
|
||||
+
|
||||
+ int (*bound_puts)(char *);
|
||||
+ int rc;
|
||||
+
|
||||
+ /* Allocate closure and bound_puts */
|
||||
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
|
||||
+
|
||||
+ if (closure)
|
||||
+ @{
|
||||
+ /* Initialize the argument info vectors */
|
||||
+ args[0] = &ffi_type_pointer;
|
||||
+
|
||||
+ /* Initialize the cif */
|
||||
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
+ &ffi_type_uint, args) == FFI_OK)
|
||||
+ @{
|
||||
+ /* Initialize the closure, setting stream to stdout */
|
||||
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
||||
+ stdout, bound_puts) == FFI_OK)
|
||||
+ @{
|
||||
+ rc = bound_puts("Hello World!");
|
||||
+ /* rc now holds the result of the call to fputs */
|
||||
+ @}
|
||||
+ @}
|
||||
+ @}
|
||||
+
|
||||
+ /* Deallocate both closure, and bound_puts */
|
||||
+ ffi_closure_free(closure);
|
||||
+
|
||||
+ return 0;
|
||||
+@}
|
||||
+
|
||||
+@end example
|
||||
+
|
||||
|
||||
@node Missing Features
|
||||
@chapter Missing Features
|
||||
@@ -525,6 +580,8 @@ There is no support for bit fields in st
|
||||
@item
|
||||
The closure API is
|
||||
|
||||
+@c FIXME: ...
|
||||
+
|
||||
@item
|
||||
The ``raw'' API is undocumented.
|
||||
@c argument promotion?
|
||||
Index: libffi/ChangeLog.libffi
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog.libffi
|
||||
+++ libffi/ChangeLog.libffi
|
||||
@@ -1,3 +1,8 @@
|
||||
+2010-01-12 Conrad Irwin <conrad.irwin@gmail.com>
|
||||
+
|
||||
+ * doc/libffi.texi: Add closure example.
|
||||
+ * doc/libffi.info: Rebuilt.
|
||||
+
|
||||
2009-12-25 Samuli Suominen <ssuominen@gentoo.org>
|
||||
|
||||
* configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64.
|
||||
+64
-111
@@ -2,7 +2,10 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,10 @@
|
||||
@@ -65,6 +65,13 @@
|
||||
* testsuite/libffi.call/cls_longdouble.c: Likewise.
|
||||
* testsuite/libffi.call/huge_struct.c: Likewise.
|
||||
|
||||
+2010-08-05 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the
|
||||
@@ -17,7 +20,7 @@ Index: libffi/Makefile.am
|
||||
===================================================================
|
||||
--- libffi.orig/Makefile.am
|
||||
+++ libffi/Makefile.am
|
||||
@@ -178,6 +178,14 @@ libffi_convenience_la_SOURCES = $(libffi
|
||||
@@ -177,6 +177,14 @@ libffi_convenience_la_SOURCES = $(libffi
|
||||
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
|
||||
|
||||
AM_CFLAGS = -Wall -g -fexceptions
|
||||
@@ -51,7 +54,7 @@ Index: libffi/configure.ac
|
||||
m4_undefine([_AC_ARG_VAR_PRECIOUS])
|
||||
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||
|
||||
@@ -400,6 +404,7 @@ AC_ARG_ENABLE(debug,
|
||||
@@ -399,6 +403,7 @@ AC_ARG_ENABLE(debug,
|
||||
if test "$enable_debug" = "yes"; then
|
||||
AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
|
||||
fi)
|
||||
@@ -59,81 +62,28 @@ Index: libffi/configure.ac
|
||||
|
||||
AC_ARG_ENABLE(structs,
|
||||
[ --disable-structs omit code for struct support],
|
||||
Index: libffi/msvcc.sh
|
||||
===================================================================
|
||||
--- libffi.orig/msvcc.sh
|
||||
+++ libffi/msvcc.sh
|
||||
@@ -42,7 +42,7 @@
|
||||
# format and translated into something sensible for cl or ml.
|
||||
#
|
||||
|
||||
-args="-nologo"
|
||||
+args="-nologo -W3"
|
||||
md=-MD
|
||||
cl="cl"
|
||||
ml="ml"
|
||||
@@ -67,13 +67,25 @@ do
|
||||
safeseh=
|
||||
shift 1
|
||||
;;
|
||||
+ -O0)
|
||||
+ args="$args -Od"
|
||||
+ shift 1
|
||||
+ ;;
|
||||
-O*)
|
||||
- args="$args $1"
|
||||
+ # If we're optimizing, make sure we explicitly turn on some optimizations
|
||||
+ # that are implicitly disabled by debug symbols (-Zi).
|
||||
+ args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO"
|
||||
shift 1
|
||||
;;
|
||||
-g)
|
||||
- # Can't specify -RTC1 or -Zi in opt. -Gy is ok. Use -OPT:REF?
|
||||
- args="$args -D_DEBUG -RTC1 -Zi"
|
||||
+ # Enable debug symbol generation.
|
||||
+ args="$args -Zi -DEBUG"
|
||||
+ shift 1
|
||||
+ ;;
|
||||
+ -DFFI_DEBUG)
|
||||
+ # Link against debug CRT and enable runtime error checks.
|
||||
+ args="$args -RTC1"
|
||||
+ defines="$defines $1"
|
||||
md=-MDd
|
||||
shift 1
|
||||
;;
|
||||
@@ -110,8 +122,8 @@ do
|
||||
shift 1
|
||||
;;
|
||||
-Wall)
|
||||
- # -Wall on MSVC is overzealous. Use -W3 instead.
|
||||
- args="$args -W3"
|
||||
+ # -Wall on MSVC is overzealous, and we already build with -W3. Nothing
|
||||
+ # to do here.
|
||||
shift 1
|
||||
;;
|
||||
-Werror)
|
||||
Index: libffi/Makefile.in
|
||||
===================================================================
|
||||
--- libffi.orig/Makefile.in
|
||||
+++ libffi/Makefile.in
|
||||
@@ -62,6 +62,11 @@ target_triplet = @target@
|
||||
@SH64_TRUE@am__append_24 = src/sh64/sysv.S src/sh64/ffi.c
|
||||
@PA_LINUX_TRUE@am__append_25 = src/pa/linux.S src/pa/ffi.c
|
||||
@PA_HPUX_TRUE@am__append_26 = src/pa/hpux32.S src/pa/ffi.c
|
||||
@@ -61,6 +61,11 @@ target_triplet = @target@
|
||||
@SH64_TRUE@am__append_23 = src/sh64/sysv.S src/sh64/ffi.c
|
||||
@PA_LINUX_TRUE@am__append_24 = src/pa/linux.S src/pa/ffi.c
|
||||
@PA_HPUX_TRUE@am__append_25 = src/pa/hpux32.S src/pa/ffi.c
|
||||
+# Build debug. Define FFI_DEBUG on the commandline so that, when building with
|
||||
+# MSVC, it can link against the debug CRT.
|
||||
+@FFI_DEBUG_TRUE@am__append_27 = -DFFI_DEBUG
|
||||
+@FFI_DEBUG_TRUE@am__append_26 = -DFFI_DEBUG
|
||||
+# Build opt.
|
||||
+@FFI_DEBUG_FALSE@am__append_28 = -O2
|
||||
+@FFI_DEBUG_FALSE@am__append_27 = -O2
|
||||
subdir = .
|
||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in $(srcdir)/doc/stamp-vti \
|
||||
@@ -482,7 +487,7 @@ nodist_libffi_la_SOURCES = $(am__append_
|
||||
$(am__append_24) $(am__append_25) $(am__append_26)
|
||||
@@ -481,7 +486,7 @@ nodist_libffi_la_SOURCES = $(am__append_
|
||||
$(am__append_24) $(am__append_25)
|
||||
libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
|
||||
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
|
||||
-AM_CFLAGS = -Wall -g -fexceptions
|
||||
+AM_CFLAGS = -Wall -g -fexceptions $(am__append_27) $(am__append_28)
|
||||
+AM_CFLAGS = -Wall -g -fexceptions $(am__append_26) $(am__append_27)
|
||||
libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
|
||||
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
|
||||
AM_CCASFLAGS = $(AM_CPPFLAGS)
|
||||
@@ -141,7 +91,7 @@ Index: libffi/configure
|
||||
===================================================================
|
||||
--- libffi.orig/configure
|
||||
+++ libffi/configure
|
||||
@@ -748,6 +748,8 @@ LTLIBOBJS
|
||||
@@ -791,6 +791,8 @@ LTLIBOBJS
|
||||
LIBOBJS
|
||||
toolexeclibdir
|
||||
toolexecdir
|
||||
@@ -150,7 +100,7 @@ Index: libffi/configure
|
||||
TARGETDIR
|
||||
TARGET
|
||||
HAVE_LONG_DOUBLE
|
||||
@@ -3189,9 +3191,12 @@ am__tar='${AMTAR} chof - "$$tardir"'; am
|
||||
@@ -2763,9 +2765,12 @@ am__tar='${AMTAR} chof - "$$tardir"'; am
|
||||
# We must force CC to /not/ be precious variables; otherwise
|
||||
# the wrong, non-multilib-adjusted value will be used in multilibs.
|
||||
# As a side effect, we have to subst CFLAGS ourselves.
|
||||
@@ -163,7 +113,7 @@ Index: libffi/configure
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
@@ -4172,6 +4177,7 @@ else
|
||||
@@ -3888,6 +3893,7 @@ else
|
||||
fi
|
||||
|
||||
|
||||
@@ -171,107 +121,107 @@ Index: libffi/configure
|
||||
|
||||
|
||||
|
||||
@@ -5044,13 +5050,13 @@ if test "${lt_cv_nm_interface+set}" = se
|
||||
@@ -4776,13 +4782,13 @@ if test "${lt_cv_nm_interface+set}" = se
|
||||
else
|
||||
lt_cv_nm_interface="BSD nm"
|
||||
echo "int some_variable = 0;" > conftest.$ac_ext
|
||||
- (eval echo "\"\$as_me:5047: $ac_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:5053: $ac_compile\"" >&5)
|
||||
- (eval echo "\"\$as_me:4779: $ac_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:4785: $ac_compile\"" >&5)
|
||||
(eval "$ac_compile" 2>conftest.err)
|
||||
cat conftest.err >&5
|
||||
- (eval echo "\"\$as_me:5050: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
||||
+ (eval echo "\"\$as_me:5056: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
||||
- (eval echo "\"\$as_me:4782: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
||||
+ (eval echo "\"\$as_me:4788: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
|
||||
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
|
||||
cat conftest.err >&5
|
||||
- (eval echo "\"\$as_me:5053: output\"" >&5)
|
||||
+ (eval echo "\"\$as_me:5059: output\"" >&5)
|
||||
- (eval echo "\"\$as_me:4785: output\"" >&5)
|
||||
+ (eval echo "\"\$as_me:4791: output\"" >&5)
|
||||
cat conftest.out >&5
|
||||
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
|
||||
lt_cv_nm_interface="MS dumpbin"
|
||||
@@ -6256,7 +6262,7 @@ ia64-*-hpux*)
|
||||
@@ -5988,7 +5994,7 @@ ia64-*-hpux*)
|
||||
;;
|
||||
*-*-irix6*)
|
||||
# Find out which ABI we are using.
|
||||
- echo '#line 6259 "configure"' > conftest.$ac_ext
|
||||
+ echo '#line 6265 "configure"' > conftest.$ac_ext
|
||||
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
|
||||
- echo '#line 5991 "configure"' > conftest.$ac_ext
|
||||
+ echo '#line 5997 "configure"' > conftest.$ac_ext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>&5
|
||||
ac_status=$?
|
||||
@@ -7782,11 +7788,11 @@ else
|
||||
@@ -7841,11 +7847,11 @@ else
|
||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
- (eval echo "\"\$as_me:7785: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:7791: $lt_compile\"" >&5)
|
||||
- (eval echo "\"\$as_me:7844: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:7850: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
- echo "$as_me:7789: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:7795: \$? = $ac_status" >&5
|
||||
- echo "$as_me:7848: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:7854: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
@@ -8121,11 +8127,11 @@ else
|
||||
@@ -8180,11 +8186,11 @@ else
|
||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
- (eval echo "\"\$as_me:8124: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8130: $lt_compile\"" >&5)
|
||||
- (eval echo "\"\$as_me:8183: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8189: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>conftest.err)
|
||||
ac_status=$?
|
||||
cat conftest.err >&5
|
||||
- echo "$as_me:8128: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8134: \$? = $ac_status" >&5
|
||||
- echo "$as_me:8187: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8193: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s "$ac_outfile"; then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
# So say no if there are warnings other than the usual output.
|
||||
@@ -8226,11 +8232,11 @@ else
|
||||
@@ -8285,11 +8291,11 @@ else
|
||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
- (eval echo "\"\$as_me:8229: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8235: $lt_compile\"" >&5)
|
||||
- (eval echo "\"\$as_me:8288: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8294: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
- echo "$as_me:8233: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8239: \$? = $ac_status" >&5
|
||||
- echo "$as_me:8292: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8298: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
@@ -8281,11 +8287,11 @@ else
|
||||
@@ -8340,11 +8346,11 @@ else
|
||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
||||
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
|
||||
-e 's:$: $lt_compiler_flag:'`
|
||||
- (eval echo "\"\$as_me:8284: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8290: $lt_compile\"" >&5)
|
||||
- (eval echo "\"\$as_me:8343: $lt_compile\"" >&5)
|
||||
+ (eval echo "\"\$as_me:8349: $lt_compile\"" >&5)
|
||||
(eval "$lt_compile" 2>out/conftest.err)
|
||||
ac_status=$?
|
||||
cat out/conftest.err >&5
|
||||
- echo "$as_me:8288: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8294: \$? = $ac_status" >&5
|
||||
- echo "$as_me:8347: \$? = $ac_status" >&5
|
||||
+ echo "$as_me:8353: \$? = $ac_status" >&5
|
||||
if (exit $ac_status) && test -s out/conftest2.$ac_objext
|
||||
then
|
||||
# The compiler can only warn and ignore the option if not recognized
|
||||
@@ -10651,7 +10657,7 @@ else
|
||||
@@ -11143,7 +11149,7 @@ else
|
||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
-#line 10654 "configure"
|
||||
+#line 10660 "configure"
|
||||
-#line 11146 "configure"
|
||||
+#line 11152 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
@@ -10747,7 +10753,7 @@ else
|
||||
@@ -11239,7 +11245,7 @@ else
|
||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
-#line 10750 "configure"
|
||||
+#line 10756 "configure"
|
||||
-#line 11242 "configure"
|
||||
+#line 11248 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
@@ -12465,6 +12471,14 @@ $as_echo "#define FFI_DEBUG 1" >>confdef
|
||||
@@ -14766,6 +14772,14 @@ _ACEOF
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -285,14 +235,17 @@ Index: libffi/configure
|
||||
+
|
||||
|
||||
# Check whether --enable-structs was given.
|
||||
if test "${enable_structs+set}" = set; then :
|
||||
@@ -12763,6 +12777,10 @@ if test -z "${PA64_HPUX_TRUE}" && test -
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
if test "${enable_structs+set}" = set; then
|
||||
@@ -15166,6 +15180,13 @@ Usually this means the macro was only in
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
|
||||
+if test -z "${FFI_DEBUG_TRUE}" && test -z "${FFI_DEBUG_FALSE}"; then
|
||||
+ as_fn_error "conditional \"FFI_DEBUG\" was never defined.
|
||||
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
+ { { $as_echo "$as_me:$LINENO: error: conditional \"FFI_DEBUG\" was never defined.
|
||||
+Usually this means the macro was only invoked conditionally." >&5
|
||||
+$as_echo "$as_me: error: conditional \"FFI_DEBUG\" was never defined.
|
||||
+Usually this means the macro was only invoked conditionally." >&2;}
|
||||
+ { (exit 1); exit 1; }; }
|
||||
+fi
|
||||
|
||||
: ${CONFIG_STATUS=./config.status}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
Index: libffi/include/ffi.h.in
|
||||
===================================================================
|
||||
--- libffi.orig/include/ffi.h.in
|
||||
+++ libffi/include/ffi.h.in
|
||||
@@ -57,7 +57,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Specify which architecture libffi is configured for. */
|
||||
+#ifndef @TARGET@
|
||||
#define @TARGET@
|
||||
+#endif
|
||||
|
||||
/* ---- System configuration information --------------------------------- */
|
||||
|
||||
Index: libffi/src/powerpc/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/powerpc/ffitarget.h
|
||||
+++ libffi/src/powerpc/ffitarget.h
|
||||
@@ -31,12 +31,18 @@
|
||||
/* ---- System specific configurations ----------------------------------- */
|
||||
|
||||
#if defined (POWERPC) && defined (__powerpc64__) /* linux64 */
|
||||
+#ifndef POWERPC64
|
||||
#define POWERPC64
|
||||
+#endif
|
||||
#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin */
|
||||
+#ifndef POWERPC64
|
||||
#define POWERPC64
|
||||
+#endif
|
||||
#elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */
|
||||
+#ifndef POWERPC64
|
||||
#define POWERPC64
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
#ifndef LIBFFI_ASM
|
||||
typedef unsigned long ffi_arg;
|
||||
Index: libffi/src/s390/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/s390/ffitarget.h
|
||||
+++ libffi/src/s390/ffitarget.h
|
||||
@@ -28,8 +28,10 @@
|
||||
#define LIBFFI_TARGET_H
|
||||
|
||||
#if defined (__s390x__)
|
||||
+#ifndef S390X
|
||||
#define S390X
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
/* ---- System specific configurations ----------------------------------- */
|
||||
|
||||
Index: libffi/src/sparc/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/sparc/ffitarget.h
|
||||
+++ libffi/src/sparc/ffitarget.h
|
||||
@@ -30,8 +30,10 @@
|
||||
/* ---- System specific configurations ----------------------------------- */
|
||||
|
||||
#if defined(__arch64__) || defined(__sparcv9)
|
||||
+#ifndef SPARC64
|
||||
#define SPARC64
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
#ifndef LIBFFI_ASM
|
||||
typedef unsigned long ffi_arg;
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
* src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
|
||||
|
||||
+2010-07-07 Dan Horák <dan@danny.cz>
|
||||
+
|
||||
+ * include/ffi.h.in: Protect #define with #ifndef.
|
||||
+ * src/powerpc/ffitarget.h: Ditto.
|
||||
+ * src/s390/ffitarget.h: Ditto.
|
||||
+ * src/sparc/ffitarget.h: Ditto.
|
||||
+
|
||||
2010-05-11 Dan Witte <dwitte@mozilla.com>
|
||||
|
||||
* doc/libffi.tex: Document previous change.
|
||||
+6
-18
@@ -2,7 +2,10 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,9 @@
|
||||
@@ -65,6 +65,12 @@
|
||||
* testsuite/libffi.call/cls_longdouble.c: Likewise.
|
||||
* testsuite/libffi.call/huge_struct.c: Likewise.
|
||||
|
||||
+2010-07-22 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI.
|
||||
@@ -12,21 +15,6 @@ Index: libffi/ChangeLog
|
||||
2010-07-10 Evan Phoenix <evan@fallingsnow.net>
|
||||
|
||||
* src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
|
||||
Index: libffi/src/arm/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/arm/ffitarget.h
|
||||
+++ libffi/src/arm/ffitarget.h
|
||||
@@ -34,8 +34,8 @@ typedef signed long ffi_sarg;
|
||||
typedef enum ffi_abi {
|
||||
FFI_FIRST_ABI = 0,
|
||||
FFI_SYSV,
|
||||
- FFI_DEFAULT_ABI = FFI_SYSV,
|
||||
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
|
||||
+ FFI_LAST_ABI,
|
||||
+ FFI_DEFAULT_ABI = FFI_SYSV
|
||||
} ffi_abi;
|
||||
#endif
|
||||
|
||||
Index: libffi/src/avr32/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/avr32/ffitarget.h
|
||||
@@ -246,7 +234,7 @@ Index: libffi/src/s390/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/s390/ffitarget.h
|
||||
+++ libffi/src/s390/ffitarget.h
|
||||
@@ -40,8 +40,8 @@ typedef signed long ffi_sarg;
|
||||
@@ -42,8 +42,8 @@ typedef signed long ffi_sarg;
|
||||
typedef enum ffi_abi {
|
||||
FFI_FIRST_ABI = 0,
|
||||
FFI_SYSV,
|
||||
@@ -291,7 +279,7 @@ Index: libffi/src/sparc/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/sparc/ffitarget.h
|
||||
+++ libffi/src/sparc/ffitarget.h
|
||||
@@ -42,12 +42,12 @@ typedef enum ffi_abi {
|
||||
@@ -44,12 +44,12 @@ typedef enum ffi_abi {
|
||||
FFI_V8,
|
||||
FFI_V8PLUS,
|
||||
FFI_V9,
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
+2010-03-14 Matthias Klose <doko@ubuntu.com>
|
||||
+
|
||||
+ * src/x86/ffi64.c: Fix typo in comment.
|
||||
+ * src/x86/ffi.c: Use /* ... */ comment style.
|
||||
+
|
||||
2010-07-07 Neil Roberts <neil@linux.intel.com>
|
||||
|
||||
* src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to
|
||||
Index: libffi/src/x86/ffi.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffi.c
|
||||
+++ libffi/src/x86/ffi.c
|
||||
@@ -585,10 +585,10 @@ ffi_prep_raw_closure_loc (ffi_raw_closur
|
||||
return FFI_BAD_ABI;
|
||||
}
|
||||
|
||||
- // we currently don't support certain kinds of arguments for raw
|
||||
- // closures. This should be implemented by a separate assembly language
|
||||
- // routine, since it would require argument processing, something we
|
||||
- // don't do now for performance.
|
||||
+ /* we currently don't support certain kinds of arguments for raw
|
||||
+ closures. This should be implemented by a separate assembly
|
||||
+ language routine, since it would require argument processing,
|
||||
+ something we don't do now for performance. */
|
||||
|
||||
for (i = cif->nargs-1; i >= 0; i--)
|
||||
{
|
||||
Index: libffi/src/x86/ffi64.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffi64.c
|
||||
+++ libffi/src/x86/ffi64.c
|
||||
@@ -50,9 +50,10 @@ extern void ffi_call_unix64 (void *args,
|
||||
gcc/config/i386/i386.c. Do *not* change one without the other. */
|
||||
|
||||
/* Register class used for passing given 64bit part of the argument.
|
||||
- These represent classes as documented by the PS ABI, with the exception
|
||||
- of SSESF, SSEDF classes, that are basically SSE class, just gcc will
|
||||
- use SF or DFmode move instead of DImode to avoid reformating penalties.
|
||||
+ These represent classes as documented by the PS ABI, with the
|
||||
+ exception of SSESF, SSEDF classes, that are basically SSE class,
|
||||
+ just gcc will use SF or DFmode move instead of DImode to avoid
|
||||
+ reformatting penalties.
|
||||
|
||||
Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
|
||||
whenever possible (upper half does contain padding). */
|
||||
@@ -2,7 +2,7 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -6,6 +6,10 @@
|
||||
@@ -73,6 +73,10 @@
|
||||
* src/prep_cif.c: Push stack space computation into src/x86/ffi.c
|
||||
for X86_ANY so return value space doesn't get added twice.
|
||||
|
||||
@@ -17,7 +17,7 @@ Index: libffi/msvcc.sh
|
||||
===================================================================
|
||||
--- libffi.orig/msvcc.sh
|
||||
+++ libffi/msvcc.sh
|
||||
@@ -46,6 +46,7 @@ args="-nologo"
|
||||
@@ -46,6 +46,7 @@ args="-nologo -W3"
|
||||
md=-MD
|
||||
cl="cl"
|
||||
ml="ml"
|
||||
|
||||
-954
@@ -1,954 +0,0 @@
|
||||
Index: libffi/ChangeLog.libffi
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog.libffi
|
||||
+++ libffi/ChangeLog.libffi
|
||||
@@ -1,3 +1,26 @@
|
||||
+2010-01-15 Anthony Green <green@redhat.com>
|
||||
+
|
||||
+ * README: Add notes on building with Microsoft Visual C++.
|
||||
+
|
||||
+2010-01-15 Daniel Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * msvcc.sh: New file.
|
||||
+
|
||||
+ * src/x86/win32.S: Port assembly routines to MSVC and #ifdef.
|
||||
+ * src/x86/ffi.c: Tweak function declaration and remove excess
|
||||
+ parens.
|
||||
+ * include/ffi.h.in: Add __declspec(align(8)) to typedef struct
|
||||
+ ffi_closure.
|
||||
+
|
||||
+ * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new
|
||||
+ function ffi_call_win32 on X86_WIN32.
|
||||
+ * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32.
|
||||
+ (ffi_call_STDCALL): Remove.
|
||||
+
|
||||
+ * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code
|
||||
+ to ffi_prep_cif_machdep for x86.
|
||||
+ * src/x86/ffi.c (ffi_prep_cif_machdep): To here.
|
||||
+
|
||||
2010-01-15 Oliver Kiddle <okiddle@yahoo.co.uk>
|
||||
|
||||
* src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for
|
||||
Index: libffi/include/ffi.h.in
|
||||
===================================================================
|
||||
--- libffi.orig/include/ffi.h.in
|
||||
+++ libffi/include/ffi.h.in
|
||||
@@ -251,6 +251,9 @@ size_t ffi_java_raw_size (ffi_cif *cif);
|
||||
|
||||
#if FFI_CLOSURES
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+__declspec(align(8))
|
||||
+#endif
|
||||
typedef struct {
|
||||
char tramp[FFI_TRAMPOLINE_SIZE];
|
||||
ffi_cif *cif;
|
||||
Index: libffi/src/prep_cif.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/prep_cif.c
|
||||
+++ libffi/src/prep_cif.c
|
||||
@@ -109,16 +109,13 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
|
||||
/* Perform a sanity check on the return type */
|
||||
FFI_ASSERT_VALID_TYPE(cif->rtype);
|
||||
|
||||
- /* x86-64 and s390 stack space allocation is handled in prep_machdep. */
|
||||
-#if !defined M68K && !defined __x86_64__ && !defined S390 && !defined PA
|
||||
+ /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */
|
||||
+#if !defined M68K && !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA
|
||||
/* Make space for the return structure pointer */
|
||||
if (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
#ifdef SPARC
|
||||
&& (cif->abi != FFI_V9 || cif->rtype->size > 32)
|
||||
#endif
|
||||
-#ifdef X86_DARWIN
|
||||
- && (cif->rtype->size > 8)
|
||||
-#endif
|
||||
)
|
||||
bytes = STACK_ARG_SIZE(sizeof(void*));
|
||||
#endif
|
||||
@@ -134,7 +131,7 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
|
||||
check after the initialization. */
|
||||
FFI_ASSERT_VALID_TYPE(*ptr);
|
||||
|
||||
-#if !defined __x86_64__ && !defined S390 && !defined PA
|
||||
+#if !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA
|
||||
#ifdef SPARC
|
||||
if (((*ptr)->type == FFI_TYPE_STRUCT
|
||||
&& ((*ptr)->size > 16 || cif->abi != FFI_V9))
|
||||
Index: libffi/src/x86/ffi.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffi.c
|
||||
+++ libffi/src/x86/ffi.c
|
||||
@@ -148,13 +148,13 @@ void ffi_prep_args(char *stack, extended
|
||||
/* Perform machine dependent cif processing */
|
||||
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
||||
{
|
||||
+ unsigned int i;
|
||||
+ ffi_type **ptr;
|
||||
+
|
||||
/* Set the return type flag */
|
||||
switch (cif->rtype->type)
|
||||
{
|
||||
case FFI_TYPE_VOID:
|
||||
-#ifdef X86
|
||||
- case FFI_TYPE_STRUCT:
|
||||
-#endif
|
||||
#if defined(X86) || defined (X86_WIN32) || defined(X86_FREEBSD) || defined(X86_DARWIN) || defined(X86_WIN64)
|
||||
case FFI_TYPE_UINT8:
|
||||
case FFI_TYPE_UINT16:
|
||||
@@ -165,7 +165,6 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
case FFI_TYPE_UINT32:
|
||||
case FFI_TYPE_SINT32:
|
||||
#endif
|
||||
-
|
||||
case FFI_TYPE_SINT64:
|
||||
case FFI_TYPE_FLOAT:
|
||||
case FFI_TYPE_DOUBLE:
|
||||
@@ -184,8 +183,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
cif->flags = FFI_TYPE_SINT64;
|
||||
break;
|
||||
|
||||
-#ifndef X86
|
||||
case FFI_TYPE_STRUCT:
|
||||
+#ifndef X86
|
||||
if (cif->rtype->size == 1)
|
||||
{
|
||||
cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
|
||||
@@ -207,15 +206,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
|
||||
}
|
||||
else
|
||||
+#endif
|
||||
{
|
||||
cif->flags = FFI_TYPE_STRUCT;
|
||||
-#ifdef X86_WIN64
|
||||
// allocate space for return value pointer
|
||||
cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
|
||||
-#endif
|
||||
}
|
||||
break;
|
||||
-#endif
|
||||
|
||||
default:
|
||||
#ifdef X86_WIN64
|
||||
@@ -229,41 +226,36 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
break;
|
||||
}
|
||||
|
||||
-#ifdef X86_DARWIN
|
||||
- cif->bytes = (cif->bytes + 15) & ~0xF;
|
||||
-#endif
|
||||
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
||||
+ {
|
||||
+ if (((*ptr)->alignment - 1) & cif->bytes)
|
||||
+ cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
|
||||
+ cif->bytes += ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
|
||||
+ }
|
||||
|
||||
#ifdef X86_WIN64
|
||||
- {
|
||||
- unsigned int i;
|
||||
- ffi_type **ptr;
|
||||
-
|
||||
- for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
||||
- {
|
||||
- if (((*ptr)->alignment - 1) & cif->bytes)
|
||||
- cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
|
||||
- cif->bytes += ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
|
||||
- }
|
||||
- }
|
||||
// ensure space for storing four registers
|
||||
cif->bytes += 4 * sizeof(ffi_arg);
|
||||
#endif
|
||||
|
||||
+#ifdef X86_DARWIN
|
||||
+ cif->bytes = (cif->bytes + 15) & ~0xF;
|
||||
+#endif
|
||||
+
|
||||
return FFI_OK;
|
||||
}
|
||||
|
||||
-extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
|
||||
- unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
-
|
||||
-#ifdef X86_WIN32
|
||||
-extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *,
|
||||
- unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
-
|
||||
-#endif /* X86_WIN32 */
|
||||
#ifdef X86_WIN64
|
||||
extern int
|
||||
ffi_call_win64(void (*)(char *, extended_cif *), extended_cif *,
|
||||
unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
+#elif defined(X86_WIN32)
|
||||
+extern void
|
||||
+ffi_call_win32(void (*)(char *, extended_cif *), extended_cif *,
|
||||
+ unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
+#else
|
||||
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
|
||||
+ unsigned, unsigned, unsigned *, void (*fn)(void));
|
||||
#endif
|
||||
|
||||
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
||||
@@ -321,18 +313,18 @@ void ffi_call(ffi_cif *cif, void (*fn)(v
|
||||
cif->flags, ecif.rvalue, fn);
|
||||
}
|
||||
break;
|
||||
+#elif defined(X86_WIN32)
|
||||
+ case FFI_SYSV:
|
||||
+ case FFI_STDCALL:
|
||||
+ ffi_call_win32(ffi_prep_args, &ecif, cif->bytes, cif->flags,
|
||||
+ ecif.rvalue, fn);
|
||||
+ break;
|
||||
#else
|
||||
case FFI_SYSV:
|
||||
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
|
||||
fn);
|
||||
break;
|
||||
-#ifdef X86_WIN32
|
||||
- case FFI_STDCALL:
|
||||
- ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes, cif->flags,
|
||||
- ecif.rvalue, fn);
|
||||
- break;
|
||||
-#endif /* X86_WIN32 */
|
||||
-#endif /* X86_WIN64 */
|
||||
+#endif
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
break;
|
||||
@@ -342,6 +334,8 @@ void ffi_call(ffi_cif *cif, void (*fn)(v
|
||||
|
||||
/** private members **/
|
||||
|
||||
+/* The following __attribute__((regparm(1))) decorations will have no effect
|
||||
+ on MSVC - standard cdecl convention applies. */
|
||||
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
|
||||
void** args, ffi_cif* cif);
|
||||
void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
|
||||
@@ -390,11 +384,8 @@ ffi_closure_win64_inner (ffi_closure *cl
|
||||
}
|
||||
|
||||
#else
|
||||
-unsigned int FFI_HIDDEN
|
||||
-ffi_closure_SYSV_inner (closure, respp, args)
|
||||
- ffi_closure *closure;
|
||||
- void **respp;
|
||||
- void *args;
|
||||
+unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
|
||||
+ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
|
||||
{
|
||||
/* our various things... */
|
||||
ffi_cif *cif;
|
||||
@@ -505,7 +496,7 @@ ffi_prep_incoming_args_SYSV(char *stack,
|
||||
/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
|
||||
-({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
unsigned int __fun = (unsigned int)(FUN); \
|
||||
unsigned int __ctx = (unsigned int)(CTX); \
|
||||
unsigned int __dis = __fun - (__ctx + 10); \
|
||||
@@ -513,10 +504,10 @@ ffi_prep_incoming_args_SYSV(char *stack,
|
||||
*(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
|
||||
*(unsigned char *) &__tramp[5] = 0xe9; \
|
||||
*(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
|
||||
- })
|
||||
+ }
|
||||
|
||||
#define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \
|
||||
-({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
|
||||
unsigned int __fun = (unsigned int)(FUN); \
|
||||
unsigned int __ctx = (unsigned int)(CTX); \
|
||||
unsigned int __dis = __fun - (__ctx + 10); \
|
||||
@@ -527,7 +518,7 @@ ffi_prep_incoming_args_SYSV(char *stack,
|
||||
*(unsigned int*) &__tramp[6] = __dis; /* call __fun */ \
|
||||
*(unsigned char *) &__tramp[10] = 0xc2; \
|
||||
*(unsigned short*) &__tramp[11] = __size; /* ret __size */ \
|
||||
- })
|
||||
+ }
|
||||
|
||||
/* the cif must already be prep'ed */
|
||||
|
||||
@@ -627,16 +618,6 @@ ffi_prep_args_raw(char *stack, extended_
|
||||
* libffi-1.20, this is not the case.)
|
||||
*/
|
||||
|
||||
-extern void
|
||||
-ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned,
|
||||
- unsigned, unsigned *, void (*fn)(void));
|
||||
-
|
||||
-#ifdef X86_WIN32
|
||||
-extern void
|
||||
-ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, unsigned,
|
||||
- unsigned, unsigned *, void (*fn)(void));
|
||||
-#endif /* X86_WIN32 */
|
||||
-
|
||||
void
|
||||
ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
|
||||
{
|
||||
@@ -660,16 +641,18 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(vo
|
||||
|
||||
switch (cif->abi)
|
||||
{
|
||||
+#ifdef X86_WIN32
|
||||
+ case FFI_SYSV:
|
||||
+ case FFI_STDCALL:
|
||||
+ ffi_call_win32(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
|
||||
+ ecif.rvalue, fn);
|
||||
+ break;
|
||||
+#else
|
||||
case FFI_SYSV:
|
||||
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
|
||||
ecif.rvalue, fn);
|
||||
break;
|
||||
-#ifdef X86_WIN32
|
||||
- case FFI_STDCALL:
|
||||
- ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
|
||||
- ecif.rvalue, fn);
|
||||
- break;
|
||||
-#endif /* X86_WIN32 */
|
||||
+#endif
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
break;
|
||||
Index: libffi/src/x86/win32.S
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/win32.S
|
||||
+++ libffi/src/x86/win32.S
|
||||
@@ -2,6 +2,7 @@
|
||||
win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
|
||||
Copyright (c) 2001 John Beniton
|
||||
Copyright (c) 2002 Ranjit Mathew
|
||||
+ Copyright (c) 2009 Daniel Witte
|
||||
|
||||
|
||||
X86 Foreign Function Interface
|
||||
@@ -31,14 +32,371 @@
|
||||
#define LIBFFI_ASM
|
||||
#include <fficonfig.h>
|
||||
#include <ffi.h>
|
||||
-
|
||||
+
|
||||
+#ifdef _MSC_VER
|
||||
+
|
||||
+.386
|
||||
+.MODEL FLAT, C
|
||||
+
|
||||
+EXTRN ffi_closure_SYSV_inner:NEAR
|
||||
+
|
||||
+_TEXT SEGMENT
|
||||
+
|
||||
+ffi_call_win32 PROC NEAR,
|
||||
+ ffi_prep_args : NEAR PTR DWORD,
|
||||
+ ecif : NEAR PTR DWORD,
|
||||
+ cif_bytes : DWORD,
|
||||
+ cif_flags : DWORD,
|
||||
+ rvalue : NEAR PTR DWORD,
|
||||
+ fn : NEAR PTR DWORD
|
||||
+
|
||||
+ ;; Make room for all of the new args.
|
||||
+ mov ecx, cif_bytes
|
||||
+ sub esp, ecx
|
||||
+
|
||||
+ mov eax, esp
|
||||
+
|
||||
+ ;; Place all of the ffi_prep_args in position
|
||||
+ push ecif
|
||||
+ push eax
|
||||
+ call ffi_prep_args
|
||||
+
|
||||
+ ;; Return stack to previous state and call the function
|
||||
+ add esp, 8
|
||||
+
|
||||
+ call fn
|
||||
+
|
||||
+ ;; cdecl: we restore esp in the epilogue, so there's no need to
|
||||
+ ;; remove the space we pushed for the args.
|
||||
+ ;; stdcall: the callee has already cleaned the stack.
|
||||
+
|
||||
+ ;; Load ecx with the return type code
|
||||
+ mov ecx, cif_flags
|
||||
+
|
||||
+ ;; If the return value pointer is NULL, assume no return value.
|
||||
+ cmp rvalue, 0
|
||||
+ jne ca_jumptable
|
||||
+
|
||||
+ ;; Even if there is no space for the return value, we are
|
||||
+ ;; obliged to handle floating-point values.
|
||||
+ cmp ecx, FFI_TYPE_FLOAT
|
||||
+ jne ca_epilogue
|
||||
+ fstp st(0)
|
||||
+
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_jumptable:
|
||||
+ jmp [ca_jumpdata + 4 * ecx]
|
||||
+ca_jumpdata:
|
||||
+ ;; Do not insert anything here between label and jump table.
|
||||
+ dd offset ca_epilogue ;; FFI_TYPE_VOID
|
||||
+ dd offset ca_retint ;; FFI_TYPE_INT
|
||||
+ dd offset ca_retfloat ;; FFI_TYPE_FLOAT
|
||||
+ dd offset ca_retdouble ;; FFI_TYPE_DOUBLE
|
||||
+ dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
+ dd offset ca_retint8 ;; FFI_TYPE_UINT8
|
||||
+ dd offset ca_retint8 ;; FFI_TYPE_SINT8
|
||||
+ dd offset ca_retint16 ;; FFI_TYPE_UINT16
|
||||
+ dd offset ca_retint16 ;; FFI_TYPE_SINT16
|
||||
+ dd offset ca_retint ;; FFI_TYPE_UINT32
|
||||
+ dd offset ca_retint ;; FFI_TYPE_SINT32
|
||||
+ dd offset ca_retint64 ;; FFI_TYPE_UINT64
|
||||
+ dd offset ca_retint64 ;; FFI_TYPE_SINT64
|
||||
+ dd offset ca_epilogue ;; FFI_TYPE_STRUCT
|
||||
+ dd offset ca_retint ;; FFI_TYPE_POINTER
|
||||
+ dd offset ca_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
+ dd offset ca_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
+ dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
+
|
||||
+ca_retint8:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ mov [ecx + 0], al
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retint16:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ mov [ecx + 0], ax
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retint:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ mov [ecx + 0], eax
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retint64:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ mov [ecx + 0], eax
|
||||
+ mov [ecx + 4], edx
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retfloat:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ fstp DWORD PTR [ecx]
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retdouble:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ fstp QWORD PTR [ecx]
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_retlongdouble:
|
||||
+ ;; Load %ecx with the pointer to storage for the return value
|
||||
+ mov ecx, rvalue
|
||||
+ fstp TBYTE PTR [ecx]
|
||||
+ jmp ca_epilogue
|
||||
+
|
||||
+ca_epilogue:
|
||||
+ ;; Epilogue code is autogenerated.
|
||||
+ ret
|
||||
+ffi_call_win32 ENDP
|
||||
+
|
||||
+ffi_closure_SYSV PROC NEAR FORCEFRAME
|
||||
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
+
|
||||
+ sub esp, 40
|
||||
+ lea edx, [ebp - 24]
|
||||
+ mov [ebp - 12], edx ;; resp
|
||||
+ lea edx, [ebp + 8]
|
||||
+ mov [esp + 8], edx ;; args
|
||||
+ lea edx, [ebp - 12]
|
||||
+ mov [esp + 4], edx ;; &resp
|
||||
+ mov [esp], eax ;; closure
|
||||
+ call ffi_closure_SYSV_inner
|
||||
+ mov ecx, [ebp - 12]
|
||||
+
|
||||
+cs_jumptable:
|
||||
+ jmp [cs_jumpdata + 4 * eax]
|
||||
+cs_jumpdata:
|
||||
+ ;; Do not insert anything here between the label and jump table.
|
||||
+ dd offset cs_epilogue ;; FFI_TYPE_VOID
|
||||
+ dd offset cs_retint ;; FFI_TYPE_INT
|
||||
+ dd offset cs_retfloat ;; FFI_TYPE_FLOAT
|
||||
+ dd offset cs_retdouble ;; FFI_TYPE_DOUBLE
|
||||
+ dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
+ dd offset cs_retint8 ;; FFI_TYPE_UINT8
|
||||
+ dd offset cs_retint8 ;; FFI_TYPE_SINT8
|
||||
+ dd offset cs_retint16 ;; FFI_TYPE_UINT16
|
||||
+ dd offset cs_retint16 ;; FFI_TYPE_SINT16
|
||||
+ dd offset cs_retint ;; FFI_TYPE_UINT32
|
||||
+ dd offset cs_retint ;; FFI_TYPE_SINT32
|
||||
+ dd offset cs_retint64 ;; FFI_TYPE_UINT64
|
||||
+ dd offset cs_retint64 ;; FFI_TYPE_SINT64
|
||||
+ dd offset cs_retstruct ;; FFI_TYPE_STRUCT
|
||||
+ dd offset cs_retint ;; FFI_TYPE_POINTER
|
||||
+ dd offset cs_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
+ dd offset cs_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
+ dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
+
|
||||
+cs_retint8:
|
||||
+ mov al, [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retint16:
|
||||
+ mov ax, [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retint:
|
||||
+ mov eax, [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retint64:
|
||||
+ mov eax, [ecx + 0]
|
||||
+ mov edx, [ecx + 4]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retfloat:
|
||||
+ fld DWORD PTR [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retdouble:
|
||||
+ fld QWORD PTR [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retlongdouble:
|
||||
+ fld TBYTE PTR [ecx]
|
||||
+ jmp cs_epilogue
|
||||
+
|
||||
+cs_retstruct:
|
||||
+ ;; Caller expects us to pop struct return value pointer hidden arg.
|
||||
+ ;; Epilogue code is autogenerated.
|
||||
+ ret 4
|
||||
+
|
||||
+cs_epilogue:
|
||||
+ ;; Epilogue code is autogenerated.
|
||||
+ ret
|
||||
+ffi_closure_SYSV ENDP
|
||||
+
|
||||
+#if !FFI_NO_RAW_API
|
||||
+
|
||||
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
|
||||
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
|
||||
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
|
||||
+#define CIF_FLAGS_OFFSET 20
|
||||
+
|
||||
+ffi_closure_raw_SYSV PROC NEAR USES esi
|
||||
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
+
|
||||
+ sub esp, 40
|
||||
+ mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
|
||||
+ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
|
||||
+ mov [esp + 12], edx ;; user_data
|
||||
+ lea edx, [ebp + 8]
|
||||
+ mov [esp + 8], edx ;; raw_args
|
||||
+ lea edx, [ebp - 24]
|
||||
+ mov [esp + 4], edx ;; &res
|
||||
+ mov [esp], esi ;; cif
|
||||
+ call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET] ;; closure->fun
|
||||
+ mov eax, [esi + CIF_FLAGS_OFFSET] ;; cif->flags
|
||||
+ lea ecx, [ebp - 24]
|
||||
+
|
||||
+cr_jumptable:
|
||||
+ jmp [cr_jumpdata + 4 * eax]
|
||||
+cr_jumpdata:
|
||||
+ ;; Do not insert anything here between the label and jump table.
|
||||
+ dd offset cr_epilogue ;; FFI_TYPE_VOID
|
||||
+ dd offset cr_retint ;; FFI_TYPE_INT
|
||||
+ dd offset cr_retfloat ;; FFI_TYPE_FLOAT
|
||||
+ dd offset cr_retdouble ;; FFI_TYPE_DOUBLE
|
||||
+ dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
+ dd offset cr_retint8 ;; FFI_TYPE_UINT8
|
||||
+ dd offset cr_retint8 ;; FFI_TYPE_SINT8
|
||||
+ dd offset cr_retint16 ;; FFI_TYPE_UINT16
|
||||
+ dd offset cr_retint16 ;; FFI_TYPE_SINT16
|
||||
+ dd offset cr_retint ;; FFI_TYPE_UINT32
|
||||
+ dd offset cr_retint ;; FFI_TYPE_SINT32
|
||||
+ dd offset cr_retint64 ;; FFI_TYPE_UINT64
|
||||
+ dd offset cr_retint64 ;; FFI_TYPE_SINT64
|
||||
+ dd offset cr_epilogue ;; FFI_TYPE_STRUCT
|
||||
+ dd offset cr_retint ;; FFI_TYPE_POINTER
|
||||
+ dd offset cr_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
+ dd offset cr_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
+ dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
+
|
||||
+cr_retint8:
|
||||
+ mov al, [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retint16:
|
||||
+ mov ax, [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retint:
|
||||
+ mov eax, [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retint64:
|
||||
+ mov eax, [ecx + 0]
|
||||
+ mov edx, [ecx + 4]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retfloat:
|
||||
+ fld DWORD PTR [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retdouble:
|
||||
+ fld QWORD PTR [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_retlongdouble:
|
||||
+ fld TBYTE PTR [ecx]
|
||||
+ jmp cr_epilogue
|
||||
+
|
||||
+cr_epilogue:
|
||||
+ ;; Epilogue code is autogenerated.
|
||||
+ ret
|
||||
+ffi_closure_raw_SYSV ENDP
|
||||
+
|
||||
+#endif /* !FFI_NO_RAW_API */
|
||||
+
|
||||
+ffi_closure_STDCALL PROC NEAR FORCEFRAME
|
||||
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
|
||||
+
|
||||
+ sub esp, 40
|
||||
+ lea edx, [ebp - 24]
|
||||
+ mov [ebp - 12], edx ;; resp
|
||||
+ lea edx, [ebp + 12] ;; account for stub return address on stack
|
||||
+ mov [esp + 8], edx ;; args
|
||||
+ lea edx, [ebp - 12]
|
||||
+ mov [esp + 4], edx ;; &resp
|
||||
+ mov [esp], eax ;; closure
|
||||
+ call ffi_closure_SYSV_inner
|
||||
+ mov ecx, [ebp - 12]
|
||||
+
|
||||
+cd_jumptable:
|
||||
+ jmp [cd_jumpdata + 4 * eax]
|
||||
+cd_jumpdata:
|
||||
+ ;; Do not insert anything here between the label and jump table.
|
||||
+ dd offset cd_epilogue ;; FFI_TYPE_VOID
|
||||
+ dd offset cd_retint ;; FFI_TYPE_INT
|
||||
+ dd offset cd_retfloat ;; FFI_TYPE_FLOAT
|
||||
+ dd offset cd_retdouble ;; FFI_TYPE_DOUBLE
|
||||
+ dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE
|
||||
+ dd offset cd_retint8 ;; FFI_TYPE_UINT8
|
||||
+ dd offset cd_retint8 ;; FFI_TYPE_SINT8
|
||||
+ dd offset cd_retint16 ;; FFI_TYPE_UINT16
|
||||
+ dd offset cd_retint16 ;; FFI_TYPE_SINT16
|
||||
+ dd offset cd_retint ;; FFI_TYPE_UINT32
|
||||
+ dd offset cd_retint ;; FFI_TYPE_SINT32
|
||||
+ dd offset cd_retint64 ;; FFI_TYPE_UINT64
|
||||
+ dd offset cd_retint64 ;; FFI_TYPE_SINT64
|
||||
+ dd offset cd_epilogue ;; FFI_TYPE_STRUCT
|
||||
+ dd offset cd_retint ;; FFI_TYPE_POINTER
|
||||
+ dd offset cd_retint8 ;; FFI_TYPE_SMALL_STRUCT_1B
|
||||
+ dd offset cd_retint16 ;; FFI_TYPE_SMALL_STRUCT_2B
|
||||
+ dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B
|
||||
+
|
||||
+cd_retint8:
|
||||
+ mov al, [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retint16:
|
||||
+ mov ax, [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retint:
|
||||
+ mov eax, [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retint64:
|
||||
+ mov eax, [ecx + 0]
|
||||
+ mov edx, [ecx + 4]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retfloat:
|
||||
+ fld DWORD PTR [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retdouble:
|
||||
+ fld QWORD PTR [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_retlongdouble:
|
||||
+ fld TBYTE PTR [ecx]
|
||||
+ jmp cd_epilogue
|
||||
+
|
||||
+cd_epilogue:
|
||||
+ ;; Epilogue code is autogenerated.
|
||||
+ ret
|
||||
+ffi_closure_STDCALL ENDP
|
||||
+
|
||||
+_TEXT ENDS
|
||||
+END
|
||||
+
|
||||
+#else
|
||||
+
|
||||
.text
|
||||
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
- .globl _ffi_call_SYSV
|
||||
- .def _ffi_call_SYSV; .scl 2; .type 32; .endef
|
||||
-_ffi_call_SYSV:
|
||||
+ .globl _ffi_call_win32
|
||||
+ .def _ffi_call_win32; .scl 2; .type 32; .endef
|
||||
+_ffi_call_win32:
|
||||
.LFB1:
|
||||
pushl %ebp
|
||||
.LCFI0:
|
||||
@@ -61,8 +419,10 @@ _ffi_call_SYSV:
|
||||
# FIXME: Align the stack to a 128-bit boundary to avoid
|
||||
# potential performance hits.
|
||||
|
||||
- call *28(%ebp)
|
||||
+ call *28(%ebp)
|
||||
|
||||
+ # stdcall functions pop arguments off the stack themselves
|
||||
+
|
||||
# Load %ecx with the return type code
|
||||
movl 20(%ebp),%ecx
|
||||
|
||||
@@ -181,164 +541,11 @@ _ffi_call_SYSV:
|
||||
movl %ebp,%esp
|
||||
popl %ebp
|
||||
ret
|
||||
-.ffi_call_SYSV_end:
|
||||
+.ffi_call_win32_end:
|
||||
.LFE1:
|
||||
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
- .globl _ffi_call_STDCALL
|
||||
- .def _ffi_call_STDCALL; .scl 2; .type 32; .endef
|
||||
-_ffi_call_STDCALL:
|
||||
-.LFB2:
|
||||
- pushl %ebp
|
||||
-.LCFI2:
|
||||
- movl %esp,%ebp
|
||||
-.LCFI3:
|
||||
- # Make room for all of the new args.
|
||||
- movl 16(%ebp),%ecx
|
||||
- subl %ecx,%esp
|
||||
-
|
||||
- movl %esp,%eax
|
||||
-
|
||||
- # Place all of the ffi_prep_args in position
|
||||
- pushl 12(%ebp)
|
||||
- pushl %eax
|
||||
- call *8(%ebp)
|
||||
-
|
||||
- # Return stack to previous state and call the function
|
||||
- addl $8,%esp
|
||||
-
|
||||
- # FIXME: Align the stack to a 128-bit boundary to avoid
|
||||
- # potential performance hits.
|
||||
-
|
||||
- call *28(%ebp)
|
||||
-
|
||||
- # stdcall functions pop arguments off the stack themselves
|
||||
-
|
||||
- # Load %ecx with the return type code
|
||||
- movl 20(%ebp),%ecx
|
||||
-
|
||||
- # If the return value pointer is NULL, assume no return value.
|
||||
- cmpl $0,24(%ebp)
|
||||
- jne 0f
|
||||
-
|
||||
- # Even if there is no space for the return value, we are
|
||||
- # obliged to handle floating-point values.
|
||||
- cmpl $FFI_TYPE_FLOAT,%ecx
|
||||
- jne .Lsc_noretval
|
||||
- fstp %st(0)
|
||||
-
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-0:
|
||||
- call 1f
|
||||
- # Do not insert anything here between the call and the jump table.
|
||||
-.Lsc_store_table:
|
||||
- .long .Lsc_noretval /* FFI_TYPE_VOID */
|
||||
- .long .Lsc_retint /* FFI_TYPE_INT */
|
||||
- .long .Lsc_retfloat /* FFI_TYPE_FLOAT */
|
||||
- .long .Lsc_retdouble /* FFI_TYPE_DOUBLE */
|
||||
- .long .Lsc_retlongdouble /* FFI_TYPE_LONGDOUBLE */
|
||||
- .long .Lsc_retuint8 /* FFI_TYPE_UINT8 */
|
||||
- .long .Lsc_retsint8 /* FFI_TYPE_SINT8 */
|
||||
- .long .Lsc_retuint16 /* FFI_TYPE_UINT16 */
|
||||
- .long .Lsc_retsint16 /* FFI_TYPE_SINT16 */
|
||||
- .long .Lsc_retint /* FFI_TYPE_UINT32 */
|
||||
- .long .Lsc_retint /* FFI_TYPE_SINT32 */
|
||||
- .long .Lsc_retint64 /* FFI_TYPE_UINT64 */
|
||||
- .long .Lsc_retint64 /* FFI_TYPE_SINT64 */
|
||||
- .long .Lsc_retstruct /* FFI_TYPE_STRUCT */
|
||||
- .long .Lsc_retint /* FFI_TYPE_POINTER */
|
||||
- .long .Lsc_retstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
|
||||
- .long .Lsc_retstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
|
||||
- .long .Lsc_retstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
|
||||
-
|
||||
-1:
|
||||
- add %ecx, %ecx
|
||||
- add %ecx, %ecx
|
||||
- add (%esp),%ecx
|
||||
- add $4, %esp
|
||||
- jmp *(%ecx)
|
||||
-
|
||||
- /* Sign/zero extend as appropriate. */
|
||||
-.Lsc_retsint8:
|
||||
- movsbl %al, %eax
|
||||
- jmp .Lsc_retint
|
||||
-
|
||||
-.Lsc_retsint16:
|
||||
- movswl %ax, %eax
|
||||
- jmp .Lsc_retint
|
||||
-
|
||||
-.Lsc_retuint8:
|
||||
- movzbl %al, %eax
|
||||
- jmp .Lsc_retint
|
||||
-
|
||||
-.Lsc_retuint16:
|
||||
- movzwl %ax, %eax
|
||||
- jmp .Lsc_retint
|
||||
-
|
||||
-.Lsc_retint:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- movl %eax,0(%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retfloat:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- fstps (%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retdouble:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- fstpl (%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retlongdouble:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- fstpt (%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retint64:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- movl %eax,0(%ecx)
|
||||
- movl %edx,4(%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retstruct1b:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- movb %al,0(%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retstruct2b:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- movw %ax,0(%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retstruct4b:
|
||||
- # Load %ecx with the pointer to storage for the return value
|
||||
- movl 24(%ebp),%ecx
|
||||
- movl %eax,0(%ecx)
|
||||
- jmp .Lsc_epilogue
|
||||
-
|
||||
-.Lsc_retstruct:
|
||||
- # Nothing to do!
|
||||
-
|
||||
-.Lsc_noretval:
|
||||
-.Lsc_epilogue:
|
||||
- movl %ebp,%esp
|
||||
- popl %ebp
|
||||
- ret
|
||||
-.ffi_call_STDCALL_end:
|
||||
-.LFE2:
|
||||
-
|
||||
- # This assumes we are using gas.
|
||||
- .balign 16
|
||||
.globl _ffi_closure_SYSV
|
||||
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
|
||||
_ffi_closure_SYSV:
|
||||
@@ -742,38 +949,6 @@ _ffi_closure_STDCALL:
|
||||
.LEFDE1:
|
||||
|
||||
|
||||
-.LSFDE2:
|
||||
- .long .LEFDE2-.LASFDE2 /* FDE Length */
|
||||
-.LASFDE2:
|
||||
- .long .LASFDE2-.Lframe1 /* FDE CIE offset */
|
||||
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
|
||||
- .long .LFB2-. /* FDE initial location */
|
||||
-#else
|
||||
- .long .LFB2
|
||||
-#endif
|
||||
- .long .LFE2-.LFB2 /* FDE address range */
|
||||
-#ifdef __PIC__
|
||||
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
|
||||
-#endif
|
||||
- /* DW_CFA_xxx CFI instructions go here. */
|
||||
-
|
||||
- .byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
- .long .LCFI2-.LFB2
|
||||
- .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
|
||||
- .byte 0x8 /* .uleb128 0x8 */
|
||||
- .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
|
||||
- .byte 0x2 /* .uleb128 0x2 */
|
||||
-
|
||||
- .byte 0x4 /* DW_CFA_advance_loc4 */
|
||||
- .long .LCFI3-.LCFI2
|
||||
- .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
|
||||
- .byte 0x5 /* .uleb128 0x5 */
|
||||
-
|
||||
- /* End of DW_CFA_xxx CFI instructions. */
|
||||
- .align 4
|
||||
-.LEFDE2:
|
||||
-
|
||||
-
|
||||
.LSFDE3:
|
||||
.long .LEFDE3-.LASFDE3 /* FDE Length */
|
||||
.LASFDE3:
|
||||
@@ -875,3 +1050,6 @@ _ffi_closure_STDCALL:
|
||||
/* End of DW_CFA_xxx CFI instructions. */
|
||||
.align 4
|
||||
.LEFDE5:
|
||||
+
|
||||
+#endif /* !_MSC_VER */
|
||||
+
|
||||
Index: libffi/README
|
||||
===================================================================
|
||||
--- libffi.orig/README
|
||||
+++ libffi/README
|
||||
@@ -109,6 +109,14 @@ will add some extra code which will supp
|
||||
are using Purify with libffi. Only use this switch when using
|
||||
Purify, as it will slow down the library.
|
||||
|
||||
+It's also possible to build libffi on Windows platforms with
|
||||
+Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
|
||||
+wrapper script during configuration like so:
|
||||
+
|
||||
+path/to/configure --enable-shared --enable-static \
|
||||
+ CC=path/to/msvcc.sh LD=link \
|
||||
+ CPP=\"cl -nologo -EP\"
|
||||
+
|
||||
Configure has many other options. Use "configure --help" to see them all.
|
||||
|
||||
Once configure has finished, type "make". Note that you must be using
|
||||
@@ -128,6 +136,8 @@ See the ChangeLog files for details.
|
||||
3.0.10 ???-??-??
|
||||
Fix the N64 build on mips-sgi-irix6.5.
|
||||
Testsuite fixes for Tru64 Unix.
|
||||
+ Enable builds with Microsoft's compiler.
|
||||
+ Enable x86 builds with Sun's compiler.
|
||||
|
||||
3.0.9 Dec-31-09
|
||||
Add AVR32 and win64 ports. Add ARM softfp support.
|
||||
@@ -2,7 +2,7 @@ Index: libffi/README
|
||||
===================================================================
|
||||
--- libffi.orig/README
|
||||
+++ libffi/README
|
||||
@@ -113,9 +113,13 @@ It's also possible to build libffi on Wi
|
||||
@@ -114,9 +114,13 @@ It's also possible to build libffi on Wi
|
||||
Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
|
||||
wrapper script during configuration like so:
|
||||
|
||||
@@ -23,14 +23,11 @@ Index: libffi/msvcc.sh
|
||||
===================================================================
|
||||
--- libffi.orig/msvcc.sh
|
||||
+++ libffi/msvcc.sh
|
||||
@@ -42,10 +42,7 @@
|
||||
@@ -42,7 +42,7 @@
|
||||
# format and translated into something sensible for cl or ml.
|
||||
#
|
||||
|
||||
-# Disable specific warnings, and enable warnings-as-errors so we catch any
|
||||
-# mistranslated args.
|
||||
-nowarn="-wd4127 -wd4820 -wd4706 -wd4100 -wd4255 -wd4668 -wd4053 -wd4324"
|
||||
-args="-nologo -W3 -WX $nowarn"
|
||||
-args="-nologo"
|
||||
+args="-nologo -W3"
|
||||
md=-MD
|
||||
cl="cl"
|
||||
@@ -39,12 +36,15 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
@@ -131,6 +131,11 @@
|
||||
* man/Makefile.in: Regenerate.
|
||||
* testsuite/Makefile.in: Regenerate.
|
||||
|
||||
+2010-03-30 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * msvcc.sh: Disable build warnings.
|
||||
+ * README (tested): Clarify windows build procedure.
|
||||
+
|
||||
2010-03-14 Matthias Klose <doko@ubuntu.com>
|
||||
2010-03-15 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
|
||||
|
||||
* src/x86/ffi64.c: Fix typo in comment.
|
||||
* configure.ac (libffi_cv_as_x86_64_unwind_section_type): New test.
|
||||
|
||||
-296
@@ -1,296 +0,0 @@
|
||||
Index: libffi/configure.ac
|
||||
===================================================================
|
||||
--- libffi.orig/configure.ac
|
||||
+++ libffi/configure.ac
|
||||
@@ -84,7 +84,7 @@ case "$host" in
|
||||
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||
;;
|
||||
- i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
|
||||
+ i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
||||
TARGET=X86_WIN32; TARGETDIR=x86
|
||||
# All mingw/cygwin/win32 builds require this for sharedlib
|
||||
AM_LTLDFLAGS="-no-undefined"
|
||||
Index: libffi/src/closures.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/closures.c
|
||||
+++ libffi/src/closures.c
|
||||
@@ -44,7 +44,7 @@
|
||||
# define FFI_MMAP_EXEC_WRIT 1
|
||||
# define HAVE_MNTENT 1
|
||||
# endif
|
||||
-# if defined(X86_WIN32) || defined(X86_WIN64)
|
||||
+# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
|
||||
/* Windows systems may have Data Execution Protection (DEP) enabled,
|
||||
which requires the use of VirtualMalloc/VirtualFree to alloc/free
|
||||
executable memory. */
|
||||
@@ -193,11 +193,11 @@ static int dlmalloc_trim(size_t) MAYBE_U
|
||||
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
||||
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
||||
|
||||
-#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
|
||||
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||
/* Use these for mmap and munmap within dlmalloc.c. */
|
||||
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
||||
static int dlmunmap(void *, size_t);
|
||||
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
|
||||
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||
|
||||
#define mmap dlmmap
|
||||
#define munmap dlmunmap
|
||||
@@ -207,7 +207,7 @@ static int dlmunmap(void *, size_t);
|
||||
#undef mmap
|
||||
#undef munmap
|
||||
|
||||
-#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
|
||||
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||
|
||||
/* A mutex used to synchronize access to *exec* variables in this file. */
|
||||
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -522,7 +522,7 @@ segment_holding_code (mstate m, char* ad
|
||||
}
|
||||
#endif
|
||||
|
||||
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
|
||||
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||
|
||||
/* Allocate a chunk of memory with the given size. Returns a pointer
|
||||
to the writable address, and sets *CODE to the executable
|
||||
Index: libffi/src/dlmalloc.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/dlmalloc.c
|
||||
+++ libffi/src/dlmalloc.c
|
||||
@@ -459,6 +459,14 @@ DEFAULT_MMAP_THRESHOLD default: 25
|
||||
#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
|
||||
#endif /* WIN32 */
|
||||
|
||||
+#ifdef __OS2__
|
||||
+#define INCL_DOS
|
||||
+#include <os2.h>
|
||||
+#define HAVE_MMAP 1
|
||||
+#define HAVE_MORECORE 0
|
||||
+#define LACKS_SYS_MMAN_H
|
||||
+#endif /* __OS2__ */
|
||||
+
|
||||
#if defined(DARWIN) || defined(_DARWIN)
|
||||
/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
|
||||
#ifndef HAVE_MORECORE
|
||||
@@ -1288,7 +1296,7 @@ extern void* sbrk(ptrdiff_t);
|
||||
#define IS_MMAPPED_BIT (SIZE_T_ONE)
|
||||
#define USE_MMAP_BIT (SIZE_T_ONE)
|
||||
|
||||
-#ifndef WIN32
|
||||
+#if !defined(WIN32) && !defined (__OS2__)
|
||||
#define CALL_MUNMAP(a, s) munmap((a), (s))
|
||||
#define MMAP_PROT (PROT_READ|PROT_WRITE)
|
||||
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
||||
@@ -1311,6 +1319,42 @@ static int dev_zero_fd = -1; /* Cached f
|
||||
#endif /* MAP_ANONYMOUS */
|
||||
|
||||
#define DIRECT_MMAP(s) CALL_MMAP(s)
|
||||
+
|
||||
+#elif defined(__OS2__)
|
||||
+
|
||||
+/* OS/2 MMAP via DosAllocMem */
|
||||
+static void* os2mmap(size_t size) {
|
||||
+ void* ptr;
|
||||
+ if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) &&
|
||||
+ DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE))
|
||||
+ return MFAIL;
|
||||
+ return ptr;
|
||||
+}
|
||||
+
|
||||
+#define os2direct_mmap(n) os2mmap(n)
|
||||
+
|
||||
+/* This function supports releasing coalesed segments */
|
||||
+static int os2munmap(void* ptr, size_t size) {
|
||||
+ while (size) {
|
||||
+ ULONG ulSize = size;
|
||||
+ ULONG ulFlags = 0;
|
||||
+ if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0)
|
||||
+ return -1;
|
||||
+ if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 ||
|
||||
+ ulSize > size)
|
||||
+ return -1;
|
||||
+ if (DosFreeMem(ptr) != 0)
|
||||
+ return -1;
|
||||
+ ptr = ( void * ) ( ( char * ) ptr + ulSize );
|
||||
+ size -= ulSize;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define CALL_MMAP(s) os2mmap(s)
|
||||
+#define CALL_MUNMAP(a, s) os2munmap((a), (s))
|
||||
+#define DIRECT_MMAP(s) os2direct_mmap(s)
|
||||
+
|
||||
#else /* WIN32 */
|
||||
|
||||
/* Win32 MMAP via VirtualAlloc */
|
||||
@@ -1387,7 +1431,7 @@ static int win32munmap(void* ptr, size_t
|
||||
unique mparams values are initialized only once.
|
||||
*/
|
||||
|
||||
-#ifndef WIN32
|
||||
+#if !defined(WIN32) && !defined(__OS2__)
|
||||
/* By default use posix locks */
|
||||
#include <pthread.h>
|
||||
#define MLOCK_T pthread_mutex_t
|
||||
@@ -1401,6 +1445,16 @@ static MLOCK_T morecore_mutex = PTHREAD_
|
||||
|
||||
static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
+#elif defined(__OS2__)
|
||||
+#define MLOCK_T HMTX
|
||||
+#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE)
|
||||
+#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT)
|
||||
+#define RELEASE_LOCK(l) DosReleaseMutexSem(*l)
|
||||
+#if HAVE_MORECORE
|
||||
+static MLOCK_T morecore_mutex;
|
||||
+#endif /* HAVE_MORECORE */
|
||||
+static MLOCK_T magic_init_mutex;
|
||||
+
|
||||
#else /* WIN32 */
|
||||
/*
|
||||
Because lock-protected regions have bounded times, and there
|
||||
@@ -2492,10 +2546,15 @@ static int init_mparams(void) {
|
||||
}
|
||||
RELEASE_MAGIC_INIT_LOCK();
|
||||
|
||||
-#ifndef WIN32
|
||||
+#if !defined(WIN32) && !defined(__OS2__)
|
||||
mparams.page_size = malloc_getpagesize;
|
||||
mparams.granularity = ((DEFAULT_GRANULARITY != 0)?
|
||||
DEFAULT_GRANULARITY : mparams.page_size);
|
||||
+#elif defined (__OS2__)
|
||||
+ /* if low-memory is used, os2munmap() would break
|
||||
+ if it were anything other than 64k */
|
||||
+ mparams.page_size = 4096u;
|
||||
+ mparams.granularity = 65536u;
|
||||
#else /* WIN32 */
|
||||
{
|
||||
SYSTEM_INFO system_info;
|
||||
Index: libffi/src/x86/win32.S
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/win32.S
|
||||
+++ libffi/src/x86/win32.S
|
||||
@@ -395,7 +395,9 @@ END
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_call_win32
|
||||
+#ifndef __OS2__
|
||||
.def _ffi_call_win32; .scl 2; .type 32; .endef
|
||||
+#endif
|
||||
_ffi_call_win32:
|
||||
.LFB1:
|
||||
pushl %ebp
|
||||
@@ -547,7 +549,9 @@ _ffi_call_win32:
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_SYSV
|
||||
+#ifndef __OS2__
|
||||
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
|
||||
+#endif
|
||||
_ffi_closure_SYSV:
|
||||
.LFB3:
|
||||
pushl %ebp
|
||||
@@ -668,7 +672,9 @@ _ffi_closure_SYSV:
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_raw_SYSV
|
||||
+#ifndef __OS2__
|
||||
.def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
|
||||
+#endif
|
||||
_ffi_closure_raw_SYSV:
|
||||
.LFB4:
|
||||
pushl %ebp
|
||||
@@ -784,7 +790,9 @@ _ffi_closure_raw_SYSV:
|
||||
# This assumes we are using gas.
|
||||
.balign 16
|
||||
.globl _ffi_closure_STDCALL
|
||||
+#ifndef __OS2__
|
||||
.def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
|
||||
+#endif
|
||||
_ffi_closure_STDCALL:
|
||||
.LFB5:
|
||||
pushl %ebp
|
||||
@@ -890,7 +898,9 @@ _ffi_closure_STDCALL:
|
||||
.ffi_closure_STDCALL_end:
|
||||
.LFE5:
|
||||
|
||||
+#ifndef __OS2__
|
||||
.section .eh_frame,"w"
|
||||
+#endif
|
||||
.Lframe1:
|
||||
.LSCIE1:
|
||||
.long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
|
||||
Index: libffi/ltmain.sh
|
||||
===================================================================
|
||||
--- libffi.orig/ltmain.sh
|
||||
+++ libffi/ltmain.sh
|
||||
@@ -1,6 +1,6 @@
|
||||
# Generated from ltmain.m4sh.
|
||||
|
||||
-# ltmain.sh (GNU libtool) 2.2.6
|
||||
+# ltmain.sh (GNU libtool) 2.2.6b
|
||||
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
|
||||
@@ -65,7 +65,7 @@
|
||||
# compiler: $LTCC
|
||||
# compiler flags: $LTCFLAGS
|
||||
# linker: $LD (gnu? $with_gnu_ld)
|
||||
-# $progname: (GNU libtool) 2.2.6
|
||||
+# $progname: (GNU libtool) 2.2.6b
|
||||
# automake: $automake_version
|
||||
# autoconf: $autoconf_version
|
||||
#
|
||||
@@ -73,9 +73,9 @@
|
||||
|
||||
PROGRAM=ltmain.sh
|
||||
PACKAGE=libtool
|
||||
-VERSION=2.2.6
|
||||
+VERSION=2.2.6b
|
||||
TIMESTAMP=""
|
||||
-package_revision=1.3012
|
||||
+package_revision=1.3017
|
||||
|
||||
# Be Bourne compatible
|
||||
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
||||
Index: libffi/m4/ltversion.m4
|
||||
===================================================================
|
||||
--- libffi.orig/m4/ltversion.m4
|
||||
+++ libffi/m4/ltversion.m4
|
||||
@@ -9,15 +9,15 @@
|
||||
|
||||
# Generated from ltversion.in.
|
||||
|
||||
-# serial 3012 ltversion.m4
|
||||
+# serial 3017 ltversion.m4
|
||||
# This file is part of GNU Libtool
|
||||
|
||||
-m4_define([LT_PACKAGE_VERSION], [2.2.6])
|
||||
-m4_define([LT_PACKAGE_REVISION], [1.3012])
|
||||
+m4_define([LT_PACKAGE_VERSION], [2.2.6b])
|
||||
+m4_define([LT_PACKAGE_REVISION], [1.3017])
|
||||
|
||||
AC_DEFUN([LTVERSION_VERSION],
|
||||
-[macro_version='2.2.6'
|
||||
-macro_revision='1.3012'
|
||||
+[macro_version='2.2.6b'
|
||||
+macro_revision='1.3017'
|
||||
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||
_LT_DECL(, macro_revision, 0)
|
||||
])
|
||||
Index: libffi/README
|
||||
===================================================================
|
||||
--- libffi.orig/README
|
||||
+++ libffi/README
|
||||
@@ -75,6 +75,7 @@ tested:
|
||||
| X86 | Linux |
|
||||
| X86 | Mac OSX |
|
||||
| X86 | OpenBSD |
|
||||
+| X86 | OS/2 |
|
||||
| X86 | Solaris |
|
||||
| X86 | Windows/Cygwin |
|
||||
| X86 | Windows/MingW |
|
||||
@@ -1,135 +0,0 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,10 @@
|
||||
+2010-04-13 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * msvcc.sh: Build with -W3 instead of -Wall.
|
||||
+ * src/powerpc/ffi_darwin.c: Remove build warnings.
|
||||
+ * src/x86/ffi.c: Ditto.
|
||||
+ * src/x86/ffitarget.h: Ditto.
|
||||
+
|
||||
2010-03-30 Dan Witte <dwitte@mozilla.com>
|
||||
|
||||
* msvcc.sh: Disable build warnings.
|
||||
Index: libffi/msvcc.sh
|
||||
===================================================================
|
||||
--- libffi.orig/msvcc.sh
|
||||
+++ libffi/msvcc.sh
|
||||
@@ -42,7 +42,7 @@
|
||||
# format and translated into something sensible for cl or ml.
|
||||
#
|
||||
|
||||
-args="-nologo -W3"
|
||||
+args="-nologo"
|
||||
md=-MD
|
||||
cl="cl"
|
||||
ml="ml"
|
||||
@@ -108,7 +108,8 @@ do
|
||||
shift 1
|
||||
;;
|
||||
-Wall)
|
||||
- args="$args -Wall"
|
||||
+ # -Wall on MSVC is overzealous. Use -W3 instead.
|
||||
+ args="$args -W3"
|
||||
shift 1
|
||||
;;
|
||||
-Werror)
|
||||
Index: libffi/src/powerpc/ffi_darwin.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/powerpc/ffi_darwin.c
|
||||
+++ libffi/src/powerpc/ffi_darwin.c
|
||||
@@ -344,7 +344,7 @@ ffi_status
|
||||
ffi_prep_cif_machdep (ffi_cif *cif)
|
||||
{
|
||||
/* All this is for the DARWIN ABI. */
|
||||
- int i;
|
||||
+ unsigned i;
|
||||
ffi_type **ptr;
|
||||
unsigned bytes;
|
||||
int fparg_count = 0, intarg_count = 0;
|
||||
@@ -542,11 +542,11 @@ ffi_call (ffi_cif *cif, void (*fn)(void)
|
||||
{
|
||||
case FFI_AIX:
|
||||
ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
|
||||
- ffi_prep_args);
|
||||
+ FFI_FN(ffi_prep_args));
|
||||
break;
|
||||
case FFI_DARWIN:
|
||||
ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
|
||||
- ffi_prep_args);
|
||||
+ FFI_FN(ffi_prep_args));
|
||||
break;
|
||||
default:
|
||||
FFI_ASSERT(0);
|
||||
@@ -799,9 +799,9 @@ ffi_closure_helper_DARWIN (ffi_closure *
|
||||
if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
|
||||
size_al = ALIGN (arg_types[i]->size, 8);
|
||||
if (size_al < 3 && cif->abi == FFI_DARWIN)
|
||||
- avalue[i] = (void *) pgr + 8 - size_al;
|
||||
+ avalue[i] = (char *) pgr + 8 - size_al;
|
||||
else
|
||||
- avalue[i] = (void *) pgr;
|
||||
+ avalue[i] = pgr;
|
||||
pgr += (size_al + 7) / 8;
|
||||
#else
|
||||
/* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
|
||||
@@ -812,9 +812,9 @@ ffi_closure_helper_DARWIN (ffi_closure *
|
||||
if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
|
||||
size_al = ALIGN(arg_types[i]->size, 8);
|
||||
if (size_al < 3 && cif->abi == FFI_DARWIN)
|
||||
- avalue[i] = (void*) pgr + 4 - size_al;
|
||||
+ avalue[i] = (char*) pgr + 4 - size_al;
|
||||
else
|
||||
- avalue[i] = (void*) pgr;
|
||||
+ avalue[i] = pgr;
|
||||
pgr += (size_al + 3) / 4;
|
||||
#endif
|
||||
break;
|
||||
Index: libffi/src/x86/ffi.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffi.c
|
||||
+++ libffi/src/x86/ffi.c
|
||||
@@ -209,7 +209,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
#endif
|
||||
{
|
||||
cif->flags = FFI_TYPE_STRUCT;
|
||||
- // allocate space for return value pointer
|
||||
+ /* allocate space for return value pointer */
|
||||
cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
|
||||
}
|
||||
break;
|
||||
@@ -234,7 +234,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif
|
||||
}
|
||||
|
||||
#ifdef X86_WIN64
|
||||
- // ensure space for storing four registers
|
||||
+ /* ensure space for storing four registers */
|
||||
cif->bytes += 4 * sizeof(ffi_arg);
|
||||
#endif
|
||||
|
||||
@@ -292,8 +292,8 @@ void ffi_call(ffi_cif *cif, void (*fn)(v
|
||||
#ifdef X86_WIN64
|
||||
case FFI_WIN64:
|
||||
{
|
||||
- // Make copies of all struct arguments
|
||||
- // NOTE: not sure if responsibility should be here or in caller
|
||||
+ /* Make copies of all struct arguments
|
||||
+ NOTE: not sure if responsibility should be here or in caller */
|
||||
unsigned int i;
|
||||
for (i=0; i < cif->nargs;i++) {
|
||||
size_t size = cif->arg_types[i]->size;
|
||||
Index: libffi/src/x86/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffitarget.h
|
||||
+++ libffi/src/x86/ffitarget.h
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#ifdef X86_WIN64
|
||||
#define FFI_SIZEOF_ARG 8
|
||||
-#define USE_BUILTIN_FFS 0 // not yet implemented in mingw-64
|
||||
+#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
|
||||
#endif
|
||||
|
||||
/* ---- Generic type definitions ----------------------------------------- */
|
||||
@@ -1,25 +0,0 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,7 @@
|
||||
+2010-07-10 Evan Phoenix <evan@fallingsnow.net>
|
||||
+
|
||||
+ * src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
|
||||
+
|
||||
2010-05-05 Michael Kohler <michaelkohler@live.com>
|
||||
|
||||
* src/dlmalloc.c (dlfree): Fix spelling.
|
||||
Index: libffi/src/closures.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/closures.c
|
||||
+++ libffi/src/closures.c
|
||||
@@ -146,7 +146,7 @@ selinux_enabled_check (void)
|
||||
p = strchr (p + 1, ' ');
|
||||
if (p == NULL)
|
||||
break;
|
||||
- if (strncmp (p + 1, "selinuxfs ", 10) != 0)
|
||||
+ if (strncmp (p + 1, "selinuxfs ", 10) == 0)
|
||||
{
|
||||
free (buf);
|
||||
fclose (f);
|
||||
@@ -1,16 +1,7 @@
|
||||
stand-alone
|
||||
closure-api-example-doc
|
||||
sunstudio
|
||||
msvc
|
||||
fix-comments
|
||||
msvcc-warning
|
||||
remove-warnings
|
||||
os2
|
||||
spelling
|
||||
selinux
|
||||
ffi_last_abi
|
||||
win64-struct-args
|
||||
define-generic-symbols-carefully
|
||||
stdcall-x86-closure-fix
|
||||
ml64-safeseh
|
||||
debug-build
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,10 @@
|
||||
+2010-05-05 Michael Kohler <michaelkohler@live.com>
|
||||
+
|
||||
+ * src/dlmalloc.c (dlfree): Fix spelling.
|
||||
+ * src/ia64/ffi.c (ffi_prep_cif_machdep): Ditto.
|
||||
+ * configure.ac: Ditto.
|
||||
+ * configure: Rebuilt.
|
||||
+
|
||||
2010-04-13 Dan Witte <dwitte@mozilla.com>
|
||||
|
||||
* msvcc.sh: Build with -W3 instead of -Wall.
|
||||
Index: libffi/configure
|
||||
===================================================================
|
||||
--- libffi.orig/configure
|
||||
+++ libffi/configure
|
||||
@@ -11178,7 +11178,7 @@ TARGETDIR="unknown"
|
||||
case "$host" in
|
||||
alpha*-*-*)
|
||||
TARGET=ALPHA; TARGETDIR=alpha;
|
||||
- # Support 128-bit long double, changable via command-line switch.
|
||||
+ # Support 128-bit long double, changeable via command-line switch.
|
||||
HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
|
||||
;;
|
||||
|
||||
Index: libffi/configure.ac
|
||||
===================================================================
|
||||
--- libffi.orig/configure.ac
|
||||
+++ libffi/configure.ac
|
||||
@@ -43,7 +43,7 @@ TARGETDIR="unknown"
|
||||
case "$host" in
|
||||
alpha*-*-*)
|
||||
TARGET=ALPHA; TARGETDIR=alpha;
|
||||
- # Support 128-bit long double, changable via command-line switch.
|
||||
+ # Support 128-bit long double, changeable via command-line switch.
|
||||
HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
|
||||
;;
|
||||
|
||||
Index: libffi/src/dlmalloc.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/dlmalloc.c
|
||||
+++ libffi/src/dlmalloc.c
|
||||
@@ -4251,7 +4251,7 @@ void* dlmalloc(size_t bytes) {
|
||||
|
||||
void dlfree(void* mem) {
|
||||
/*
|
||||
- Consolidate freed chunks with preceeding or succeeding bordering
|
||||
+ Consolidate freed chunks with preceding or succeeding bordering
|
||||
free chunks, if they exist, and then place in a bin. Intermixed
|
||||
with special cases for top, dv, mmapped chunks, and usage errors.
|
||||
*/
|
||||
Index: libffi/src/ia64/ffi.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/ia64/ffi.c
|
||||
+++ libffi/src/ia64/ffi.c
|
||||
@@ -225,7 +225,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
|
||||
int flags;
|
||||
|
||||
/* Adjust cif->bytes to include space for the bits of the ia64_args frame
|
||||
- that preceeds the integer register portion. The estimate that the
|
||||
+ that precedes the integer register portion. The estimate that the
|
||||
generic bits did for the argument space required is good enough for the
|
||||
integer component. */
|
||||
cif->bytes += offsetof(struct ia64_args, gp_regs[0]);
|
||||
+11440
-626
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,10 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,11 @@
|
||||
@@ -65,6 +65,14 @@
|
||||
* testsuite/libffi.call/cls_longdouble.c: Likewise.
|
||||
* testsuite/libffi.call/huge_struct.c: Likewise.
|
||||
|
||||
+2010-08-04 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
+ * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
Index: libffi/ChangeLog.libffi
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog.libffi
|
||||
+++ libffi/ChangeLog.libffi
|
||||
@@ -1,3 +1,8 @@
|
||||
+2010-01-15 Oliver Kiddle <okiddle@yahoo.co.uk>
|
||||
+
|
||||
+ * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for
|
||||
+ Sun Studio compiler compatibility.
|
||||
+
|
||||
2010-01-12 Conrad Irwin <conrad.irwin@gmail.com>
|
||||
|
||||
* doc/libffi.texi: Add closure example.
|
||||
Index: libffi/src/x86/ffitarget.h
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/ffitarget.h
|
||||
+++ libffi/src/x86/ffitarget.h
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -----------------------------------------------------------------*-C-*-
|
||||
- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
|
||||
+ ffitarget.h - Copyright (c) 1996-2003, 2010 Red Hat, Inc.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Target configuration macros for x86 and x86-64.
|
||||
@@ -74,10 +74,10 @@ typedef enum ffi_abi {
|
||||
#else
|
||||
|
||||
/* ---- Intel x86 and AMD x86-64 - */
|
||||
-#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
|
||||
+#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64))
|
||||
FFI_SYSV,
|
||||
FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
|
||||
-#ifdef __i386__
|
||||
+#if defined(__i386__) || defined(__i386)
|
||||
FFI_DEFAULT_ABI = FFI_SYSV,
|
||||
#else
|
||||
FFI_DEFAULT_ABI = FFI_UNIX64,
|
||||
+146
-18
@@ -51,9 +51,9 @@ Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -8,6 +8,14 @@
|
||||
|
||||
* src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
|
||||
@@ -102,6 +102,14 @@
|
||||
* fficonfig.h.in: Regenerate.
|
||||
* src/x86/sysv.S (.eh_frame): Use .ascii, .string or error.
|
||||
|
||||
+2010-05-11 Dan Witte <dwitte@mozilla.com>
|
||||
+
|
||||
@@ -70,7 +70,47 @@ Index: libffi/doc/libffi.info
|
||||
===================================================================
|
||||
--- libffi.orig/doc/libffi.info
|
||||
+++ libffi/doc/libffi.info
|
||||
@@ -147,7 +147,9 @@ To prepare a call interface object, use
|
||||
@@ -1,10 +1,10 @@
|
||||
-This is doc/libffi.info, produced by makeinfo version 4.12 from
|
||||
-./doc/libffi.texi.
|
||||
+This is ../libffi/doc/libffi.info, produced by makeinfo version 4.13
|
||||
+from ../libffi/doc/libffi.texi.
|
||||
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
- Copyright (C) 2008 Red Hat, Inc.
|
||||
+ Copyright (C) 2008, 2010 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
@@ -13,7 +13,7 @@ library.
|
||||
included in the section entitled "GNU General Public License".
|
||||
|
||||
|
||||
-INFO-DIR-SECTION
|
||||
+INFO-DIR-SECTION Development
|
||||
START-INFO-DIR-ENTRY
|
||||
* libffi: (libffi). Portable foreign-function interface library.
|
||||
END-INFO-DIR-ENTRY
|
||||
@@ -27,7 +27,7 @@ libffi
|
||||
This manual is for Libffi, a portable foreign-function interface
|
||||
library.
|
||||
|
||||
- Copyright (C) 2008 Red Hat, Inc.
|
||||
+ Copyright (C) 2008, 2010 Red Hat, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this
|
||||
document under the terms of the GNU General Public License as
|
||||
@@ -89,6 +89,7 @@ File: libffi.info, Node: Using libffi,
|
||||
* Types:: libffi type descriptions.
|
||||
* Multiple ABIs:: Different passing styles on one platform.
|
||||
* The Closure API:: Writing a generic function.
|
||||
+* Closure Example:: A closure example.
|
||||
|
||||
|
||||
File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
|
||||
@@ -146,7 +147,9 @@ To prepare a call interface object, use
|
||||
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
|
||||
@@ -81,20 +121,108 @@ Index: libffi/doc/libffi.info
|
||||
|
||||
|
||||
File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
|
||||
@@ -577,15 +579,15 @@ Node: Top706
|
||||
Node: Introduction1448
|
||||
Node: Using libffi3084
|
||||
Node: The Basics3570
|
||||
-Node: Simple Example6177
|
||||
-Node: Types7204
|
||||
-Node: Primitive Types7487
|
||||
-Node: Structures9307
|
||||
-Node: Type Example10167
|
||||
-Node: Multiple ABIs11390
|
||||
-Node: The Closure API11761
|
||||
-Node: Closure Example14705
|
||||
-Node: Missing Features16264
|
||||
-Node: Index16757
|
||||
@@ -368,7 +371,7 @@ instance, the x86 platform has both `std
|
||||
necessarily platform-specific.
|
||||
|
||||
|
||||
-File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
|
||||
+File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
|
||||
|
||||
2.5 The Closure API
|
||||
===================
|
||||
@@ -444,6 +447,62 @@ is deprecated, as it cannot handle the n
|
||||
executable addresses.
|
||||
|
||||
|
||||
+File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
|
||||
+
|
||||
+2.6 Closure Example
|
||||
+===================
|
||||
+
|
||||
+A trivial example that creates a new `puts' by binding `fputs' with
|
||||
+`stdin'.
|
||||
+
|
||||
+ #include <stdio.h>
|
||||
+ #include <ffi.h>
|
||||
+
|
||||
+ /* Acts like puts with the file given at time of enclosure. */
|
||||
+ void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
|
||||
+ FILE *stream)
|
||||
+ {
|
||||
+ *ret = fputs(*(char **)args[0], stream);
|
||||
+ }
|
||||
+
|
||||
+ int main()
|
||||
+ {
|
||||
+ ffi_cif cif;
|
||||
+ ffi_type *args[1];
|
||||
+ ffi_closure *closure;
|
||||
+
|
||||
+ int (*bound_puts)(char *);
|
||||
+ int rc;
|
||||
+
|
||||
+ /* Allocate closure and bound_puts */
|
||||
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
|
||||
+
|
||||
+ if (closure)
|
||||
+ {
|
||||
+ /* Initialize the argument info vectors */
|
||||
+ args[0] = &ffi_type_pointer;
|
||||
+
|
||||
+ /* Initialize the cif */
|
||||
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
||||
+ &ffi_type_uint, args) == FFI_OK)
|
||||
+ {
|
||||
+ /* Initialize the closure, setting stream to stdout */
|
||||
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
||||
+ stdout, bound_puts) == FFI_OK)
|
||||
+ {
|
||||
+ rc = bound_puts("Hello World!");
|
||||
+ /* rc now holds the result of the call to fputs */
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Deallocate both closure, and bound_puts */
|
||||
+ ffi_closure_free(closure);
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
|
||||
|
||||
3 Missing Features
|
||||
@@ -480,7 +539,7 @@ Index
|
||||
* closures: The Closure API. (line 13)
|
||||
* FFI: Introduction. (line 31)
|
||||
* ffi_call: The Basics. (line 41)
|
||||
-* ffi_closure_alloca: The Closure API. (line 19)
|
||||
+* ffi_closure_alloc: The Closure API. (line 19)
|
||||
* ffi_closure_free: The Closure API. (line 26)
|
||||
* FFI_CLOSURES: The Closure API. (line 13)
|
||||
* ffi_prep_cif: The Basics. (line 16)
|
||||
@@ -516,18 +575,19 @@ Index
|
||||
|
||||
|
||||
Tag Table:
|
||||
-Node: Top670
|
||||
-Node: Introduction1406
|
||||
-Node: Using libffi3042
|
||||
-Node: The Basics3477
|
||||
-Node: Simple Example6084
|
||||
-Node: Types7111
|
||||
-Node: Primitive Types7394
|
||||
-Node: Structures9214
|
||||
-Node: Type Example10074
|
||||
-Node: Multiple ABIs11297
|
||||
-Node: The Closure API11668
|
||||
-Node: Missing Features14588
|
||||
-Node: Index15081
|
||||
+Node: Top706
|
||||
+Node: Introduction1448
|
||||
+Node: Using libffi3084
|
||||
+Node: The Basics3570
|
||||
+Node: Simple Example6356
|
||||
+Node: Types7383
|
||||
+Node: Primitive Types7666
|
||||
|
||||
Reference in New Issue
Block a user