Skip to content

Commit

Permalink
Merge pull request #1383 from matthiasblaesing/update-libffi-3_4_2
Browse files Browse the repository at this point in the history
Update to libffi 3.4.2
  • Loading branch information
matthiasblaesing committed Oct 20, 2021
2 parents b19ff07 + fe33d83 commit 203fc1f
Show file tree
Hide file tree
Showing 135 changed files with 2,775 additions and 521 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,7 @@ Features
* [#1377](https://github.com/java-native-access/jna/pull/1377): Add `RegLoadAppKey` to `c.s.j.p.win32.Advapi32` and `registryLoadAppKey` to `c.s.j.p.win32.Advapi32Util` - [@mfilippov](https://github.com/mfilippov).
* [#1093](https://github.com/java-native-access/jna/issues/1093): Add `OpenFileMapping` to `c.s.j.p.win32.Kernel32` - [@lmitusinski](https://github.com/lmitusinski).
* [#1388](https://github.com/java-native-access/jna/issues/1388): Map the arch `zarch_64` as reported by SAPJVM8 to `s390x` - [@MBaesken](https://github.com/MBaesken).
* [#1381](https://github.com/java-native-access/jna/issues/1381): Update embedded libffi to 3.4.2 - [@matthiasblaesing](https://github.com/matthiasblaesing).

Bug Fixes
---------
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Expand Up @@ -76,7 +76,7 @@
<!-- jnidispatch library release version -->
<property name="jni.major" value="6"/>
<property name="jni.minor" value="1"/>
<property name="jni.revision" value="1"/>
<property name="jni.revision" value="2"/>
<property name="jni.build" value="0"/> <!--${build.number}-->
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
<property name="jni.md5" value="147a998f0cbc89681a1ae6c0dd121629"/>
Expand Down
Binary file modified lib/native/android-aarch64.jar
Binary file not shown.
Binary file modified lib/native/android-arm.jar
Binary file not shown.
Binary file modified lib/native/android-armv7.jar
Binary file not shown.
Binary file modified lib/native/android-mips.jar
Binary file not shown.
Binary file modified lib/native/android-mips64.jar
Binary file not shown.
Binary file modified lib/native/android-x86-64.jar
Binary file not shown.
Binary file modified lib/native/android-x86.jar
Binary file not shown.
Binary file modified lib/native/darwin-aarch64.jar
Binary file not shown.
Binary file modified lib/native/darwin-x86-64.jar
Binary file not shown.
Binary file modified lib/native/freebsd-x86-64.jar
Binary file not shown.
Binary file modified lib/native/freebsd-x86.jar
Binary file not shown.
Binary file modified lib/native/linux-aarch64.jar
Binary file not shown.
Binary file modified lib/native/linux-arm.jar
Binary file not shown.
Binary file modified lib/native/linux-armel.jar
Binary file not shown.
Binary file modified lib/native/linux-mips64el.jar
Binary file not shown.
Binary file modified lib/native/linux-ppc.jar
Binary file not shown.
Binary file modified lib/native/linux-ppc64le.jar
Binary file not shown.
Binary file modified lib/native/linux-s390x.jar
Binary file not shown.
Binary file modified lib/native/linux-x86-64.jar
Binary file not shown.
Binary file modified lib/native/linux-x86.jar
Binary file not shown.
Binary file modified lib/native/openbsd-x86-64.jar
Binary file not shown.
Binary file modified lib/native/openbsd-x86.jar
Binary file not shown.
Binary file modified lib/native/sunos-sparc.jar
Binary file not shown.
Binary file modified lib/native/sunos-sparcv9.jar
Binary file not shown.
Binary file modified lib/native/sunos-x86-64.jar
Binary file not shown.
Binary file modified lib/native/sunos-x86.jar
Binary file not shown.
Binary file modified lib/native/win32-aarch64.jar
Binary file not shown.
Binary file modified lib/native/win32-x86-64.jar
Binary file not shown.
Binary file modified lib/native/win32-x86.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions native/callback.c
Expand Up @@ -201,6 +201,16 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
cb->conversion_flags[i] = CVT_FLOAT;
cvt = 1;
}
else if (cb->arg_types[i]->type == FFI_TYPE_UINT16 || cb->arg_types[i]->type == FFI_TYPE_SINT16) {
cb->java_arg_types[i+3] = &ffi_type_sint;
cb->conversion_flags[i] = CVT_SHORT;
cvt = 1;
}
else if (cb->arg_types[i]->type == FFI_TYPE_UINT8 || cb->arg_types[i]->type == FFI_TYPE_SINT8) {
cb->java_arg_types[i+3] = &ffi_type_sint;
cb->conversion_flags[i] = CVT_BYTE;
cvt = 1;
}
else if (cb->java_arg_types[i+3]->type == FFI_TYPE_STRUCT) {
// All callback structure arguments are passed as a jobject
cb->java_arg_types[i+3] = &ffi_type_pointer;
Expand Down Expand Up @@ -429,6 +439,14 @@ invoke_callback(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbar
args[i+3] = alloca(sizeof(double));
*((double *)args[i+3]) = *(float*)cbargs[i];
break;
case CVT_SHORT:
args[i+3] = alloca(sizeof(int));
*((int *)args[i+3]) = *(short*)cbargs[i];
break;
case CVT_BYTE:
args[i+3] = alloca(sizeof(int));
*((int *)args[i+3]) = *(char*)cbargs[i];
break;
case CVT_DEFAULT:
break;
default:
Expand Down
41 changes: 33 additions & 8 deletions native/dispatch.c
Expand Up @@ -422,12 +422,17 @@ ffi_error(JNIEnv* env, const char* op, ffi_status status) {
char msg[MSG_SIZE];
switch(status) {
case FFI_BAD_ABI:
snprintf(msg, sizeof(msg), "%s: Invalid calling convention", op);
snprintf(msg, sizeof(msg), "%s: Invalid calling convention (FFI_BAD_ABI)", op);
throwByName(env, EIllegalArgument, msg);
return JNI_TRUE;
case FFI_BAD_TYPEDEF:
snprintf(msg, sizeof(msg),
"%s: Invalid structure definition (native typedef error)", op);
"%s: Invalid structure definition (native typedef error, FFI_BAD_TYPEDEF)", op);
throwByName(env, EIllegalArgument, msg);
return JNI_TRUE;
case FFI_BAD_ARGTYPE:
snprintf(msg, sizeof(msg),
"%s: Invalid argument type (FFI_BAD_ARGTYPE)", op);
throwByName(env, EIllegalArgument, msg);
return JNI_TRUE;
default:
Expand Down Expand Up @@ -493,19 +498,39 @@ dispatch(JNIEnv *env, void* func, jint flags, jobjectArray args,
}
else if ((*env)->IsInstanceOf(env, arg, classByte)) {
c_args[i].b = (*env)->GetByteField(env, arg, FID_Byte_value);
arg_types[i] = &ffi_type_sint8;
arg_values[i] = &c_args[i].b;
// Promote char to int if we prepare a varargs call
if(fixed_args && i >= fixed_args && sizeof(char) < sizeof(int)) {
arg_types[i] = &ffi_type_uint32;
arg_values[i] = alloca(sizeof(int));
*(int*)arg_values[i] = (int) c_args[i].b;
} else {
arg_types[i] = &ffi_type_sint8;
arg_values[i] = &c_args[i].b;
}
}
else if ((*env)->IsInstanceOf(env, arg, classShort)) {
c_args[i].s = (*env)->GetShortField(env, arg, FID_Short_value);
arg_types[i] = &ffi_type_sint16;
arg_values[i] = &c_args[i].s;
// Promote short to int if we prepare a varargs call
if(fixed_args && i >= fixed_args && sizeof(short) < sizeof(int)) {
arg_types[i] = &ffi_type_uint32;
arg_values[i] = alloca(sizeof(int));
*(int*)arg_values[i] = (int) c_args[i].s;
} else {
arg_types[i] = &ffi_type_sint16;
arg_values[i] = &c_args[i].s;
}
}
else if ((*env)->IsInstanceOf(env, arg, classCharacter)) {
if (sizeof(wchar_t) == 2) {
c_args[i].c = (*env)->GetCharField(env, arg, FID_Character_value);
arg_types[i] = &ffi_type_uint16;
arg_values[i] = &c_args[i].c;
if(fixed_args && i >= fixed_args && sizeof(short) < sizeof(int)) {
arg_types[i] = &ffi_type_uint32;
arg_values[i] = alloca(sizeof(int));
*(int*)arg_values[i] = (int) c_args[i].c;
} else {
arg_types[i] = &ffi_type_uint16;
arg_values[i] = &c_args[i].c;
}
}
else if (sizeof(wchar_t) == 4) {
c_args[i].i = (*env)->GetCharField(env, arg, FID_Character_value);
Expand Down
2 changes: 2 additions & 0 deletions native/dispatch.h
Expand Up @@ -117,6 +117,8 @@ enum {
CVT_TYPE_MAPPER_WSTRING = com_sun_jna_Native_CVT_TYPE_MAPPER_WSTRING,
CVT_OBJECT = com_sun_jna_Native_CVT_OBJECT,
CVT_JNIENV = com_sun_jna_Native_CVT_JNIENV,
CVT_SHORT = com_sun_jna_Native_CVT_SHORT,
CVT_BYTE = com_sun_jna_Native_CVT_BYTE,
};

/* callback behavior flags */
Expand Down
36 changes: 27 additions & 9 deletions native/libffi/.appveyor.yml
Expand Up @@ -15,13 +15,19 @@ platform:
- arm
- arm64

configuration:
- Debug
- Release

environment:
global:
CYG_ROOT: C:/cygwin
CYG_CACHE: C:/cygwin/var/cache/setup
CYG_ROOT: C:/cygwin64
CYG_CACHE: C:/cygwin64/var/cache/setup
CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
VSVER: 15
matrix:
- VSVER: 15
- SHARED_ARG: "--enable-shared --disable-static"
- SHARED_ARG: "--enable-static --disable-shared"

install:
- ps: >-
Expand Down Expand Up @@ -50,8 +56,13 @@ install:
$env:MSVCC="/cygdrive/c/projects/libffi/msvcc.sh -m64"
$env:SRC_ARCHITECTURE="x86"
}
- 'appveyor DownloadFile https://cygwin.com/setup-x86.exe -FileName setup.exe'
- 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu >NUL'
If ($env:Configuration -Match "Debug") {
$env:DEBUG_ARG="--enable-debug"
} Else {
$env:DEBUG_ARG="--disable-debug"
}
- 'appveyor DownloadFile https://cygwin.com/setup-x86_64.exe -FileName setup.exe'
- 'setup.exe -qgnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P dejagnu -P autoconf -P automake -P libtool'
- '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"'
- echo call VsDevCmd to set VS150COMNTOOLS
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
Expand All @@ -60,7 +71,14 @@ install:
- call "%VSCOMNTOOLS%..\..\vc\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM%

build_script:
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include; make; find .;)"
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/; make check; cat `find ./ -name libffi.log`)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; ./autogen.sh)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; ./configure CC='%MSVCC%' CXX='%MSVCC%' LD='link' CPP='cl -nologo -EP' CXXCPP='cl -nologo -EP' CPPFLAGS='-DFFI_BUILDING_DLL' AR='/cygdrive/c/projects/libffi/.travis/ar-lib lib' NM='dumpbin -symbols' STRIP=':' --build=$BUILD --host=$HOST $DEBUG_ARG $SHARED_ARG)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; make)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp $HOST/.libs/libffi.lib $HOST/testsuite/libffi-8.lib || true)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/ || true)"
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; TERM=none make check RUNTESTFLAGS='-v -v -v -v --target '$HOST DEJAGNU=$PWD/.appveyor/site.exp SITEDIR=$PWD/.appveyor)"


on_finish:
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)"
16 changes: 16 additions & 0 deletions native/libffi/.appveyor/site.exp
@@ -0,0 +1,16 @@
# Copyright (C) 2021 Anthony Green

lappend boards_dir $::env(SITEDIR)

verbose "Global Config File: target_triplet is $target_triplet" 1
global target_list

case "$target_triplet" in {
{ "aarch*cygwin*" } {
set target_list "unix-noexec"
}
{ "arm*cygwin*" } {
set target_list "unix-noexec"
}
}

7 changes: 7 additions & 0 deletions native/libffi/.appveyor/unix-noexec.exp
@@ -0,0 +1,7 @@
load_generic_config "remote"

proc noexec_load { dest prog args } {
return "unsupported"
}

set_board_info protocol "noexec"
2 changes: 1 addition & 1 deletion native/libffi/.travis.yml
Expand Up @@ -75,7 +75,7 @@ before_install:
- if test x"$MEVAL" != x; then eval ${MEVAL}; fi

install:
- travis_wait 30 ./.travis/install.sh
- travis_wait 60 ./.travis/install.sh

script:
- if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi
Expand Down
Empty file modified native/libffi/.travis/ar-lib 100644 → 100755
Empty file.
Empty file modified native/libffi/.travis/build-cross-in-container.sh 100644 → 100755
Empty file.
Empty file modified native/libffi/.travis/build-in-container.sh 100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions native/libffi/.travis/build.sh 100644 → 100755
Expand Up @@ -55,7 +55,7 @@ function build_foreign_linux()

function build_cross_linux()
{
${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh
${DOCKER} run --rm -t -i -v $(pwd):/opt ${SET_QEMU_CPU} -e HOST="${HOST}" -e CC="${HOST}-gcc-8 ${GCC_OPTIONS}" -e CXX="${HOST}-g++-8 ${GCC_OPTIONS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/cross-ci-build-container:latest bash -c /opt/.travis/build-in-container.sh

./rlgl l --key=${RLGL_KEY} https://rl.gl
ID=$(./rlgl start)
Expand All @@ -65,7 +65,7 @@ function build_cross_linux()

function build_cross()
{
${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST}
${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST}
${DOCKER} run --rm -t -i -v $(pwd):/opt -e HOST="${HOST}" -e CC="${HOST}-gcc ${GCC_OPTIONS}" -e CXX="${HOST}-g++ ${GCC_OPTIONS}" -e TRAVIS_BUILD_DIR=/opt -e DEJAGNU="${DEJAGNU}" -e RUNTESTFLAGS="${RUNTESTFLAGS}" -e LIBFFI_TEST_OPTIMIZATION="${LIBFFI_TEST_OPTIMIZATION}" quay.io/moxielogic/libffi-ci-${HOST} bash -c /opt/.travis/build-cross-in-container.sh

./rlgl l --key=${RLGL_KEY} https://rl.gl
Expand Down Expand Up @@ -106,7 +106,7 @@ case "$HOST" in
;;
arm32v7-linux-gnu)
./autogen.sh
build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest
build_foreign_linux arm quay.io/moxielogic/arm32v7-ci-build-container:latest
;;
mips64el-linux-gnu | sparc64-linux-gnu)
build_cfarm
Expand Down
Empty file modified native/libffi/.travis/compile 100644 → 100755
Empty file.
7 changes: 4 additions & 3 deletions native/libffi/.travis/install.sh 100644 → 100755
Expand Up @@ -2,7 +2,8 @@
set -x

if [[ $TRAVIS_OS_NAME != 'linux' ]]; then
brew update > brew-update.log 2>&1
brew update --verbose
# brew update > brew-update.log 2>&1
# fix an issue with libtool on travis by reinstalling it
brew uninstall libtool;
brew install libtool dejagnu;
Expand All @@ -26,7 +27,7 @@ else
wget -qO - https://rl.gl/cli/rlgl-linux-s390x.tgz | \
tar --strip-components=2 -xvzf - ./rlgl/rlgl;
;;
*)
*)
wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \
tar --strip-components=2 -xvzf - ./rlgl/rlgl;
;;
Expand All @@ -36,7 +37,7 @@ else
sudo apt-get update
case $HOST in
mips64el-linux-gnu | sparc64-linux-gnu)
;;
;;
alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu)
sudo apt-get install qemu-user-static
;;
Expand Down
2 changes: 1 addition & 1 deletion native/libffi/LICENSE
@@ -1,4 +1,4 @@
libffi - Copyright (c) 1996-2020 Anthony Green, Red Hat, Inc and others.
libffi - Copyright (c) 1996-2021 Anthony Green, Red Hat, Inc and others.
See source files for details.

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
3 changes: 2 additions & 1 deletion native/libffi/Makefile.am
Expand Up @@ -38,7 +38,8 @@ toolexeclib_LTLIBRARIES = libffi.la
noinst_LTLIBRARIES = libffi_convenience.la

libffi_la_SOURCES = src/prep_cif.c src/types.c \
src/raw_api.c src/java_raw_api.c src/closures.c
src/raw_api.c src/java_raw_api.c src/closures.c \
src/tramp.c

if FFI_DEBUG
libffi_la_SOURCES += src/debug.c
Expand Down

0 comments on commit 203fc1f

Please sign in to comment.