mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
Add trampoline test
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24763 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ae953625b5
commit
35a9c7d918
4 changed files with 169 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
|||
2007-03-05 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* configure.ac, config/config.trampoline.c: Add trampoline test.
|
||||
|
||||
2007-03-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSAffineTransform.h: Add flags to allow
|
||||
|
|
103
config/config.trampoline.c
Normal file
103
config/config.trampoline.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* Trampoline test */
|
||||
|
||||
/*
|
||||
* Copyright 1995-1999, 2001-2002, 2004-2006 Bruno Haible, <bruno@clisp.org>
|
||||
*
|
||||
* This is free software distributed under the GNU General Public Licence
|
||||
* described in the file COPYING. Contact the author if you don't have this
|
||||
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
|
||||
* on this software.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "trampoline_r.h"
|
||||
|
||||
#define MAGIC1 0x9db9af42
|
||||
#define MAGIC2 0x614a13c9
|
||||
#define MAGIC3 0x7aff3cb4
|
||||
#define MAGIC4 0xa2f9d045
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef int (*function)(...);
|
||||
#else
|
||||
typedef int (*function)();
|
||||
#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
int f (void* env, int x)
|
||||
#else
|
||||
int f (int x)
|
||||
#endif
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#ifdef __m68k__
|
||||
#ifdef __NetBSD__
|
||||
register void* env __asm__("a1");
|
||||
#else
|
||||
register void* env __asm__("a0");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __mips__
|
||||
register void* env __asm__("$2");
|
||||
#endif
|
||||
#ifdef __mips64__
|
||||
register void* env __asm__("$2");
|
||||
#endif
|
||||
#if defined(__sparc__) && !defined(__sparc64__)
|
||||
register void* env __asm__("%g2");
|
||||
#endif
|
||||
#ifdef __sparc64__
|
||||
register void* env __asm__("%g5");
|
||||
#endif
|
||||
#ifdef __alpha__
|
||||
register void* env __asm__("$1");
|
||||
#endif
|
||||
#ifdef __hppa__
|
||||
register void* env __asm__("%r29");
|
||||
#endif
|
||||
#ifdef __arm__
|
||||
register void* env __asm__("r12");
|
||||
#endif
|
||||
#ifdef __powerpc__
|
||||
#ifdef __NetBSD__
|
||||
register void* env __asm__("r13");
|
||||
#else
|
||||
register void* env __asm__("r11");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __m88k__
|
||||
register void* env __asm__("r11");
|
||||
#endif
|
||||
#ifdef __convex__
|
||||
register void* env __asm__("s0");
|
||||
#endif
|
||||
#ifdef __ia64__
|
||||
register void* env __asm__("r15");
|
||||
#endif
|
||||
#ifdef __x86_64__
|
||||
register void* env __asm__("r10");
|
||||
#endif
|
||||
#ifdef __s390__
|
||||
register void* env __asm__("r0");
|
||||
#endif
|
||||
|
||||
return x + (int)((long*)env)[0] + (int)((long*)env)[1] + MAGIC3;
|
||||
#else
|
||||
return x + MAGIC3;
|
||||
#endif
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
function cf = alloc_trampoline_r((function)&f, (void*)MAGIC1, (void*)MAGIC2);
|
||||
#ifdef __GNUC__
|
||||
if ((*cf)(MAGIC4) == MAGIC1+MAGIC2+MAGIC3+MAGIC4)
|
||||
#else
|
||||
if ((*cf)(MAGIC4) == MAGIC3+MAGIC4)
|
||||
#endif
|
||||
{ free_trampoline_r(cf); printf("Works, test1 passed.\n"); exit(0); }
|
||||
else
|
||||
{ printf("Doesn't work!\n"); exit(1); }
|
||||
}
|
48
configure
vendored
48
configure
vendored
|
@ -15395,8 +15395,8 @@ fi
|
|||
have_forward_hook=yes
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
|
||||
echo "$as_me:$LINENO: checking \"for forwarding callback in runtime\"" >&5
|
||||
echo $ECHO_N "checking \"for forwarding callback in runtime\"... $ECHO_C" >&6
|
||||
echo "$as_me:$LINENO: checking for forwarding callback in runtime" >&5
|
||||
echo $ECHO_N "checking for forwarding callback in runtime... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#include "$srcdir/config/config.forward.m"
|
||||
_ACEOF
|
||||
|
@ -15557,6 +15557,46 @@ rm -f conftest.err conftest.$ac_objext \
|
|||
echo "$as_me:$LINENO: result: ffcall" >&5
|
||||
echo "${ECHO_T}ffcall" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: checking if ffcall trampolines work" >&5
|
||||
echo $ECHO_N "checking if ffcall trampolines work... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#include "$srcdir/config/config.trampoline.c"
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
have_working_trampoline=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
have_working_trampoline=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $have_working_trampoline" >&5
|
||||
echo "${ECHO_T}$have_working_trampoline" >&6
|
||||
if test $have_working_trampoline = no; then
|
||||
ffi_ok=no
|
||||
fi
|
||||
else
|
||||
ffi_ok=no
|
||||
fi
|
||||
|
@ -15567,6 +15607,10 @@ echo "${ECHO_T}none" >&6
|
|||
echo
|
||||
if test $have_forward_hook = no; then
|
||||
echo "You do not have an up-to-date libobjc library installed"
|
||||
elif test $have_working_trampoline = no; then
|
||||
echo "You have ffcall, but it does not work properly. Most likely because"
|
||||
echo "your're system's security policy is blocking some parts of ffcall"
|
||||
echo "we recommend installing libffi instead."
|
||||
else
|
||||
echo "You do not have either ffcall or libffi installed, or configure needs"
|
||||
echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them"
|
||||
|
|
20
configure.ac
20
configure.ac
|
@ -1553,7 +1553,7 @@ case "$target_os" in
|
|||
cygwin*) PASS_ARG=yes;;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING("use of pass-through arguments")
|
||||
AC_MSG_CHECKING(use of pass-through arguments)
|
||||
AC_ARG_ENABLE(pass-arguments,
|
||||
[ --enable-pass-arguments Force user main call to NSProcessInfo initialize],,
|
||||
enable_pass_arguments=$PASS_ARG)
|
||||
|
@ -1566,7 +1566,7 @@ fi
|
|||
AC_SUBST(GS_PASS_ARGUMENTS)
|
||||
AC_MSG_RESULT($enable_pass_arguments)
|
||||
|
||||
AC_MSG_CHECKING("use of fake-main definition")
|
||||
AC_MSG_CHECKING(use of fake-main definition)
|
||||
AC_ARG_ENABLE(fake-main,
|
||||
[ --enable-fake-main Force redefine of user main function],,
|
||||
enable_fake_main=no)
|
||||
|
@ -1675,7 +1675,7 @@ fi
|
|||
have_forward_hook=yes
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
|
||||
AC_MSG_CHECKING("for forwarding callback in runtime")
|
||||
AC_MSG_CHECKING(for forwarding callback in runtime)
|
||||
AC_COMPILE_IFELSE([#include "$srcdir/config/config.forward.m"],
|
||||
have_forward_hook=yes, have_forward_hook=no)
|
||||
AC_MSG_RESULT($have_forward_hook)
|
||||
|
@ -1685,7 +1685,7 @@ if test $have_forward_hook = no; then
|
|||
fi
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
|
||||
AC_MSG_CHECKING("FFI library usage")
|
||||
AC_MSG_CHECKING(FFI library usage)
|
||||
WITH_FFI=none
|
||||
if test $enable_libffi = yes; then
|
||||
AC_DEFINE(USE_LIBFFI,1,
|
||||
|
@ -1705,6 +1705,14 @@ elif test $enable_ffcall = yes; then
|
|||
if test $ffi_ok = yes; then
|
||||
AC_MSG_RESULT(ffcall)
|
||||
fi
|
||||
AC_MSG_CHECKING(if ffcall trampolines work)
|
||||
AC_RUN_IFELSE([#include "$srcdir/config/config.trampoline.c"],
|
||||
have_working_trampoline=yes, have_working_trampoline=no,
|
||||
have_working_trampoline=yes)
|
||||
AC_MSG_RESULT($have_working_trampoline)
|
||||
if test $have_working_trampoline = no; then
|
||||
ffi_ok=no
|
||||
fi
|
||||
else
|
||||
ffi_ok=no
|
||||
fi
|
||||
|
@ -1714,6 +1722,10 @@ if test $ffi_ok = no; then
|
|||
echo
|
||||
if test $have_forward_hook = no; then
|
||||
echo "You do not have an up-to-date libobjc library installed"
|
||||
elif test "$have_working_trampoline" = no; then
|
||||
echo "You have ffcall, but it does not work properly. Most likely because"
|
||||
echo "your're system's security policy is blocking some parts of ffcall"
|
||||
echo "we recommend installing libffi instead."
|
||||
else
|
||||
echo "You do not have either ffcall or libffi installed, or configure needs"
|
||||
echo "--with-ffi-include and/or --with-ffi-library flags so GNUstep can find them"
|
||||
|
|
Loading…
Reference in a new issue