Visitar URL original
Add support for DragonFly BSD x86_64 · java-native-access/jna@7b2a4dc · GitHub
Skip to content

Commit 7b2a4dc

Browse files
committed
Add support for DragonFly BSD x86_64
DragonFly BSD is currently x86_64 only, so don't bother with other architectures at the moment. The changes are based on the existing support for other BSDs. Add an empty 'dragonflybsd-x86-64.jar' as a placeholder by copying from 'out-of-date.jar'. Enhance 'native/Makefile' to include more paths for searching for X11 headers, because the X11 header paths are different on BSDs. In addition, add the 'X11INC' variable to allow user to specify extra paths for X11 headers if really necessary. Tested on DragonFly 6.5 with OpenJDK 17.0.8 and Ant 1.10.13.
1 parent 7da005e commit 7b2a4dc

9 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎build.xml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ processor=S390x;osname=linux,
397397
com/sun/jna/linux-loongarch64/libjnidispatch.so;
398398
processor=loongarch64;osname=linux,
399399
400+
com/sun/jna/dragonflybsd-x86-64/libjnidispatch.so;
401+
processor=x86-64;osname=dragonflybsd,
402+
400403
com/sun/jna/freebsd-x86/libjnidispatch.so;
401404
processor=x86;osname=freebsd,
402405
com/sun/jna/freebsd-x86-64/libjnidispatch.so;
@@ -528,6 +531,9 @@ osname=macosx;processor=aarch64
528531
<zipfileset src="${lib.native}/sunos-sparcv9.jar"
529532
includes="*jnidispatch*"
530533
prefix="com/sun/jna/sunos-sparcv9"/>
534+
<zipfileset src="${lib.native}/dragonflybsd-x86-64.jar"
535+
includes="*jnidispatch*"
536+
prefix="com/sun/jna/dragonflybsd-x86-64"/>
531537
<zipfileset src="${lib.native}/freebsd-x86.jar"
532538
includes="*jnidispatch*"
533539
prefix="com/sun/jna/freebsd-x86"/>
@@ -723,6 +729,7 @@ osname=macosx;processor=aarch64
723729
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-loongarch64.jar" overwrite="true"/>
724730
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-s390x.jar" overwrite="true"/>
725731
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-riscv64.jar" overwrite="true"/>
732+
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/dragonflybsd-x86-64.jar" overwrite="true"/>
726733
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86.jar" overwrite="true"/>
727734
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86-64.jar" overwrite="true"/>
728735
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-aarch64.jar" overwrite="true"/>
@@ -909,6 +916,7 @@ osname=macosx;processor=aarch64
909916
</condition>
910917
<condition property="make" value="gmake">
911918
<or>
919+
<equals arg1="${build.os.name}" arg2="DragonFlyBSD"/>
912920
<equals arg1="${build.os.name}" arg2="FreeBSD"/>
913921
<equals arg1="${build.os.name}" arg2="OpenBSD"/>
914922
<equals arg1="${build.os.name}" arg2="NetBSD"/>

‎common.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
<condition property="os.prefix" value="sunos-${jre.arch}">
100100
<equals arg1="${build.os.name}" arg2="SunOS"/>
101101
</condition>
102+
<condition property="os.prefix" value="dragonflybsd-${jre.arch}">
103+
<equals arg1="${build.os.name}" arg2="DragonFlyBSD"/>
104+
</condition>
102105
<condition property="os.prefix" value="freebsd-${jre.arch}">
103106
<equals arg1="${build.os.name}" arg2="FreeBSD"/>
104107
</condition>

‎dist/dragonflybsd-x86-64.jar‎

48.2 KB
Binary file not shown.

‎native/Makefile‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Linux (i386/amd64/ppc/arm)
1616
# Solaris (i386/amd64/sparc/sparcv9)
1717
# AIX (ppc/ppc64)
18+
# DragonFly (x86-64)
1819
# FreeBSD (i386/amd64/aarch64)
1920
# OpenBSD/NetBSD (i386/amd64)
2021
# Android (arm/armv7/aarch64/x86/x86-64/mipsel/mips64el)
@@ -46,6 +47,7 @@ OS=$(shell uname | sed -e 's/CYGWIN.*/win32/g' \
4647
-e 's/NetBSD/netbsd/g' \
4748
-e 's/GNU\/kFreeBSD/kfreebsd/g' \
4849
-e 's/FreeBSD/freebsd/g' \
50+
-e 's/DragonFly/dragonfly/g' \
4951
-e 's/OpenBSD/openbsd/g' \
5052
-e 's/Darwin.*/darwin/g' \
5153
-e 's/AIX.*/aix/g' \
@@ -289,10 +291,14 @@ LDFLAGS+=-Wl,-soname,$@,-Bsymbolic
289291
endif
290292
endif
291293

292-
ifneq (,$(findstring bsd,$(OS)))
294+
ifneq (,$(or $(findstring bsd,$(OS)),$(findstring dragonfly,$(OS))))
293295
ARCH=$(shell uname -m | sed 's/i.86/i386/g')
294296
PCFLAGS+=-fPIC
295-
CINCLUDES+=-I/usr/X11R6/include
297+
# This is a mess: X11 headers locate in /usr/local/include on FreeBSD and
298+
# DragonFly, in /usr/X11R7/include on NetBSD, and in /usr/X11R6/include on
299+
# OpenBSD.
300+
CINCLUDES+=-I/usr/local/include -I/usr/X11R7/include -I/usr/X11R6/include
301+
CINCLUDES+=$(X11INC) # Allow extra X11 include path if necessary.
296302
LDFLAGS=-o $@ -shared
297303
CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT -DUSE_DEAFULT_LIBNAME_ENCODING
298304
endif

‎native/build.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<condition property="os.prefix" value="sunos-${jre.arch}">
2424
<os name="SunOS"/>
2525
</condition>
26+
<condition property="os.prefix" value="dragonflybsd-${jre.arch}">
27+
<os name="DragonFlyBSD"/>
28+
</condition>
2629
<condition property="os.prefix" value="freebsd-${jre.arch}">
2730
<os name="FreeBSD"/>
2831
</condition>
@@ -347,6 +350,7 @@
347350
</condition>
348351
<condition property="make" value="gmake">
349352
<or>
353+
<os name="DragonFlyBSD"/>
350354
<os name="FreeBSD"/>
351355
<os name="OpenBSD"/>
352356
<os name="NetBSD"/>

‎src/com/sun/jna/Native.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static File getTempDir() throws IOException {
13261326
if(Platform.isMac()) {
13271327
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html
13281328
jnatmp = new File(System.getProperty("user.home"), "Library/Caches/JNA/temp");
1329-
} else if (Platform.isLinux() || Platform.isSolaris() || Platform.isAIX() || Platform.isFreeBSD() || Platform.isNetBSD() || Platform.isOpenBSD() || Platform.iskFreeBSD()) {
1329+
} else if (Platform.isLinux() || Platform.isSolaris() || Platform.isAIX() || Platform.isDragonFlyBSD() || Platform.isFreeBSD() || Platform.isNetBSD() || Platform.isOpenBSD() || Platform.iskFreeBSD()) {
13301330
// https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
13311331
// The XDG_CACHE_DIR is expected to be per user
13321332
String xdgCacheEnvironment = System.getenv("XDG_CACHE_HOME");

‎src/com/sun/jna/Platform.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public final class Platform {
4242
public static final int GNU = 9;
4343
public static final int KFREEBSD = 10;
4444
public static final int NETBSD = 11;
45+
public static final int DRAGONFLYBSD = 12;
4546

4647
/** Whether read-only (final) fields within Structures are supported. */
4748
public static final boolean RO_FIELDS;
@@ -110,6 +111,9 @@ else if (osName.equalsIgnoreCase("gnu/kfreebsd")) {
110111
else if (osName.equalsIgnoreCase("netbsd")) {
111112
osType = NETBSD;
112113
}
114+
else if (osName.equalsIgnoreCase("dragonflybsd")) {
115+
osType = DRAGONFLYBSD;
116+
}
113117
else {
114118
osType = UNSPECIFIED;
115119
}
@@ -160,6 +164,9 @@ public static final boolean isWindows() {
160164
public static final boolean isSolaris() {
161165
return osType == SOLARIS;
162166
}
167+
public static final boolean isDragonFlyBSD() {
168+
return osType == DRAGONFLYBSD;
169+
}
163170
public static final boolean isFreeBSD() {
164171
return osType == FREEBSD;
165172
}
@@ -329,6 +336,9 @@ static String getNativeLibraryResourcePrefix(int osType, String arch, String nam
329336
case Platform.SOLARIS:
330337
osPrefix = "sunos-" + arch;
331338
break;
339+
case Platform.DRAGONFLYBSD:
340+
osPrefix = "dragonflybsd-" + arch;
341+
break;
332342
case Platform.FREEBSD:
333343
osPrefix = "freebsd-" + arch;
334344
break;

‎test/com/sun/jna/NativeLibraryTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void testMapSharedLibraryName() {
4848
{ Platform.LINUX, "lib", ".so" },
4949
{ Platform.WINDOWS, "", ".dll" },
5050
{ Platform.SOLARIS, "lib", ".so" },
51+
{ Platform.DRAGONFLYBSD, "lib", ".so" },
5152
{ Platform.FREEBSD, "lib", ".so" },
5253
{ Platform.OPENBSD, "lib", ".so" },
5354
{ Platform.WINDOWSCE, "", ".dll" },

‎test/com/sun/jna/PlatformTest.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public void testOSPrefix() {
8383
Platform.getNativeLibraryResourcePrefix(Platform.LINUX,
8484
"arm", "Linux/Gnu"));
8585
}
86+
assertEquals("Wrong resource path DragonFlyBSD/x86-64", "dragonflybsd-x86-64",
87+
Platform.getNativeLibraryResourcePrefix(Platform.DRAGONFLYBSD,
88+
"x86-64", "DragonFlyBSD"));
8689
assertEquals("Wrong resource path OpenBSD/x86", "openbsd-x86",
8790
Platform.getNativeLibraryResourcePrefix(Platform.OPENBSD,
8891
"x86", "OpenBSD"));

0 commit comments

Comments
 (0)