Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add loongarch support #1547

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions build.xml
Expand Up @@ -489,6 +489,8 @@ com/sun/jna/linux-mips64el/libjnidispatch.so;
processor=mips64el;osname=linux,
com/sun/jna/linux-s390x/libjnidispatch.so;
processor=S390x;osname=linux,
com/sun/jna/linux-loongarch64/libjnidispatch.so;
processor=loongarch64;osname=linux,

com/sun/jna/freebsd-x86/libjnidispatch.so;
processor=x86;osname=freebsd,
Expand Down Expand Up @@ -554,6 +556,9 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<zipfileset src="${lib.native}/linux-s390x.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-s390x"/>
<zipfileset src="${lib.native}/linux-loongarch64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-loongarch64"/>
<zipfileset src="${lib.native}/sunos-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-x86"/>
Expand Down Expand Up @@ -747,6 +752,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-sparcv9.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-mips64el.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-s390x.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-loongarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/openbsd-x86.jar" overwrite="true"/>
Expand Down
Binary file modified dist/aix-ppc.jar
Binary file not shown.
Binary file modified dist/aix-ppc64.jar
Binary file not shown.
Binary file modified dist/android-aarch64.jar
Binary file not shown.
Binary file modified dist/android-arm.jar
Binary file not shown.
Binary file modified dist/android-armv7.jar
Binary file not shown.
Binary file modified dist/android-mips.jar
Binary file not shown.
Binary file modified dist/android-mips64.jar
Binary file not shown.
Binary file modified dist/android-x86-64.jar
Binary file not shown.
Binary file modified dist/android-x86.jar
Binary file not shown.
Binary file modified dist/darwin.jar
Binary file not shown.
Binary file modified dist/doc.zip
Binary file not shown.
Binary file modified dist/freebsd-x86-64.jar
Binary file not shown.
Binary file modified dist/freebsd-x86.jar
Binary file not shown.
Binary file modified dist/jna-min.jar
Binary file not shown.
Binary file modified dist/jna-platform.jar
Binary file not shown.
Binary file modified dist/jna.aar
Binary file not shown.
Binary file modified dist/jna.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-alphamask.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-balloonmanager.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-balloontips.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-dnd.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-monitordemo.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-msoffice.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-nativewindowmsg.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-shapedwindow.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-w32keyhook.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-w32printing.jar
Binary file not shown.
Binary file modified dist/jnacontrib/demo-x11.jar
Binary file not shown.
Binary file modified dist/linux-aarch64.jar
Binary file not shown.
Binary file modified dist/linux-arm.jar
Binary file not shown.
Binary file modified dist/linux-armel.jar
Binary file not shown.
Binary file added dist/linux-loongarch64.jar
Binary file not shown.
Binary file modified dist/linux-mips64el.jar
Binary file not shown.
Binary file modified dist/linux-ppc.jar
Binary file not shown.
Binary file modified dist/linux-ppc64le.jar
Binary file not shown.
Binary file modified dist/linux-s390x.jar
Binary file not shown.
Binary file modified dist/linux-x86-64.jar
Binary file not shown.
Binary file modified dist/linux-x86.jar
Binary file not shown.
Binary file modified dist/openbsd-x86-64.jar
Binary file not shown.
Binary file modified dist/openbsd-x86.jar
Binary file not shown.
Binary file modified dist/src-full.zip
Binary file not shown.
Binary file modified dist/src.zip
Binary file not shown.
Binary file modified dist/sunos-sparc.jar
Binary file not shown.
Binary file modified dist/sunos-sparcv9.jar
Binary file not shown.
Binary file modified dist/sunos-x86-64.jar
Binary file not shown.
Binary file modified dist/sunos-x86.jar
Binary file not shown.
Binary file added dist/win32-aarch64.jar
Binary file not shown.
Binary file modified dist/win32-x86-64.jar
Binary file not shown.
Binary file modified dist/win32-x86.jar
Binary file not shown.
Binary file modified lib/native/aix-ppc.jar
Binary file not shown.
Binary file modified lib/native/aix-ppc64.jar
Binary file not shown.
Binary file modified lib/native/android-aarch64.jar
Binary file not shown.
Binary file modified lib/native/android-arm.jar 100755 → 100644
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 100755 → 100644
Binary file not shown.
Binary file modified lib/native/darwin.jar
Binary file not shown.
Binary file modified lib/native/freebsd-x86-64.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/freebsd-x86.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/linux-aarch64.jar
Binary file not shown.
Binary file modified lib/native/linux-arm.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/linux-armel.jar
Binary file not shown.
Empty file modified lib/native/linux-ia64.jar 100755 → 100644
Empty file.
Binary file added lib/native/linux-loongarch64.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 100755 → 100644
Binary file not shown.
Empty file modified lib/native/linux-ppc64.jar 100755 → 100644
Empty file.
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 100755 → 100644
Binary file not shown.
Binary file modified lib/native/openbsd-x86-64.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/openbsd-x86.jar 100755 → 100644
Binary file not shown.
Empty file modified lib/native/out-of-date.jar 100755 → 100644
Empty file.
Binary file modified lib/native/sunos-sparc.jar
Binary file not shown.
Binary file modified lib/native/sunos-sparcv9.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/sunos-x86-64.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/sunos-x86.jar 100755 → 100644
Binary file not shown.
Empty file modified lib/native/w32ce-arm.jar 100755 → 100644
Empty file.
Binary file added lib/native/win32-aarch64.jar
Binary file not shown.
Binary file modified lib/native/win32-x86-64.jar 100755 → 100644
Binary file not shown.
Binary file modified lib/native/win32-x86.jar
Binary file not shown.
122 changes: 66 additions & 56 deletions native/Makefile
Expand Up @@ -9,9 +9,9 @@
#
# Supported platforms (built and tested):
#
# Windows 2000/XP/2003/Vista (x86/amd64)
# Windows (x86/amd64/aarch64)
# Windows CE/Mobile (arm)
# Darwin/OS X (i386/x86_64/ppc)
# Darwin/OS X (i386/x86-64/ppc/aarch64)
# Linux (i386/amd64/ppc/arm)
# Solaris (i386/amd64/sparc/sparcv9)
# AIX (ppc/ppc64)
Expand Down Expand Up @@ -246,8 +246,21 @@ LIBS=psapi.lib
ARSFX=.lib
ifeq ($(ARCH),amd64)
CC+= -m64
endif
FFI_CONFIG+= && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
FFI_TARGET=$(FFI_SRC)/src/x86/ffitarget.h
else ifeq ($(ARCH),aarch64)
# Force $(CC) fallback; avoid arch mismatch
WINDRES=false
# Disable mingw; no aarch64 support
MINGW=
FFI_CONFIG+=--host=aarch64-cygwin
# Skip building assembly callback functions
CDEFINES+= -DASMFN_OFF
DLLCB=
CC+= -marm64
FFI_CONFIG+=--host=aarch64-cygwin
endif
FFI_TARGET?=$(FFI_SRC)/src/$(ARCH)/ffitarget.h
FFI_CONFIG+= && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_TARGET) include
FFI_ENV+=LD="$(LD)" CPP="$(CPP)" CXXCPP="$(CPP)"
EXTRAOBJS+=$(DLLCB)

Expand Down Expand Up @@ -321,14 +334,20 @@ endif
endif

# CC_OPTS only applied to objects build for jnidispatch, not for libffi
# -Wno-unknown-warning-option
# -Wno-unknown-warning-option
# => Suppress warning for unknown warnings
# -Werror => Treat warnings as errors
# -Wno-clobbered => Silence GCC warning about clobbered automatic variables.
# The "longjmp" case only happens in protect.h in the logic
# that implements "protected" mode. In that case an exception
# is raised and the value of the potentially clobbered
# variables is ignored.
# -Wno-alloca-larger-than => Silence warnings about unbounded alloca calls in
# the dispatch logic. GCC tries to assert, that the size of
# the allocated memory is bounded and thus a check for the
# variable needs to be inplace. For the JNA case, the size
# comes from the Java side, so checks are not visible on the
# C side and thus can't be checked there.
#
# Enable this only on GCC versions, that can work with it. It is assumed, that
# GCC version 4.X is the lower bound. That version is problematic, as it
Expand All @@ -337,7 +356,7 @@ ifeq ($(CC),gcc)
GCC_MAJOR_VERSION = $(shell gcc -dumpversion | cut -f 1 -d '.')
ifneq ($(GCC_MAJOR_VERSION),4)
ifneq ($(GCC_MAJOR_VERSION),3)
LOC_CC_OPTS=-Wno-unknown-warning-option -Werror -Wno-clobbered -Wno-unused-variable
LOC_CC_OPTS=-Wno-unknown-warning-option -Werror -Wno-clobbered -Wno-unused-variable -Wno-alloca-larger-than
endif
endif
else
Expand Down Expand Up @@ -373,47 +392,61 @@ endif


ifeq ($(OS),darwin)
XCODE_VERSION=$(shell xcodebuild -version | grep Xcode | sed 's/^Xcode \([1-9]\).*/\1/g')
JAVA_INCLUDES+=-I/System/Library/Frameworks/JavaVM.framework/Headers
DEFAULT_ARCH=$(shell arch)
ARCH=$(shell arch)
HOST_CONFIG=--host $(ARCH)-apple-darwin
FFI_ENV += CC="$(CC)" CFLAGS="-arch $(ARCH) $(ISYSROOT) $(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" LD="$(LD) -arch $(ARCH)"
ALT_ARCHS=
ifneq ($(ARCH),i386)
ALT_ARCHS+=i386

DARWIN_ARCH=$(ARCH)
ifeq ($(ARCH),aarch64)
DARWIN_ARCH=arm64
else
ifeq ($(ARCH),x86-64)
DARWIN_ARCH=x86_64
else
ifeq ($(ARCH),x86)
DARWIN_ARCH=x86
else
endif
ifneq ($(ARCH),x86_64)
ALT_ARCHS+=x86_64
endif
endif

XCODE_VERSION=$(shell xcodebuild -version | grep Xcode | sed 's/^Xcode \([1-9][0-9]*\).*/\1/g')
MACOS_VERSION_MAJOR=$(shell sw_vers -productVersion | cut -d. -f 1)
MACOS_VERSION_MINOR=$(shell sw_vers -productVersion | cut -d. -f 2)
JAVA_INCLUDES+=-I/System/Library/Frameworks/JavaVM.framework/Headers
# Actual deployment target depends on SDK support
MACOSX_DEPLOYMENT_TARGET=10.3
DEFAULT_ARCH=$(shell arch)
HOST_CONFIG=--host $(DARWIN_ARCH)-apple-darwin
FFI_ENV += CC="$(CC)" CFLAGS="-mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) -arch $(DARWIN_ARCH) $(ISYSROOT) $(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" LD="$(LD) -arch $(DARWIN_ARCH)"
LIBSFX=.dylib
JNISFX=-$(ARCH).jnilib
# JAWT no longer supported on OSX
CDEFINES+=-DTARGET_RT_MAC_CFM=0 -DFFI_MMAP_EXEC_WRIT -DNO_JAWT

ifneq ($(ARCH),ppc)
ifeq ($(XCODE_VERSION),3)
# Xcode 3 options
# not supported on XCode 4+
ALT_ARCHS+=ppc
else
ifneq ($(XCODE_VERSION),3)
# Xcode 4+ options
NO_COMPACT_UNWIND=-Wl,-no_compact_unwind
endif
endif
LIBSFX=.dylib
JNISFX=.jnilib
ifneq ($(SDKROOT),)
SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT)
ISYSROOT=-isysroot $(SDKROOT)
ARCHFLAGS=-arch i386 -arch x86_64
ifeq ($(XCODE_VERSION),3)
ARCHFLAGS+=-arch ppc
endif
ARCHFLAGS+=-arch $(DARWIN_ARCH)
endif

PCFLAGS+=$(ISYSROOT) -x objective-c
# JAWT no longer supported on OSX
CDEFINES+=-DTARGET_RT_MAC_CFM=0 -DFFI_MMAP_EXEC_WRIT -DNO_JAWT
LDFLAGS=$(ARCHFLAGS) -dynamiclib -o $@ -framework JavaVM \

# MAJOR < 10 || (MAJOR = 10 && MINOR < 7)
MACOS_LT_10_7 = $(shell [ ${MACOS_VERSION_MAJOR} -lt 10 -o ${MACOS_VERSION_MAJOR} -eq 10 -a ${MACOS_VERSION_MINOR} -lt 7 ] && echo true)

# JavaVM.framwork is "Deprecated in OS X v10.7."
ifeq ($(MACOS_LT_10_7),true)
FRAMEWORK=-framework JavaVM
endif

LDFLAGS=$(ARCHFLAGS) -dynamiclib -o $@ $(FRAMEWORK) \
-compatibility_version $(shell echo ${JNA_JNI_VERSION}|sed 's/^\([0-9][0-9]*\).*/\1/g') \
-current_version $(JNA_JNI_VERSION) \
-mmacosx-version-min=10.3 \
-mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) \
-framework Foundation \
$(NO_COMPACT_UNWIND) \
-install_name ${@F} \
Expand All @@ -428,11 +461,7 @@ endif
$(BUILD)/%.o : %.c dispatch.h protect.h $(FFI_LIB)
@mkdir -p $(BUILD)
ifneq ($(SDKROOT),)
$(CC) $(LOC_CC_OPTS) -arch $(ARCH) $(CFLAGS) -c $< -o $@.$(ARCH)
for arch in $(ALT_ARCHS); do \
$(CC) $(LOC_CC_OPTS) -arch $$arch -I$(BUILD)/libffi.$$arch/include $(CFLAGS) -c $< -o $@.$$arch; \
done
lipo -create -output $@ $@.*
$(CC) $(LOC_CC_OPTS) -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) -arch $(DARWIN_ARCH) $(CFLAGS) -c $< -o $@
else
$(CC) $(CFLAGS) $(LOC_CC_OPTS) -c $< $(COUT)
endif
Expand Down Expand Up @@ -488,25 +517,6 @@ $(FFI_LIB):
&& $(FFI_ENV) $(FFI_SRC)/configure $(FFI_CONFIG) $(HOST_CONFIG)); \
fi
$(MAKE) -C $(FFI_BUILD)
ifneq ($(SDKROOT),)
@for arch in $(ALT_ARCHS); do \
mkdir -p $(BUILD)/libffi.$$arch; \
if [ ! -f $(BUILD)/libffi.$$arch/Makefile ]; then \
echo "Configuring libffi ($$arch)"; \
(cd $(BUILD)/libffi.$$arch \
&& CC="$(CC)" CFLAGS="-arch $$arch $(ISYSROOT) $(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" \
LDFLAGS="-arch $$arch" \
$(FFI_SRC)/configure $(FFI_CONFIG) --host=$$arch-apple-darwin --disable-dependency-tracking); \
fi; \
$(MAKE) -C $(BUILD)/libffi.$$arch; \
done
ifneq ($(ALT_ARCHS),)
/usr/bin/libtool -static -o $@.tmp $(FFI_BUILD)/.libs/${@F} $(BUILD)/libffi.*/.libs/${@F}
else
/usr/bin/libtool -static -o $@.tmp $(FFI_BUILD)/.libs/${@F}
endif
mv $@.tmp $@
endif
endif

clean:
Expand Down
86 changes: 44 additions & 42 deletions native/build.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="compile-native" default="install">
<project name="compile-native" default="install"
xmlns:if="ant:if"
xmlns:unless="ant:unless">
<dirname property="module.root.folder" file="${ant.file}"/>
<dirname property="workspace.root.folder" file="${module.root.folder}"/>
<property name="jna.parent.folder" value="${workspace.root.folder}${file.separator}parent"/>
Expand All @@ -15,8 +17,7 @@
<condition property="os.prefix" value="win32-${jre.arch}">
<os family="windows"/>
</condition>
<!-- Darwin builds are universal, no arch required -->
<condition property="os.prefix" value="darwin">
<condition property="os.prefix" value="darwin-${jre.arch}">
<os family="mac"/>
</condition>
<condition property="os.prefix" value="sunos-${jre.arch}">
Expand All @@ -38,6 +39,9 @@
message="OS/arch not supported (${os.name}/${jre.arch}), edit build.xml and native/Makefile to add it."/>
<!-- Keep all natives separate -->
<property name="native.subdir" value="native-${os.prefix}"/>
<condition property="darwin.build" value="true">
<matches string="${os.prefix}" pattern="^darwin-"/>
</condition>

<!-- ################# figure out the compatibility version ################## -->
<!-- Set up restrictions for w32ce, based on JavaME/CDC -->
Expand Down Expand Up @@ -236,26 +240,26 @@
<equals arg1="${os.prefix}" arg2="android-armv7"/>
</condition>
<condition property="ARCH" value="aarch64">
<equals arg1="${os.prefix}" arg2="android-aarch64"/>
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
<matches string="${os.prefix}" pattern="-aarch64$"/>
</condition>
<condition property="ARCH" value="x86-64">
<equals arg1="${os.prefix}" arg2="android-x86-64"/>
<matches string="${os.prefix}" pattern="-x86-64$"/>
</condition>
<condition property="ARCH" value="ppc">
<matches string="${os.prefix}" pattern="-ppc$"/>
</condition>
<condition property="ARCH" value="ppc64">
<matches string="${os.prefix}" pattern="-ppc64$"/>
</condition>
<condition property="ARCH" value="x86">
<matches string="${os.prefix}" pattern="-x86$"/>
</condition>
<condition property="ARCH" value="mips">
<equals arg1="${os.prefix}" arg2="android-mips"/>
</condition>
<condition property="ARCH" value="mips64">
<equals arg1="${os.prefix}" arg2="android-mips64"/>
</condition>
<condition property="ARCH" value="ppc">
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
</condition>
<condition property="ARCH" value="ppc64">
<equals arg1="${os.prefix}" arg2="aix-ppc64"/>
</condition>
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
<!-- use ANT_OPTS=-d64/-d32 to build 64-bit/32-bit if not the platform default -->
<property name="ARCH" value="${os.arch}"/>
Expand All @@ -279,44 +283,42 @@
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
<isset property="SDKROOT"/>
</condition>
<property name="xcode" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform"/>
<condition property="make.SDKROOT" value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.11.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.11.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.9.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.9.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.8.sdk">
<!-- If not manually provided, detect the SDKROOT in various locations:
- Modern build environments ("MacOSX.sdk", no version):
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

- macOS 10.8 and older:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX(version).sdk

- Prior versions:
/Developer/SDKs/MacOSX(version).sdk
-->
<condition property="make.SDKROOT" value="SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.8.sdk"/>
<matches string="${os.prefix}" pattern="^darwin-"/>
<available file="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
<condition property="sdk-parent" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
<matches string="${os.prefix}" pattern="^darwin-"/>
<available file="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"/>
</and>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
<condition property="sdk-parent" value="/Developer/SDKs">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
<matches string="${os.prefix}" pattern="^darwin-"/>
<available file="/Developer/SDKs"/>
</and>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
</and>
<!-- Multiple SDKs is common; find the most recent (sort -V requires 10.12+) -->
<exec executable="sh" dir="${sdk-parent}" outputproperty="sdk-latest" if:set="darwin.build" unless:set="make.SDKROOT">
<arg value="-c"/>
<arg line="&quot;ls -d MacOSX10.*.sdk | sort -t &quot;.&quot; -k2 -n | tail -1&quot;"/>
</exec>
<condition property="make.SDKROOT" value="SDKROOT=${sdk-parent}/${sdk-latest}" else="IGNORE=">
<isset property="sdk-latest"/>
</condition>
<echo level="info" message="make.SDKROOT: ${make.SDKROOT}"/>

<!-- Windows drive letters, separator and spaces in absolute paths wreak havoc on make -->
<condition property="make.BUILD"
Expand Down
4 changes: 2 additions & 2 deletions native/callback.c
Expand Up @@ -51,7 +51,7 @@
extern "C" {
#endif

#if defined(_WIN32) && !defined(_WIN32_WCE)
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(ASMFN_OFF)
#include "com_sun_jna_win32_DLLCallback.h"
#ifdef _WIN64
#ifdef _MSC_VER
Expand Down Expand Up @@ -313,7 +313,6 @@ create_callback(JNIEnv* env, jobject obj, jobject method,
}
void
free_callback(JNIEnv* env, callback *cb) {
int i;
(*env)->DeleteWeakGlobalRef(env, cb->object);
ffi_closure_free(cb->closure);
free(cb->arg_types);
Expand All @@ -332,6 +331,7 @@ free_callback(JNIEnv* env, callback *cb) {
}
free(cb->arg_jtypes);
#ifdef DLL_FPTRS
int i;
for (i=0;i < DLL_FPTRS;i++) {
if (fn[i] == cb->saved_x_closure) {
fn[i] = NULL;
Expand Down