Skip to content

Commit 203fc1f

Browse files
Merge pull request #1383 from matthiasblaesing/update-libffi-3_4_2
Update to libffi 3.4.2
2 parents b19ff07 + fe33d83 commit 203fc1f

File tree

135 files changed

+2775
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+2775
-521
lines changed

CHANGES.md

+1

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<!-- jnidispatch library release version -->
7777
<property name="jni.major" value="6"/>
7878
<property name="jni.minor" value="1"/>
79-
<property name="jni.revision" value="1"/>
79+
<property name="jni.revision" value="2"/>
8080
<property name="jni.build" value="0"/> <!--${build.number}-->
8181
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
8282
<property name="jni.md5" value="147a998f0cbc89681a1ae6c0dd121629"/>

lib/native/android-aarch64.jar

3.21 KB
Binary file not shown.

lib/native/android-arm.jar

2.58 KB
Binary file not shown.

lib/native/android-armv7.jar

2.45 KB
Binary file not shown.

lib/native/android-mips.jar

1.01 KB
Binary file not shown.

lib/native/android-mips64.jar

982 Bytes
Binary file not shown.

lib/native/android-x86-64.jar

2.77 KB
Binary file not shown.

lib/native/android-x86.jar

2.88 KB
Binary file not shown.

lib/native/darwin-aarch64.jar

177 Bytes
Binary file not shown.

lib/native/darwin-x86-64.jar

390 Bytes
Binary file not shown.

lib/native/freebsd-x86-64.jar

1017 Bytes
Binary file not shown.

lib/native/freebsd-x86.jar

1.14 KB
Binary file not shown.

lib/native/linux-aarch64.jar

2.65 KB
Binary file not shown.

lib/native/linux-arm.jar

2.18 KB
Binary file not shown.

lib/native/linux-armel.jar

2.22 KB
Binary file not shown.

lib/native/linux-mips64el.jar

1.04 KB
Binary file not shown.

lib/native/linux-ppc.jar

999 Bytes
Binary file not shown.

lib/native/linux-ppc64le.jar

1.03 KB
Binary file not shown.

lib/native/linux-s390x.jar

1008 Bytes
Binary file not shown.

lib/native/linux-x86-64.jar

2.55 KB
Binary file not shown.

lib/native/linux-x86.jar

2.82 KB
Binary file not shown.

lib/native/openbsd-x86-64.jar

2.12 KB
Binary file not shown.

lib/native/openbsd-x86.jar

1019 Bytes
Binary file not shown.

lib/native/sunos-sparc.jar

1.73 KB
Binary file not shown.

lib/native/sunos-sparcv9.jar

1.19 KB
Binary file not shown.

lib/native/sunos-x86-64.jar

1.02 KB
Binary file not shown.

lib/native/sunos-x86.jar

953 Bytes
Binary file not shown.

lib/native/win32-aarch64.jar

-455 Bytes
Binary file not shown.

lib/native/win32-x86-64.jar

4 Bytes
Binary file not shown.

lib/native/win32-x86.jar

-1.74 KB
Binary file not shown.

native/callback.c

+18
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
201201
cb->conversion_flags[i] = CVT_FLOAT;
202202
cvt = 1;
203203
}
204+
else if (cb->arg_types[i]->type == FFI_TYPE_UINT16 || cb->arg_types[i]->type == FFI_TYPE_SINT16) {
205+
cb->java_arg_types[i+3] = &ffi_type_sint;
206+
cb->conversion_flags[i] = CVT_SHORT;
207+
cvt = 1;
208+
}
209+
else if (cb->arg_types[i]->type == FFI_TYPE_UINT8 || cb->arg_types[i]->type == FFI_TYPE_SINT8) {
210+
cb->java_arg_types[i+3] = &ffi_type_sint;
211+
cb->conversion_flags[i] = CVT_BYTE;
212+
cvt = 1;
213+
}
204214
else if (cb->java_arg_types[i+3]->type == FFI_TYPE_STRUCT) {
205215
// All callback structure arguments are passed as a jobject
206216
cb->java_arg_types[i+3] = &ffi_type_pointer;
@@ -429,6 +439,14 @@ invoke_callback(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbar
429439
args[i+3] = alloca(sizeof(double));
430440
*((double *)args[i+3]) = *(float*)cbargs[i];
431441
break;
442+
case CVT_SHORT:
443+
args[i+3] = alloca(sizeof(int));
444+
*((int *)args[i+3]) = *(short*)cbargs[i];
445+
break;
446+
case CVT_BYTE:
447+
args[i+3] = alloca(sizeof(int));
448+
*((int *)args[i+3]) = *(char*)cbargs[i];
449+
break;
432450
case CVT_DEFAULT:
433451
break;
434452
default:

native/dispatch.c

+33-8
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,17 @@ ffi_error(JNIEnv* env, const char* op, ffi_status status) {
422422
char msg[MSG_SIZE];
423423
switch(status) {
424424
case FFI_BAD_ABI:
425-
snprintf(msg, sizeof(msg), "%s: Invalid calling convention", op);
425+
snprintf(msg, sizeof(msg), "%s: Invalid calling convention (FFI_BAD_ABI)", op);
426426
throwByName(env, EIllegalArgument, msg);
427427
return JNI_TRUE;
428428
case FFI_BAD_TYPEDEF:
429429
snprintf(msg, sizeof(msg),
430-
"%s: Invalid structure definition (native typedef error)", op);
430+
"%s: Invalid structure definition (native typedef error, FFI_BAD_TYPEDEF)", op);
431+
throwByName(env, EIllegalArgument, msg);
432+
return JNI_TRUE;
433+
case FFI_BAD_ARGTYPE:
434+
snprintf(msg, sizeof(msg),
435+
"%s: Invalid argument type (FFI_BAD_ARGTYPE)", op);
431436
throwByName(env, EIllegalArgument, msg);
432437
return JNI_TRUE;
433438
default:
@@ -493,19 +498,39 @@ dispatch(JNIEnv *env, void* func, jint flags, jobjectArray args,
493498
}
494499
else if ((*env)->IsInstanceOf(env, arg, classByte)) {
495500
c_args[i].b = (*env)->GetByteField(env, arg, FID_Byte_value);
496-
arg_types[i] = &ffi_type_sint8;
497-
arg_values[i] = &c_args[i].b;
501+
// Promote char to int if we prepare a varargs call
502+
if(fixed_args && i >= fixed_args && sizeof(char) < sizeof(int)) {
503+
arg_types[i] = &ffi_type_uint32;
504+
arg_values[i] = alloca(sizeof(int));
505+
*(int*)arg_values[i] = (int) c_args[i].b;
506+
} else {
507+
arg_types[i] = &ffi_type_sint8;
508+
arg_values[i] = &c_args[i].b;
509+
}
498510
}
499511
else if ((*env)->IsInstanceOf(env, arg, classShort)) {
500512
c_args[i].s = (*env)->GetShortField(env, arg, FID_Short_value);
501-
arg_types[i] = &ffi_type_sint16;
502-
arg_values[i] = &c_args[i].s;
513+
// Promote short to int if we prepare a varargs call
514+
if(fixed_args && i >= fixed_args && sizeof(short) < sizeof(int)) {
515+
arg_types[i] = &ffi_type_uint32;
516+
arg_values[i] = alloca(sizeof(int));
517+
*(int*)arg_values[i] = (int) c_args[i].s;
518+
} else {
519+
arg_types[i] = &ffi_type_sint16;
520+
arg_values[i] = &c_args[i].s;
521+
}
503522
}
504523
else if ((*env)->IsInstanceOf(env, arg, classCharacter)) {
505524
if (sizeof(wchar_t) == 2) {
506525
c_args[i].c = (*env)->GetCharField(env, arg, FID_Character_value);
507-
arg_types[i] = &ffi_type_uint16;
508-
arg_values[i] = &c_args[i].c;
526+
if(fixed_args && i >= fixed_args && sizeof(short) < sizeof(int)) {
527+
arg_types[i] = &ffi_type_uint32;
528+
arg_values[i] = alloca(sizeof(int));
529+
*(int*)arg_values[i] = (int) c_args[i].c;
530+
} else {
531+
arg_types[i] = &ffi_type_uint16;
532+
arg_values[i] = &c_args[i].c;
533+
}
509534
}
510535
else if (sizeof(wchar_t) == 4) {
511536
c_args[i].i = (*env)->GetCharField(env, arg, FID_Character_value);

native/dispatch.h

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ enum {
117117
CVT_TYPE_MAPPER_WSTRING = com_sun_jna_Native_CVT_TYPE_MAPPER_WSTRING,
118118
CVT_OBJECT = com_sun_jna_Native_CVT_OBJECT,
119119
CVT_JNIENV = com_sun_jna_Native_CVT_JNIENV,
120+
CVT_SHORT = com_sun_jna_Native_CVT_SHORT,
121+
CVT_BYTE = com_sun_jna_Native_CVT_BYTE,
120122
};
121123

122124
/* callback behavior flags */

native/libffi/.appveyor.yml

+27-9
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ platform:
1515
- arm
1616
- arm64
1717

18+
configuration:
19+
- Debug
20+
- Release
21+
1822
environment:
1923
global:
20-
CYG_ROOT: C:/cygwin
21-
CYG_CACHE: C:/cygwin/var/cache/setup
24+
CYG_ROOT: C:/cygwin64
25+
CYG_CACHE: C:/cygwin64/var/cache/setup
2226
CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/
27+
VSVER: 15
2328
matrix:
24-
- VSVER: 15
29+
- SHARED_ARG: "--enable-shared --disable-static"
30+
- SHARED_ARG: "--enable-static --disable-shared"
2531

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

6273
build_script:
63-
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; ./autogen.sh;)"
64-
- 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;)"
65-
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include; make; find .;)"
66-
- c:\cygwin\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/; make check; cat `find ./ -name libffi.log`)"
74+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; ./autogen.sh)"
75+
- 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)"
76+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp src/%SRC_ARCHITECTURE%/ffitarget.h include)"
77+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; make)"
78+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp $HOST/.libs/libffi.lib $HOST/testsuite/libffi-8.lib || true)"
79+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cp `find . -name 'libffi-?.dll'` $HOST/testsuite/ || true)"
80+
- 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)"
81+
82+
83+
on_finish:
84+
- c:\cygwin64\bin\sh -lc "(cd $OLDPWD; cat `find ./ -name libffi.log`)"

native/libffi/.appveyor/site.exp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (C) 2021 Anthony Green
2+
3+
lappend boards_dir $::env(SITEDIR)
4+
5+
verbose "Global Config File: target_triplet is $target_triplet" 1
6+
global target_list
7+
8+
case "$target_triplet" in {
9+
{ "aarch*cygwin*" } {
10+
set target_list "unix-noexec"
11+
}
12+
{ "arm*cygwin*" } {
13+
set target_list "unix-noexec"
14+
}
15+
}
16+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load_generic_config "remote"
2+
3+
proc noexec_load { dest prog args } {
4+
return "unsupported"
5+
}
6+
7+
set_board_info protocol "noexec"

native/libffi/.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ before_install:
7575
- if test x"$MEVAL" != x; then eval ${MEVAL}; fi
7676

7777
install:
78-
- travis_wait 30 ./.travis/install.sh
78+
- travis_wait 60 ./.travis/install.sh
7979

8080
script:
8181
- if ! test x"$MEVAL" = x; then eval ${MEVAL}; fi

native/libffi/.travis/ar-lib

100644100755
File mode changed.

native/libffi/.travis/build-cross-in-container.sh

100644100755
File mode changed.

native/libffi/.travis/build-in-container.sh

100644100755
File mode changed.

native/libffi/.travis/build.sh

100644100755
+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function build_foreign_linux()
5555

5656
function build_cross_linux()
5757
{
58-
${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
58+
${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
5959

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

6666
function build_cross()
6767
{
68-
${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST}
68+
${DOCKER} pull quay.io/moxielogic/libffi-ci-${HOST}
6969
${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
7070

7171
./rlgl l --key=${RLGL_KEY} https://rl.gl
@@ -106,7 +106,7 @@ case "$HOST" in
106106
;;
107107
arm32v7-linux-gnu)
108108
./autogen.sh
109-
build_foreign_linux arm moxielogic/arm32v7-ci-build-container:latest
109+
build_foreign_linux arm quay.io/moxielogic/arm32v7-ci-build-container:latest
110110
;;
111111
mips64el-linux-gnu | sparc64-linux-gnu)
112112
build_cfarm

native/libffi/.travis/compile

100644100755
File mode changed.

native/libffi/.travis/install.sh

100644100755
+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
set -x
33

44
if [[ $TRAVIS_OS_NAME != 'linux' ]]; then
5-
brew update > brew-update.log 2>&1
5+
brew update --verbose
6+
# brew update > brew-update.log 2>&1
67
# fix an issue with libtool on travis by reinstalling it
78
brew uninstall libtool;
89
brew install libtool dejagnu;
@@ -26,7 +27,7 @@ else
2627
wget -qO - https://rl.gl/cli/rlgl-linux-s390x.tgz | \
2728
tar --strip-components=2 -xvzf - ./rlgl/rlgl;
2829
;;
29-
*)
30+
*)
3031
wget -qO - https://rl.gl/cli/rlgl-linux-amd64.tgz | \
3132
tar --strip-components=2 -xvzf - ./rlgl/rlgl;
3233
;;
@@ -36,7 +37,7 @@ else
3637
sudo apt-get update
3738
case $HOST in
3839
mips64el-linux-gnu | sparc64-linux-gnu)
39-
;;
40+
;;
4041
alpha-linux-gnu | arm32v7-linux-gnu | m68k-linux-gnu | sh4-linux-gnu)
4142
sudo apt-get install qemu-user-static
4243
;;

native/libffi/LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
libffi - Copyright (c) 1996-2020 Anthony Green, Red Hat, Inc and others.
1+
libffi - Copyright (c) 1996-2021 Anthony Green, Red Hat, Inc and others.
22
See source files for details.
33

44
Permission is hereby granted, free of charge, to any person obtaining

native/libffi/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ toolexeclib_LTLIBRARIES = libffi.la
3838
noinst_LTLIBRARIES = libffi_convenience.la
3939

4040
libffi_la_SOURCES = src/prep_cif.c src/types.c \
41-
src/raw_api.c src/java_raw_api.c src/closures.c
41+
src/raw_api.c src/java_raw_api.c src/closures.c \
42+
src/tramp.c
4243

4344
if FFI_DEBUG
4445
libffi_la_SOURCES += src/debug.c

0 commit comments

Comments
 (0)