python/manuel: update to 1.13.0
[oi-userland.git] / components / runtime / openjdk-24 / patches / 1_java-solaris-sparc.patch
blobc77950fdbff27fb865313a1ffc65582e1831f843
1 diff -Nru jdk-jdk-24-11.orig/bin/unshuffle_list.txt jdk-jdk-24-11/bin/unshuffle_list.txt
2 --- jdk-jdk-24-11.orig/bin/unshuffle_list.txt 2024-08-15 09:39:31.000000000 +0200
3 +++ jdk-jdk-24-11/bin/unshuffle_list.txt 2024-08-17 20:36:14.210850676 +0200
4 @@ -100,6 +100,7 @@
5 src/langtools/sample : langtools/src/sample
6 src/linux : jdk/src/linux
7 src/sample : jdk/src/sample
8 +src/solaris : jdk/src/solaris
9 src/hotspot/share : hotspot/src/share/vm
10 src/hotspot/cpu/aarch64 : hotspot/src/cpu/aarch64/vm
11 src/hotspot/cpu/arm : hotspot/src/cpu/arm/vm
12 @@ -112,6 +113,7 @@
13 src/hotspot/os/linux : hotspot/src/os/linux/vm
14 src/hotspot/os/posix/dtrace : hotspot/src/os/posix/dtrace
15 src/hotspot/os/posix : hotspot/src/os/posix/vm
16 +src/hotspot/os/solaris : hotspot/src/os/solaris/vm
17 src/hotspot/os/windows : hotspot/src/os/windows/vm
18 src/hotspot/os_cpu/aix_ppc : hotspot/src/os_cpu/aix_ppc/vm
19 src/hotspot/os_cpu/bsd_x86 : hotspot/src/os_cpu/bsd_x86/vm
20 @@ -122,6 +124,7 @@
21 src/hotspot/os_cpu/linux_s390 : hotspot/src/os_cpu/linux_s390/vm
22 src/hotspot/os_cpu/linux_x86 : hotspot/src/os_cpu/linux_x86/vm
23 src/hotspot/os_cpu/linux_zero : hotspot/src/os_cpu/linux_zero/vm
24 +src/hotspot/os_cpu/solaris_x86 : hotspot/src/os_cpu/solaris_x86/vm
25 src/hotspot/os_cpu/windows_x86 : hotspot/src/os_cpu/windows_x86/vm
26 src/hotspot : hotspot/src
27 src/utils/IdealGraphVisualizer : hotspot/src/share/tools/IdealGraphVisualizer
28 diff -Nru jdk-jdk-24-11.orig/make/autoconf/basic_tools.m4 jdk-jdk-24-11/make/autoconf/basic_tools.m4
29 --- jdk-jdk-24-11.orig/make/autoconf/basic_tools.m4 2024-08-15 09:39:31.000000000 +0200
30 +++ jdk-jdk-24-11/make/autoconf/basic_tools.m4 2024-08-17 20:36:14.212524326 +0200
31 @@ -290,6 +290,8 @@
32 TAR_TYPE="bsd"
33 elif test "x$($TAR --version | $GREP "busybox")" != "x"; then
34 TAR_TYPE="busybox"
35 + elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
36 + TAR_TYPE="solaris"
37 elif test "x$OPENJDK_BUILD_OS" = "xaix"; then
38 TAR_TYPE="aix"
40 diff -Nru jdk-jdk-24-11.orig/make/autoconf/build-aux/config.guess jdk-jdk-24-11/make/autoconf/build-aux/config.guess
41 --- jdk-jdk-24-11.orig/make/autoconf/build-aux/config.guess 2024-08-15 09:39:31.000000000 +0200
42 +++ jdk-jdk-24-11/make/autoconf/build-aux/config.guess 2024-08-17 20:36:14.212923852 +0200
43 @@ -53,6 +53,14 @@
47 +# Test and fix solaris on x86_64
48 +echo $OUT | grep i386-pc-solaris > /dev/null 2> /dev/null
49 +if test $? = 0; then
50 + # isainfo -n returns either i386 or amd64
51 + REAL_CPU=`isainfo -n`
52 + OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
53 +fi
55 # Test and fix cygwin on x86_64
56 echo $OUT | grep 86-pc-cygwin > /dev/null 2> /dev/null
57 if test $? != 0; then
58 diff -Nru jdk-jdk-24-11.orig/make/autoconf/build-performance.m4 jdk-jdk-24-11/make/autoconf/build-performance.m4
59 --- jdk-jdk-24-11.orig/make/autoconf/build-performance.m4 2024-08-15 09:39:31.000000000 +0200
60 +++ jdk-jdk-24-11/make/autoconf/build-performance.m4 2024-08-17 20:36:14.213406305 +0200
61 @@ -33,6 +33,9 @@
62 if test "$NUM_CORES" -eq "0"; then
63 NUM_CORES=`cat /proc/cpuinfo | grep -c ^CPU`
65 + elif test -x /usr/sbin/psrinfo; then
66 + # Looks like a Solaris system
67 + NUM_CORES=`/usr/sbin/psrinfo -v | grep -c on-line`
68 elif test -x /usr/sbin/sysctl; then
69 # Looks like a MacOSX system
70 NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
71 @@ -65,7 +68,7 @@
72 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
73 FOUND_MEM=yes
74 elif test -x /usr/sbin/prtconf; then
75 - # Looks like an AIX system
76 + # Looks like a Solaris or AIX system
77 MEMORY_SIZE=`/usr/sbin/prtconf 2> /dev/null | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'`
78 FOUND_MEM=yes
79 elif test -x /usr/sbin/sysctl; then
80 diff -Nru jdk-jdk-24-11.orig/make/autoconf/flags-cflags.m4 jdk-jdk-24-11/make/autoconf/flags-cflags.m4
81 --- jdk-jdk-24-11.orig/make/autoconf/flags-cflags.m4 2024-08-15 09:39:31.000000000 +0200
82 +++ jdk-jdk-24-11/make/autoconf/flags-cflags.m4 2024-08-17 20:36:14.214067510 +0200
83 @@ -455,6 +455,9 @@
84 if test "x$OPENJDK_TARGET_OS" = xlinux; then
85 CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64"
86 CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
87 + elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
88 + CFLAGS_OS_DEF_JVM="-DSOLARIS"
89 + CFLAGS_OS_DEF_JDK="-D__solaris__"
90 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
91 CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
92 CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
93 diff -Nru jdk-jdk-24-11.orig/make/autoconf/jdk-options.m4 jdk-jdk-24-11/make/autoconf/jdk-options.m4
94 --- jdk-jdk-24-11.orig/make/autoconf/jdk-options.m4 2024-08-15 09:39:31.000000000 +0200
95 +++ jdk-jdk-24-11/make/autoconf/jdk-options.m4 2024-08-17 20:36:14.214637929 +0200
96 @@ -280,7 +280,7 @@
97 ZIP_EXTERNAL_DEBUG_SYMBOLS=false
98 elif test "x$with_native_debug_symbols" = xexternal; then
100 - if test "x$OPENJDK_TARGET_OS" = xlinux; then
101 + if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
102 if test "x$OBJCOPY" = x; then
103 # enabling of enable-debug-symbols and can't find objcopy
104 # this is an error
105 @@ -293,7 +293,7 @@
106 ZIP_EXTERNAL_DEBUG_SYMBOLS=false
107 elif test "x$with_native_debug_symbols" = xzipped; then
109 - if test "x$OPENJDK_TARGET_OS" = xlinux; then
110 + if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
111 if test "x$OBJCOPY" = x; then
112 # enabling of enable-debug-symbols and can't find objcopy
113 # this is an error
114 diff -Nru jdk-jdk-24-11.orig/make/autoconf/libraries.m4 jdk-jdk-24-11/make/autoconf/libraries.m4
115 --- jdk-jdk-24-11.orig/make/autoconf/libraries.m4 2024-08-15 09:39:31.000000000 +0200
116 +++ jdk-jdk-24-11/make/autoconf/libraries.m4 2024-08-17 20:36:14.215081403 +0200
117 @@ -133,13 +133,15 @@
118 BASIC_JVM_LIBS="$LIBM"
120 # Dynamic loading library
121 - if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
122 + if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
123 BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBDL"
126 # Threading library
127 if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
128 BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lpthread"
129 + elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
130 + BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread"
133 # librt for legacy clock_gettime
134 @@ -156,6 +158,12 @@
135 BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat"
138 + if test "x$OPENJDK_TARGET_OS" = xsolaris; then
139 + BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lsocket -lsched -ldoor -lnsl \
140 + -lrt -lkstat"
141 + BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBCXX_JVM"
142 + fi
144 if test "x$OPENJDK_TARGET_OS" = xwindows; then
145 BASIC_JVM_LIBS="$BASIC_JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
146 comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib powrprof.lib uuid.lib \
147 diff -Nru jdk-jdk-24-11.orig/make/autoconf/platform.m4 jdk-jdk-24-11/make/autoconf/platform.m4
148 --- jdk-jdk-24-11.orig/make/autoconf/platform.m4 2024-08-15 09:39:31.000000000 +0200
149 +++ jdk-jdk-24-11/make/autoconf/platform.m4 2024-08-17 20:36:14.215673635 +0200
150 @@ -202,6 +202,10 @@
151 VAR_OS=linux
152 VAR_OS_TYPE=unix
154 + *solaris*)
155 + VAR_OS=solaris
156 + VAR_OS_TYPE=unix
157 + ;;
158 *darwin*)
159 VAR_OS=macosx
160 VAR_OS_TYPE=unix
161 @@ -472,6 +476,17 @@
163 AC_SUBST(OPENJDK_$1_CPU_LEGACY_LIB)
165 + # OPENJDK_$1_CPU_ISADIR is normally empty. On 64-bit Solaris systems, it is set to
166 + # /amd64 or /sparcv9. This string is appended to some library paths, like this:
167 + # /usr/lib${OPENJDK_$1_CPU_ISADIR}/libexample.so
168 + OPENJDK_$1_CPU_ISADIR=""
169 + if test "x$OPENJDK_$1_OS" = xsolaris; then
170 + if test "x$OPENJDK_$1_CPU" = xx86_64; then
171 + OPENJDK_$1_CPU_ISADIR="/amd64"
172 + fi
173 + fi
174 + AC_SUBST(OPENJDK_$1_CPU_ISADIR)
176 # Setup OPENJDK_$1_CPU_OSARCH, which is used to set the os.arch Java system property
177 OPENJDK_$1_CPU_OSARCH="$OPENJDK_$1_CPU"
178 if test "x$OPENJDK_$1_OS" = xlinux && test "x$OPENJDK_$1_CPU" = xx86; then
179 @@ -603,6 +618,9 @@
181 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
183 + if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
184 + RELEASE_FILE_OS_NAME=SunOS
185 + fi
186 if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
187 RELEASE_FILE_OS_NAME=Linux
189 diff -Nru jdk-jdk-24-11.orig/make/autoconf/toolchain.m4 jdk-jdk-24-11/make/autoconf/toolchain.m4
190 --- jdk-jdk-24-11.orig/make/autoconf/toolchain.m4 2024-08-15 09:39:31.000000000 +0200
191 +++ jdk-jdk-24-11/make/autoconf/toolchain.m4 2024-08-17 20:36:14.216220563 +0200
192 @@ -39,6 +39,7 @@
194 # These toolchains are valid on different platforms
195 VALID_TOOLCHAINS_linux="gcc clang"
196 +VALID_TOOLCHAINS_solaris="gcc"
197 VALID_TOOLCHAINS_macosx="clang"
198 VALID_TOOLCHAINS_aix="clang"
199 VALID_TOOLCHAINS_windows="microsoft"
200 diff -Nru jdk-jdk-24-11.orig/make/common/FileUtils.gmk jdk-jdk-24-11/make/common/FileUtils.gmk
201 --- jdk-jdk-24-11.orig/make/common/FileUtils.gmk 2024-08-15 09:39:31.000000000 +0200
202 +++ jdk-jdk-24-11/make/common/FileUtils.gmk 2024-08-17 20:36:14.216688154 +0200
203 @@ -114,7 +114,33 @@
204 ################################################################################
205 # All install-file and related macros automatically call DecodeSpace when needed.
207 -ifeq ($(call isTargetOs, macosx), true)
208 +ifeq ($(call isTargetOs, solaris), true)
209 + # On Solaris, if the target is a symlink and exists, cp won't overwrite.
210 + # Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the
211 + # name of the target file differs from the source file, rename after copy.
212 + # If the source and target parent directories are the same, recursive copy doesn't work
213 + # so we fall back on regular copy, which isn't preserving symlinks.
214 + define install-file
215 + $(call MakeTargetDir)
216 + $(RM) '$(call DecodeSpace, $@)'
217 + if [ '$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))' != \
218 + '$(call DecodeSpace, $(dir $(call EncodeSpace, $<)))' ]; then \
219 + $(CP) -f -r -P '$(call DecodeSpace, $<)' \
220 + '$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))'; \
221 + if [ '$(call DecodeSpace, $(notdir $(call EncodeSpace, $@)))' != \
222 + '$(call DecodeSpace, $(notdir $(call EncodeSpace, $(<))))' ]; then \
223 + $(MV) '$(call DecodeSpace, $(dir $(call EncodeSpace, $@))/$(notdir $(call EncodeSpace, $<)))' \
224 + '$(call DecodeSpace, $@)'; \
225 + fi; \
226 + else \
227 + if [ -L '$(call DecodeSpace, $<)' ]; then \
228 + $(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \
229 + exit 1; \
230 + fi; \
231 + $(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \
232 + fi
233 + endef
234 +else ifeq ($(call isTargetOs, macosx), true)
235 # On mac, extended attributes sometimes creep into the source files, which may later
236 # cause the creation of ._* files which confuses testing. Clear these with xattr if
237 # set. Some files get their write permissions removed after being copied to the
238 diff -Nru jdk-jdk-24-11.orig/make/common/modules/LauncherCommon.gmk jdk-jdk-24-11/make/common/modules/LauncherCommon.gmk
239 --- jdk-jdk-24-11.orig/make/common/modules/LauncherCommon.gmk 2024-08-15 09:39:31.000000000 +0200
240 +++ jdk-jdk-24-11/make/common/modules/LauncherCommon.gmk 2024-08-17 20:36:14.217237893 +0200
241 @@ -133,17 +133,20 @@
242 -DLAUNCHER_NAME='"$$(LAUNCHER_NAME)"' \
243 -DPROGNAME='"$1"' \
244 $$($1_CFLAGS), \
245 + CFLAGS_solaris := -fPIC, \
246 CFLAGS_windows := $$($1_CFLAGS_windows), \
247 EXTRA_HEADER_DIRS := java.base:libjvm, \
248 DISABLED_WARNINGS_gcc := unused-function, \
249 LDFLAGS := $$($1_LDFLAGS), \
250 LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
251 LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
252 + LDFLAGS_solaris := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \
253 JDK_LIBS := java.base:libjli, \
254 JDK_LIBS_windows := java.base:libjava, \
255 LIBS := $$($1_LIBS), \
256 LIBS_unix := $(LIBZ_LIBS), \
257 LIBS_linux := $(LIBDL) -lpthread, \
258 + LIBS_solaris := $(LIBDL) -lthread, \
259 LIBS_macosx := \
260 -framework ApplicationServices \
261 -framework Cocoa \
262 diff -Nru jdk-jdk-24-11.orig/make/hotspot/gensrc/GensrcAdlc.gmk jdk-jdk-24-11/make/hotspot/gensrc/GensrcAdlc.gmk
263 --- jdk-jdk-24-11.orig/make/hotspot/gensrc/GensrcAdlc.gmk 2024-08-15 09:39:31.000000000 +0200
264 +++ jdk-jdk-24-11/make/hotspot/gensrc/GensrcAdlc.gmk 2024-08-17 20:36:14.217755229 +0200
265 @@ -36,6 +36,9 @@
266 # NOTE: No optimization or debug flags set here
267 ifeq ($(call isBuildOs, linux), true)
268 ADLC_CFLAGS := -fno-exceptions -DLINUX
269 + else ifeq ($(call isBuildOs, solaris), true)
270 + ADLC_LDFLAGS := -m64
271 + ADLC_CFLAGS := -m64 -fpermissive
272 else ifeq ($(call isBuildOs, aix), true)
273 ifeq ($(TOOLCHAIN_TYPE), clang)
274 ADLC_LDFLAGS += -m64
275 @@ -101,6 +104,8 @@
276 # ADLC flags depending on target OS
277 ifeq ($(call isTargetOs, linux), true)
278 ADLCFLAGS += -DLINUX=1 -D_GNU_SOURCE=1
279 + else ifeq ($(call isTargetOs, solaris), true)
280 + ADLCFLAGS += -DSOLARIS=1
281 else ifeq ($(call isTargetOs, aix), true)
282 ADLCFLAGS += -DAIX=1
283 else ifeq ($(call isTargetOs, macosx), true)
284 diff -Nru jdk-jdk-24-11.orig/make/hotspot/gensrc/GensrcDtrace.gmk jdk-jdk-24-11/make/hotspot/gensrc/GensrcDtrace.gmk
285 --- jdk-jdk-24-11.orig/make/hotspot/gensrc/GensrcDtrace.gmk 2024-08-15 09:39:31.000000000 +0200
286 +++ jdk-jdk-24-11/make/hotspot/gensrc/GensrcDtrace.gmk 2024-08-17 20:36:14.218212801 +0200
287 @@ -28,7 +28,10 @@
289 ifeq ($(call check-jvm-feature, dtrace), true)
291 - ifeq ($(call isTargetOs, macosx), true)
292 + ifeq ($(call isTargetOs, solaris), true)
293 + DTRACE_FLAGS := -64
294 + DTRACE_CPP_FLAGS := -D_LP64 -x c
295 + else ifeq ($(call isTargetOs, macosx), true)
296 DTRACE_CPP_FLAGS := -D_LP64 -x c
297 else ifeq ($(call isTargetOs, linux), true)
298 DTRACE_CPP_FLAGS := -x c
299 @@ -51,4 +54,59 @@
300 TARGETS += $(patsubst $(DTRACE_SOURCE_DIR)/%.d, \
301 $(DTRACE_GENSRC_DIR)/%.h, $(wildcard $(DTRACE_SOURCE_DIR)/*.d))
303 + ifeq ($(call isTargetOs, solaris), true)
304 + ############################################################################
305 + # First we need to generate the dtraceGenOffsets tool. When run, this will
306 + # produce two header files and a C++ file. Note that generateJvmOffsets.cpp
307 + # is using the same JVM_CFLAGS as libjvm.so.
309 + # Include support files that will setup JVM compiler flags.
310 + include lib/JvmFeatures.gmk
311 + include lib/JvmFlags.gmk
313 + # We cannot compile until the JVMTI and JFR gensrc has finished.
314 + # JFR_FILES is defined in GensrcJfr.gmk.
315 + JVMTI_H := $(JVM_VARIANT_OUTPUTDIR)/gensrc/jvmtifiles/jvmti.h
317 + $(eval $(call SetupNativeCompilation, BUILD_DTRACE_GEN_OFFSETS, \
318 + NAME := dtraceGenOffsets, \
319 + TYPE := EXECUTABLE, \
320 + SRC := $(TOPDIR)/make/hotspot/src/native/dtrace, \
321 + TOOLCHAIN := $(TOOLCHAIN_BUILD), \
322 + LDFLAGS := -m64, \
323 + CFLAGS := -m64 $(JVM_CFLAGS), \
324 + EXTRA_DEPS := $(JVMTI_H) $(JFR_FILES), \
325 + OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
326 + OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
327 + ))
329 + DTRACE_GEN_OFFSETS_TOOL := $(BUILD_DTRACE_GEN_OFFSETS_TARGET)
331 + # Argument 1: Output filename
332 + # Argument 2: dtrace-gen-offset tool command line option
333 + define SetupDtraceOffsetsGeneration
334 + $$(eval $$(call SetupExecute, dtrace_offset_$$(strip $2), \
335 + INFO := Generating dtrace $2 file, \
336 + DEPS := $$(BUILD_DTRACE_GEN_OFFSETS), \
337 + OUTPUT_FILE := $1, \
338 + COMMAND := ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $1 ), \
339 + ))
341 + TARGETS += $$(dtrace_offset_$$(strip $2)_TARGET)
342 + endef
344 + JVM_OFFSETS_H := $(DTRACE_GENSRC_DIR)/JvmOffsets.h
345 + JVM_OFFSETS_CPP := $(DTRACE_GENSRC_DIR)/JvmOffsets.cpp
346 + JVM_OFFSETS_INDEX_H := $(DTRACE_GENSRC_DIR)/JvmOffsetsIndex.h
348 + ############################################################################
349 + # Run the dtrace-gen-offset tool to generate these three files.
350 + # The generated JvmOffsets.cpp is compiled with the rest of libjvm.
351 + # The header files are used by libjvm_db and jhelper.d, respectively.
353 + $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header))
354 + $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index))
355 + $(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table))
356 + endif
358 endif
359 diff -Nru jdk-jdk-24-11.orig/make/hotspot/lib/CompileDtraceLibraries.gmk jdk-jdk-24-11/make/hotspot/lib/CompileDtraceLibraries.gmk
360 --- jdk-jdk-24-11.orig/make/hotspot/lib/CompileDtraceLibraries.gmk 1970-01-01 01:00:00.000000000 +0100
361 +++ jdk-jdk-24-11/make/hotspot/lib/CompileDtraceLibraries.gmk 2024-08-17 20:36:14.278308555 +0200
362 @@ -0,0 +1,62 @@
364 +# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
365 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
367 +# This code is free software; you can redistribute it and/or modify it
368 +# under the terms of the GNU General Public License version 2 only, as
369 +# published by the Free Software Foundation. Oracle designates this
370 +# particular file as subject to the "Classpath" exception as provided
371 +# by Oracle in the LICENSE file that accompanied this code.
373 +# This code is distributed in the hope that it will be useful, but WITHOUT
374 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
375 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376 +# version 2 for more details (a copy is included in the LICENSE file that
377 +# accompanied this code).
379 +# You should have received a copy of the GNU General Public License version
380 +# 2 along with this work; if not, write to the Free Software Foundation,
381 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
383 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
384 +# or visit www.oracle.com if you need additional information or have any
385 +# questions.
388 +ifeq ($(call check-jvm-feature, dtrace), true)
389 + ifeq ($(call isTargetOs, solaris), true)
390 + JNI_INCLUDE_FLAGS := \
391 + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
392 + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
395 + ############################################################################
396 + # Build the stand-alone dtrace libraries.
398 + LIBJVM_DTRACE_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_dtrace
399 + $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DTRACE, \
400 + NAME := jvm_dtrace, \
401 + OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
402 + SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
403 + CFLAGS := $(JNI_INCLUDE_FLAGS) -m64 -G -mt -KPIC -xldscope=hidden, \
404 + LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
405 + LIBS := $(LIBDL) -lthread -ldoor, \
406 + OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
407 + ))
409 + # Note that libjvm_db.c has tests for COMPILER2, but this was never set by
410 + # the old build.
411 + LIBJVM_DB_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/libjvm_db
412 + $(eval $(call SetupNativeCompilation, BUILD_LIBJVM_DB, \
413 + NAME := jvm_db, \
414 + OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
415 + SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_db, \
416 + CFLAGS := -I$(DTRACE_GENSRC_DIR) $(JNI_INCLUDE_FLAGS) -m64 -G -mt -KPIC -xldscope=hidden, \
417 + LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
418 + OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
419 + ))
421 + TARGETS += $(BUILD_LIBJVM_DTRACE) $(BUILD_LIBJVM_DB)
423 + endif
424 +endif
425 diff -Nru jdk-jdk-24-11.orig/make/hotspot/lib/CompileJvm.gmk jdk-jdk-24-11/make/hotspot/lib/CompileJvm.gmk
426 --- jdk-jdk-24-11.orig/make/hotspot/lib/CompileJvm.gmk 2024-08-15 09:39:31.000000000 +0200
427 +++ jdk-jdk-24-11/make/hotspot/lib/CompileJvm.gmk 2024-08-17 20:36:14.218712813 +0200
428 @@ -31,6 +31,9 @@
429 include lib/JvmOverrideFiles.gmk
430 include lib/JvmFlags.gmk
432 +# Include support files that will setup DTRACE_EXTRA_OBJECT_FILES.
433 +include lib/JvmDtraceObjects.gmk
435 ################################################################################
436 # Setup compilation of the main Hotspot native library (libjvm).
438 @@ -171,6 +174,7 @@
439 EXCLUDES := $(JVM_EXCLUDES), \
440 EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
441 EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
442 + EXTRA_OBJECT_FILES := $(DTRACE_EXTRA_OBJECT_FILES), \
443 DEFAULT_CFLAGS := false, \
444 CFLAGS := $(JVM_CFLAGS), \
445 abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
446 diff -Nru jdk-jdk-24-11.orig/make/hotspot/lib/CompileLibraries.gmk jdk-jdk-24-11/make/hotspot/lib/CompileLibraries.gmk
447 --- jdk-jdk-24-11.orig/make/hotspot/lib/CompileLibraries.gmk 2024-08-15 09:39:31.000000000 +0200
448 +++ jdk-jdk-24-11/make/hotspot/lib/CompileLibraries.gmk 2024-08-17 20:36:14.219078486 +0200
449 @@ -32,6 +32,7 @@
450 include HotspotCommon.gmk
452 include lib/CompileJvm.gmk
453 +include lib/CompileDtraceLibraries.gmk
455 ifneq ($(GTEST_FRAMEWORK_SRC), )
456 ifneq ($(CREATING_BUILDJDK), true)
457 diff -Nru jdk-jdk-24-11.orig/make/hotspot/lib/JvmDtraceObjects.gmk jdk-jdk-24-11/make/hotspot/lib/JvmDtraceObjects.gmk
458 --- jdk-jdk-24-11.orig/make/hotspot/lib/JvmDtraceObjects.gmk 1970-01-01 01:00:00.000000000 +0100
459 +++ jdk-jdk-24-11/make/hotspot/lib/JvmDtraceObjects.gmk 2024-08-17 20:36:14.278644420 +0200
460 @@ -0,0 +1,122 @@
462 +# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
463 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
465 +# This code is free software; you can redistribute it and/or modify it
466 +# under the terms of the GNU General Public License version 2 only, as
467 +# published by the Free Software Foundation. Oracle designates this
468 +# particular file as subject to the "Classpath" exception as provided
469 +# by Oracle in the LICENSE file that accompanied this code.
471 +# This code is distributed in the hope that it will be useful, but WITHOUT
472 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
473 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
474 +# version 2 for more details (a copy is included in the LICENSE file that
475 +# accompanied this code).
477 +# You should have received a copy of the GNU General Public License version
478 +# 2 along with this work; if not, write to the Free Software Foundation,
479 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
481 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
482 +# or visit www.oracle.com if you need additional information or have any
483 +# questions.
486 +ifeq ($(call check-jvm-feature, dtrace), true)
487 + ifeq ($(call isTargetOs, solaris), true)
489 + ############################################################################
490 + # Integrate with libjvm. Here we generate two object files which are
491 + # linked with libjvm.so. This step is complicated from a dependency
492 + # perspective. We add these two files to the linking of libjvm using
493 + # EXTRA_OBJECT_FILES, but they need to be created outside the call to
494 + # SetupNativeCompilation. Also, one of the files is dependent on compiled
495 + # object files from the libjvm compilation, so this generation must happen
496 + # as a part of the libjvm compilation.
498 + DTRACE_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace.o
499 + DTRACE_JHELPER_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace_jhelper.o
501 + DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ)
503 + ############################################################################
504 + # Generate DTRACE_OBJ which is linked with libjvm.so. It depends on a set of
505 + # object files from the compilation.
507 + # Concatenate all *.d files into a single file
508 + DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
509 + hotspot_jni.d \
510 + hotspot.d \
511 + hs_private.d \
514 + # *.d in the objs dir is used for generated make dependency files, so use
515 + # *.dt for dtrace files to avoid clashes.
516 + $(JVM_OUTPUTDIR)/objs/dtrace.dt: $(DTRACE_SOURCE_FILES)
517 + $(call LogInfo, Generating $(@F))
518 + $(call MakeDir, $(@D))
519 + $(CAT) $^ > $@
521 + DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
522 + ciEnv.o \
523 + classLoadingService.o \
524 + compileBroker.o \
525 + gcVMOperations.o \
526 + hashtable.o \
527 + instanceKlass.o \
528 + java.o \
529 + jni.o \
530 + jvm.o \
531 + memoryManager.o \
532 + nmethod.o \
533 + objectMonitor.o \
534 + runtimeService.o \
535 + sharedRuntime.o \
536 + synchronizer.o \
537 + thread.o \
538 + unsafe.o \
539 + vmThread.o \
542 + ifeq ($(call check-jvm-feature, parallelgc), true)
543 + DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
544 + psVMOperations.o \
546 + endif
548 + DTRACE_FLAGS := -64 -G
549 + DTRACE_CPP_FLAGS := -D_LP64
551 + # Make sure we run our selected compiler for preprocessing instead of letting
552 + # the dtrace tool pick it on it's own.
553 + $(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.dt $(DTRACE_INSTRUMENTED_OBJS)
554 + $(call LogInfo, Generating $(@F) from $(<F) and object files)
555 + $(call MakeDir, $(DTRACE_SUPPORT_DIR))
556 + $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).dt, \
557 + ($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).dt))
558 + $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
559 + -s $(DTRACE_SUPPORT_DIR)/$(@F).dt $(sort $(DTRACE_INSTRUMENTED_OBJS)))
561 + ############################################################################
562 + # Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.
564 + JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
566 + # jhelper.d includes JvmOffsetsIndex.h which was created by the gensrc step.
567 + DTRACE_GENSRC_DIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/dtracefiles
568 + JVM_OFFSETS_INDEX_H := $(DTRACE_GENSRC_DIR)/JvmOffsetsIndex.h
570 + # Make sure we run our selected compiler for preprocessing instead of letting
571 + # the dtrace tool pick it on it's own.
572 + $(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
573 + $(call LogInfo, Running dtrace for $(<F))
574 + $(call MakeDir, $(DTRACE_SUPPORT_DIR))
575 + $(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).dt, \
576 + ($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_GENSRC_DIR) $^ \
577 + > $(DTRACE_SUPPORT_DIR)/$(@F).dt))
578 + $(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
579 + -s $(DTRACE_SUPPORT_DIR)/$(@F).dt)
581 + endif
582 +endif
583 diff -Nru jdk-jdk-24-11.orig/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp jdk-jdk-24-11/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp
584 --- jdk-jdk-24-11.orig/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp 1970-01-01 01:00:00.000000000 +0100
585 +++ jdk-jdk-24-11/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp 2024-08-17 20:36:14.279160659 +0200
586 @@ -0,0 +1,316 @@
588 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
589 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
591 + * This code is free software; you can redistribute it and/or modify it
592 + * under the terms of the GNU General Public License version 2 only, as
593 + * published by the Free Software Foundation.
595 + * This code is distributed in the hope that it will be useful, but WITHOUT
596 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
597 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
598 + * version 2 for more details (a copy is included in the LICENSE file that
599 + * accompanied this code).
601 + * You should have received a copy of the GNU General Public License version
602 + * 2 along with this work; if not, write to the Free Software Foundation,
603 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
605 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
606 + * or visit www.oracle.com if you need additional information or have any
607 + * questions.
609 + */
612 + * This is to provide sanity check in jhelper.d which compares SCCS
613 + * versions of generateJvmOffsets.cpp used to create and extract
614 + * contents of __JvmOffsets[] table.
615 + * The __JvmOffsets[] table is located in generated JvmOffsets.cpp.
617 + * GENOFFS_SCCS_VER 34
618 + */
620 +#include <stdio.h>
621 +#include <strings.h>
623 +/* A workaround for private and protected fields */
624 +#define private public
625 +#define protected public
627 +#include <proc_service.h>
628 +#include "gc/shared/collectedHeap.hpp"
629 +#include "memory/heap.hpp"
630 +#include "oops/compressedOops.hpp"
631 +#include "runtime/vmStructs.hpp"
633 +typedef enum GEN_variant {
634 + GEN_OFFSET = 0,
635 + GEN_INDEX = 1,
636 + GEN_TABLE = 2
637 +} GEN_variant;
639 +#ifdef COMPILER1
640 +#ifdef ASSERT
643 + * To avoid the most part of potential link errors
644 + * we link this program with -z nodefs .
646 + * But for 'debug1' and 'fastdebug1' we still have to provide
647 + * a particular workaround for the following symbols below.
648 + * It will be good to find out a generic way in the future.
649 + */
651 +#pragma weak tty
653 +#if defined(i386) || defined(__i386) || defined(__amd64)
654 +#pragma weak noreg
655 +#endif /* i386 */
657 +LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;
659 +address StubRoutines::_call_stub_return_address = NULL;
661 +StubQueue* AbstractInterpreter::_code = NULL;
663 +#endif /* ASSERT */
664 +#endif /* COMPILER1 */
666 +#define GEN_OFFS_NAME(Type,Name,OutputType) \
667 + switch(gen_variant) { \
668 + case GEN_OFFSET: \
669 + printf("#define OFFSET_%-33s %ld\n", \
670 + #OutputType #Name, offset_of(Type, Name)); \
671 + break; \
672 + case GEN_INDEX: \
673 + printf("#define IDX_OFFSET_%-33s %d\n", \
674 + #OutputType #Name, index++); \
675 + break; \
676 + case GEN_TABLE: \
677 + printf("\tOFFSET_%s,\n", #OutputType #Name); \
678 + break; \
681 +#define GEN_OFFS(Type,Name) \
682 + GEN_OFFS_NAME(Type,Name,Type)
684 +#define GEN_SIZE(Type) \
685 + switch(gen_variant) { \
686 + case GEN_OFFSET: \
687 + printf("#define SIZE_%-35s %ld\n", \
688 + #Type, sizeof(Type)); \
689 + break; \
690 + case GEN_INDEX: \
691 + printf("#define IDX_SIZE_%-35s %d\n", \
692 + #Type, index++); \
693 + break; \
694 + case GEN_TABLE: \
695 + printf("\tSIZE_%s,\n", #Type); \
696 + break; \
699 +#define GEN_VALUE(String,Value) \
700 + switch(gen_variant) { \
701 + case GEN_OFFSET: \
702 + printf("#define %-40s %d\n", #String, Value); \
703 + break; \
704 + case GEN_INDEX: \
705 + printf("#define IDX_%-40s %d\n", #String, index++); \
706 + break; \
707 + case GEN_TABLE: \
708 + printf("\t" #String ",\n"); \
709 + break; \
712 +void gen_prologue(GEN_variant gen_variant) {
713 + const char *suffix = "Undefined-Suffix";
715 + switch(gen_variant) {
716 + case GEN_OFFSET: suffix = ".h"; break;
717 + case GEN_INDEX: suffix = "Index.h"; break;
718 + case GEN_TABLE: suffix = ".cpp"; break;
721 + printf("/*\n");
722 + printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);
723 + printf(" * The generateJvmOffsets program generates this file!\n");
724 + printf(" */\n\n");
725 + switch(gen_variant) {
727 + case GEN_OFFSET:
728 + case GEN_INDEX:
729 + break;
731 + case GEN_TABLE:
732 + printf("#include \"JvmOffsets.h\"\n");
733 + printf("\n");
734 + printf("int __JvmOffsets[] = {\n");
735 + break;
739 +void gen_epilogue(GEN_variant gen_variant) {
740 + if (gen_variant != GEN_TABLE) {
741 + return;
743 + printf("};\n\n");
744 + return;
747 +int generateJvmOffsets(GEN_variant gen_variant) {
748 + int index = 0; /* It is used to generate JvmOffsetsIndex.h */
749 + int pointer_size = sizeof(void *);
750 + int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;
752 + gen_prologue(gen_variant);
754 + GEN_VALUE(DATA_MODEL, data_model);
755 + GEN_VALUE(POINTER_SIZE, pointer_size);
756 +#if COMPILER1_AND_COMPILER2
757 + GEN_VALUE(COMPILER, 3);
758 +#elif COMPILER1
759 + GEN_VALUE(COMPILER, 1);
760 +#elif COMPILER2
761 + GEN_VALUE(COMPILER, 2);
762 +#else
763 + GEN_VALUE(COMPILER, 0);
764 +#endif // COMPILER1 && COMPILER2
765 + printf("\n");
767 + GEN_OFFS(CollectedHeap, _reserved);
768 + GEN_OFFS(MemRegion, _start);
769 + GEN_OFFS(MemRegion, _word_size);
770 + GEN_SIZE(HeapWord);
771 + printf("\n");
773 + GEN_OFFS(VMStructEntry, typeName);
774 + GEN_OFFS(VMStructEntry, fieldName);
775 + GEN_OFFS(VMStructEntry, address);
776 + GEN_SIZE(VMStructEntry);
777 + printf("\n");
779 + GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);
780 +#if defined(i386) || defined(__i386) || defined(__amd64)
781 + GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);
782 + GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);
783 + GEN_VALUE(OFFSET_interpreter_frame_bcp_offset, -7 * pointer_size);
784 +#endif
786 + GEN_OFFS(Klass, _name);
787 + GEN_OFFS(ConstantPool, _pool_holder);
788 + printf("\n");
790 + GEN_VALUE(OFFSET_HeapBlockHeader_used, (int) offset_of(HeapBlock::Header, _used));
791 + GEN_OFFS(oopDesc, _metadata);
792 + printf("\n");
794 + GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);
795 + GEN_VALUE(ConstMethod_has_linenumber_table, ConstMethod::_has_linenumber_table);
796 + GEN_OFFS(AccessFlags, _flags);
797 + GEN_OFFS(Symbol, _length);
798 + GEN_OFFS(Symbol, _body);
799 + printf("\n");
801 + GEN_OFFS(Method, _constMethod);
802 + GEN_OFFS(Method, _access_flags);
803 + printf("\n");
805 + GEN_OFFS(ConstMethod, _constants);
806 + GEN_OFFS(ConstMethod, _flags);
807 + GEN_OFFS(ConstMethod, _code_size);
808 + GEN_OFFS(ConstMethod, _name_index);
809 + GEN_OFFS(ConstMethod, _signature_index);
810 + printf("\n");
812 + GEN_OFFS(CodeHeap, _memory);
813 + GEN_OFFS(CodeHeap, _segmap);
814 + GEN_OFFS(CodeHeap, _log2_segment_size);
815 + printf("\n");
817 + GEN_OFFS(VirtualSpace, _low_boundary);
818 + GEN_OFFS(VirtualSpace, _high_boundary);
819 + GEN_OFFS(VirtualSpace, _low);
820 + GEN_OFFS(VirtualSpace, _high);
821 + printf("\n");
823 + /* We need to use different names here because of the template parameter */
824 + GEN_OFFS_NAME(GrowableArray<CodeHeap*>, _data, GrowableArray_CodeHeap);
825 + GEN_OFFS_NAME(GrowableArray<CodeHeap*>, _len, GrowableArray_CodeHeap);
826 + printf("\n");
828 + GEN_OFFS(CodeBlob, _name);
829 + GEN_OFFS(CodeBlob, _header_size);
830 + GEN_OFFS(CodeBlob, _content_begin);
831 + GEN_OFFS(CodeBlob, _code_begin);
832 + GEN_OFFS(CodeBlob, _code_end);
833 + GEN_OFFS(CodeBlob, _data_offset);
834 + GEN_OFFS(CodeBlob, _frame_size);
835 + printf("\n");
837 + GEN_OFFS(nmethod, _method);
838 + GEN_OFFS(nmethod, _dependencies_offset);
839 + GEN_OFFS(nmethod, _metadata_offset);
840 + GEN_OFFS(nmethod, _scopes_data_begin);
841 + GEN_OFFS(nmethod, _scopes_pcs_offset);
842 + GEN_OFFS(nmethod, _handler_table_offset);
843 + GEN_OFFS(nmethod, _deopt_handler_begin);
844 + GEN_OFFS(nmethod, _orig_pc_offset);
846 + GEN_OFFS(PcDesc, _pc_offset);
847 + GEN_OFFS(PcDesc, _scope_decode_offset);
849 + printf("\n");
851 + GEN_OFFS(NarrowPtrStruct, _base);
852 + GEN_OFFS(NarrowPtrStruct, _shift);
853 + printf("\n");
855 + GEN_VALUE(SIZE_HeapBlockHeader, (int) sizeof(HeapBlock::Header));
856 + GEN_SIZE(oopDesc);
857 + GEN_SIZE(ConstantPool);
858 + printf("\n");
860 + GEN_SIZE(PcDesc);
861 + GEN_SIZE(Method);
862 + GEN_SIZE(ConstMethod);
863 + GEN_SIZE(nmethod);
864 + GEN_SIZE(CodeBlob);
865 + GEN_SIZE(BufferBlob);
866 + GEN_SIZE(SingletonBlob);
867 + GEN_SIZE(RuntimeStub);
868 + GEN_SIZE(SafepointBlob);
870 + gen_epilogue(gen_variant);
871 + printf("\n");
873 + fflush(stdout);
874 + return 0;
877 +const char *HELP =
878 + "HELP: generateJvmOffsets {-header | -index | -table} \n";
880 +int main(int argc, const char *argv[]) {
881 + GEN_variant gen_var;
883 + if (argc != 2) {
884 + printf("%s", HELP);
885 + return 1;
888 + if (0 == strcmp(argv[1], "-header")) {
889 + gen_var = GEN_OFFSET;
891 + else if (0 == strcmp(argv[1], "-index")) {
892 + gen_var = GEN_INDEX;
894 + else if (0 == strcmp(argv[1], "-table")) {
895 + gen_var = GEN_TABLE;
897 + else {
898 + printf("%s", HELP);
899 + return 1;
901 + return generateJvmOffsets(gen_var);
903 diff -Nru jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris
904 --- jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris 1970-01-01 01:00:00.000000000 +0100
905 +++ jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris 2024-08-17 20:36:14.279471117 +0200
906 @@ -0,0 +1,25 @@
908 +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
909 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
911 +# This code is free software; you can redistribute it and/or modify it
912 +# under the terms of the GNU General Public License version 2 only, as
913 +# published by the Free Software Foundation.
915 +# This code is distributed in the hope that it will be useful, but WITHOUT
916 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
917 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
918 +# version 2 for more details (a copy is included in the LICENSE file that
919 +# accompanied this code).
921 +# You should have received a copy of the GNU General Public License version
922 +# 2 along with this work; if not, write to the Free Software Foundation,
923 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
925 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
926 +# or visit www.oracle.com if you need additional information or have any
927 +# questions.
930 +JVM_handle_solaris_signal
931 +sysThreadAvailableStackWithSlack
932 diff -Nru jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris-dtrace-compiler1 jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris-dtrace-compiler1
933 --- jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris-dtrace-compiler1 1970-01-01 01:00:00.000000000 +0100
934 +++ jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris-dtrace-compiler1 2024-08-17 20:36:14.279731815 +0200
935 @@ -0,0 +1,34 @@
937 +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
938 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
940 +# This code is free software; you can redistribute it and/or modify it
941 +# under the terms of the GNU General Public License version 2 only, as
942 +# published by the Free Software Foundation.
944 +# This code is distributed in the hope that it will be useful, but WITHOUT
945 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
946 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
947 +# version 2 for more details (a copy is included in the LICENSE file that
948 +# accompanied this code).
950 +# You should have received a copy of the GNU General Public License version
951 +# 2 along with this work; if not, write to the Free Software Foundation,
952 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
954 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
955 +# or visit www.oracle.com if you need additional information or have any
956 +# questions.
959 +__1cGMethodG__vtbl_
960 +__1cHnmethodG__vtbl_
961 +__1cICodeBlobG__vtbl_
962 +__1cIUniverseO_collectedHeap_
963 +__1cJCodeCacheG_heaps_
964 +__1cKBufferBlobG__vtbl_
965 +__1cLRuntimeStubG__vtbl_
966 +__1cNSafepointBlobG__vtbl_
967 +__1cSDeoptimizationBlobG__vtbl_
969 +__JvmOffsets
970 diff -Nru jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris-dtrace-compiler2 jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris-dtrace-compiler2
971 --- jdk-jdk-24-11.orig/make/hotspot/symbols/symbols-solaris-dtrace-compiler2 1970-01-01 01:00:00.000000000 +0100
972 +++ jdk-jdk-24-11/make/hotspot/symbols/symbols-solaris-dtrace-compiler2 2024-08-17 20:36:14.279997063 +0200
973 @@ -0,0 +1,36 @@
975 +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
976 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
978 +# This code is free software; you can redistribute it and/or modify it
979 +# under the terms of the GNU General Public License version 2 only, as
980 +# published by the Free Software Foundation.
982 +# This code is distributed in the hope that it will be useful, but WITHOUT
983 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
984 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
985 +# version 2 for more details (a copy is included in the LICENSE file that
986 +# accompanied this code).
988 +# You should have received a copy of the GNU General Public License version
989 +# 2 along with this work; if not, write to the Free Software Foundation,
990 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
992 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
993 +# or visit www.oracle.com if you need additional information or have any
994 +# questions.
997 +__1cGMethodG__vtbl_
998 +__1cHnmethodG__vtbl_
999 +__1cICodeBlobG__vtbl_
1000 +__1cIUniverseO_collectedHeap_
1001 +__1cJCodeCacheG_heaps_
1002 +__1cKBufferBlobG__vtbl_
1003 +__1cLRuntimeStubG__vtbl_
1004 +__1cNSafepointBlobG__vtbl_
1005 +__1cSDeoptimizationBlobG__vtbl_
1006 +__1cNExceptionBlobG__vtbl_
1007 +__1cQUncommonTrapBlobG__vtbl_
1009 +__JvmOffsets
1010 diff -Nru jdk-jdk-24-11.orig/make/ide/visualstudio/hotspot/CreateVSProject.gmk jdk-jdk-24-11/make/ide/visualstudio/hotspot/CreateVSProject.gmk
1011 --- jdk-jdk-24-11.orig/make/ide/visualstudio/hotspot/CreateVSProject.gmk 2024-08-15 09:39:31.000000000 +0200
1012 +++ jdk-jdk-24-11/make/ide/visualstudio/hotspot/CreateVSProject.gmk 2024-08-17 20:36:14.219571741 +0200
1013 @@ -76,6 +76,7 @@
1014 -ignorePath linux \
1015 -ignorePath posix \
1016 -ignorePath ppc \
1017 + -ignorePath solaris \
1018 -ignorePath x86_32 \
1019 -ignorePath zero \
1021 diff -Nru jdk-jdk-24-11.orig/make/modules/java.base/Copy.gmk jdk-jdk-24-11/make/modules/java.base/Copy.gmk
1022 --- jdk-jdk-24-11.orig/make/modules/java.base/Copy.gmk 2024-08-15 09:39:31.000000000 +0200
1023 +++ jdk-jdk-24-11/make/modules/java.base/Copy.gmk 2024-08-17 20:36:14.220100479 +0200
1024 @@ -190,7 +190,7 @@
1026 TARGETS += $(NET_PROPERTIES_DST)
1028 -ifeq ($(call isTargetOs, linux), true)
1029 +ifeq ($(call isTargetOs, solaris linux), true)
1030 $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
1031 FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
1032 DEST := $(CONF_DST_DIR)/sdp, \
1033 diff -Nru jdk-jdk-24-11.orig/make/modules/java.base/gensrc/GensrcMisc.gmk jdk-jdk-24-11/make/modules/java.base/gensrc/GensrcMisc.gmk
1034 --- jdk-jdk-24-11.orig/make/modules/java.base/gensrc/GensrcMisc.gmk 2024-08-15 09:39:31.000000000 +0200
1035 +++ jdk-jdk-24-11/make/modules/java.base/gensrc/GensrcMisc.gmk 2024-08-17 20:36:14.220962745 +0200
1036 @@ -136,6 +136,21 @@
1038 endif
1040 +################################################################################
1042 +ifeq ($(call isTargetOs, solaris), true)
1044 + GENSRC_SC_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/fs/SolarisConstants.java
1046 + $(GENSRC_SC_FILE): \
1047 + $(TOPDIR)/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template
1048 + $(generate-preproc-src)
1050 + TARGETS += $(GENSRC_SC_FILE)
1052 +endif
1054 +################################################################################
1055 # Create the javax/crypto/JceSecurity.class, using the build default.
1057 ifeq ($(UNLIMITED_CRYPTO), true)
1058 diff -Nru jdk-jdk-24-11.orig/make/modules/java.base/lib/CoreLibraries.gmk jdk-jdk-24-11/make/modules/java.base/lib/CoreLibraries.gmk
1059 --- jdk-jdk-24-11.orig/make/modules/java.base/lib/CoreLibraries.gmk 2024-08-15 09:39:31.000000000 +0200
1060 +++ jdk-jdk-24-11/make/modules/java.base/lib/CoreLibraries.gmk 2024-08-17 20:36:14.221485791 +0200
1061 @@ -28,7 +28,7 @@
1062 ################################################################################
1064 LIBVERIFY_OPTIMIZATION := HIGH
1065 -ifeq ($(call isTargetOs, linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1066 +ifeq ($(call isTargetOs, solaris linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1067 LIBVERIFY_OPTIMIZATION := LOW
1068 endif
1070 @@ -60,6 +60,7 @@
1071 DISABLED_WARNINGS_gcc_ProcessImpl_md.c := unused-result, \
1072 JDK_LIBS := libjvm, \
1073 LIBS_linux := $(LIBDL), \
1074 + LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL), \
1075 LIBS_aix := $(LIBDL) $(LIBM),\
1076 LIBS_macosx := \
1077 -framework CoreFoundation \
1078 @@ -171,6 +172,7 @@
1079 DISABLED_WARNINGS_clang := format-nonliteral deprecated-non-prototype, \
1080 LIBS_unix := $(LIBZ_LIBS), \
1081 LIBS_linux := $(LIBDL) -lpthread, \
1082 + LIBS_solaris := $(LIBDL), \
1083 LIBS_macosx := \
1084 -framework ApplicationServices \
1085 -framework Cocoa \
1086 diff -Nru jdk-jdk-24-11.orig/make/modules/java.base/Lib.gmk jdk-jdk-24-11/make/modules/java.base/Lib.gmk
1087 --- jdk-jdk-24-11.orig/make/modules/java.base/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1088 +++ jdk-jdk-24-11/make/modules/java.base/Lib.gmk 2024-08-17 20:36:14.220540690 +0200
1089 @@ -56,6 +56,7 @@
1090 -delayload:winhttp.dll, \
1091 JDK_LIBS := libjava libjvm, \
1092 LIBS_linux := $(LIBDL), \
1093 + LIBS_solaris := -lnsl -lsocket $(LIBDL), \
1094 LIBS_aix := $(LIBDL),\
1095 LIBS_windows := advapi32.lib delayimp.lib iphlpapi.lib secur32.lib \
1096 winhttp.lib ws2_32.lib, \
1097 @@ -77,8 +78,9 @@
1098 libnio/ch \
1099 libnio/fs \
1100 libjvm, \
1101 - JDK_LIBS := libjava libnet, \
1102 + JDK_LIBS := libjava libjvm libnet, \
1103 LIBS_linux := $(LIBDL) -lpthread, \
1104 + LIBS_solaris := -lsocket -lposix4 $(LIBDL) -lsendfile, \
1105 LIBS_aix := $(LIBDL), \
1106 LIBS_macosx := \
1107 -framework CoreFoundation \
1108 @@ -117,6 +119,7 @@
1109 OPTIMIZATION := LOW, \
1110 jsig.c_CFLAGS := -DHOTSPOT_VM_DISTRO='"$(HOTSPOT_VM_DISTRO)"', \
1111 LIBS_linux := $(LIBDL), \
1112 + LIBS_solaris := $(LIBDL), \
1113 LIBS_aix := $(LIBDL), \
1116 diff -Nru jdk-jdk-24-11.orig/make/modules/java.desktop/Gensrc.gmk jdk-jdk-24-11/make/modules/java.desktop/Gensrc.gmk
1117 --- jdk-jdk-24-11.orig/make/modules/java.desktop/Gensrc.gmk 2024-08-15 09:39:31.000000000 +0200
1118 +++ jdk-jdk-24-11/make/modules/java.desktop/Gensrc.gmk 2024-08-17 20:36:14.221870402 +0200
1119 @@ -32,7 +32,7 @@
1120 include gensrc/GensrcIcons.gmk
1121 endif
1123 -ifeq ($(call isTargetOs, linux aix), true)
1124 +ifeq ($(call isTargetOs, linux solaris aix), true)
1125 include gensrc/GensrcX11Wrappers.gmk
1126 endif
1128 diff -Nru jdk-jdk-24-11.orig/make/modules/java.desktop/lib/AwtLibraries.gmk jdk-jdk-24-11/make/modules/java.desktop/lib/AwtLibraries.gmk
1129 --- jdk-jdk-24-11.orig/make/modules/java.desktop/lib/AwtLibraries.gmk 2024-08-15 09:39:31.000000000 +0200
1130 +++ jdk-jdk-24-11/make/modules/java.desktop/lib/AwtLibraries.gmk 2024-08-17 20:36:14.222969382 +0200
1131 @@ -57,7 +57,7 @@
1133 endif
1135 -ifeq ($(call isTargetOs, linux macosx aix), true)
1136 +ifeq ($(call isTargetOs, solaris linux macosx aix), true)
1137 LIBAWT_EXCLUDE_FILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c
1138 endif
1140 @@ -125,6 +125,7 @@
1141 JDK_LIBS := java.base:libjava java.base:libjvm, \
1142 LIBS_unix := $(LIBM), \
1143 LIBS_linux := $(LIBDL), \
1144 + LIBS_solaris := $(LIBDL), \
1145 LIBS_aix := $(LIBDL),\
1146 LIBS_macosx := \
1147 -framework ApplicationServices \
1148 @@ -180,8 +181,9 @@
1149 EXTRA_HEADER_DIRS := $(LIBAWT_HEADLESS_EXTRA_HEADER_DIRS), \
1150 DISABLED_WARNINGS_gcc_X11Renderer.c := unused-function, \
1151 DISABLED_WARNINGS_gcc_X11SurfaceData.c := unused-function, \
1152 - JDK_LIBS := libawt java.base:libjava, \
1153 + JDK_LIBS := libawt java.base:libjava java.base:libjvm, \
1154 LIBS_linux := $(LIBDL) $(LIBM), \
1155 + LIBS_solaris := $(LIBDL) $(LIBM) $(LIBCXX), \
1156 STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS), \
1159 @@ -265,7 +267,7 @@
1160 DISABLED_WARNINGS_clang_aix_sun_awt_X11_GtkFileDialogPeer.c := \
1161 parentheses, \
1162 DISABLED_WARNINGS_clang_aix_awt_InputMethod.c := sign-compare, \
1163 - JDK_LIBS := libawt java.base:libjava, \
1164 + JDK_LIBS := libawt java.base:libjava java.base:libjvm, \
1165 LIBS_unix := $(LIBDL) $(LIBM) $(X_LIBS) -lX11 -lXext -lXi -lXrender \
1166 -lXtst, \
1167 LIBS_linux := -lpthread, \
1168 @@ -382,7 +384,7 @@
1169 endif
1171 ifeq ($(call isTargetOsType, unix)+$(call isTargetOs, macosx), true+false)
1172 - LIBJAWT_JDK_LIBS_unix := libawt
1173 + LIBJAWT_JDK_LIBS_unix := libawt java.base:libjava java.base:libjvm
1174 ifeq ($(ENABLE_HEADLESS_ONLY), false)
1175 LIBJAWT_JDK_LIBS_unix += libawt_xawt
1176 else
1177 @@ -402,6 +404,7 @@
1178 LDFLAGS_windows := $(LDFLAGS_CXX_JDK), \
1179 LDFLAGS_macosx := -Wl$(COMMA)-rpath$(COMMA)@loader_path, \
1180 JDK_LIBS_unix := $(LIBJAWT_JDK_LIBS_unix), \
1181 + LIBS_solaris := $(X_LIBS) -lXrender, \
1182 JDK_LIBS_windows := libawt, \
1183 JDK_LIBS_macosx := libawt_lwawt, \
1184 LIBS_macosx := -framework Cocoa, \
1185 diff -Nru jdk-jdk-24-11.orig/make/modules/java.desktop/lib/ClientLibraries.gmk jdk-jdk-24-11/make/modules/java.desktop/lib/ClientLibraries.gmk
1186 --- jdk-jdk-24-11.orig/make/modules/java.desktop/lib/ClientLibraries.gmk 2024-08-15 09:39:31.000000000 +0200
1187 +++ jdk-jdk-24-11/make/modules/java.desktop/lib/ClientLibraries.gmk 2024-08-17 20:36:14.223505430 +0200
1188 @@ -87,7 +87,7 @@
1189 DISABLED_WARNINGS_gcc := format-nonliteral type-limits \
1190 stringop-truncation, \
1191 DISABLED_WARNINGS_clang := format-nonliteral, \
1192 - JDK_LIBS := libawt java.base:libjava, \
1193 + JDK_LIBS := libawt java.base:libjava java.base:libjvm, \
1194 LIBS_unix := $(LCMS_LIBS) $(LIBM), \
1197 @@ -121,7 +121,7 @@
1198 DISABLED_WARNINGS_gcc_imageioJPEG.c := clobbered array-bounds, \
1199 DISABLED_WARNINGS_gcc_jcmaster.c := implicit-fallthrough, \
1200 DISABLED_WARNINGS_gcc_jdphuff.c := shift-negative-value, \
1201 - JDK_LIBS := java.base:libjava, \
1202 + JDK_LIBS := java.base:libjava java.base:libjvm, \
1203 LIBS := $(LIBJPEG_LIBS), \
1206 @@ -242,6 +242,7 @@
1207 LIBS := $(GIFLIB_LIBS) $(LIBJPEG_LIBS) $(LIBZ_LIBS) $(PNG_LIBS), \
1208 LIBS_unix := $(LIBM) -lpthread, \
1209 LIBS_linux := $(LIBDL) $(X_LIBS) -lX11 -lXext, \
1210 + LIBS_solaris := $(LIBDL) $(X_LIBS) -lX11 -lXext, \
1211 LIBS_macosx := -liconv \
1212 -framework ApplicationServices \
1213 -framework Cocoa \
1214 @@ -290,7 +291,7 @@
1215 -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
1216 -DHB_NO_PRAGMA_GCC_DIAGNOSTIC
1217 endif
1218 - ifeq ($(call isTargetOs, linux macosx), true)
1219 + ifeq ($(call isTargetOs, solaris linux macosx), true)
1220 HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES -DHB_NO_VISIBILITY
1221 endif
1223 diff -Nru jdk-jdk-24-11.orig/make/modules/java.desktop/Lib.gmk jdk-jdk-24-11/make/modules/java.desktop/Lib.gmk
1224 --- jdk-jdk-24-11.orig/make/modules/java.desktop/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1225 +++ jdk-jdk-24-11/make/modules/java.desktop/Lib.gmk 2024-08-17 20:36:14.222241178 +0200
1226 @@ -48,10 +48,15 @@
1227 -DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \
1228 -DUSE_PORTS=TRUE \
1229 -DUSE_DAUDIO=TRUE \
1230 - -DUSE_PLATFORM_MIDI_OUT=TRUE \
1231 - -DUSE_PLATFORM_MIDI_IN=TRUE \
1234 + ifeq ($(call isTargetOs, solaris), false)
1235 + LIBJSOUND_CFLAGS += \
1236 + -DUSE_PLATFORM_MIDI_OUT=TRUE \
1237 + -DUSE_PLATFORM_MIDI_IN=TRUE \
1239 + endif
1241 LIBJSOUND_LINK_TYPE := C
1242 ifeq ($(call isTargetOs, macosx), true)
1243 LIBJSOUND_LINK_TYPE := C++
1244 diff -Nru jdk-jdk-24-11.orig/make/modules/java.instrument/Lib.gmk jdk-jdk-24-11/make/modules/java.instrument/Lib.gmk
1245 --- jdk-jdk-24-11.orig/make/modules/java.instrument/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1246 +++ jdk-jdk-24-11/make/modules/java.instrument/Lib.gmk 2024-08-17 20:36:14.223928936 +0200
1247 @@ -39,6 +39,7 @@
1248 JDK_LIBS := java.base:libjava java.base:libjli java.base:libjvm, \
1249 LIBS_unix := $(LIBZ_LIBS), \
1250 LIBS_linux := $(LIBDL), \
1251 + LIBS_solaris := $(LIBDL), \
1252 LIBS_aix := $(LIBDL) -liconv, \
1253 LIBS_macosx := -liconv \
1254 -framework ApplicationServices \
1255 diff -Nru jdk-jdk-24-11.orig/make/modules/java.management/Lib.gmk jdk-jdk-24-11/make/modules/java.management/Lib.gmk
1256 --- jdk-jdk-24-11.orig/make/modules/java.management/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1257 +++ jdk-jdk-24-11/make/modules/java.management/Lib.gmk 2024-08-17 20:36:14.224358336 +0200
1258 @@ -30,7 +30,7 @@
1259 ################################################################################
1261 LIBMANAGEMENT_OPTIMIZATION := HIGH
1262 -ifeq ($(call isTargetOs, linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1263 +ifeq ($(call isTargetOs, solaris linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1264 LIBMANAGEMENT_OPTIMIZATION := LOW
1265 endif
1267 @@ -38,6 +38,7 @@
1268 NAME := management, \
1269 OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
1270 JDK_LIBS := java.base:libjava java.base:libjvm, \
1271 + LIBS_solaris := -lkstat, \
1272 LIBS_aix := -lperfstat,\
1273 LIBS_windows := advapi32.lib psapi.lib, \
1275 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.attach/Lib.gmk jdk-jdk-24-11/make/modules/jdk.attach/Lib.gmk
1276 --- jdk-jdk-24-11.orig/make/modules/jdk.attach/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1277 +++ jdk-jdk-24-11/make/modules/jdk.attach/Lib.gmk 2024-08-17 20:36:14.224753384 +0200
1278 @@ -41,7 +41,8 @@
1279 OPTIMIZATION := LOW, \
1280 CFLAGS := $(LIBATTACH_CFLAGS), \
1281 CFLAGS_windows := -Gy, \
1282 - JDK_LIBS := java.base:libjava, \
1283 + JDK_LIBS := java.base:libjava java.base:libjvm, \
1284 + LIBS_solaris := -ldoor, \
1285 LIBS_windows := advapi32.lib psapi.lib, \
1288 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.crypto.cryptoki/Copy.gmk jdk-jdk-24-11/make/modules/jdk.crypto.cryptoki/Copy.gmk
1289 --- jdk-jdk-24-11.orig/make/modules/jdk.crypto.cryptoki/Copy.gmk 1970-01-01 01:00:00.000000000 +0100
1290 +++ jdk-jdk-24-11/make/modules/jdk.crypto.cryptoki/Copy.gmk 2024-08-17 20:36:14.280320389 +0200
1291 @@ -0,0 +1,45 @@
1293 +# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
1294 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1296 +# This code is free software; you can redistribute it and/or modify it
1297 +# under the terms of the GNU General Public License version 2 only, as
1298 +# published by the Free Software Foundation. Oracle designates this
1299 +# particular file as subject to the "Classpath" exception as provided
1300 +# by Oracle in the LICENSE file that accompanied this code.
1302 +# This code is distributed in the hope that it will be useful, but WITHOUT
1303 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1304 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1305 +# version 2 for more details (a copy is included in the LICENSE file that
1306 +# accompanied this code).
1308 +# You should have received a copy of the GNU General Public License version
1309 +# 2 along with this work; if not, write to the Free Software Foundation,
1310 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1312 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1313 +# or visit www.oracle.com if you need additional information or have any
1314 +# questions.
1317 +include CopyCommon.gmk
1319 +################################################################################
1321 +ifeq ($(call isTargetOs, solaris), true)
1323 + SUNPKCS11_CFG_SRC := \
1324 + $(TOPDIR)/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg
1325 + SUNPKCS11_CFG_DST := $(CONF_DST_DIR)/security/sunpkcs11-solaris.cfg
1327 + $(SUNPKCS11_CFG_DST): $(SUNPKCS11_CFG_SRC)
1328 + $(call install-file)
1330 + SECURITY_PKCS11_CONF_FILES += $(SUNPKCS11_CFG_DST)
1332 + TARGETS := $(SUNPKCS11_CFG_DST)
1334 +endif
1336 +################################################################################
1337 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.hotspot.agent/Lib.gmk jdk-jdk-24-11/make/modules/jdk.hotspot.agent/Lib.gmk
1338 --- jdk-jdk-24-11.orig/make/modules/jdk.hotspot.agent/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1339 +++ jdk-jdk-24-11/make/modules/jdk.hotspot.agent/Lib.gmk 2024-08-17 20:36:14.225185309 +0200
1340 @@ -67,8 +67,9 @@
1341 CFLAGS := $(LIBSAPROC_CFLAGS), \
1342 CXXFLAGS := $(LIBSAPROC_CFLAGS) $(LIBSAPROC_CXXFLAGS), \
1343 EXTRA_SRC := $(LIBSAPROC_EXTRA_SRC), \
1344 - JDK_LIBS := java.base:libjava, \
1345 + JDK_LIBS := java.base:libjava java.base:libjvm, \
1346 LIBS_linux := $(LIBDL), \
1347 + LIBS_solaris := -ldl -lstdc++ -lthread -lproc, \
1348 LIBS_macosx := \
1349 -framework CoreFoundation \
1350 -framework Foundation \
1351 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.jdwp.agent/Lib.gmk jdk-jdk-24-11/make/modules/jdk.jdwp.agent/Lib.gmk
1352 --- jdk-jdk-24-11.orig/make/modules/jdk.jdwp.agent/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1353 +++ jdk-jdk-24-11/make/modules/jdk.jdwp.agent/Lib.gmk 2024-08-17 20:36:14.225665255 +0200
1354 @@ -37,6 +37,7 @@
1355 include \
1356 libjdwp/export, \
1357 LIBS_linux := -lpthread, \
1358 + LIBS_solaris := -lnsl -lsocket, \
1359 LIBS_windows := iphlpapi.lib ws2_32.lib, \
1362 @@ -63,6 +64,7 @@
1363 java.base:libjava \
1364 java.base:libjvm, \
1365 LIBS_linux := $(LIBDL), \
1366 + LIBS_solaris := $(LIBDL), \
1367 LIBS_macosx := -liconv, \
1368 LIBS_aix := -liconv, \
1370 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.management/Lib.gmk jdk-jdk-24-11/make/modules/jdk.management/Lib.gmk
1371 --- jdk-jdk-24-11.orig/make/modules/jdk.management/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1372 +++ jdk-jdk-24-11/make/modules/jdk.management/Lib.gmk 2024-08-17 20:36:14.226112992 +0200
1373 @@ -37,7 +37,7 @@
1374 endif
1376 LIBMANAGEMENT_EXT_OPTIMIZATION := HIGH
1377 -ifeq ($(call isTargetOs, linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1378 +ifeq ($(call isTargetOs, solaris linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
1379 LIBMANAGEMENT_EXT_OPTIMIZATION := LOW
1380 endif
1382 @@ -47,6 +47,7 @@
1383 DISABLED_WARNINGS_clang_UnixOperatingSystem.c := format-nonliteral, \
1384 CFLAGS := $(LIBMANAGEMENT_EXT_CFLAGS), \
1385 JDK_LIBS := java.base:libjava java.base:libjvm, \
1386 + LIBS_solaris := -lkstat, \
1387 LIBS_aix := -lperfstat,\
1388 LIBS_windows := advapi32.lib psapi.lib, \
1390 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.management.agent/Lib.gmk jdk-jdk-24-11/make/modules/jdk.management.agent/Lib.gmk
1391 --- jdk-jdk-24-11.orig/make/modules/jdk.management.agent/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1392 +++ jdk-jdk-24-11/make/modules/jdk.management.agent/Lib.gmk 2024-08-17 20:36:14.226494569 +0200
1393 @@ -32,7 +32,7 @@
1394 $(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT_AGENT, \
1395 NAME := management_agent, \
1396 OPTIMIZATION := LOW, \
1397 - JDK_LIBS := java.base:libjava, \
1398 + JDK_LIBS := java.base:libjava java.base:libjvm, \
1399 LIBS_windows := advapi32.lib, \
1402 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.net/Lib.gmk jdk-jdk-24-11/make/modules/jdk.net/Lib.gmk
1403 --- jdk-jdk-24-11.orig/make/modules/jdk.net/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1404 +++ jdk-jdk-24-11/make/modules/jdk.net/Lib.gmk 2024-08-17 20:36:14.226919292 +0200
1405 @@ -29,6 +29,8 @@
1406 ## Build libextnet
1407 ################################################################################
1409 +ifeq ($(call isTargetOs, solaris), false)
1411 $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \
1412 NAME := extnet, \
1413 OPTIMIZATION := LOW, \
1414 @@ -38,3 +40,5 @@
1417 TARGETS += $(BUILD_LIBEXTNET)
1419 +endif
1420 diff -Nru jdk-jdk-24-11.orig/make/modules/jdk.sctp/Lib.gmk jdk-jdk-24-11/make/modules/jdk.sctp/Lib.gmk
1421 --- jdk-jdk-24-11.orig/make/modules/jdk.sctp/Lib.gmk 2024-08-15 09:39:31.000000000 +0200
1422 +++ jdk-jdk-24-11/make/modules/jdk.sctp/Lib.gmk 2024-08-17 20:36:14.227293130 +0200
1423 @@ -40,6 +40,7 @@
1424 java.base:libnio/ch, \
1425 JDK_LIBS := java.base:libjava java.base:libnet, \
1426 LIBS_linux := $(LIBDL) -lpthread, \
1427 + LIBS_solaris := -lsocket, \
1430 TARGETS += $(BUILD_LIBSCTP)
1431 diff -Nru jdk-jdk-24-11.orig/make/RunTestsPrebuilt.gmk jdk-jdk-24-11/make/RunTestsPrebuilt.gmk
1432 --- jdk-jdk-24-11.orig/make/RunTestsPrebuilt.gmk 2024-08-15 09:39:31.000000000 +0200
1433 +++ jdk-jdk-24-11/make/RunTestsPrebuilt.gmk 2024-08-17 20:36:14.211533741 +0200
1434 @@ -168,6 +168,8 @@
1435 OPENJDK_TARGET_OS := linux
1436 else ifeq ($(UNAME_OS), Darwin)
1437 OPENJDK_TARGET_OS := macosx
1438 + else ifeq ($(UNAME_OS), SunOS)
1439 + OPENJDK_TARGET_OS := solaris
1440 else
1441 OPENJDK_TARGET_OS := $(UNAME_OS)
1442 endif
1443 @@ -180,15 +182,28 @@
1444 # Assume little endian unless otherwise specified
1445 OPENJDK_TARGET_CPU_ENDIAN := little
1447 -UNAME_CPU := $(shell $(UNAME) -m)
1448 -ifeq ($(UNAME_CPU), i686)
1449 - OPENJDK_TARGET_CPU := x86
1450 - OPENJDK_TARGET_CPU_BITS := 32
1451 -else
1452 - # Assume all others are 64-bit. We use the same CPU name as uname for
1453 - # at least x86_64 and aarch64.
1454 - OPENJDK_TARGET_CPU := $(UNAME_CPU)
1455 +ifeq ($(OPENJDK_TARGET_OS), solaris)
1456 + # On solaris, use uname -p
1457 + UNAME_CPU := $(shell $(UNAME) -p)
1458 + # Assume 64-bit platform
1459 OPENJDK_TARGET_CPU_BITS := 64
1460 + ifeq ($(UNAME_CPU), i386)
1461 + OPENJDK_TARGET_CPU := x86_64
1462 + else
1463 + OPENJDK_TARGET_CPU := $(UNAME_CPU)
1464 + endif
1465 +else
1466 + # ... all others use uname -m
1467 + UNAME_CPU := $(shell $(UNAME) -m)
1468 + ifeq ($(UNAME_CPU), i686)
1469 + OPENJDK_TARGET_CPU := x86
1470 + OPENJDK_TARGET_CPU_BITS := 32
1471 + else
1472 + # Assume all others are 64-bit. We use the same CPU name as uname for
1473 + # at least x86_64 and aarch64.
1474 + OPENJDK_TARGET_CPU := $(UNAME_CPU)
1475 + OPENJDK_TARGET_CPU_BITS := 64
1476 + endif
1477 endif
1479 OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU)
1480 @@ -213,6 +228,11 @@
1481 else ifeq ($(OPENJDK_TARGET_OS), macosx)
1482 NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
1483 MEMORY_SIZE := $(shell $(EXPR) `/usr/sbin/sysctl -n hw.memsize` / 1024 / 1024)
1484 +else ifeq ($(OPENJDK_TARGET_OS), solaris)
1485 + NUM_CORES := $(shell /usr/sbin/psrinfo -v | $(GREP) -c on-line)
1486 + MEMORY_SIZE := $(shell \
1487 + /usr/sbin/prtconf 2> /dev/null | $(GREP) "^Memory [Ss]ize" | $(AWK) '{print $$3}' \
1489 else ifeq ($(OPENJDK_TARGET_OS), windows)
1490 NUM_CORES := $(NUMBER_OF_PROCESSORS)
1491 MEMORY_SIZE := $(shell \
1492 diff -Nru jdk-jdk-24-11.orig/make/RunTestsPrebuiltSpec.gmk jdk-jdk-24-11/make/RunTestsPrebuiltSpec.gmk
1493 --- jdk-jdk-24-11.orig/make/RunTestsPrebuiltSpec.gmk 2024-08-15 09:39:31.000000000 +0200
1494 +++ jdk-jdk-24-11/make/RunTestsPrebuiltSpec.gmk 2024-08-17 20:36:14.211929696 +0200
1495 @@ -173,6 +173,16 @@
1496 FILE := file
1497 ULIMIT := ulimit
1499 +# On Solaris gnu versions of some tools are required.
1500 +ifeq ($(OPENJDK_BUILD_OS), solaris)
1501 + AWK := gawk
1502 + GREP := ggrep
1503 + EGREP := ggrep -E
1504 + FGREP := grep -F
1505 + SED := gsed
1506 + TAR := gtar
1507 +endif
1509 ifeq ($(OPENJDK_BUILD_OS), windows)
1510 PATHTOOL := cygpath
1511 endif
1512 diff -Nru jdk-jdk-24-11.orig/make/scripts/compare.sh jdk-jdk-24-11/make/scripts/compare.sh
1513 --- jdk-jdk-24-11.orig/make/scripts/compare.sh 2024-08-15 09:39:31.000000000 +0200
1514 +++ jdk-jdk-24-11/make/scripts/compare.sh 2024-08-17 20:36:14.228245938 +0200
1515 @@ -75,7 +75,14 @@
1516 # Disassembly diff filters. These filters try to filter out ephemeral parts of the
1517 # disassembly, such as hard-coded addresses, to be able to catch "actual" differences.
1519 -if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1520 +if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
1521 + if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
1522 + # Random strings looking like this differ: <.XAKoKoPIac2W0OA.
1523 + DIS_DIFF_FILTER="$SED \
1524 + -e 's/<\.[A-Za-z0-9]\{\15}\./<.SYM./' \
1526 + fi
1527 +elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
1528 if [ "$OPENJDK_TARGET_CPU" = "x86" ]; then
1529 DIS_DIFF_FILTER="$SED -r \
1530 -e 's/^ [0-9A-F]{16}: //' \
1531 @@ -398,7 +405,14 @@
1534 CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
1535 - $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
1536 + # On solaris, there is no -q option.
1537 + if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
1538 + $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \
1539 + | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \
1540 + > $CONTENTS_DIFF_FILE
1541 + else
1542 + $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
1543 + fi
1545 ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
1546 ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)
1547 @@ -420,8 +434,14 @@
1550 if [ "$CMP_ZIPS_CONTENTS" = "true" ]; then
1551 - DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
1552 - | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
1553 + if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
1554 + DIFFING_FILES=$($GREP -e 'differ$' -e '^diff ' $CONTENTS_DIFF_FILE \
1555 + | $SED -e 's/^Files //g' -e 's/diff -r //g' | $CUT -f 1 -d ' ' \
1556 + | $SED "s|$OTHER_UNZIPDIR/||g")
1557 + else
1558 + DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
1559 + | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
1560 + fi
1562 # Separate executable/library files from other files in zip.
1563 DIFFING_TEXT_FILES=
1564 @@ -769,6 +789,10 @@
1565 # to filter out that extra information.
1566 $DUMPBIN -exports $OTHER_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
1567 $DUMPBIN -exports $THIS_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
1568 + elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
1569 + # Some symbols get seemingly random 15 character prefixes. Filter them out.
1570 + $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
1571 + $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
1572 elif [ "$OPENJDK_TARGET_OS" = "aix" ]; then
1573 $OBJDUMP -T $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
1574 $OBJDUMP -T $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
1575 diff -Nru jdk-jdk-24-11.orig/make/scripts/hide_important_warnings_from_javac.sh jdk-jdk-24-11/make/scripts/hide_important_warnings_from_javac.sh
1576 --- jdk-jdk-24-11.orig/make/scripts/hide_important_warnings_from_javac.sh 2024-08-15 09:39:31.000000000 +0200
1577 +++ jdk-jdk-24-11/make/scripts/hide_important_warnings_from_javac.sh 2024-08-17 20:36:14.228584296 +0200
1578 @@ -22,8 +22,13 @@
1579 # questions.
1582 -GREP=grep
1584 +if [ -x /usr/bin/ggrep ] ; then
1585 + # Gnu grep on Solaris
1586 + # (reference configure and build/solaris-i586-clientANDserver-release/spec.gmk
1587 + GREP=/usr/bin/ggrep
1588 +else
1589 + GREP=grep
1592 EXP="Note: Some input files use or override a deprecated API."
1593 EXP="${EXP}|Note: Recompile with -Xlint:deprecation for details."
1594 diff -Nru jdk-jdk-24-11.orig/make/test/JtregNativeHotspot.gmk jdk-jdk-24-11/make/test/JtregNativeHotspot.gmk
1595 --- jdk-jdk-24-11.orig/make/test/JtregNativeHotspot.gmk 2024-08-15 09:39:31.000000000 +0200
1596 +++ jdk-jdk-24-11/make/test/JtregNativeHotspot.gmk 2024-08-17 20:36:14.229502399 +0200
1597 @@ -867,6 +867,10 @@
1598 BUILD_HOTSPOT_JTREG_LIBRARIES_JDK_LIBS_libatExit := java.base:libjvm
1599 BUILD_HOTSPOT_JTREG_EXECUTABLES_JDK_LIBS_exedaemonDestroy := java.base:libjvm
1601 +ifeq ($(call isTargetOs, solaris), true)
1602 + BUILD_HOTSPOT_JTREG_EXCLUDE += libterminatedThread.c
1603 +endif
1605 ifeq ($(call isTargetOs, windows), true)
1606 BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
1607 BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c libTestJNI.c libCompleteExit.c libMonitorWithDeadObjectTest.c libTestPsig.c exeGetCreatedJavaVMs.c
1608 diff -Nru jdk-jdk-24-11.orig/make/test/JtregNativeJdk.gmk jdk-jdk-24-11/make/test/JtregNativeJdk.gmk
1609 --- jdk-jdk-24-11.orig/make/test/JtregNativeJdk.gmk 2024-08-15 09:39:31.000000000 +0200
1610 +++ jdk-jdk-24-11/make/test/JtregNativeJdk.gmk 2024-08-17 20:36:14.230011926 +0200
1611 @@ -59,10 +59,10 @@
1612 BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeCallerAccessTest := java.base:libjvm
1613 BUILD_JDK_JTREG_EXECUTABLES_JDK_LIBS_exeNullCallerTest := java.base:libjvm
1615 -BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libstringPlatformChars := java.base:libjava
1616 +BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libstringPlatformChars := java.base:libjava java.base:libjvm
1617 BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libTracePinnedThreads := java.base:libjvm
1618 -BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libNewDirectByteBuffer := java.base:libjava
1619 -BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libGetXSpace := java.base:libjava
1620 +BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libNewDirectByteBuffer := java.base:libjava java.base:libjvm
1621 +BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libGetXSpace := java.base:libjava java.base:libjvm
1623 # Platform specific setup
1624 ifeq ($(call isTargetOs, windows), true)
1625 @@ -74,7 +74,7 @@
1626 BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib
1627 BUILD_JDK_JTREG_EXECUTABLES_CFLAGS_exeNullCallerTest := /EHsc
1628 else
1629 - BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libDirectIO := java.base:libjava
1630 + BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libDirectIO := java.base:libjava java.base:libjvm
1631 BUILD_JDK_JTREG_LIBRARIES_LDFLAGS_libNativeThread := -pthread
1633 # java.lang.foreign tests
1634 @@ -91,6 +91,9 @@
1635 ifeq ($(call isTargetOs, linux), true)
1636 BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libInheritedChannel := java.base:libjava
1637 BUILD_JDK_JTREG_EXECUTABLES_LIBS_exelauncher := -ldl
1638 + else ifeq ($(call isTargetOs, solaris), true)
1639 + BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libInheritedChannel := java.base:libjava java.base:libjvm
1640 + BUILD_JDK_JTREG_EXECUTABLES_LIBS_exelauncher := -lsocket -lnsl -lthread -ldl
1641 endif
1642 BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX)
1643 endif
1644 diff -Nru jdk-jdk-24-11.orig/src/hotspot/cpu/x86/globalDefinitions_x86.hpp jdk-jdk-24-11/src/hotspot/cpu/x86/globalDefinitions_x86.hpp
1645 --- jdk-jdk-24-11.orig/src/hotspot/cpu/x86/globalDefinitions_x86.hpp 2024-08-15 09:39:31.000000000 +0200
1646 +++ jdk-jdk-24-11/src/hotspot/cpu/x86/globalDefinitions_x86.hpp 2024-08-17 20:36:14.230584183 +0200
1647 @@ -52,7 +52,7 @@
1648 #define DEFAULT_PADDING_SIZE DEFAULT_CACHE_LINE_SIZE
1649 #endif
1651 -#if defined(LINUX) || defined(__APPLE__)
1652 +#if defined(LINUX) || defined(SOLARIS) || defined(__APPLE__)
1653 #define SUPPORT_RESERVED_STACK_AREA
1654 #endif
1656 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/posix/include/jvm_md.h jdk-jdk-24-11/src/hotspot/os/posix/include/jvm_md.h
1657 --- jdk-jdk-24-11.orig/src/hotspot/os/posix/include/jvm_md.h 2024-08-15 09:39:31.000000000 +0200
1658 +++ jdk-jdk-24-11/src/hotspot/os/posix/include/jvm_md.h 2024-08-17 20:36:14.231063235 +0200
1659 @@ -54,7 +54,7 @@
1660 #endif
1661 #define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX
1663 -#if defined(AIX)
1664 +#if defined(AIX) || defined(SOLARIS)
1665 #define JVM_MAXPATHLEN MAXPATHLEN
1666 #else
1667 // Hack: MAXPATHLEN is 4095 on some Linux and 4096 on others. This may
1668 @@ -87,8 +87,14 @@
1669 #define JVM_SIGTERM SIGTERM
1671 #define BREAK_SIGNAL SIGQUIT /* Thread dumping support. */
1672 +#ifdef SOLARIS
1673 +#define ASYNC_SIGNAL SIGJVM2 /* Event-based suspend/resume support */
1674 +#endif // SOLARIS
1675 #define SHUTDOWN1_SIGNAL SIGHUP /* Shutdown Hooks support. */
1676 #define SHUTDOWN2_SIGNAL SIGINT
1677 #define SHUTDOWN3_SIGNAL SIGTERM
1679 +/* With 1.4.1 libjsig added versioning: used in os_solaris.cpp and jsig.c */
1680 +#define JSIG_VERSION_1_4_1 0x30140100
1682 #endif /* !_JAVASOFT_JVM_MD_H_ */
1683 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/posix/os_posix.cpp jdk-jdk-24-11/src/hotspot/os/posix/os_posix.cpp
1684 --- jdk-jdk-24-11.orig/src/hotspot/os/posix/os_posix.cpp 2024-08-15 09:39:31.000000000 +0200
1685 +++ jdk-jdk-24-11/src/hotspot/os/posix/os_posix.cpp 2024-08-17 20:36:14.231847638 +0200
1686 @@ -591,7 +591,7 @@
1687 st->print("%ld", sysconf(_SC_CHILD_MAX));
1689 print_rlimit(st, ", THREADS", RLIMIT_THREADS);
1690 -#else
1691 +#elif !defined(SOLARIS)
1692 print_rlimit(st, ", NPROC", RLIMIT_NPROC);
1693 #endif
1695 @@ -609,6 +609,12 @@
1696 print_rlimit(st, ", MEMLOCK", RLIMIT_MEMLOCK, true);
1697 #endif
1699 +#if defined(SOLARIS)
1700 + // maximum size of mapped address space of a process in bytes;
1701 + // if the limit is exceeded, mmap and brk fail
1702 + print_rlimit(st, ", VMEM", RLIMIT_VMEM, true);
1703 +#endif
1705 // MacOS; The maximum size (in bytes) to which a process's resident set size may grow.
1706 #if defined(__APPLE__)
1707 print_rlimit(st, ", RSS", RLIMIT_RSS, true);
1708 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/posix/os_posix.inline.hpp jdk-jdk-24-11/src/hotspot/os/posix/os_posix.inline.hpp
1709 --- jdk-jdk-24-11.orig/src/hotspot/os/posix/os_posix.inline.hpp 2024-08-15 09:39:31.000000000 +0200
1710 +++ jdk-jdk-24-11/src/hotspot/os/posix/os_posix.inline.hpp 2024-08-17 20:36:14.232189381 +0200
1711 @@ -34,8 +34,10 @@
1712 #include <sys/socket.h>
1713 #include <netdb.h>
1715 +#ifndef SOLARIS
1716 // Aix does not have NUMA support but need these for compilation.
1717 inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; }
1718 +#endif // !SOLARIS
1720 // Platform Mutex/Monitor implementation
1722 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/posix/vmError_posix.cpp jdk-jdk-24-11/src/hotspot/os/posix/vmError_posix.cpp
1723 --- jdk-jdk-24-11.orig/src/hotspot/os/posix/vmError_posix.cpp 2024-08-15 09:39:31.000000000 +0200
1724 +++ jdk-jdk-24-11/src/hotspot/os/posix/vmError_posix.cpp 2024-08-17 20:36:14.232534684 +0200
1725 @@ -41,6 +41,9 @@
1726 #include <sys/syscall.h>
1727 #include <unistd.h>
1728 #endif
1729 +#ifdef SOLARIS
1730 +#include <thread.h>
1731 +#endif
1732 #ifdef AIX
1733 #include <unistd.h>
1734 #endif
1735 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/attachListener_solaris.cpp jdk-jdk-24-11/src/hotspot/os/solaris/attachListener_solaris.cpp
1736 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/attachListener_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
1737 +++ jdk-jdk-24-11/src/hotspot/os/solaris/attachListener_solaris.cpp 2024-08-17 20:36:14.280981357 +0200
1738 @@ -0,0 +1,719 @@
1740 + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
1741 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1743 + * This code is free software; you can redistribute it and/or modify it
1744 + * under the terms of the GNU General Public License version 2 only, as
1745 + * published by the Free Software Foundation.
1747 + * This code is distributed in the hope that it will be useful, but WITHOUT
1748 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1749 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1750 + * version 2 for more details (a copy is included in the LICENSE file that
1751 + * accompanied this code).
1753 + * You should have received a copy of the GNU General Public License version
1754 + * 2 along with this work; if not, write to the Free Software Foundation,
1755 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1757 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1758 + * or visit www.oracle.com if you need additional information or have any
1759 + * questions.
1761 + */
1763 +#include "precompiled.hpp"
1764 +#include "logging/log.hpp"
1765 +#include "runtime/interfaceSupport.inline.hpp"
1766 +#include "runtime/os.inline.hpp"
1767 +#include "services/attachListener.hpp"
1768 +#include "services/dtraceAttacher.hpp"
1769 +#include "utilities/vmError.hpp"
1771 +#include <door.h>
1772 +#include <limits.h>
1773 +#include <string.h>
1774 +#include <signal.h>
1775 +#include <sys/types.h>
1776 +#include <sys/socket.h>
1777 +#include <sys/stat.h>
1779 +// stropts.h uses STR in stream ioctl defines
1780 +#undef STR
1781 +#include <stropts.h>
1782 +#undef STR
1783 +#define STR(a) #a
1785 +// The attach mechanism on Solaris is implemented using the Doors IPC
1786 +// mechanism. The first tool to attempt to attach causes the attach
1787 +// listener thread to startup. This thread creats a door that is
1788 +// associated with a function that enqueues an operation to the attach
1789 +// listener. The door is attached to a file in the file system so that
1790 +// client (tools) can locate it. To enqueue an operation to the VM the
1791 +// client calls through the door which invokes the enqueue function in
1792 +// this process. The credentials of the client are checked and if the
1793 +// effective uid matches this process then the operation is enqueued.
1794 +// When an operation completes the attach listener is required to send the
1795 +// operation result and any result data to the client. In this implementation
1796 +// the result is returned via a UNIX domain socket. A pair of connected
1797 +// sockets (socketpair) is created in the enqueue function and the file
1798 +// descriptor for one of the sockets is returned to the client as the
1799 +// return from the door call. The other end is retained in this process.
1800 +// When the operation completes the result is sent to the client and
1801 +// the socket is closed.
1803 +// forward reference
1804 +class SolarisAttachOperation;
1806 +class SolarisAttachListener: AllStatic {
1807 + private:
1809 + // the path to which we attach the door file descriptor
1810 + static char _door_path[PATH_MAX+1];
1811 + static volatile bool _has_door_path;
1813 + // door descriptor returned by door_create
1814 + static int _door_descriptor;
1816 + static bool _atexit_registered;
1818 + // mutex to protect operation list
1819 + static pthread_mutex_t _mutex;
1821 + // semaphore to wakeup listener thread
1822 + static sema_t _wakeup;
1824 + static pthread_mutex_t* mutex() { return &_mutex; }
1825 + static sema_t* wakeup() { return &_wakeup; }
1827 + // enqueued operation list
1828 + static SolarisAttachOperation* _head;
1829 + static SolarisAttachOperation* _tail;
1831 + static SolarisAttachOperation* head() { return _head; }
1832 + static void set_head(SolarisAttachOperation* head) { _head = head; }
1834 + static SolarisAttachOperation* tail() { return _tail; }
1835 + static void set_tail(SolarisAttachOperation* tail) { _tail = tail; }
1837 + // create the door
1838 + static int create_door();
1840 + public:
1841 + enum {
1842 + ATTACH_PROTOCOL_VER = 1 // protocol version
1843 + };
1844 + enum {
1845 + ATTACH_ERROR_BADREQUEST = 100, // error codes
1846 + ATTACH_ERROR_BADVERSION = 101,
1847 + ATTACH_ERROR_RESOURCE = 102,
1848 + ATTACH_ERROR_INTERNAL = 103,
1849 + ATTACH_ERROR_DENIED = 104
1850 + };
1852 + static void set_door_path(char* path) {
1853 + if (path == NULL) {
1854 + _door_path[0] = '\0';
1855 + _has_door_path = false;
1856 + } else {
1857 + strncpy(_door_path, path, PATH_MAX);
1858 + _door_path[PATH_MAX] = '\0';
1859 + _has_door_path = true;
1863 + static void set_door_descriptor(int dd) { _door_descriptor = dd; }
1865 + // initialize the listener, returns 0 if okay
1866 + static int init();
1868 + static char* door_path() { return _door_path; }
1869 + static bool has_door_path() { return _has_door_path; }
1870 + static int door_descriptor() { return _door_descriptor; }
1872 + // enqueue an operation
1873 + static void enqueue(SolarisAttachOperation* op);
1875 + // dequeue an operation
1876 + static SolarisAttachOperation* dequeue();
1880 +// SolarisAttachOperation is an AttachOperation that additionally encapsulates
1881 +// a socket connection to the requesting client/tool. SolarisAttachOperation
1882 +// can additionally be held in a linked list.
1884 +class SolarisAttachOperation: public AttachOperation {
1885 + private:
1886 + friend class SolarisAttachListener;
1888 + // connection to client
1889 + int _socket;
1891 + // linked list support
1892 + SolarisAttachOperation* _next;
1894 + SolarisAttachOperation* next() { return _next; }
1895 + void set_next(SolarisAttachOperation* next) { _next = next; }
1897 + public:
1898 + void complete(jint res, bufferedStream* st);
1900 + void set_socket(int s) { _socket = s; }
1901 + int socket() const { return _socket; }
1903 + SolarisAttachOperation(char* name) : AttachOperation(name) {
1904 + set_socket(-1);
1905 + set_next(NULL);
1909 +// statics
1910 +char SolarisAttachListener::_door_path[PATH_MAX+1];
1911 +volatile bool SolarisAttachListener::_has_door_path;
1912 +int SolarisAttachListener::_door_descriptor = -1;
1913 +bool SolarisAttachListener::_atexit_registered = false;
1914 +pthread_mutex_t SolarisAttachListener::_mutex;
1915 +sema_t SolarisAttachListener::_wakeup;
1916 +SolarisAttachOperation* SolarisAttachListener::_head = NULL;
1917 +SolarisAttachOperation* SolarisAttachListener::_tail = NULL;
1919 +// Supporting class to help split a buffer into individual components
1920 +class ArgumentIterator : public StackObj {
1921 + private:
1922 + char* _pos;
1923 + char* _end;
1924 + public:
1925 + ArgumentIterator(char* arg_buffer, size_t arg_size) {
1926 + _pos = arg_buffer;
1927 + _end = _pos + arg_size - 1;
1929 + char* next() {
1930 + if (*_pos == '\0') {
1931 + // advance the iterator if possible (null arguments)
1932 + if (_pos < _end) {
1933 + _pos += 1;
1935 + return NULL;
1937 + char* res = _pos;
1938 + char* next_pos = strchr(_pos, '\0');
1939 + if (next_pos < _end) {
1940 + next_pos++;
1942 + _pos = next_pos;
1943 + return res;
1947 +// Calls from the door function to check that the client credentials
1948 +// match this process. Returns 0 if credentials okay, otherwise -1.
1949 +static int check_credentials() {
1950 + ucred_t *cred_info = NULL;
1951 + int ret = -1; // deny by default
1953 + // get client credentials
1954 + if (door_ucred(&cred_info) == -1) {
1955 + return -1; // unable to get them, deny
1958 + // get euid/egid from ucred_free
1959 + uid_t ucred_euid = ucred_geteuid(cred_info);
1960 + gid_t ucred_egid = ucred_getegid(cred_info);
1962 + // check that the effective uid/gid matches
1963 + if (os::Posix::matches_effective_uid_and_gid_or_root(ucred_euid, ucred_egid)) {
1964 + ret = 0; // allow
1967 + ucred_free(cred_info);
1968 + return ret;
1972 +// Parses the argument buffer to create an AttachOperation that we should
1973 +// enqueue to the attach listener.
1974 +// The buffer is expected to be formatted as follows:
1975 +// <ver>0<cmd>0<arg>0<arg>0<arg>0
1976 +// where <ver> is the version number (must be "1"), <cmd> is the command
1977 +// name ("load, "datadump", ...) and <arg> is an argument.
1979 +static SolarisAttachOperation* create_operation(char* argp, size_t arg_size, int* err) {
1980 + // assume bad request until parsed
1981 + *err = SolarisAttachListener::ATTACH_ERROR_BADREQUEST;
1983 + if (arg_size < 2 || argp[arg_size-1] != '\0') {
1984 + return NULL; // no ver or not null terminated
1987 + // Use supporting class to iterate over the buffer
1988 + ArgumentIterator args(argp, arg_size);
1990 + // First check the protocol version
1991 + char* ver = args.next();
1992 + if (ver == NULL) {
1993 + return NULL;
1995 + if (atoi(ver) != SolarisAttachListener::ATTACH_PROTOCOL_VER) {
1996 + *err = SolarisAttachListener::ATTACH_ERROR_BADVERSION;
1997 + return NULL;
2000 + // Get command name and create the operation
2001 + char* name = args.next();
2002 + if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
2003 + return NULL;
2005 + SolarisAttachOperation* op = new SolarisAttachOperation(name);
2007 + // Iterate over the arguments
2008 + for (int i=0; i<AttachOperation::arg_count_max; i++) {
2009 + char* arg = args.next();
2010 + if (arg == NULL) {
2011 + op->set_arg(i, NULL);
2012 + } else {
2013 + if (strlen(arg) > AttachOperation::arg_length_max) {
2014 + delete op;
2015 + return NULL;
2017 + op->set_arg(i, arg);
2021 + // return operation
2022 + *err = 0;
2023 + return op;
2026 +// This is door function which the client executes via a door_call.
2027 +extern "C" {
2028 + static void enqueue_proc(void* cookie, char* argp, size_t arg_size,
2029 + door_desc_t* dt, uint_t n_desc)
2031 + int return_fd = -1;
2032 + SolarisAttachOperation* op = NULL;
2034 + // wait up to 10 seconds for listener to be up and running
2035 + jint res = 0;
2036 + int sleep_count = 0;
2037 + while (!AttachListener::is_initialized()) {
2038 + sleep(1); // 1 second
2039 + sleep_count++;
2040 + if (sleep_count > 10) { // try for 10 seconds
2041 + debug_only(warning("door_call when not enabled"));
2042 + res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
2043 + break;
2047 + // check client credentials
2048 + if (res == 0) {
2049 + if (check_credentials() != 0) {
2050 + res = (jint)SolarisAttachListener::ATTACH_ERROR_DENIED;
2054 + // if we are stopped at ShowMessageBoxOnError then maybe we can
2055 + // load a diagnostic library
2056 + if (res == 0 && VMError::is_error_reported()) {
2057 + if (ShowMessageBoxOnError) {
2058 + // TBD - support loading of diagnostic library here
2061 + // can't enqueue operation after fatal error
2062 + res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
2065 + // create the operation
2066 + if (res == 0) {
2067 + int err;
2068 + op = create_operation(argp, arg_size, &err);
2069 + res = (op == NULL) ? (jint)err : 0;
2072 + // create a pair of connected sockets. Store the file descriptor
2073 + // for one end in the operation and enqueue the operation. The
2074 + // file descriptor for the other end wil be returned to the client.
2075 + if (res == 0) {
2076 + int s[2];
2077 + if (socketpair(PF_UNIX, SOCK_STREAM, 0, s) < 0) {
2078 + delete op;
2079 + res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
2080 + } else {
2081 + op->set_socket(s[0]);
2082 + return_fd = s[1];
2083 + SolarisAttachListener::enqueue(op);
2087 + // Return 0 (success) + file descriptor, or non-0 (error)
2088 + if (res == 0) {
2089 + door_desc_t desc;
2090 + // DOOR_RELEASE flag makes sure fd is closed after passing it to
2091 + // the client. See door_return(3DOOR) man page.
2092 + desc.d_attributes = DOOR_DESCRIPTOR | DOOR_RELEASE;
2093 + desc.d_data.d_desc.d_descriptor = return_fd;
2094 + door_return((char*)&res, sizeof(res), &desc, 1);
2095 + } else {
2096 + door_return((char*)&res, sizeof(res), NULL, 0);
2101 +// atexit hook to detach the door and remove the file
2102 +extern "C" {
2103 + static void listener_cleanup() {
2104 + int dd = SolarisAttachListener::door_descriptor();
2105 + if (dd >= 0) {
2106 + SolarisAttachListener::set_door_descriptor(-1);
2107 + ::close(dd);
2109 + if (SolarisAttachListener::has_door_path()) {
2110 + char* path = SolarisAttachListener::door_path();
2111 + ::fdetach(path);
2112 + ::unlink(path);
2113 + SolarisAttachListener::set_door_path(NULL);
2118 +// Create the door
2119 +int SolarisAttachListener::create_door() {
2120 + char door_path[PATH_MAX];
2121 + char initial_path[PATH_MAX];
2122 + int fd, res;
2124 + // register function to cleanup
2125 + if (!_atexit_registered) {
2126 + _atexit_registered = true;
2127 + ::atexit(listener_cleanup);
2130 + // create the door descriptor
2131 + int dd = ::door_create(enqueue_proc, NULL, 0);
2132 + if (dd < 0) {
2133 + return -1;
2136 + int n = snprintf(door_path, PATH_MAX, "%s/.java_pid%d",
2137 + os::get_temp_directory(), os::current_process_id());
2138 + if (n < (int)PATH_MAX) {
2139 + snprintf(initial_path, PATH_MAX+4, "%s.tmp", door_path);
2141 + if (n >= (int)PATH_MAX) {
2142 + return -1;
2144 + RESTARTABLE(::creat(initial_path, S_IRUSR | S_IWUSR), fd);
2145 + if (fd == -1) {
2146 + log_debug(attach)("attempt to create door file %s failed (%d)", initial_path, errno);
2147 + ::door_revoke(dd);
2148 + return -1;
2150 + assert(fd >= 0, "bad file descriptor");
2151 + ::close(fd);
2153 + // attach the door descriptor to the file
2154 + if ((res = ::fattach(dd, initial_path)) == -1) {
2155 + // if busy then detach and try again
2156 + if (errno == EBUSY) {
2157 + ::fdetach(initial_path);
2158 + res = ::fattach(dd, initial_path);
2160 + if (res == -1) {
2161 + log_debug(attach)("unable to create door - fattach failed (%d)", errno);
2162 + ::door_revoke(dd);
2163 + dd = -1;
2167 + // rename file so that clients can attach
2168 + if (dd >= 0) {
2169 + if (::rename(initial_path, door_path) == -1) {
2170 + ::close(dd);
2171 + ::fdetach(initial_path);
2172 + log_debug(attach)("unable to create door - rename %s to %s failed (%d)", initial_path, door_path, errno);
2173 + dd = -1;
2176 + if (dd >= 0) {
2177 + set_door_descriptor(dd);
2178 + set_door_path(door_path);
2179 + log_trace(attach)("door file %s created succesfully", door_path);
2180 + } else {
2181 + // unable to create door, attach it to file, or rename file into place
2182 + ::unlink(initial_path);
2183 + return -1;
2186 + return 0;
2189 +// Initialization - create the door, locks, and other initialization
2190 +int SolarisAttachListener::init() {
2191 + if (create_door()) {
2192 + return -1;
2195 + int status = pthread_mutex_init(&_mutex, NULL);
2196 + assert_status(status==0, status, "mutex_init");
2198 + status = ::sema_init(&_wakeup, 0, NULL, NULL);
2199 + assert_status(status==0, status, "sema_init");
2201 + set_head(NULL);
2202 + set_tail(NULL);
2204 + return 0;
2207 +// Dequeue an operation
2208 +SolarisAttachOperation* SolarisAttachListener::dequeue() {
2209 + for (;;) {
2210 + int res;
2212 + // wait for somebody to enqueue something
2213 + while ((res = ::sema_wait(wakeup())) == EINTR)
2215 + if (res) {
2216 + warning("sema_wait failed: %s", os::strerror(res));
2217 + return NULL;
2220 + // lock the list
2221 + res = pthread_mutex_lock(mutex());
2222 + assert(res == 0, "mutex_lock failed");
2224 + // remove the head of the list
2225 + SolarisAttachOperation* op = head();
2226 + if (op != NULL) {
2227 + set_head(op->next());
2228 + if (head() == NULL) {
2229 + set_tail(NULL);
2233 + // unlock
2234 + pthread_mutex_unlock(mutex());
2236 + // if we got an operation when return it.
2237 + if (op != NULL) {
2238 + return op;
2243 +// Enqueue an operation
2244 +void SolarisAttachListener::enqueue(SolarisAttachOperation* op) {
2245 + // lock list
2246 + int res = pthread_mutex_lock(mutex());
2247 + assert(res == 0, "mutex_lock failed");
2249 + // enqueue at tail
2250 + op->set_next(NULL);
2251 + if (head() == NULL) {
2252 + set_head(op);
2253 + } else {
2254 + tail()->set_next(op);
2256 + set_tail(op);
2258 + // wakeup the attach listener
2259 + RESTARTABLE(::sema_post(wakeup()), res);
2260 + assert(res == 0, "sema_post failed");
2262 + // unlock
2263 + pthread_mutex_unlock(mutex());
2267 +// support function - writes the (entire) buffer to a socket
2268 +static int write_fully(int s, char* buf, int len) {
2269 + do {
2270 + int n = ::write(s, buf, len);
2271 + if (n == -1) {
2272 + if (errno != EINTR) return -1;
2273 + } else {
2274 + buf += n;
2275 + len -= n;
2278 + while (len > 0);
2279 + return 0;
2282 +// Complete an operation by sending the operation result and any result
2283 +// output to the client. At this time the socket is in blocking mode so
2284 +// potentially we can block if there is a lot of data and the client is
2285 +// non-responsive. For most operations this is a non-issue because the
2286 +// default send buffer is sufficient to buffer everything. In the future
2287 +// if there are operations that involves a very big reply then it the
2288 +// socket could be made non-blocking and a timeout could be used.
2290 +void SolarisAttachOperation::complete(jint res, bufferedStream* st) {
2291 + if (this->socket() >= 0) {
2292 + JavaThread* thread = JavaThread::current();
2293 + ThreadBlockInVM tbivm(thread);
2295 + // write operation result
2296 + char msg[32];
2297 + sprintf(msg, "%d\n", res);
2298 + int rc = write_fully(this->socket(), msg, strlen(msg));
2300 + // write any result data
2301 + if (rc == 0) {
2302 + write_fully(this->socket(), (char*) st->base(), st->size());
2303 + ::shutdown(this->socket(), 2);
2306 + // done
2307 + ::close(this->socket());
2309 + delete this;
2313 +// AttachListener functions
2315 +AttachOperation* AttachListener::dequeue() {
2316 + JavaThread* thread = JavaThread::current();
2317 + ThreadBlockInVM tbivm(thread);
2319 + AttachOperation* op = SolarisAttachListener::dequeue();
2321 + return op;
2325 +// Performs initialization at vm startup
2326 +// For Solaris we remove any stale .java_pid file which could cause
2327 +// an attaching process to think we are ready to receive a door_call
2328 +// before we are properly initialized
2330 +void AttachListener::vm_start() {
2331 + char fn[PATH_MAX+1];
2332 + struct stat64 st;
2333 + int ret;
2335 + int n = snprintf(fn, sizeof(fn), "%s/.java_pid%d",
2336 + os::get_temp_directory(), os::current_process_id());
2337 + assert(n < sizeof(fn), "java_pid file name buffer overflow");
2339 + RESTARTABLE(::stat64(fn, &st), ret);
2340 + if (ret == 0) {
2341 + ret = ::unlink(fn);
2342 + if (ret == -1) {
2343 + log_debug(attach)("Failed to remove stale attach pid file at %s", fn);
2348 +int AttachListener::pd_init() {
2349 + JavaThread* thread = JavaThread::current();
2350 + ThreadBlockInVM tbivm(thread);
2352 + int ret_code = SolarisAttachListener::init();
2354 + return ret_code;
2357 +bool AttachListener::check_socket_file() {
2358 + int ret;
2359 + struct stat64 st;
2360 + ret = stat64(SolarisAttachListener::door_path(), &st);
2361 + if (ret == -1) { // need to restart attach listener.
2362 + log_debug(attach)("Door file %s does not exist - Restart Attach Listener",
2363 + SolarisAttachListener::door_path());
2365 + listener_cleanup();
2367 + // wait to terminate current attach listener instance...
2368 + while (AttachListener::transit_state(AL_INITIALIZING,
2369 + AL_NOT_INITIALIZED) != AL_NOT_INITIALIZED) {
2370 + os::naked_yield();
2372 + return is_init_trigger();
2374 + return false;
2377 +// Attach Listener is started lazily except in the case when
2378 +// +ReduseSignalUsage is used
2379 +bool AttachListener::init_at_startup() {
2380 + if (ReduceSignalUsage) {
2381 + return true;
2382 + } else {
2383 + return false;
2387 +// If the file .attach_pid<pid> exists in the working directory
2388 +// or /tmp then this is the trigger to start the attach mechanism
2389 +bool AttachListener::is_init_trigger() {
2390 + if (init_at_startup() || is_initialized()) {
2391 + return false; // initialized at startup or already initialized
2393 + char fn[PATH_MAX + 1];
2394 + int ret;
2395 + struct stat64 st;
2396 + sprintf(fn, ".attach_pid%d", os::current_process_id());
2397 + RESTARTABLE(::stat64(fn, &st), ret);
2398 + if (ret == -1) {
2399 + log_trace(attach)("Failed to find attach file: %s, trying alternate", fn);
2400 + snprintf(fn, sizeof(fn), "%s/.attach_pid%d",
2401 + os::get_temp_directory(), os::current_process_id());
2402 + RESTARTABLE(::stat64(fn, &st), ret);
2403 + if (ret == -1) {
2404 + log_debug(attach)("Failed to find attach file: %s", fn);
2407 + if (ret == 0) {
2408 + // simple check to avoid starting the attach mechanism when
2409 + // a bogus non-root user creates the file
2410 + if (os::Posix::matches_effective_uid_or_root(st.st_uid)) {
2411 + init();
2412 + log_trace(attach)("Attach triggered by %s", fn);
2413 + return true;
2414 + } else {
2415 + log_debug(attach)("File %s has wrong user id %d (vs %d). Attach is not triggered", fn, st.st_uid, geteuid());
2418 + return false;
2421 +// if VM aborts then remove listener
2422 +void AttachListener::abort() {
2423 + listener_cleanup();
2426 +void AttachListener::pd_data_dump() {
2427 + os::signal_notify(SIGQUIT);
2430 +static jint enable_dprobes(AttachOperation* op, outputStream* out) {
2431 + const char* probe = op->arg(0);
2432 + if (probe == NULL || probe[0] == '\0') {
2433 + out->print_cr("No probe specified");
2434 + return JNI_ERR;
2435 + } else {
2436 + char *end;
2437 + long val = strtol(probe, &end, 10);
2438 + if (end == probe || val < 0 || val > INT_MAX) {
2439 + out->print_cr("invalid probe type");
2440 + return JNI_ERR;
2441 + } else {
2442 + int probe_typess = (int) val;
2443 + DTrace::enable_dprobes(probe_typess);
2444 + return JNI_OK;
2449 +// platform specific operations table
2450 +static AttachOperationFunctionInfo funcs[] = {
2451 + { "enabledprobes", enable_dprobes },
2452 + { NULL, NULL }
2455 +void AttachListener::pd_detachall() {
2456 + DTrace::detach_all_clients();
2458 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/c1_globals_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/c1_globals_solaris.hpp
2459 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/c1_globals_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
2460 +++ jdk-jdk-24-11/src/hotspot/os/solaris/c1_globals_solaris.hpp 2024-08-17 20:36:14.281239251 +0200
2461 @@ -0,0 +1,36 @@
2463 + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2464 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2466 + * This code is free software; you can redistribute it and/or modify it
2467 + * under the terms of the GNU General Public License version 2 only, as
2468 + * published by the Free Software Foundation.
2470 + * This code is distributed in the hope that it will be useful, but WITHOUT
2471 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2472 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2473 + * version 2 for more details (a copy is included in the LICENSE file that
2474 + * accompanied this code).
2476 + * You should have received a copy of the GNU General Public License version
2477 + * 2 along with this work; if not, write to the Free Software Foundation,
2478 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2480 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2481 + * or visit www.oracle.com if you need additional information or have any
2482 + * questions.
2484 + */
2486 +#ifndef OS_SOLARIS_C1_GLOBALS_SOLARIS_HPP
2487 +#define OS_SOLARIS_C1_GLOBALS_SOLARIS_HPP
2489 +#include "utilities/globalDefinitions.hpp"
2490 +#include "utilities/macros.hpp"
2493 +// Sets the default values for operating system dependent flags used by the
2494 +// client compiler. (see c1_globals.hpp)
2497 +#endif // OS_SOLARIS_C1_GLOBALS_SOLARIS_HPP
2498 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/c2_globals_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/c2_globals_solaris.hpp
2499 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/c2_globals_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
2500 +++ jdk-jdk-24-11/src/hotspot/os/solaris/c2_globals_solaris.hpp 2024-08-17 20:36:14.281494122 +0200
2501 @@ -0,0 +1,36 @@
2503 + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2504 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2506 + * This code is free software; you can redistribute it and/or modify it
2507 + * under the terms of the GNU General Public License version 2 only, as
2508 + * published by the Free Software Foundation.
2510 + * This code is distributed in the hope that it will be useful, but WITHOUT
2511 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2512 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2513 + * version 2 for more details (a copy is included in the LICENSE file that
2514 + * accompanied this code).
2516 + * You should have received a copy of the GNU General Public License version
2517 + * 2 along with this work; if not, write to the Free Software Foundation,
2518 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2520 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2521 + * or visit www.oracle.com if you need additional information or have any
2522 + * questions.
2524 + */
2526 +#ifndef OS_SOLARIS_C2_GLOBALS_SOLARIS_HPP
2527 +#define OS_SOLARIS_C2_GLOBALS_SOLARIS_HPP
2529 +#include "utilities/globalDefinitions.hpp"
2530 +#include "utilities/macros.hpp"
2533 +// Sets the default values for operating system dependent flags used by the
2534 +// server compiler. (see c2_globals.hpp)
2537 +#endif // OS_SOLARIS_C2_GLOBALS_SOLARIS_HPP
2538 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/decoder_solaris.cpp jdk-jdk-24-11/src/hotspot/os/solaris/decoder_solaris.cpp
2539 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/decoder_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
2540 +++ jdk-jdk-24-11/src/hotspot/os/solaris/decoder_solaris.cpp 2024-08-17 20:36:14.281757467 +0200
2541 @@ -0,0 +1,32 @@
2543 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
2544 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2546 + * This code is free software; you can redistribute it and/or modify it
2547 + * under the terms of the GNU General Public License version 2 only, as
2548 + * published by the Free Software Foundation.
2550 + * This code is distributed in the hope that it will be useful, but WITHOUT
2551 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2552 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2553 + * version 2 for more details (a copy is included in the LICENSE file that
2554 + * accompanied this code).
2556 + * You should have received a copy of the GNU General Public License version
2557 + * 2 along with this work; if not, write to the Free Software Foundation,
2558 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2560 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2561 + * or visit www.oracle.com if you need additional information or have any
2562 + * questions.
2564 + */
2566 +#include "utilities/decoder_elf.hpp"
2568 +#include <demangle.h>
2570 +bool ElfDecoder::demangle(const char* symbol, char *buf, int buflen) {
2571 + return !cplus_demangle(symbol, buf, (size_t)buflen);
2574 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/dtrace/jhelper.d jdk-jdk-24-11/src/hotspot/os/solaris/dtrace/jhelper.d
2575 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/dtrace/jhelper.d 1970-01-01 01:00:00.000000000 +0100
2576 +++ jdk-jdk-24-11/src/hotspot/os/solaris/dtrace/jhelper.d 2024-08-17 20:36:14.282282042 +0200
2577 @@ -0,0 +1,540 @@
2579 + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2580 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2582 + * This code is free software; you can redistribute it and/or modify it
2583 + * under the terms of the GNU General Public License version 2 only, as
2584 + * published by the Free Software Foundation.
2586 + * This code is distributed in the hope that it will be useful, but WITHOUT
2587 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2588 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2589 + * version 2 for more details (a copy is included in the LICENSE file that
2590 + * accompanied this code).
2592 + * You should have received a copy of the GNU General Public License version
2593 + * 2 along with this work; if not, write to the Free Software Foundation,
2594 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2596 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2597 + * or visit www.oracle.com if you need additional information or have any
2598 + * questions.
2600 + */
2602 +/* This file is auto-generated */
2603 +#include "JvmOffsetsIndex.h"
2605 +#define DEBUG
2607 +#ifdef DEBUG
2608 +#define MARK_LINE this->line = __LINE__
2609 +#else
2610 +#define MARK_LINE
2611 +#endif
2613 +#ifdef _LP64
2614 +#define STACK_BIAS 0x7ff
2615 +#define pointer uint64_t
2616 +#else
2617 +#define STACK_BIAS 0
2618 +#define pointer uint32_t
2619 +#endif
2621 +extern pointer __JvmOffsets;
2623 +/* GrowableArray<CodeHeaps*>* */
2624 +extern pointer __1cJCodeCacheG_heaps_;
2626 +extern pointer __1cIUniverseO_collectedHeap_;
2628 +extern pointer __1cHnmethodG__vtbl_;
2629 +extern pointer __1cGMethodG__vtbl_;
2630 +extern pointer __1cKBufferBlobG__vtbl_;
2632 +#define copyin_ptr(ADDR) *(pointer*) copyin((pointer) (ADDR), sizeof(pointer))
2633 +#define copyin_uchar(ADDR) *(uchar_t*) copyin((pointer) (ADDR), sizeof(uchar_t))
2634 +#define copyin_uint16(ADDR) *(uint16_t*) copyin((pointer) (ADDR), sizeof(uint16_t))
2635 +#define copyin_uint32(ADDR) *(uint32_t*) copyin((pointer) (ADDR), sizeof(uint32_t))
2636 +#define copyin_int32(ADDR) *(int32_t*) copyin((pointer) (ADDR), sizeof(int32_t))
2637 +#define copyin_uint8(ADDR) *(uint8_t*) copyin((pointer) (ADDR), sizeof(uint8_t))
2639 +#define copyin_offset(JVM_CONST) JVM_CONST = \
2640 + copyin_int32(JvmOffsetsPtr + IDX_##JVM_CONST * sizeof(int32_t))
2642 +int init_done;
2644 +dtrace:helper:ustack:
2646 + MARK_LINE;
2647 + this->done = 0;
2648 + /*
2649 + * TBD:
2650 + * Here we initialize init_done, otherwise jhelper does not work.
2651 + * Therefore, copyin_offset() statements work multiple times now.
2652 + * There is a hope we could avoid it in the future, and so,
2653 + * this initialization can be removed.
2654 + */
2655 + init_done = 0;
2656 + this->error = (char *) NULL;
2657 + this->result = (char *) NULL;
2658 + this->isMethod = 0;
2659 + this->codecache = 0;
2660 + this->klass = (pointer) NULL;
2661 + this->vtbl = (pointer) NULL;
2662 + this->suffix = '\0';
2665 +dtrace:helper:ustack:
2667 + MARK_LINE;
2668 + /* Initialization of JvmOffsets constants */
2669 + JvmOffsetsPtr = (pointer) &``__JvmOffsets;
2672 +dtrace:helper:ustack:
2673 +/!init_done && !this->done/
2675 + MARK_LINE;
2677 + copyin_offset(POINTER_SIZE);
2678 + copyin_offset(COMPILER);
2679 + copyin_offset(OFFSET_CollectedHeap_reserved);
2680 + copyin_offset(OFFSET_MemRegion_start);
2681 + copyin_offset(OFFSET_MemRegion_word_size);
2682 + copyin_offset(SIZE_HeapWord);
2684 + copyin_offset(OFFSET_interpreter_frame_method);
2685 + copyin_offset(OFFSET_Klass_name);
2686 + copyin_offset(OFFSET_ConstantPool_pool_holder);
2688 + copyin_offset(OFFSET_HeapBlockHeader_used);
2689 + copyin_offset(OFFSET_oopDesc_metadata);
2691 + copyin_offset(OFFSET_Symbol_length);
2692 + copyin_offset(OFFSET_Symbol_body);
2694 + copyin_offset(OFFSET_Method_constMethod);
2695 + copyin_offset(OFFSET_ConstMethod_constants);
2696 + copyin_offset(OFFSET_ConstMethod_name_index);
2697 + copyin_offset(OFFSET_ConstMethod_signature_index);
2699 + copyin_offset(OFFSET_CodeHeap_memory);
2700 + copyin_offset(OFFSET_CodeHeap_segmap);
2701 + copyin_offset(OFFSET_CodeHeap_log2_segment_size);
2703 + copyin_offset(OFFSET_GrowableArray_CodeHeap_data);
2704 + copyin_offset(OFFSET_GrowableArray_CodeHeap_len);
2706 + copyin_offset(OFFSET_VirtualSpace_low);
2707 + copyin_offset(OFFSET_VirtualSpace_high);
2709 + copyin_offset(OFFSET_CodeBlob_name);
2711 + copyin_offset(OFFSET_nmethod_method);
2712 + copyin_offset(SIZE_HeapBlockHeader);
2713 + copyin_offset(SIZE_oopDesc);
2714 + copyin_offset(SIZE_ConstantPool);
2716 + copyin_offset(OFFSET_NarrowPtrStruct_base);
2717 + copyin_offset(OFFSET_NarrowPtrStruct_shift);
2719 + /*
2720 + * The PC to translate is in arg0.
2721 + */
2722 + this->pc = arg0;
2724 +#if defined(__i386) || defined(__amd64)
2725 + this->methodPtr = copyin_ptr(arg1 + OFFSET_interpreter_frame_method);
2726 +#else
2727 +#error "Don't know architecture"
2728 +#endif
2730 + /* Read address of GrowableArray<CodeHeaps*> */
2731 + // this->code_heaps_address = copyin_ptr(&``__1cJCodeCacheG_heaps_);
2732 + this->code_heaps_address = * ( uint64_t * ) copyin ( ( uint64_t ) ( &``__1cJCodeCacheG_heaps_ ) , sizeof ( uint64_t ) );
2734 + /* Read address of _data array field in GrowableArray */
2735 + this->code_heaps_array_address = copyin_ptr(this->code_heaps_address + OFFSET_GrowableArray_CodeHeap_data);
2736 + this->number_of_heaps = copyin_uint32(this->code_heaps_address + OFFSET_GrowableArray_CodeHeap_len);
2738 + this->Method_vtbl = (pointer) &``__1cGMethodG__vtbl_;
2740 + /*
2741 + * Get Java heap bounds
2742 + */
2743 + // this->Universe_collectedHeap = copyin_ptr(&``__1cIUniverseO_collectedHeap_);
2744 + this->Universe_collectedHeap = * ( uint64_t * ) copyin ( ( uint64_t ) ( &``__1cIUniverseO_collectedHeap_ ) , sizeof ( uint64_t ) );
2746 + this->heap_start = copyin_ptr(this->Universe_collectedHeap +
2747 + OFFSET_CollectedHeap_reserved +
2748 + OFFSET_MemRegion_start);
2749 + this->heap_size = SIZE_HeapWord *
2750 + copyin_ptr(this->Universe_collectedHeap +
2751 + OFFSET_CollectedHeap_reserved +
2752 + OFFSET_MemRegion_word_size
2753 + );
2754 + this->heap_end = this->heap_start + this->heap_size;
2758 + * IMPORTANT: At the moment the ustack helper supports up to 5 code heaps in
2759 + * the code cache. If more code heaps are added the following probes have to
2760 + * be extended. This is done by simply adding a probe to get the heap bounds
2761 + * and another probe to set the code heap address of the newly created heap.
2762 + */
2765 + * ----- BEGIN: Get bounds of code heaps -----
2766 + */
2767 +dtrace:helper:ustack:
2768 +/init_done < 1 && this->number_of_heaps >= 1 && !this->done/
2770 + MARK_LINE;
2771 + /* CodeHeap 1 */
2772 + init_done = 1;
2773 + this->code_heap1_address = copyin_ptr(this->code_heaps_array_address);
2774 + this->code_heap1_low = copyin_ptr(this->code_heap1_address +
2775 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2776 + this->code_heap1_high = copyin_ptr(this->code_heap1_address +
2777 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
2780 +dtrace:helper:ustack:
2781 +/init_done < 2 && this->number_of_heaps >= 2 && !this->done/
2783 + MARK_LINE;
2784 + /* CodeHeap 2 */
2785 + init_done = 2;
2786 + this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
2787 + this->code_heap2_address = copyin_ptr(this->code_heaps_array_address);
2788 + this->code_heap2_low = copyin_ptr(this->code_heap2_address +
2789 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2790 + this->code_heap2_high = copyin_ptr(this->code_heap2_address +
2791 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
2794 +dtrace:helper:ustack:
2795 +/init_done < 3 && this->number_of_heaps >= 3 && !this->done/
2797 + /* CodeHeap 3 */
2798 + init_done = 3;
2799 + this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
2800 + this->code_heap3_address = copyin_ptr(this->code_heaps_array_address);
2801 + this->code_heap3_low = copyin_ptr(this->code_heap3_address +
2802 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2803 + this->code_heap3_high = copyin_ptr(this->code_heap3_address +
2804 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
2807 +dtrace:helper:ustack:
2808 +/init_done < 4 && this->number_of_heaps >= 4 && !this->done/
2810 + /* CodeHeap 4 */
2811 + init_done = 4;
2812 + this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
2813 + this->code_heap4_address = copyin_ptr(this->code_heaps_array_address);
2814 + this->code_heap4_low = copyin_ptr(this->code_heap4_address +
2815 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2816 + this->code_heap4_high = copyin_ptr(this->code_heap4_address +
2817 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
2820 +dtrace:helper:ustack:
2821 +/init_done < 5 && this->number_of_heaps >= 5 && !this->done/
2823 + /* CodeHeap 5 */
2824 + init_done = 5;
2825 + this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
2826 + this->code_heap5_address = copyin_ptr(this->code_heaps_array_address);
2827 + this->code_heap5_low = copyin_ptr(this->code_heap5_address +
2828 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2829 + this->code_heap5_high = copyin_ptr(this->code_heap5_address +
2830 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
2833 + * ----- END: Get bounds of code heaps -----
2834 + */
2837 + * ----- BEGIN: Get address of the code heap pc points to -----
2838 + */
2839 +dtrace:helper:ustack:
2840 +/!this->done && this->number_of_heaps >= 1 && this->code_heap1_low <= this->pc && this->pc < this->code_heap1_high/
2842 + MARK_LINE;
2843 + this->codecache = 1;
2844 + this->code_heap_address = this->code_heap1_address;
2847 +dtrace:helper:ustack:
2848 +/!this->done && this->number_of_heaps >= 2 && this->code_heap2_low <= this->pc && this->pc < this->code_heap2_high/
2850 + MARK_LINE;
2851 + this->codecache = 1;
2852 + this->code_heap_address = this->code_heap2_address;
2855 +dtrace:helper:ustack:
2856 +/!this->done && this->number_of_heaps >= 3 && this->code_heap3_low <= this->pc && this->pc < this->code_heap3_high/
2858 + MARK_LINE;
2859 + this->codecache = 1;
2860 + this->code_heap_address = this->code_heap3_address;
2863 +dtrace:helper:ustack:
2864 +/!this->done && this->number_of_heaps >= 4 && this->code_heap4_low <= this->pc && this->pc < this->code_heap4_high/
2866 + MARK_LINE;
2867 + this->codecache = 1;
2868 + this->code_heap_address = this->code_heap4_address;
2871 +dtrace:helper:ustack:
2872 +/!this->done && this->number_of_heaps >= 5 && this->code_heap5_low <= this->pc && this->pc < this->code_heap5_high/
2874 + MARK_LINE;
2875 + this->codecache = 1;
2876 + this->code_heap_address = this->code_heap5_address;
2879 + * ----- END: Get address of the code heap pc points to -----
2880 + */
2882 +dtrace:helper:ustack:
2883 +/!this->done && this->codecache/
2885 + MARK_LINE;
2886 + /*
2887 + * Get code heap configuration
2888 + */
2889 + this->code_heap_low = copyin_ptr(this->code_heap_address +
2890 + OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
2891 + this->code_heap_segmap_low = copyin_ptr(this->code_heap_address +
2892 + OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_low);
2893 + this->code_heap_log2_segment_size = copyin_uint32(
2894 + this->code_heap_address + OFFSET_CodeHeap_log2_segment_size);
2896 + /*
2897 + * Find start
2898 + */
2899 + this->segment = (this->pc - this->code_heap_low) >>
2900 + this->code_heap_log2_segment_size;
2901 + this->block = this->code_heap_segmap_low;
2902 + this->tag = copyin_uchar(this->block + this->segment);
2905 +dtrace:helper:ustack:
2906 +/!this->done && this->codecache && this->tag > 0/
2908 + MARK_LINE;
2909 + this->tag = copyin_uchar(this->block + this->segment);
2910 + this->segment = this->segment - this->tag;
2913 +dtrace:helper:ustack:
2914 +/!this->done && this->codecache && this->tag > 0/
2916 + MARK_LINE;
2917 + this->tag = copyin_uchar(this->block + this->segment);
2918 + this->segment = this->segment - this->tag;
2921 +dtrace:helper:ustack:
2922 +/!this->done && this->codecache && this->tag > 0/
2924 + MARK_LINE;
2925 + this->tag = copyin_uchar(this->block + this->segment);
2926 + this->segment = this->segment - this->tag;
2929 +dtrace:helper:ustack:
2930 +/!this->done && this->codecache && this->tag > 0/
2932 + MARK_LINE;
2933 + this->tag = copyin_uchar(this->block + this->segment);
2934 + this->segment = this->segment - this->tag;
2937 +dtrace:helper:ustack:
2938 +/!this->done && this->codecache && this->tag > 0/
2940 + MARK_LINE;
2941 + this->tag = copyin_uchar(this->block + this->segment);
2942 + this->segment = this->segment - this->tag;
2945 +dtrace:helper:ustack:
2946 +/!this->done && this->codecache && this->tag > 0/
2948 + MARK_LINE;
2949 + this->error = "<couldn't find start>";
2950 + this->done = 1;
2953 +dtrace:helper:ustack:
2954 +/!this->done && this->codecache/
2956 + MARK_LINE;
2957 + this->block = this->code_heap_low +
2958 + (this->segment << this->code_heap_log2_segment_size);
2959 + this->used = copyin_uint32(this->block + OFFSET_HeapBlockHeader_used);
2962 +dtrace:helper:ustack:
2963 +/!this->done && this->codecache && !this->used/
2965 + MARK_LINE;
2966 + this->error = "<block not in use>";
2967 + this->done = 1;
2970 +dtrace:helper:ustack:
2971 +/!this->done && this->codecache/
2973 + MARK_LINE;
2974 + this->start = this->block + SIZE_HeapBlockHeader;
2975 + this->vtbl = copyin_ptr(this->start);
2977 + this->nmethod_vtbl = (pointer) &``__1cHnmethodG__vtbl_;
2978 + this->BufferBlob_vtbl = (pointer) &``__1cKBufferBlobG__vtbl_;
2981 +dtrace:helper:ustack:
2982 +/!this->done && this->vtbl == this->nmethod_vtbl/
2984 + MARK_LINE;
2985 + this->methodPtr = copyin_ptr(this->start + OFFSET_nmethod_method);
2986 + this->suffix = '*';
2987 + this->isMethod = 1;
2990 +dtrace:helper:ustack:
2991 +/!this->done && this->vtbl == this->BufferBlob_vtbl/
2993 + MARK_LINE;
2994 + this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name);
2998 +dtrace:helper:ustack:
2999 +/!this->done && this->vtbl == this->BufferBlob_vtbl && this->methodPtr != 0/
3001 + MARK_LINE;
3002 + this->klass = copyin_ptr(this->methodPtr);
3003 + this->isMethod = this->klass == this->Method_vtbl;
3004 + this->done = !this->isMethod;
3007 +dtrace:helper:ustack:
3008 +/!this->done && !this->isMethod/
3010 + MARK_LINE;
3011 + this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name);
3012 + this->result = this->name != 0 ? copyinstr(this->name) : "<CodeBlob>";
3013 + this->done = 1;
3016 +dtrace:helper:ustack:
3017 +/!this->done && this->isMethod/
3019 + MARK_LINE;
3020 + this->constMethod = copyin_ptr(this->methodPtr +
3021 + OFFSET_Method_constMethod);
3023 + this->nameIndex = copyin_uint16(this->constMethod +
3024 + OFFSET_ConstMethod_name_index);
3026 + this->signatureIndex = copyin_uint16(this->constMethod +
3027 + OFFSET_ConstMethod_signature_index);
3029 + this->constantPool = copyin_ptr(this->constMethod +
3030 + OFFSET_ConstMethod_constants);
3032 + this->nameSymbol = copyin_ptr(this->constantPool +
3033 + this->nameIndex * sizeof (pointer) + SIZE_ConstantPool);
3034 + /* The symbol is a CPSlot and has lower bit set to indicate metadata */
3035 + this->nameSymbol &= (~1); /* remove metadata lsb */
3037 + this->nameSymbolLength = copyin_uint16(this->nameSymbol +
3038 + OFFSET_Symbol_length);
3040 + this->signatureSymbol = copyin_ptr(this->constantPool +
3041 + this->signatureIndex * sizeof (pointer) + SIZE_ConstantPool);
3042 + this->signatureSymbol &= (~1); /* remove metadata lsb */
3044 + this->signatureSymbolLength = copyin_uint16(this->signatureSymbol +
3045 + OFFSET_Symbol_length);
3047 + this->klassPtr = copyin_ptr(this->constantPool +
3048 + OFFSET_ConstantPool_pool_holder);
3050 + this->klassSymbol = copyin_ptr(this->klassPtr +
3051 + OFFSET_Klass_name);
3053 + this->klassSymbolLength = copyin_uint16(this->klassSymbol +
3054 + OFFSET_Symbol_length);
3056 + /*
3057 + * Enough for three strings, plus the '.', plus the trailing '\0'.
3058 + */
3059 + this->result = (char *) alloca(this->klassSymbolLength +
3060 + this->nameSymbolLength +
3061 + this->signatureSymbolLength + 2 + 1);
3063 + copyinto(this->klassSymbol + OFFSET_Symbol_body,
3064 + this->klassSymbolLength, this->result);
3066 + /*
3067 + * Add the '.' between the class and the name.
3068 + */
3069 + this->result[this->klassSymbolLength] = '.';
3071 + copyinto(this->nameSymbol + OFFSET_Symbol_body,
3072 + this->nameSymbolLength,
3073 + this->result + this->klassSymbolLength + 1);
3075 + copyinto(this->signatureSymbol + OFFSET_Symbol_body,
3076 + this->signatureSymbolLength,
3077 + this->result + this->klassSymbolLength +
3078 + this->nameSymbolLength + 1);
3080 + /*
3081 + * Now we need to add a trailing '\0' and possibly a tag character.
3082 + */
3083 + this->result[this->klassSymbolLength + 1 +
3084 + this->nameSymbolLength +
3085 + this->signatureSymbolLength] = this->suffix;
3086 + this->result[this->klassSymbolLength + 2 +
3087 + this->nameSymbolLength +
3088 + this->signatureSymbolLength] = '\0';
3090 + this->done = 1;
3093 +dtrace:helper:ustack:
3094 +/this->done && this->error == (char *) NULL/
3096 + this->result;
3099 +dtrace:helper:ustack:
3100 +/this->done && this->error != (char *) NULL/
3102 + this->error;
3105 +dtrace:helper:ustack:
3106 +/!this->done && this->codecache/
3108 + this->done = 1;
3109 + "error";
3113 +dtrace:helper:ustack:
3114 +/!this->done/
3116 + NULL;
3118 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/globals_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/globals_solaris.hpp
3119 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/globals_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
3120 +++ jdk-jdk-24-11/src/hotspot/os/solaris/globals_solaris.hpp 2024-08-17 20:36:14.282937525 +0200
3121 @@ -0,0 +1,48 @@
3123 + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
3124 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3126 + * This code is free software; you can redistribute it and/or modify it
3127 + * under the terms of the GNU General Public License version 2 only, as
3128 + * published by the Free Software Foundation.
3130 + * This code is distributed in the hope that it will be useful, but WITHOUT
3131 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3132 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3133 + * version 2 for more details (a copy is included in the LICENSE file that
3134 + * accompanied this code).
3136 + * You should have received a copy of the GNU General Public License version
3137 + * 2 along with this work; if not, write to the Free Software Foundation,
3138 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3140 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3141 + * or visit www.oracle.com if you need additional information or have any
3142 + * questions.
3144 + */
3146 +#ifndef OS_SOLARIS_GLOBALS_SOLARIS_HPP
3147 +#define OS_SOLARIS_GLOBALS_SOLARIS_HPP
3150 +// Defines Solaris specific flags. They are not available on other platforms.
3152 +#define RUNTIME_OS_FLAGS(develop, \
3153 + develop_pd, \
3154 + product, \
3155 + product_pd, \
3156 + range, \
3157 + constraint)
3160 +// Defines Solaris-specific default values. The flags are available on all
3161 +// platforms, but they may have different default values on other platforms.
3163 +define_pd_global(size_t, PreTouchParallelChunkSize, 1 * G);
3164 +define_pd_global(bool, UseLargePages, true);
3165 +define_pd_global(bool, UseLargePagesIndividualAllocation, false);
3166 +define_pd_global(bool, UseOSErrorReporting, false);
3167 +define_pd_global(bool, UseThreadPriorities, false);
3169 +#endif // OS_SOLARIS_GLOBALS_SOLARIS_HPP
3170 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_perf_solaris.cpp jdk-jdk-24-11/src/hotspot/os/solaris/os_perf_solaris.cpp
3171 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_perf_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
3172 +++ jdk-jdk-24-11/src/hotspot/os/solaris/os_perf_solaris.cpp 2024-08-17 20:36:14.284083740 +0200
3173 @@ -0,0 +1,808 @@
3175 + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3176 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3178 + * This code is free software; you can redistribute it and/or modify it
3179 + * under the terms of the GNU General Public License version 2 only, as
3180 + * published by the Free Software Foundation.
3182 + * This code is distributed in the hope that it will be useful, but WITHOUT
3183 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3184 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3185 + * version 2 for more details (a copy is included in the LICENSE file that
3186 + * accompanied this code).
3188 + * You should have received a copy of the GNU General Public License version
3189 + * 2 along with this work; if not, write to the Free Software Foundation,
3190 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3192 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3193 + * or visit www.oracle.com if you need additional information or have any
3194 + * questions.
3196 + */
3198 +#include "precompiled.hpp"
3199 +#include "jvm.h"
3200 +#include "memory/allocation.inline.hpp"
3201 +#include "runtime/os.hpp"
3202 +#include "runtime/os_perf.hpp"
3203 +#include "runtime/vm_version.hpp"
3204 +#include "os_solaris.inline.hpp"
3205 +#include "utilities/globalDefinitions.hpp"
3206 +#include "utilities/macros.hpp"
3208 +#include <sys/types.h>
3209 +#include <procfs.h>
3210 +#include <dirent.h>
3211 +#include <errno.h>
3212 +#include <stdio.h>
3213 +#include <stdlib.h>
3214 +#include <strings.h>
3215 +#include <unistd.h>
3216 +#include <fcntl.h>
3217 +#include <kstat.h>
3218 +#include <unistd.h>
3219 +#include <string.h>
3220 +#include <sys/sysinfo.h>
3221 +#include <sys/lwp.h>
3222 +#include <pthread.h>
3223 +#include <time.h>
3224 +#include <utmpx.h>
3225 +#include <dlfcn.h>
3226 +#include <sys/loadavg.h>
3227 +#include <limits.h>
3229 +static const double NANOS_PER_SEC = 1000000000.0;
3231 +struct CPUPerfTicks {
3232 + kstat_t* kstat;
3233 + uint64_t last_idle;
3234 + uint64_t last_total;
3235 + double last_ratio;
3238 +struct CPUPerfCounters {
3239 + int nProcs;
3240 + CPUPerfTicks* jvmTicks;
3241 + kstat_ctl_t* kstat_ctrl;
3244 +static int get_info(const char* path, void* info, size_t s, off_t o) {
3245 + assert(path != NULL, "path is NULL!");
3246 + assert(info != NULL, "info is NULL!");
3248 + int fd = -1;
3250 + if ((fd = os::open(path, O_RDONLY, 0)) < 0) {
3251 + return OS_ERR;
3253 + if (pread(fd, info, s, o) != s) {
3254 + close(fd);
3255 + return OS_ERR;
3257 + close(fd);
3258 + return OS_OK;
3261 +static int get_psinfo2(void* info, size_t s, off_t o) {
3262 + return get_info("/proc/self/psinfo", info, s, o);
3265 +static int get_psinfo(psinfo_t* info) {
3266 + return get_psinfo2(info, sizeof(*info), 0);
3269 +static int read_cpustat(kstat_ctl_t* kstat_ctrl, CPUPerfTicks* load, cpu_stat_t* cpu_stat) {
3270 + assert(kstat_ctrl != NULL, "kstat_ctrl pointer is NULL!");
3271 + assert(load != NULL, "load pointer is NULL!");
3272 + assert(cpu_stat != NULL, "cpu_stat pointer is NULL!");
3274 + if (load->kstat == NULL) {
3275 + // no handle.
3276 + return OS_ERR;
3278 + if (kstat_read(kstat_ctrl, load->kstat, cpu_stat) == OS_ERR) {
3279 + // disable handle for this CPU
3280 + load->kstat = NULL;
3281 + return OS_ERR;
3283 + return OS_OK;
3286 +static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters) {
3287 + assert(counters != NULL, "counters pointer is NULL!");
3289 + cpu_stat_t cpu_stat = {0};
3291 + if (which_logical_cpu >= counters->nProcs) {
3292 + return .0;
3295 + CPUPerfTicks load = counters->jvmTicks[which_logical_cpu];
3296 + if (read_cpustat(counters->kstat_ctrl, &load, &cpu_stat) != OS_OK) {
3297 + return .0;
3300 + uint_t* usage = cpu_stat.cpu_sysinfo.cpu;
3301 + if (usage == NULL) {
3302 + return .0;
3305 + uint64_t c_idle = usage[CPU_IDLE];
3306 + uint64_t c_total = 0;
3308 + for (int i = 0; i < CPU_STATES; i++) {
3309 + c_total += usage[i];
3312 + // Calculate diff against previous snapshot
3313 + uint64_t d_idle = c_idle - load.last_idle;
3314 + uint64_t d_total = c_total - load.last_total;
3316 + /** update if weve moved */
3317 + if (d_total > 0) {
3318 + // Save current values for next time around
3319 + load.last_idle = c_idle;
3320 + load.last_total = c_total;
3321 + load.last_ratio = (double) (d_total - d_idle) / d_total;
3324 + return load.last_ratio;
3327 +static int get_boot_time(uint64_t* time) {
3328 + assert(time != NULL, "time pointer is NULL!");
3329 + setutxent();
3330 + for(;;) {
3331 + struct utmpx* u;
3332 + if ((u = getutxent()) == NULL) {
3333 + break;
3335 + if (u->ut_type == BOOT_TIME) {
3336 + *time = u->ut_xtime;
3337 + endutxent();
3338 + return OS_OK;
3341 + endutxent();
3342 + return OS_ERR;
3345 +static int get_noof_context_switches(CPUPerfCounters* counters, uint64_t* switches) {
3346 + assert(switches != NULL, "switches pointer is NULL!");
3347 + assert(counters != NULL, "counter pointer is NULL!");
3348 + *switches = 0;
3349 + uint64_t s = 0;
3351 + // Collect data from all CPUs
3352 + for (int i = 0; i < counters->nProcs; i++) {
3353 + cpu_stat_t cpu_stat = {0};
3354 + CPUPerfTicks load = counters->jvmTicks[i];
3356 + if (read_cpustat(counters->kstat_ctrl, &load, &cpu_stat) == OS_OK) {
3357 + s += cpu_stat.cpu_sysinfo.pswitch;
3358 + } else {
3359 + //fail fast...
3360 + return OS_ERR;
3363 + *switches = s;
3364 + return OS_OK;
3367 +static int perf_context_switch_rate(CPUPerfCounters* counters, double* rate) {
3368 + assert(counters != NULL, "counters is NULL!");
3369 + assert(rate != NULL, "rate pointer is NULL!");
3370 + static pthread_mutex_t contextSwitchLock = PTHREAD_MUTEX_INITIALIZER;
3371 + static uint64_t lastTime = 0;
3372 + static uint64_t lastSwitches = 0;
3373 + static double lastRate = 0.0;
3375 + uint64_t lt = 0;
3376 + int res = 0;
3378 + if (lastTime == 0) {
3379 + uint64_t tmp;
3380 + if (get_boot_time(&tmp) < 0) {
3381 + return OS_ERR;
3383 + lt = tmp * 1000;
3386 + res = OS_OK;
3388 + pthread_mutex_lock(&contextSwitchLock);
3391 + uint64_t sw = 0;
3392 + clock_t t, d;
3394 + if (lastTime == 0) {
3395 + lastTime = lt;
3398 + t = clock();
3399 + d = t - lastTime;
3401 + if (d == 0) {
3402 + *rate = lastRate;
3403 + } else if (get_noof_context_switches(counters, &sw)== OS_OK) {
3404 + *rate = ((double)(sw - lastSwitches) / d) * 1000;
3405 + lastRate = *rate;
3406 + lastSwitches = sw;
3407 + lastTime = t;
3408 + } else {
3409 + *rate = 0.0;
3410 + res = OS_ERR;
3412 + if (*rate < 0.0) {
3413 + *rate = 0.0;
3414 + lastRate = 0.0;
3417 + pthread_mutex_unlock(&contextSwitchLock);
3418 + return res;
3423 +class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
3424 + friend class CPUPerformanceInterface;
3425 + private:
3426 + CPUPerfCounters _counters;
3427 + int cpu_load(int which_logical_cpu, double* cpu_load);
3428 + int context_switch_rate(double* rate);
3429 + int cpu_load_total_process(double* cpu_load);
3430 + int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad);
3432 + CPUPerformance();
3433 + ~CPUPerformance();
3434 + bool initialize();
3437 +CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
3438 + _counters.nProcs = 0;
3439 + _counters.jvmTicks = NULL;
3440 + _counters.kstat_ctrl = NULL;
3443 +bool CPUPerformanceInterface::CPUPerformance::initialize() {
3444 + // initialize kstat control structure,
3445 + _counters.kstat_ctrl = kstat_open();
3446 + assert(_counters.kstat_ctrl != NULL, "error initializing kstat control structure!");
3448 + if (NULL == _counters.kstat_ctrl) {
3449 + return false;
3452 + // Get number of CPU(s)
3453 + if ((_counters.nProcs = sysconf(_SC_NPROCESSORS_ONLN)) == OS_ERR) {
3454 + // ignore error?
3455 + _counters.nProcs = 1;
3458 + assert(_counters.nProcs > 0, "no CPUs detected in sysconf call!");
3459 + if (_counters.nProcs == 0) {
3460 + return false;
3463 + // Data structure(s) for saving CPU load (one per CPU)
3464 + size_t array_entry_count = _counters.nProcs;
3465 + _counters.jvmTicks = NEW_C_HEAP_ARRAY(CPUPerfTicks, array_entry_count, mtInternal);
3466 + memset(_counters.jvmTicks, 0, array_entry_count * sizeof(*_counters.jvmTicks));
3468 + // Get kstat cpu_stat counters for every CPU
3469 + // loop over kstat to find our cpu_stat(s)
3470 + int i = 0;
3471 + for (kstat_t* kstat = _counters.kstat_ctrl->kc_chain; kstat != NULL; kstat = kstat->ks_next) {
3472 + if (strncmp(kstat->ks_module, "cpu_stat", 8) == 0) {
3473 + if (kstat_read(_counters.kstat_ctrl, kstat, NULL) == OS_ERR) {
3474 + continue;
3476 + if (i == _counters.nProcs) {
3477 + // more cpu_stats than reported CPUs
3478 + break;
3480 + _counters.jvmTicks[i++].kstat = kstat;
3483 + return true;
3486 +CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
3487 + FREE_C_HEAP_ARRAY(char, _counters.jvmTicks);
3488 + if (_counters.kstat_ctrl != NULL) {
3489 + kstat_close(_counters.kstat_ctrl);
3493 +int CPUPerformanceInterface::CPUPerformance::cpu_load(int which_logical_cpu, double* cpu_load) {
3494 + assert(cpu_load != NULL, "cpu_load pointer is NULL!");
3495 + double t = .0;
3496 + if (-1 == which_logical_cpu) {
3497 + for (int i = 0; i < _counters.nProcs; i++) {
3498 + t += get_cpu_load(i, &_counters);
3500 + // Cap total systemload to 1.0
3501 + t = MIN2<double>((t / _counters.nProcs), 1.0);
3502 + } else {
3503 + t = MIN2<double>(get_cpu_load(which_logical_cpu, &_counters), 1.0);
3506 + *cpu_load = t;
3507 + return OS_OK;
3510 +int CPUPerformanceInterface::CPUPerformance::cpu_load_total_process(double* cpu_load) {
3511 + assert(cpu_load != NULL, "cpu_load pointer is NULL!");
3513 + psinfo_t info;
3515 + // Get the percentage of "recent cpu usage" from all the lwp:s in the JVM:s
3516 + // process. This is returned as a value between 0.0 and 1.0 multiplied by 0x8000.
3517 + if (get_psinfo2(&info.pr_pctcpu, sizeof(info.pr_pctcpu), offsetof(psinfo_t, pr_pctcpu)) != 0) {
3518 + *cpu_load = 0.0;
3519 + return OS_ERR;
3521 + *cpu_load = (double) info.pr_pctcpu / 0x8000;
3522 + return OS_OK;
3525 +int CPUPerformanceInterface::CPUPerformance::cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad) {
3526 + assert(pjvmUserLoad != NULL, "pjvmUserLoad not inited");
3527 + assert(pjvmKernelLoad != NULL, "pjvmKernelLoad not inited");
3528 + assert(psystemTotalLoad != NULL, "psystemTotalLoad not inited");
3530 + static uint64_t lastTime;
3531 + static uint64_t lastUser, lastKernel;
3532 + static double lastUserRes, lastKernelRes;
3534 + pstatus_t pss;
3535 + psinfo_t info;
3537 + *pjvmKernelLoad = *pjvmUserLoad = *psystemTotalLoad = 0;
3538 + if (get_info("/proc/self/status", &pss.pr_utime, sizeof(timestruc_t)*2, offsetof(pstatus_t, pr_utime)) != 0) {
3539 + return OS_ERR;
3542 + if (get_psinfo(&info) != 0) {
3543 + return OS_ERR;
3546 + // get the total time in user, kernel and total time
3547 + // check ratios for 'lately' and multiply the 'recent load'.
3548 + uint64_t time = (info.pr_time.tv_sec * NANOS_PER_SEC) + info.pr_time.tv_nsec;
3549 + uint64_t user = (pss.pr_utime.tv_sec * NANOS_PER_SEC) + pss.pr_utime.tv_nsec;
3550 + uint64_t kernel = (pss.pr_stime.tv_sec * NANOS_PER_SEC) + pss.pr_stime.tv_nsec;
3551 + uint64_t diff = time - lastTime;
3552 + double load = (double) info.pr_pctcpu / 0x8000;
3554 + if (diff > 0) {
3555 + lastUserRes = (load * (user - lastUser)) / diff;
3556 + lastKernelRes = (load * (kernel - lastKernel)) / diff;
3558 + // BUG9182835 - patch for clamping these values to sane ones.
3559 + lastUserRes = MIN2<double>(1, lastUserRes);
3560 + lastUserRes = MAX2<double>(0, lastUserRes);
3561 + lastKernelRes = MIN2<double>(1, lastKernelRes);
3562 + lastKernelRes = MAX2<double>(0, lastKernelRes);
3565 + double t = .0;
3566 + cpu_load(-1, &t);
3567 + // clamp at user+system and 1.0
3568 + if (lastUserRes + lastKernelRes > t) {
3569 + t = MIN2<double>(lastUserRes + lastKernelRes, 1.0);
3572 + *pjvmUserLoad = lastUserRes;
3573 + *pjvmKernelLoad = lastKernelRes;
3574 + *psystemTotalLoad = t;
3576 + lastTime = time;
3577 + lastUser = user;
3578 + lastKernel = kernel;
3580 + return OS_OK;
3583 +int CPUPerformanceInterface::CPUPerformance::context_switch_rate(double* rate) {
3584 + return perf_context_switch_rate(&_counters, rate);
3587 +CPUPerformanceInterface::CPUPerformanceInterface() {
3588 + _impl = NULL;
3591 +bool CPUPerformanceInterface::initialize() {
3592 + _impl = new CPUPerformanceInterface::CPUPerformance();
3593 + return _impl->initialize();
3596 +CPUPerformanceInterface::~CPUPerformanceInterface(void) {
3597 + if (_impl != NULL) {
3598 + delete _impl;
3602 +int CPUPerformanceInterface::cpu_load(int which_logical_cpu, double* cpu_load) const {
3603 + return _impl->cpu_load(which_logical_cpu, cpu_load);
3606 +int CPUPerformanceInterface::cpu_load_total_process(double* cpu_load) const {
3607 + return _impl->cpu_load_total_process(cpu_load);
3610 +int CPUPerformanceInterface::cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad) const {
3611 + return _impl->cpu_loads_process(pjvmUserLoad, pjvmKernelLoad, psystemTotalLoad);
3614 +int CPUPerformanceInterface::context_switch_rate(double* rate) const {
3615 + return _impl->context_switch_rate(rate);
3618 +class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
3619 + friend class SystemProcessInterface;
3620 + private:
3621 + class ProcessIterator : public CHeapObj<mtInternal> {
3622 + friend class SystemProcessInterface::SystemProcesses;
3623 + private:
3624 + DIR* _dir;
3625 + struct dirent* _entry;
3626 + bool _valid;
3628 + ProcessIterator();
3629 + ~ProcessIterator();
3630 + bool initialize();
3632 + bool is_valid() const { return _valid; }
3633 + bool is_valid_entry(struct dirent* const entry) const;
3634 + bool is_dir(const char* const name) const;
3635 + char* allocate_string(const char* const str) const;
3636 + int current(SystemProcess* const process_info);
3637 + int next_process();
3638 + };
3640 + ProcessIterator* _iterator;
3641 + SystemProcesses();
3642 + bool initialize();
3643 + ~SystemProcesses();
3645 + //information about system processes
3646 + int system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const;
3649 +bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_dir(const char* name) const {
3650 + struct stat64 mystat;
3651 + int ret_val = 0;
3653 + ret_val = ::stat64(name, &mystat);
3655 + if (ret_val < 0) {
3656 + return false;
3658 + ret_val = S_ISDIR(mystat.st_mode);
3659 + return ret_val > 0;
3662 +// if it has a numeric name, is a directory and has a 'psinfo' file in it
3663 +bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_valid_entry(struct dirent* entry) const {
3664 + // ignore the "." and ".." directories
3665 + if ((strcmp(entry->d_name, ".") == 0) ||
3666 + (strcmp(entry->d_name, "..") == 0)) {
3667 + return false;
3670 + char buffer[PATH_MAX] = {0};
3671 + uint64_t size = 0;
3672 + bool result = false;
3673 + FILE *fp = NULL;
3675 + if (atoi(entry->d_name) != 0) {
3676 + jio_snprintf(buffer, PATH_MAX, "/proc/%s", entry->d_name);
3678 + if (is_dir(buffer)) {
3679 + memset(buffer, 0, PATH_MAX);
3680 + jio_snprintf(buffer, PATH_MAX, "/proc/%s/psinfo", entry->d_name);
3681 + if ((fp = fopen(buffer, "r")) != NULL) {
3682 + int nread = 0;
3683 + psinfo_t psinfo_data;
3684 + if ((nread = fread(&psinfo_data, 1, sizeof(psinfo_t), fp)) != -1) {
3685 + // only considering system process owned by root
3686 + if (psinfo_data.pr_uid == 0) {
3687 + result = true;
3694 + if (fp != NULL) {
3695 + fclose(fp);
3698 + return result;
3701 +char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const {
3702 + if (str != NULL) {
3703 + return os::strdup_check_oom(str, mtInternal);
3705 + return NULL;
3708 +int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProcess* process_info) {
3709 + if (!is_valid()) {
3710 + return OS_ERR;
3713 + char psinfo_path[PATH_MAX] = {0};
3714 + jio_snprintf(psinfo_path, PATH_MAX, "/proc/%s/psinfo", _entry->d_name);
3716 + FILE *fp = NULL;
3717 + if ((fp = fopen(psinfo_path, "r")) == NULL) {
3718 + return OS_ERR;
3721 + int nread = 0;
3722 + psinfo_t psinfo_data;
3723 + if ((nread = fread(&psinfo_data, 1, sizeof(psinfo_t), fp)) == -1) {
3724 + fclose(fp);
3725 + return OS_ERR;
3728 + char *exe_path = NULL;
3729 + if ((psinfo_data.pr_fname != NULL) &&
3730 + (psinfo_data.pr_psargs != NULL)) {
3731 + char *path_substring = strstr(psinfo_data.pr_psargs, psinfo_data.pr_fname);
3732 + if (path_substring != NULL) {
3733 + int len = path_substring - psinfo_data.pr_psargs;
3734 + exe_path = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
3735 + jio_snprintf(exe_path, len, "%s", psinfo_data.pr_psargs);
3736 + exe_path[len] = '\0';
3740 + process_info->set_pid(atoi(_entry->d_name));
3741 + process_info->set_name(allocate_string(psinfo_data.pr_fname));
3742 + process_info->set_path(allocate_string(exe_path));
3743 + process_info->set_command_line(allocate_string(psinfo_data.pr_psargs));
3745 + if (exe_path != NULL) {
3746 + FREE_C_HEAP_ARRAY(char, exe_path);
3749 + if (fp != NULL) {
3750 + fclose(fp);
3753 + return OS_OK;
3756 +int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
3757 + if (!is_valid()) {
3758 + return OS_ERR;
3761 + do {
3762 + _entry = os::readdir(_dir);
3763 + if (_entry == NULL) {
3764 + // Error or reached end. Could use errno to distinguish those cases.
3765 + _valid = false;
3766 + return OS_ERR;
3768 + } while(!is_valid_entry(_entry));
3770 + _valid = true;
3771 + return OS_OK;
3774 +SystemProcessInterface::SystemProcesses::ProcessIterator::ProcessIterator() {
3775 + _dir = NULL;
3776 + _entry = NULL;
3777 + _valid = false;
3780 +bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
3781 + _dir = os::opendir("/proc");
3782 + _entry = NULL;
3783 + _valid = true;
3784 + next_process();
3786 + return true;
3789 +SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
3790 + if (_dir != NULL) {
3791 + os::closedir(_dir);
3795 +SystemProcessInterface::SystemProcesses::SystemProcesses() {
3796 + _iterator = NULL;
3799 +bool SystemProcessInterface::SystemProcesses::initialize() {
3800 + _iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
3801 + return _iterator->initialize();
3804 +SystemProcessInterface::SystemProcesses::~SystemProcesses() {
3805 + if (_iterator != NULL) {
3806 + delete _iterator;
3810 +int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const {
3811 + assert(system_processes != NULL, "system_processes pointer is NULL!");
3812 + assert(no_of_sys_processes != NULL, "system_processes counter pointer is NULL!");
3813 + assert(_iterator != NULL, "iterator is NULL!");
3815 + // initialize pointers
3816 + *no_of_sys_processes = 0;
3817 + *system_processes = NULL;
3819 + while (_iterator->is_valid()) {
3820 + SystemProcess* tmp = new SystemProcess();
3821 + _iterator->current(tmp);
3823 + //if already existing head
3824 + if (*system_processes != NULL) {
3825 + //move "first to second"
3826 + tmp->set_next(*system_processes);
3828 + // new head
3829 + *system_processes = tmp;
3830 + // increment
3831 + (*no_of_sys_processes)++;
3832 + // step forward
3833 + _iterator->next_process();
3835 + return OS_OK;
3838 +int SystemProcessInterface::system_processes(SystemProcess** system_procs, int* no_of_sys_processes) const {
3839 + return _impl->system_processes(system_procs, no_of_sys_processes);
3842 +SystemProcessInterface::SystemProcessInterface() {
3843 + _impl = NULL;
3846 +bool SystemProcessInterface::initialize() {
3847 + _impl = new SystemProcessInterface::SystemProcesses();
3848 + return _impl->initialize();
3852 +SystemProcessInterface::~SystemProcessInterface() {
3853 + if (_impl != NULL) {
3854 + delete _impl;
3858 +CPUInformationInterface::CPUInformationInterface() {
3859 + _cpu_info = NULL;
3862 +bool CPUInformationInterface::initialize() {
3863 + _cpu_info = new CPUInformation();
3864 + VM_Version::initialize_cpu_information();
3865 + _cpu_info->set_number_of_hardware_threads(VM_Version::number_of_threads());
3866 + _cpu_info->set_number_of_cores(VM_Version::number_of_cores());
3867 + _cpu_info->set_number_of_sockets(VM_Version::number_of_sockets());
3868 + _cpu_info->set_cpu_name(VM_Version::cpu_name());
3869 + _cpu_info->set_cpu_description(VM_Version::cpu_description());
3870 + return true;
3873 +CPUInformationInterface::~CPUInformationInterface() {
3874 + if (_cpu_info != NULL) {
3875 + if (_cpu_info->cpu_name() != NULL) {
3876 + const char* cpu_name = _cpu_info->cpu_name();
3877 + FREE_C_HEAP_ARRAY(char, cpu_name);
3878 + _cpu_info->set_cpu_name(NULL);
3880 + if (_cpu_info->cpu_description() != NULL) {
3881 + const char* cpu_desc = _cpu_info->cpu_description();
3882 + FREE_C_HEAP_ARRAY(char, cpu_desc);
3883 + _cpu_info->set_cpu_description(NULL);
3885 + delete _cpu_info;
3889 +int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
3890 + if (_cpu_info == NULL) {
3891 + return OS_ERR;
3894 + cpu_info = *_cpu_info; // shallow copy assignment
3895 + return OS_OK;
3898 +class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtInternal> {
3899 + friend class NetworkPerformanceInterface;
3900 + private:
3901 + NetworkPerformance();
3902 + NONCOPYABLE(NetworkPerformance);
3903 + bool initialize();
3904 + ~NetworkPerformance();
3905 + int network_utilization(NetworkInterface** network_interfaces) const;
3908 +NetworkPerformanceInterface::NetworkPerformance::NetworkPerformance() {
3912 +bool NetworkPerformanceInterface::NetworkPerformance::initialize() {
3913 + return true;
3916 +NetworkPerformanceInterface::NetworkPerformance::~NetworkPerformance() {
3920 +int NetworkPerformanceInterface::NetworkPerformance::network_utilization(NetworkInterface** network_interfaces) const
3922 + kstat_ctl_t* ctl = kstat_open();
3923 + if (ctl == NULL) {
3924 + return OS_ERR;
3927 + NetworkInterface* ret = NULL;
3928 + for (kstat_t* k = ctl->kc_chain; k != NULL; k = k->ks_next) {
3929 + if (strcmp(k->ks_class, "net") != 0) {
3930 + continue;
3932 + if (strcmp(k->ks_module, "link") != 0) {
3933 + continue;
3936 + if (kstat_read(ctl, k, NULL) == -1) {
3937 + return OS_ERR;
3940 + uint64_t bytes_in = UINT64_MAX;
3941 + uint64_t bytes_out = UINT64_MAX;
3942 + for (unsigned int i = 0; i < k->ks_ndata; ++i) {
3943 + kstat_named_t* data = &reinterpret_cast<kstat_named_t*>(k->ks_data)[i];
3944 + if (strcmp(data->name, "rbytes64") == 0) {
3945 + bytes_in = data->value.ui64;
3947 + else if (strcmp(data->name, "obytes64") == 0) {
3948 + bytes_out = data->value.ui64;
3952 + if ((bytes_in != UINT64_MAX) && (bytes_out != UINT64_MAX)) {
3953 + NetworkInterface* cur = new NetworkInterface(k->ks_name, bytes_in, bytes_out, ret);
3954 + ret = cur;
3958 + kstat_close(ctl);
3959 + *network_interfaces = ret;
3961 + return OS_OK;
3964 +NetworkPerformanceInterface::NetworkPerformanceInterface() {
3965 + _impl = NULL;
3968 +NetworkPerformanceInterface::~NetworkPerformanceInterface() {
3969 + if (_impl != NULL) {
3970 + delete _impl;
3974 +bool NetworkPerformanceInterface::initialize() {
3975 + _impl = new NetworkPerformanceInterface::NetworkPerformance();
3976 + return _impl->initialize();
3979 +int NetworkPerformanceInterface::network_utilization(NetworkInterface** network_interfaces) const {
3980 + return _impl->network_utilization(network_interfaces);
3982 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.cpp jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.cpp
3983 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
3984 +++ jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.cpp 2024-08-17 20:36:14.286129716 +0200
3985 @@ -0,0 +1,2940 @@
3987 + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3988 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3990 + * This code is free software; you can redistribute it and/or modify it
3991 + * under the terms of the GNU General Public License version 2 only, as
3992 + * published by the Free Software Foundation.
3994 + * This code is distributed in the hope that it will be useful, but WITHOUT
3995 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3996 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3997 + * version 2 for more details (a copy is included in the LICENSE file that
3998 + * accompanied this code).
4000 + * You should have received a copy of the GNU General Public License version
4001 + * 2 along with this work; if not, write to the Free Software Foundation,
4002 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4004 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4005 + * or visit www.oracle.com if you need additional information or have any
4006 + * questions.
4008 + */
4010 +// no precompiled headers
4011 +#include "jvm.h"
4012 +#include "classfile/classLoader.hpp"
4013 +#include "classfile/systemDictionary.hpp"
4014 +#include "classfile/vmSymbols.hpp"
4015 +#include "code/vtableStubs.hpp"
4016 +#include "compiler/compileBroker.hpp"
4017 +#include "compiler/disassembler.hpp"
4018 +#include "interpreter/interpreter.hpp"
4019 +#include "jvmtifiles/jvmti.h"
4020 +#include "logging/log.hpp"
4021 +#include "logging/logStream.hpp"
4022 +#include "memory/allocation.inline.hpp"
4023 +#include "memory/universe.hpp"
4024 +#include "oops/oop.inline.hpp"
4025 +#include "os_solaris.inline.hpp"
4026 +#include "prims/jniFastGetField.hpp"
4027 +#include "prims/jvm_misc.hpp"
4028 +#include "runtime/arguments.hpp"
4029 +#include "runtime/atomic.hpp"
4030 +#include "runtime/globals.hpp"
4031 +#include "runtime/globals_extension.hpp"
4032 +#include "runtime/interfaceSupport.inline.hpp"
4033 +#include "runtime/java.hpp"
4034 +#include "runtime/javaCalls.hpp"
4035 +#include "runtime/javaThread.hpp"
4036 +#include "runtime/mutexLocker.hpp"
4037 +#include "runtime/objectMonitor.hpp"
4038 +#include "runtime/osInfo.hpp"
4039 +#include "runtime/orderAccess.hpp"
4040 +#include "runtime/osThread.hpp"
4041 +#include "runtime/park.hpp"
4042 +#include "runtime/perfMemory.hpp"
4043 +#include "runtime/sharedRuntime.hpp"
4044 +#include "runtime/statSampler.hpp"
4045 +#include "runtime/stubRoutines.hpp"
4046 +#include "runtime/threadCritical.hpp"
4047 +#include "runtime/threads.hpp"
4048 +#include "runtime/timer.hpp"
4049 +#include "runtime/vm_version.hpp"
4050 +#include "semaphore_posix.hpp"
4051 +#include "services/attachListener.hpp"
4052 +#include "nmt/memTracker.hpp"
4053 +#include "services/runtimeService.hpp"
4054 +#include "signals_posix.hpp"
4055 +#include "utilities/align.hpp"
4056 +#include "utilities/checkedCast.hpp"
4057 +#include "utilities/decoder.hpp"
4058 +#include "utilities/defaultStream.hpp"
4059 +#include "utilities/events.hpp"
4060 +#include "utilities/growableArray.hpp"
4061 +#include "utilities/macros.hpp"
4062 +#include "utilities/vmError.hpp"
4064 +// put OS-includes here
4065 +# include <dlfcn.h>
4066 +# include <errno.h>
4067 +# include <exception>
4068 +# include <link.h>
4069 +# include <poll.h>
4070 +# include <pthread.h>
4071 +# include <setjmp.h>
4072 +# include <signal.h>
4073 +# include <stdio.h>
4074 +# include <alloca.h>
4075 +# include <sys/filio.h>
4076 +# include <sys/ipc.h>
4077 +# include <sys/lwp.h>
4078 +# include <sys/machelf.h> // for elf Sym structure used by dladdr1
4079 +# include <sys/mman.h>
4080 +# include <sys/processor.h>
4081 +# include <sys/procset.h>
4082 +# include <sys/pset.h>
4083 +# include <sys/resource.h>
4084 +# include <sys/shm.h>
4085 +# include <sys/socket.h>
4086 +# include <sys/stat.h>
4087 +# include <sys/swap.h> // for swapctl
4088 +# include <sys/systeminfo.h>
4089 +# include <sys/time.h>
4090 +# include <sys/times.h>
4091 +# include <sys/types.h>
4092 +# include <sys/wait.h>
4093 +# include <sys/utsname.h>
4094 +# include <thread.h>
4095 +# include <unistd.h>
4096 +# include <sys/priocntl.h>
4097 +# include <sys/rtpriocntl.h>
4098 +# include <sys/tspriocntl.h>
4099 +# include <sys/iapriocntl.h>
4100 +# include <sys/fxpriocntl.h>
4101 +# include <sys/loadavg.h>
4102 +# include <string.h>
4103 +# include <stdio.h>
4104 +# include <vm/anon.h> // for swap anoninfo
4106 +# include <procfs.h>
4108 +#define MAX_PATH (2 * K)
4110 +// for timer info max values which include all bits
4111 +#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
4113 +// Here are some liblgrp types from sys/lgrp_user.h to be able to
4114 +// compile on older systems without this header file.
4116 +#ifndef MADV_ACCESS_LWP
4117 + #define MADV_ACCESS_LWP 7 /* next LWP to access heavily */
4118 +#endif
4119 +#ifndef MADV_ACCESS_MANY
4120 + #define MADV_ACCESS_MANY 8 /* many processes to access heavily */
4121 +#endif
4123 +#ifndef LGRP_RSRC_CPU
4124 + #define LGRP_RSRC_CPU 0 /* CPU resources */
4125 +#endif
4126 +#ifndef LGRP_RSRC_MEM
4127 + #define LGRP_RSRC_MEM 1 /* memory resources */
4128 +#endif
4130 +// guarded in sys/mman.h
4131 +extern "C" {
4132 +extern int getpagesizes(size_t[], int);
4135 +// Values for ThreadPriorityPolicy == 1
4136 +int prio_policy1[CriticalPriority+1] = {
4137 + -99999, 0, 16, 32, 48, 64,
4138 + 80, 96, 112, 124, 127, 127 };
4140 +// System parameters used internally
4141 +static clock_t clock_tics_per_sec = 100;
4143 +// For diagnostics to print a message once. see run_periodic_checks
4144 +static bool check_addr0_done = false;
4146 +address os::Solaris::handler_start; // start pc of thr_sighndlrinfo
4147 +address os::Solaris::handler_end; // end pc of thr_sighndlrinfo
4149 +address os::Solaris::_main_stack_base = NULL; // 4352906 workaround
4151 +os::Solaris::pthread_setname_np_func_t os::Solaris::_pthread_setname_np = NULL;
4153 +// "default" initializers for missing libc APIs
4154 +extern "C" {
4155 + int memcntl(void *, size_t, int, void *, int, int);
4156 + int meminfo(const uint64_t *, int, const uint_t *, int, uint64_t *, uint_t *);
4159 +static inline size_t adjust_stack_size(address base, size_t size) {
4160 + if ((ssize_t)size < 0) {
4161 + // 4759953: Compensate for ridiculous stack size.
4162 + size = max_intx;
4164 + if (size > (size_t)base) {
4165 + // 4812466: Make sure size doesn't allow the stack to wrap the address space.
4166 + size = (size_t)base;
4168 + return size;
4171 +static inline stack_t get_stack_info() {
4172 + stack_t st;
4173 + int retval = thr_stksegment(&st);
4174 + st.ss_size = adjust_stack_size((address)st.ss_sp, st.ss_size);
4175 + assert(retval == 0, "incorrect return value from thr_stksegment");
4176 + assert((address)&st < (address)st.ss_sp, "Invalid stack base returned");
4177 + assert((address)&st > (address)st.ss_sp-st.ss_size, "Invalid stack size returned");
4178 + return st;
4181 +bool os::is_primordial_thread(void) {
4182 + int r = thr_main();
4183 + guarantee(r == 0 || r == 1, "CR6501650 or CR6493689");
4184 + return r == 1;
4187 +address os::Solaris::current_stack_base() {
4188 + bool _is_primordial_thread = os::is_primordial_thread();
4190 + // Workaround 4352906, avoid calls to thr_stksegment by
4191 + // thr_main after the first one (it looks like we trash
4192 + // some data, causing the value for ss_sp to be incorrect).
4193 + if (!_is_primordial_thread || os::Solaris::_main_stack_base == NULL) {
4194 + stack_t st = get_stack_info();
4195 + if (_is_primordial_thread) {
4196 + // cache initial value of stack base
4197 + os::Solaris::_main_stack_base = (address)st.ss_sp;
4199 + return (address)st.ss_sp;
4200 + } else {
4201 + guarantee(os::Solaris::_main_stack_base != NULL, "Attempt to use null cached stack base");
4202 + return os::Solaris::_main_stack_base;
4206 +size_t os::Solaris::current_stack_size() {
4207 + size_t size;
4209 + if (!os::is_primordial_thread()) {
4210 + size = get_stack_info().ss_size;
4211 + } else {
4212 + struct rlimit limits;
4213 + getrlimit(RLIMIT_STACK, &limits);
4214 + size = adjust_stack_size(os::Solaris::_main_stack_base, (size_t)limits.rlim_cur);
4216 + // base may not be page aligned
4217 + address base = current_stack_base();
4218 + address bottom = align_up(base - size, os::vm_page_size());;
4219 + return (size_t)(base - bottom);
4222 +void os::current_stack_base_and_size(address* stack_base, size_t* stack_size) {
4223 + *stack_base = os::Solaris::current_stack_base();
4224 + *stack_size = os::Solaris::current_stack_size();
4227 +jint os::Solaris::_os_thread_limit = 0;
4228 +volatile jint os::Solaris::_os_thread_count = 0;
4230 +julong os::available_memory() {
4231 + return Solaris::available_memory();
4234 +julong os::free_memory() {
4235 + return Solaris::available_memory();
4238 +julong os::Solaris::available_memory() {
4239 + return (julong)sysconf(_SC_AVPHYS_PAGES) * os::vm_page_size();
4242 +julong os::Solaris::_physical_memory = 0;
4244 +jlong os::total_swap_space() {
4245 + struct anoninfo ai;
4246 + pgcnt_t allocated, reserved, available;
4247 + int ret = swapctl(SC_AINFO, &ai);
4248 + if (ret == -1) {
4249 + return -1;
4251 + return (jlong)(ai.ani_max * sysconf(_SC_PAGESIZE));
4254 +jlong os::free_swap_space() {
4255 + struct anoninfo ai;
4256 + int ret = swapctl(SC_AINFO, &ai);
4257 + if (ret == -1) {
4258 + return -1;
4260 + return (jlong)(ai.ani_free * sysconf(_SC_PAGESIZE));
4263 +julong os::physical_memory() {
4264 + return Solaris::physical_memory();
4267 +size_t os::rss() { return (size_t)0; }
4269 +static hrtime_t first_hrtime = 0;
4270 +static const hrtime_t hrtime_hz = 1000*1000*1000;
4271 +static volatile hrtime_t max_hrtime = 0;
4274 +void os::Solaris::initialize_system_info() {
4275 + set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
4276 + _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) *
4277 + (julong)sysconf(_SC_PAGESIZE);
4280 +uint os::processor_id() {
4281 + const processorid_t id = ::getcpuid();
4282 + assert(id >= 0 && id < _processor_count, "Invalid processor id");
4283 + return (uint)id;
4286 +int os::active_processor_count() {
4287 + // User has overridden the number of active processors
4288 + if (ActiveProcessorCount > 0) {
4289 + log_trace(os)("active_processor_count: "
4290 + "active processor count set by user : %d",
4291 + ActiveProcessorCount);
4292 + return ActiveProcessorCount;
4295 + int online_cpus = sysconf(_SC_NPROCESSORS_ONLN);
4296 + pid_t pid = getpid();
4297 + psetid_t pset = PS_NONE;
4298 + // Are we running in a processor set or is there any processor set around?
4299 + if (pset_bind(PS_QUERY, P_PID, pid, &pset) == 0) {
4300 + uint_t pset_cpus;
4301 + // Query the number of cpus available to us.
4302 + if (pset_info(pset, NULL, &pset_cpus, NULL) == 0) {
4303 + assert(pset_cpus > 0 && pset_cpus <= online_cpus, "sanity check");
4304 + return pset_cpus;
4307 + // Otherwise return number of online cpus
4308 + return online_cpus;
4311 +void os::set_native_thread_name(const char *name) {
4312 + if (Solaris::_pthread_setname_np != NULL) {
4313 + // Only the first 31 bytes of 'name' are processed by pthread_setname_np
4314 + // but we explicitly copy into a size-limited buffer to avoid any
4315 + // possible overflow.
4316 + char buf[32];
4317 + snprintf(buf, sizeof(buf), "%s", name);
4318 + buf[sizeof(buf) - 1] = '\0';
4319 + Solaris::_pthread_setname_np(pthread_self(), buf);
4323 +void os::init_system_properties_values() {
4324 + // The next steps are taken in the product version:
4325 + //
4326 + // Obtain the JAVA_HOME value from the location of libjvm.so.
4327 + // This library should be located at:
4328 + // <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm.so.
4329 + //
4330 + // If "/jre/lib/" appears at the right place in the path, then we
4331 + // assume libjvm.so is installed in a JDK and we use this path.
4332 + //
4333 + // Otherwise exit with message: "Could not create the Java virtual machine."
4334 + //
4335 + // The following extra steps are taken in the debugging version:
4336 + //
4337 + // If "/jre/lib/" does NOT appear at the right place in the path
4338 + // instead of exit check for $JAVA_HOME environment variable.
4339 + //
4340 + // If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>,
4341 + // then we append a fake suffix "hotspot/libjvm.so" to this path so
4342 + // it looks like libjvm.so is installed there
4343 + // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm.so.
4344 + //
4345 + // Otherwise exit.
4346 + //
4347 + // Important note: if the location of libjvm.so changes this
4348 + // code needs to be changed accordingly.
4350 +// Base path of extensions installed on the system.
4351 +#define SYS_EXT_DIR "/usr/jdk/packages"
4352 +#define EXTENSIONS_DIR "/lib/ext"
4354 + // Buffer that fits several sprintfs.
4355 + // Note that the space for the colon and the trailing null are provided
4356 + // by the nulls included by the sizeof operator.
4357 + const size_t bufsize =
4358 + MAX3((size_t)MAXPATHLEN, // For dll_dir & friends.
4359 + sizeof(SYS_EXT_DIR) + sizeof("/lib/"), // invariant ld_library_path
4360 + (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
4361 + char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
4363 + // sysclasspath, java_home, dll_dir
4365 + char *pslash;
4366 + os::jvm_path(buf, bufsize);
4368 + // Found the full path to libjvm.so.
4369 + // Now cut the path to <java_home>/jre if we can.
4370 + *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
4371 + pslash = strrchr(buf, '/');
4372 + if (pslash != NULL) {
4373 + *pslash = '\0'; // Get rid of /{client|server|hotspot}.
4375 + Arguments::set_dll_dir(buf);
4377 + if (pslash != NULL) {
4378 + pslash = strrchr(buf, '/');
4379 + if (pslash != NULL) {
4380 + *pslash = '\0'; // Get rid of /lib.
4383 + Arguments::set_java_home(buf);
4384 + if (!set_boot_path('/', ':')) {
4385 + vm_exit_during_initialization("Failed setting boot class path.", NULL);
4389 + // Where to look for native libraries.
4391 + // Use dlinfo() to determine the correct java.library.path.
4392 + //
4393 + // If we're launched by the Java launcher, and the user
4394 + // does not set java.library.path explicitly on the commandline,
4395 + // the Java launcher sets LD_LIBRARY_PATH for us and unsets
4396 + // LD_LIBRARY_PATH_32 and LD_LIBRARY_PATH_64. In this case
4397 + // dlinfo returns LD_LIBRARY_PATH + crle settings (including
4398 + // /usr/lib), which is exactly what we want.
4399 + //
4400 + // If the user does set java.library.path, it completely
4401 + // overwrites this setting, and always has.
4402 + //
4403 + // If we're not launched by the Java launcher, we may
4404 + // get here with any/all of the LD_LIBRARY_PATH[_32|64]
4405 + // settings. Again, dlinfo does exactly what we want.
4407 + Dl_serinfo info_sz, *info = &info_sz;
4408 + Dl_serpath *path;
4409 + char *library_path;
4410 + char *common_path = buf;
4412 + // Determine search path count and required buffer size.
4413 + if (dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info) == -1) {
4414 + FREE_C_HEAP_ARRAY(char, buf);
4415 + vm_exit_during_initialization("dlinfo SERINFOSIZE request", dlerror());
4418 + // Allocate new buffer and initialize.
4419 + info = (Dl_serinfo*)NEW_C_HEAP_ARRAY(char, info_sz.dls_size, mtInternal);
4420 + info->dls_size = info_sz.dls_size;
4421 + info->dls_cnt = info_sz.dls_cnt;
4423 + // Obtain search path information.
4424 + if (dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info) == -1) {
4425 + FREE_C_HEAP_ARRAY(char, buf);
4426 + FREE_C_HEAP_ARRAY(char, info);
4427 + vm_exit_during_initialization("dlinfo SERINFO request", dlerror());
4430 + path = &info->dls_serpath[0];
4432 + // Note: Due to a legacy implementation, most of the library path
4433 + // is set in the launcher. This was to accommodate linking restrictions
4434 + // on legacy Solaris implementations (which are no longer supported).
4435 + // Eventually, all the library path setting will be done here.
4436 + //
4437 + // However, to prevent the proliferation of improperly built native
4438 + // libraries, the new path component /usr/jdk/packages is added here.
4440 + // Construct the invariant part of ld_library_path.
4441 + sprintf(common_path, SYS_EXT_DIR "/lib");
4443 + // Struct size is more than sufficient for the path components obtained
4444 + // through the dlinfo() call, so only add additional space for the path
4445 + // components explicitly added here.
4446 + size_t library_path_size = info->dls_size + strlen(common_path);
4447 + library_path = NEW_C_HEAP_ARRAY(char, library_path_size, mtInternal);
4448 + library_path[0] = '\0';
4450 + // Construct the desired Java library path from the linker's library
4451 + // search path.
4452 + //
4453 + // For compatibility, it is optimal that we insert the additional path
4454 + // components specific to the Java VM after those components specified
4455 + // in LD_LIBRARY_PATH (if any) but before those added by the ld.so
4456 + // infrastructure.
4457 + if (info->dls_cnt == 0) { // Not sure this can happen, but allow for it.
4458 + strcpy(library_path, common_path);
4459 + } else {
4460 + int inserted = 0;
4461 + uint_t i;
4462 + for (i = 0; i < info->dls_cnt; i++, path++) {
4463 + uint_t flags = path->dls_flags & LA_SER_MASK;
4464 + if (((flags & LA_SER_LIBPATH) == 0) && !inserted) {
4465 + strcat(library_path, common_path);
4466 + strcat(library_path, os::path_separator());
4467 + inserted = 1;
4469 + strcat(library_path, path->dls_name);
4470 + strcat(library_path, os::path_separator());
4472 + // Eliminate trailing path separator.
4473 + library_path[strlen(library_path)-1] = '\0';
4476 + // happens before argument parsing - can't use a trace flag
4477 + // tty->print_raw("init_system_properties_values: native lib path: ");
4478 + // tty->print_raw_cr(library_path);
4480 + // Callee copies into its own buffer.
4481 + Arguments::set_library_path(library_path);
4483 + FREE_C_HEAP_ARRAY(char, library_path);
4484 + FREE_C_HEAP_ARRAY(char, info);
4487 + // Extensions directories.
4488 + sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
4489 + Arguments::set_ext_dirs(buf);
4491 + FREE_C_HEAP_ARRAY(char, buf);
4493 +#undef SYS_EXT_DIR
4494 +#undef EXTENSIONS_DIR
4497 +static thread_t main_thread;
4499 +// Thread start routine for all newly created threads
4500 +extern "C" void* thread_native_entry(void* thread_addr) {
4502 + Thread* thread = (Thread*)thread_addr;
4504 + thread->record_stack_base_and_size();
4506 + // Try to randomize the cache line index of hot stack frames.
4507 + // This helps when threads of the same stack traces evict each other's
4508 + // cache lines. The threads can be either from the same JVM instance, or
4509 + // from different JVM instances. The benefit is especially true for
4510 + // processors with hyperthreading technology.
4511 + static int counter = 0;
4512 + int pid = os::current_process_id();
4513 + alloca(((pid ^ counter++) & 7) * 128);
4515 + int prio;
4517 + thread->initialize_thread_current();
4519 + OSThread* osthr = thread->osthread();
4521 + osthr->set_lwp_id(_lwp_self()); // Store lwp in case we are bound
4523 + log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
4524 + os::current_thread_id());
4526 + if (UseNUMA) {
4527 + int lgrp_id = os::numa_get_group_id();
4528 + if (lgrp_id != -1) {
4529 + thread->set_lgrp_id(lgrp_id);
4533 + // Our priority was set when we were created, and stored in the
4534 + // osthread, but couldn't be passed through to our LWP until now.
4535 + // So read back the priority and set it again.
4537 + if (osthr->thread_id() != -1) {
4538 + if (UseThreadPriorities) {
4539 + int prio = osthr->native_priority();
4540 + os::set_native_priority(thread, prio);
4544 + assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
4546 + // initialize signal mask for this thread
4547 + PosixSignals::hotspot_sigmask(thread);
4549 + os::Solaris::init_thread_fpu_state();
4551 + thread->call_run();
4553 + // Note: at this point the thread object may already have deleted itself.
4554 + // Do not dereference it from here on out.
4556 + // One less thread is executing
4557 + // When the VMThread gets here, the main thread may have already exited
4558 + // which frees the CodeHeap containing the Atomic::dec code
4559 + if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
4560 + Atomic::dec(&os::Solaris::_os_thread_count);
4563 + log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
4565 + thr_exit(NULL);
4566 + ShouldNotReachHere();
4568 + return NULL;
4571 +static OSThread* create_os_thread(Thread* thread, thread_t thread_id) {
4572 + // Allocate the OSThread object
4573 + OSThread* osthread = new OSThread();
4574 + if (osthread == NULL) return NULL;
4576 + // Store info on the Solaris thread into the OSThread
4577 + osthread->set_thread_id(thread_id);
4578 + osthread->set_lwp_id(_lwp_self());
4580 + if (UseNUMA) {
4581 + int lgrp_id = os::numa_get_group_id();
4582 + if (lgrp_id != -1) {
4583 + thread->set_lgrp_id(lgrp_id);
4587 + // Initial thread state is INITIALIZED, not SUSPENDED
4588 + osthread->set_state(INITIALIZED);
4590 + return osthread;
4593 +bool os::create_attached_thread(JavaThread* thread) {
4594 +#ifdef ASSERT
4595 + thread->verify_not_published();
4596 +#endif
4597 + OSThread* osthread = create_os_thread(thread, thr_self());
4598 + if (osthread == NULL) {
4599 + return false;
4602 + // Initial thread state is RUNNABLE
4603 + osthread->set_state(RUNNABLE);
4604 + thread->set_osthread(osthread);
4606 + if (os::is_primordial_thread()) {
4607 + os::Solaris::correct_stack_boundaries_for_primordial_thread(thread);
4610 + // initialize signal mask for this thread
4611 + // and save the caller's signal mask
4612 + PosixSignals::hotspot_sigmask(thread);
4614 + log_info(os, thread)("Thread attached (tid: " UINTX_FORMAT ").",
4615 + os::current_thread_id());
4617 + return true;
4620 +bool os::create_main_thread(JavaThread* thread) {
4621 +#ifdef ASSERT
4622 + thread->verify_not_published();
4623 +#endif
4624 + if (_starting_thread == NULL) {
4625 + _starting_thread = create_os_thread(thread, main_thread);
4626 + if (_starting_thread == NULL) {
4627 + return false;
4631 + // The primodial thread is runnable from the start
4632 + _starting_thread->set_state(RUNNABLE);
4634 + thread->set_osthread(_starting_thread);
4636 + // initialize signal mask for this thread
4637 + // and save the caller's signal mask
4638 + PosixSignals::hotspot_sigmask(thread);
4640 + return true;
4643 +// Helper function to trace thread attributes, similar to os::Posix::describe_pthread_attr()
4644 +static char* describe_thr_create_attributes(char* buf, size_t buflen,
4645 + size_t stacksize, long flags) {
4646 + stringStream ss(buf, buflen);
4647 + ss.print("stacksize: " SIZE_FORMAT "k, ", stacksize / 1024);
4648 + ss.print("flags: ");
4649 + #define PRINT_FLAG(f) if (flags & f) ss.print( #f " ");
4650 + #define ALL(X) \
4651 + X(THR_SUSPENDED) \
4652 + X(THR_DETACHED) \
4653 + X(THR_BOUND) \
4654 + X(THR_NEW_LWP) \
4655 + X(THR_DAEMON)
4656 + ALL(PRINT_FLAG)
4657 + #undef ALL
4658 + #undef PRINT_FLAG
4659 + return buf;
4662 +// return default stack size for thr_type
4663 +size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
4664 + // default stack size when not specified by caller is 1M (2M for LP64)
4665 + size_t s = (BytesPerWord >> 2) * K * K;
4666 + return s;
4669 +bool os::create_thread(Thread* thread, ThreadType thr_type,
4670 + size_t req_stack_size) {
4671 + // Allocate the OSThread object
4672 + OSThread* osthread = new OSThread();
4673 + if (osthread == NULL) {
4674 + return false;
4677 + // calculate stack size if it's not specified by caller
4678 + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size);
4680 + // Initial state is ALLOCATED but not INITIALIZED
4681 + osthread->set_state(ALLOCATED);
4683 + if (os::Solaris::_os_thread_count > os::Solaris::_os_thread_limit) {
4684 + // We got lots of threads. Check if we still have some address space left.
4685 + // Need to be at least 5Mb of unreserved address space. We do check by
4686 + // trying to reserve some.
4687 + const size_t VirtualMemoryBangSize = 20*K*K;
4688 + char* mem = os::reserve_memory(VirtualMemoryBangSize);
4689 + if (mem == NULL) {
4690 + delete osthread;
4691 + return false;
4692 + } else {
4693 + // Release the memory again
4694 + os::release_memory(mem, VirtualMemoryBangSize);
4698 + // Setup osthread because the child thread may need it.
4699 + thread->set_osthread(osthread);
4701 + // Create the Solaris thread
4702 + thread_t tid = 0;
4703 + long flags = THR_DETACHED | THR_SUSPENDED;
4704 + int status;
4706 + // Mark that we don't have an lwp or thread id yet.
4707 + // In case we attempt to set the priority before the thread starts.
4708 + osthread->set_lwp_id(-1);
4709 + osthread->set_thread_id(-1);
4711 + status = thr_create(NULL, stack_size, thread_native_entry, thread, flags, &tid);
4713 + char buf[64];
4714 + if (status == 0) {
4715 + log_info(os, thread)("Thread \"%s\" started (tid: " UINTX_FORMAT ", attributes: %s). ",
4716 + thread->name(), (uintx) tid, describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags));
4717 + } else {
4718 + log_warning(os, thread)("Failed to start thread \"%s\" - thr_create failed (%s) for attributes: %s.",
4719 + thread->name(), os::errno_name(status), describe_thr_create_attributes(buf, sizeof(buf), stack_size, flags));
4720 + // Log some OS information which might explain why creating the thread failed.
4721 + log_info(os, thread)("Number of threads approx. running in the VM: %d", Threads::number_of_threads());
4722 + LogStream st(Log(os, thread)::info());
4723 + os::Posix::print_rlimit_info(&st);
4724 + os::print_memory_info(&st);
4727 + if (status != 0) {
4728 + thread->set_osthread(NULL);
4729 + // Need to clean up stuff we've allocated so far
4730 + delete osthread;
4731 + return false;
4734 + Atomic::inc(&os::Solaris::_os_thread_count);
4736 + // Store info on the Solaris thread into the OSThread
4737 + osthread->set_thread_id(tid);
4739 + // Remember that we created this thread so we can set priority on it
4740 + osthread->set_vm_created();
4742 + // Most thread types will set an explicit priority before starting the thread,
4743 + // but for those that don't we need a valid value to read back in thread_native_entry.
4744 + osthread->set_native_priority(NormPriority);
4746 + // Initial thread state is INITIALIZED, not SUSPENDED
4747 + osthread->set_state(INITIALIZED);
4749 + // The thread is returned suspended (in state INITIALIZED), and is started higher up in the call chain
4750 + return true;
4753 +// CR 7190089: on Solaris, primordial thread's stack needs adjusting.
4754 +// Without the adjustment, stack size is incorrect if stack is set to unlimited (ulimit -s unlimited).
4755 +void os::Solaris::correct_stack_boundaries_for_primordial_thread(Thread* thr) {
4756 + assert(is_primordial_thread(), "Call only for primordial thread");
4758 + JavaThread* jt = (JavaThread *)thr;
4759 + assert(jt != NULL, "Sanity check");
4760 + size_t stack_size;
4761 + address base = jt->stack_base();
4762 + if (Arguments::created_by_java_launcher()) {
4763 + // Use 2MB to allow for Solaris 7 64 bit mode.
4764 + stack_size = JavaThread::stack_size_at_create() == 0
4765 + ? 2048*K : JavaThread::stack_size_at_create();
4767 + // There are rare cases when we may have already used more than
4768 + // the basic stack size allotment before this method is invoked.
4769 + // Attempt to allow for a normally sized java_stack.
4770 + size_t current_stack_offset = (size_t)(base - (address)&stack_size);
4771 + stack_size += ReservedSpace::page_align_size_down(current_stack_offset);
4772 + } else {
4773 + // 6269555: If we were not created by a Java launcher, i.e. if we are
4774 + // running embedded in a native application, treat the primordial thread
4775 + // as much like a native attached thread as possible. This means using
4776 + // the current stack size from thr_stksegment(), unless it is too large
4777 + // to reliably setup guard pages. A reasonable max size is 8MB.
4778 + size_t current_size = current_stack_size();
4779 + // This should never happen, but just in case....
4780 + if (current_size == 0) current_size = 2 * K * K;
4781 + stack_size = current_size > (8 * K * K) ? (8 * K * K) : current_size;
4783 + address bottom = align_up(base - stack_size, os::vm_page_size());;
4784 + stack_size = (size_t)(base - bottom);
4786 + assert(stack_size > 0, "Stack size calculation problem");
4788 + if (stack_size > jt->stack_size()) {
4789 +#ifndef PRODUCT
4790 + struct rlimit limits;
4791 + getrlimit(RLIMIT_STACK, &limits);
4792 + size_t size = adjust_stack_size(base, (size_t)limits.rlim_cur);
4793 + assert(size >= jt->stack_size(), "Stack size problem in main thread");
4794 +#endif
4795 + tty->print_cr("Stack size of " SIZE_FORMAT " Kb exceeds current limit of " SIZE_FORMAT " Kb.\n"
4796 + "(Stack sizes are rounded up to a multiple of the system page size.)\n"
4797 + "See limit(1) to increase the stack size limit.",
4798 + stack_size / K, jt->stack_size() / K);
4799 + vm_exit(1);
4801 + assert(jt->stack_size() >= stack_size,
4802 + "Attempt to map more stack than was allocated");
4803 + jt->set_stack_size(stack_size);
4809 +// Free Solaris resources related to the OSThread
4810 +void os::free_thread(OSThread* osthread) {
4811 + assert(osthread != NULL, "os::free_thread but osthread not set");
4813 + // We are told to free resources of the argument thread,
4814 + // but we can only really operate on the current thread.
4815 + assert(Thread::current()->osthread() == osthread,
4816 + "os::free_thread but not current thread");
4818 + // Restore caller's signal mask
4819 + sigset_t sigmask = osthread->caller_sigmask();
4820 + pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
4822 + delete osthread;
4825 +void os::pd_start_thread(Thread* thread) {
4826 + int status = thr_continue(thread->osthread()->thread_id());
4827 + assert_status(status == 0, status, "thr_continue failed");
4831 +intx os::current_thread_id() {
4832 + return (intx)thr_self();
4835 +static pid_t _initial_pid = 0;
4837 +int os::current_process_id() {
4838 + return (int)(_initial_pid ? _initial_pid : getpid());
4841 +// gethrtime() should be monotonic according to the documentation,
4842 +// but some virtualized platforms are known to break this guarantee.
4843 +// getTimeNanos() must be guaranteed not to move backwards, so we
4844 +// are forced to add a check here.
4845 +inline hrtime_t getTimeNanos() {
4846 + const hrtime_t now = gethrtime();
4847 + const hrtime_t prev = max_hrtime;
4848 + if (now <= prev) {
4849 + return prev; // same or retrograde time;
4851 + const hrtime_t obsv = Atomic::cmpxchg(&max_hrtime, prev, now);
4852 + assert(obsv >= prev, "invariant"); // Monotonicity
4853 + // If the CAS succeeded then we're done and return "now".
4854 + // If the CAS failed and the observed value "obsv" is >= now then
4855 + // we should return "obsv". If the CAS failed and now > obsv > prv then
4856 + // some other thread raced this thread and installed a new value, in which case
4857 + // we could either (a) retry the entire operation, (b) retry trying to install now
4858 + // or (c) just return obsv. We use (c). No loop is required although in some cases
4859 + // we might discard a higher "now" value in deference to a slightly lower but freshly
4860 + // installed obsv value. That's entirely benign -- it admits no new orderings compared
4861 + // to (a) or (b) -- and greatly reduces coherence traffic.
4862 + // We might also condition (c) on the magnitude of the delta between obsv and now.
4863 + // Avoiding excessive CAS operations to hot RW locations is critical.
4864 + // See https://blogs.oracle.com/dave/entry/cas_and_cache_trivia_invalidate
4865 + return (prev == obsv) ? now : obsv;
4868 +double os::elapsedVTime() {
4869 + return (double)gethrvtime() / (double)hrtime_hz;
4872 +// DLL functions
4874 +// This must be hard coded because it's the system's temporary
4875 +// directory not the java application's temp directory, ala java.io.tmpdir.
4876 +const char* os::get_temp_directory() { return "/tmp"; }
4878 +// check if addr is inside libjvm.so
4879 +bool os::address_is_in_vm(address addr) {
4880 + static address libjvm_base_addr;
4881 + Dl_info dlinfo;
4883 + if (libjvm_base_addr == NULL) {
4884 + if (dladdr(CAST_FROM_FN_PTR(void *, os::address_is_in_vm), &dlinfo) != 0) {
4885 + libjvm_base_addr = (address)dlinfo.dli_fbase;
4887 + assert(libjvm_base_addr !=NULL, "Cannot obtain base address for libjvm");
4890 + if (dladdr((void *)addr, &dlinfo) != 0) {
4891 + if (libjvm_base_addr == (address)dlinfo.dli_fbase) return true;
4894 + return false;
4897 +void os::prepare_native_symbols() {
4900 +bool os::dll_address_to_function_name(address addr, char *buf,
4901 + int buflen, int * offset,
4902 + bool demangle) {
4903 + // buf is not optional, but offset is optional
4904 + assert(buf != NULL, "sanity check");
4906 + Dl_info dlinfo;
4908 +#ifdef _LP64
4909 + Elf64_Sym * info;
4910 +#else
4911 + Elf32_Sym * info;
4912 +#endif
4913 + if (dladdr1((void *)addr, &dlinfo, (void **)&info,
4914 + RTLD_DL_SYMENT) != 0) {
4915 + // see if we have a matching symbol that covers our address
4916 + if (dlinfo.dli_saddr != NULL &&
4917 + (char *)dlinfo.dli_saddr + info->st_size > (char *)addr) {
4918 + if (dlinfo.dli_sname != NULL) {
4919 + if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) {
4920 + jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
4922 + if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
4923 + return true;
4926 + // no matching symbol so try for just file info
4927 + if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
4928 + if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
4929 + buf, buflen, offset, dlinfo.dli_fname, demangle)) {
4930 + return true;
4934 + buf[0] = '\0';
4935 + if (offset != NULL) *offset = -1;
4936 + return false;
4939 +bool os::dll_address_to_library_name(address addr, char* buf,
4940 + int buflen, int* offset) {
4941 + // buf is not optional, but offset is optional
4942 + assert(buf != NULL, "sanity check");
4944 + Dl_info dlinfo;
4946 + if (dladdr((void*)addr, &dlinfo) != 0) {
4947 + if (dlinfo.dli_fname != NULL) {
4948 + jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
4950 + if (dlinfo.dli_fbase != NULL && offset != NULL) {
4951 + *offset = addr - (address)dlinfo.dli_fbase;
4953 + return true;
4956 + buf[0] = '\0';
4957 + if (offset) *offset = -1;
4958 + return false;
4961 +int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
4962 + Dl_info dli;
4963 + // Sanity check?
4964 + if (dladdr(CAST_FROM_FN_PTR(void *, os::get_loaded_modules_info), &dli) == 0 ||
4965 + dli.dli_fname == NULL) {
4966 + return 1;
4969 + void * handle = dlopen(dli.dli_fname, RTLD_LAZY);
4970 + if (handle == NULL) {
4971 + return 1;
4974 + Link_map *map;
4975 + dlinfo(handle, RTLD_DI_LINKMAP, &map);
4976 + if (map == NULL) {
4977 + dlclose(handle);
4978 + return 1;
4981 + while (map->l_prev != NULL) {
4982 + map = map->l_prev;
4985 + while (map != NULL) {
4986 + // Iterate through all map entries and call callback with fields of interest
4987 + if(callback(map->l_name, (address)map->l_addr, (address)0, param)) {
4988 + dlclose(handle);
4989 + return 1;
4991 + map = map->l_next;
4994 + dlclose(handle);
4995 + return 0;
4998 +int _print_dll_info_cb(const char * name, address base_address, address top_address, void * param) {
4999 + outputStream * out = (outputStream *) param;
5000 + out->print_cr(INTPTR_FORMAT " \t%s", (intptr_t)base_address, name);
5001 + return 0;
5004 +void os::print_dll_info(outputStream * st) {
5005 + st->print_cr("Dynamic libraries:"); st->flush();
5006 + if (get_loaded_modules_info(_print_dll_info_cb, (void *)st)) {
5007 + st->print_cr("Error: Cannot print dynamic libraries.");
5011 +static void change_endianness(Elf32_Half& val) {
5012 + unsigned char *ptr = (unsigned char *)&val;
5013 + unsigned char swp = ptr[0];
5014 + ptr[0] = ptr[1];
5015 + ptr[1] = swp;
5018 +// Loads .dll/.so and
5019 +// in case of error it checks if .dll/.so was built for the
5020 +// same architecture as Hotspot is running on
5022 +void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
5023 + log_info(os)("attempting shared library load of %s", filename);
5025 + void * result= ::dlopen(filename, RTLD_LAZY);
5026 + if (result != NULL) {
5027 + // Successful loading
5028 + Events::log(NULL, "Loaded shared library %s", filename);
5029 + log_info(os)("shared library load of %s was successful", filename);
5030 + return result;
5033 + Elf32_Ehdr elf_head;
5034 + const char* error_report = ::dlerror();
5035 + if (error_report == NULL) {
5036 + error_report = "dlerror returned no error description";
5038 + if (ebuf != NULL && ebuflen > 0) {
5039 + ::strncpy(ebuf, error_report, ebuflen-1);
5040 + ebuf[ebuflen-1]='\0';
5043 + Events::log(NULL, "Loading shared library %s failed, %s", filename, error_report);
5044 + log_info(os)("shared library load of %s failed, %s", filename, error_report);
5046 + int diag_msg_max_length=ebuflen-strlen(ebuf);
5047 + char* diag_msg_buf=ebuf+strlen(ebuf);
5049 + if (diag_msg_max_length==0) {
5050 + // No more space in ebuf for additional diagnostics message
5051 + return NULL;
5055 + int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);
5057 + if (file_descriptor < 0) {
5058 + // Can't open library, report dlerror() message
5059 + return NULL;
5062 + bool failed_to_read_elf_head=
5063 + (sizeof(elf_head)!=
5064 + (::read(file_descriptor, &elf_head,sizeof(elf_head))));
5066 + ::close(file_descriptor);
5067 + if (failed_to_read_elf_head) {
5068 + // file i/o error - report dlerror() msg
5069 + return NULL;
5072 + if (elf_head.e_ident[EI_DATA] != LITTLE_ENDIAN_ONLY(ELFDATA2LSB) BIG_ENDIAN_ONLY(ELFDATA2MSB)) {
5073 + // handle invalid/out of range endianness values
5074 + if (elf_head.e_ident[EI_DATA] == 0 || elf_head.e_ident[EI_DATA] > 2) {
5075 + return NULL;
5077 + change_endianness(elf_head.e_machine);
5080 + typedef struct {
5081 + Elf32_Half code; // Actual value as defined in elf.h
5082 + Elf32_Half compat_class; // Compatibility of archs at VM's sense
5083 + unsigned char elf_class; // 32 or 64 bit
5084 + unsigned char endianess; // MSB or LSB
5085 + char* name; // String representation
5086 + } arch_t;
5088 + static const arch_t arch_array[]={
5089 + {EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
5090 + {EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
5091 + {EM_IA_64, EM_IA_64, ELFCLASS64, ELFDATA2LSB, (char*)"IA 64"},
5092 + {EM_X86_64, EM_X86_64, ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
5093 + {EM_SPARC, EM_SPARC, ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
5094 + {EM_SPARC32PLUS, EM_SPARC, ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
5095 + {EM_SPARCV9, EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"},
5096 + {EM_PPC, EM_PPC, ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
5097 + {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
5098 + {EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"},
5099 + // we only support 64 bit z architecture
5100 + {EM_S390, EM_S390, ELFCLASS64, ELFDATA2MSB, (char*)"IBM System/390"},
5101 + {EM_AARCH64, EM_AARCH64, ELFCLASS64, ELFDATA2LSB, (char*)"AARCH64"}
5102 + };
5104 +#if (defined IA32)
5105 + static Elf32_Half running_arch_code=EM_386;
5106 +#elif (defined AMD64)
5107 + static Elf32_Half running_arch_code=EM_X86_64;
5108 +#elif (defined IA64)
5109 + static Elf32_Half running_arch_code=EM_IA_64;
5110 +#elif (defined __sparc) && (defined _LP64)
5111 + static Elf32_Half running_arch_code=EM_SPARCV9;
5112 +#elif (defined __sparc) && (!defined _LP64)
5113 + static Elf32_Half running_arch_code=EM_SPARC;
5114 +#elif (defined __powerpc64__)
5115 + static Elf32_Half running_arch_code=EM_PPC64;
5116 +#elif (defined __powerpc__)
5117 + static Elf32_Half running_arch_code=EM_PPC;
5118 +#elif (defined ARM)
5119 + static Elf32_Half running_arch_code=EM_ARM;
5120 +#else
5121 + #error Method os::dll_load requires that one of following is defined:\
5122 + IA32, AMD64, IA64, __sparc, __powerpc__, ARM, ARM
5123 +#endif
5125 + // Identify compatibility class for VM's architecture and library's architecture
5126 + // Obtain string descriptions for architectures
5128 + arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL};
5129 + int running_arch_index=-1;
5131 + for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) {
5132 + if (running_arch_code == arch_array[i].code) {
5133 + running_arch_index = i;
5135 + if (lib_arch.code == arch_array[i].code) {
5136 + lib_arch.compat_class = arch_array[i].compat_class;
5137 + lib_arch.name = arch_array[i].name;
5141 + assert(running_arch_index != -1,
5142 + "Didn't find running architecture code (running_arch_code) in arch_array");
5143 + if (running_arch_index == -1) {
5144 + // Even though running architecture detection failed
5145 + // we may still continue with reporting dlerror() message
5146 + return NULL;
5149 + if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
5150 + if (lib_arch.name != NULL) {
5151 + ::snprintf(diag_msg_buf, diag_msg_max_length-1,
5152 + " (Possible cause: can't load %s .so on a %s platform)",
5153 + lib_arch.name, arch_array[running_arch_index].name);
5154 + } else {
5155 + ::snprintf(diag_msg_buf, diag_msg_max_length-1,
5156 + " (Possible cause: can't load this .so (machine code=0x%x) on a %s platform)",
5157 + lib_arch.code, arch_array[running_arch_index].name);
5159 + return NULL;
5162 + if (lib_arch.endianess != arch_array[running_arch_index].endianess) {
5163 + ::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: endianness mismatch)");
5164 + return NULL;
5167 + // ELF file class/capacity : 0 - invalid, 1 - 32bit, 2 - 64bit
5168 + if (lib_arch.elf_class > 2 || lib_arch.elf_class < 1) {
5169 + ::snprintf(diag_msg_buf, diag_msg_max_length-1, " (Possible cause: invalid ELF file class)");
5170 + return NULL;
5173 + if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) {
5174 + ::snprintf(diag_msg_buf, diag_msg_max_length-1,
5175 + " (Possible cause: architecture word width mismatch, can't load %d-bit .so on a %d-bit platform)",
5176 + (int) lib_arch.elf_class * 32, arch_array[running_arch_index].elf_class * 32);
5177 + return NULL;
5180 + return NULL;
5183 +static inline time_t get_mtime(const char* filename) {
5184 + struct stat st;
5185 + int ret = os::stat(filename, &st);
5186 + assert(ret == 0, "failed to stat() file '%s': %s", filename, os::strerror(errno));
5187 + return st.st_mtime;
5190 +int os::compare_file_modified_times(const char* file1, const char* file2) {
5191 + time_t t1 = get_mtime(file1);
5192 + time_t t2 = get_mtime(file2);
5193 + return t1 - t2;
5196 +static bool _print_ascii_file(const char* filename, outputStream* st) {
5197 + int fd = ::open(filename, O_RDONLY);
5198 + if (fd == -1) {
5199 + return false;
5202 + char buf[32];
5203 + int bytes;
5204 + while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
5205 + st->print_raw(buf, bytes);
5208 + ::close(fd);
5210 + return true;
5213 +void os::print_os_info_brief(outputStream* st) {
5214 + os::Solaris::print_distro_info(st);
5216 + os::Posix::print_uname_info(st);
5218 + os::Solaris::print_libversion_info(st);
5221 +void os::print_os_info(outputStream* st) {
5222 + st->print("OS:");
5224 + os::Solaris::print_distro_info(st);
5226 + os::Posix::print_uname_info(st);
5228 + os::Posix::print_uptime_info(st);
5230 + os::Solaris::print_libversion_info(st);
5232 + os::Posix::print_rlimit_info(st);
5234 + os::Posix::print_load_average(st);
5237 +void os::Solaris::print_distro_info(outputStream* st) {
5238 + if (!_print_ascii_file("/etc/release", st)) {
5239 + st->print("Solaris");
5241 + st->cr();
5244 +void os::get_summary_os_info(char* buf, size_t buflen) {
5245 + strncpy(buf, "Solaris", buflen); // default to plain solaris
5246 + FILE* fp = fopen("/etc/release", "r");
5247 + if (fp != NULL) {
5248 + char tmp[256];
5249 + // Only get the first line and chop out everything but the os name.
5250 + if (fgets(tmp, sizeof(tmp), fp)) {
5251 + char* ptr = tmp;
5252 + // skip past whitespace characters
5253 + while (*ptr != '\0' && (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')) ptr++;
5254 + if (*ptr != '\0') {
5255 + char* nl = strchr(ptr, '\n');
5256 + if (nl != NULL) *nl = '\0';
5257 + strncpy(buf, ptr, buflen);
5260 + fclose(fp);
5264 +void os::Solaris::print_libversion_info(outputStream* st) {
5265 + st->print(" (T2 libthread)");
5266 + st->cr();
5269 +static bool check_addr0(outputStream* st) {
5270 + jboolean status = false;
5271 + const int read_chunk = 200;
5272 + int ret = 0;
5273 + int nmap = 0;
5274 + int fd = ::open("/proc/self/map",O_RDONLY);
5275 + if (fd >= 0) {
5276 + prmap_t *p = NULL;
5277 + char *mbuff = (char *) calloc(read_chunk, sizeof(prmap_t));
5278 + if (NULL == mbuff) {
5279 + ::close(fd);
5280 + return status;
5282 + while ((ret = ::read(fd, mbuff, read_chunk*sizeof(prmap_t))) > 0) {
5283 + //check if read() has not read partial data
5284 + if( 0 != ret % sizeof(prmap_t)){
5285 + break;
5287 + nmap = ret / sizeof(prmap_t);
5288 + p = (prmap_t *)mbuff;
5289 + for(int i = 0; i < nmap; i++){
5290 + if (p->pr_vaddr == 0x0) {
5291 + st->print("Warning: Address: " PTR_FORMAT ", Size: " SIZE_FORMAT "K, ",p->pr_vaddr, p->pr_size/1024);
5292 + st->print("Mapped file: %s, ", p->pr_mapname[0] == '\0' ? "None" : p->pr_mapname);
5293 + st->print("Access: ");
5294 + st->print("%s",(p->pr_mflags & MA_READ) ? "r" : "-");
5295 + st->print("%s",(p->pr_mflags & MA_WRITE) ? "w" : "-");
5296 + st->print("%s",(p->pr_mflags & MA_EXEC) ? "x" : "-");
5297 + st->cr();
5298 + status = true;
5300 + p++;
5303 + free(mbuff);
5304 + ::close(fd);
5306 + return status;
5309 +void os::get_summary_cpu_info(char* buf, size_t buflen) {
5310 + // Get MHz with system call. We don't seem to already have this.
5311 + processor_info_t stats;
5312 + processorid_t id = getcpuid();
5313 + int clock = 0;
5314 + if (processor_info(id, &stats) != -1) {
5315 + clock = stats.pi_clock; // pi_processor_type isn't more informative than below
5317 + snprintf(buf, buflen, "64 bit %d MHz", clock);
5320 +void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
5321 + // Nothing to do for now.
5324 +void os::print_memory_info(outputStream* st) {
5325 + st->print("Memory:");
5326 + st->print(" " SIZE_FORMAT "k page", os::vm_page_size()>>10);
5327 + st->print(", physical " UINT64_FORMAT "k", os::physical_memory()>>10);
5328 + st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10);
5329 + st->cr();
5330 + (void) check_addr0(st);
5333 +static int Maxsignum = 0;
5335 +static char saved_jvm_path[MAXPATHLEN] = { 0 };
5337 +// Find the full path to the current module, libjvm.so
5338 +void os::jvm_path(char *buf, jint buflen) {
5339 + // Error checking.
5340 + if (buflen < MAXPATHLEN) {
5341 + assert(false, "must use a large-enough buffer");
5342 + buf[0] = '\0';
5343 + return;
5345 + // Lazy resolve the path to current module.
5346 + if (saved_jvm_path[0] != 0) {
5347 + strcpy(buf, saved_jvm_path);
5348 + return;
5351 + Dl_info dlinfo;
5352 + int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
5353 + assert(ret != 0, "cannot locate libjvm");
5354 + if (ret != 0 && dlinfo.dli_fname != NULL) {
5355 + if (os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen) == NULL) {
5356 + return;
5358 + } else {
5359 + buf[0] = '\0';
5360 + return;
5363 + if (Arguments::sun_java_launcher_is_altjvm()) {
5364 + // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
5365 + // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".
5366 + // If "/jre/lib/" appears at the right place in the string, then
5367 + // assume we are installed in a JDK and we're done. Otherwise, check
5368 + // for a JAVA_HOME environment variable and fix up the path so it
5369 + // looks like libjvm.so is installed there (append a fake suffix
5370 + // hotspot/libjvm.so).
5371 + const char *p = buf + strlen(buf) - 1;
5372 + for (int count = 0; p > buf && count < 5; ++count) {
5373 + for (--p; p > buf && *p != '/'; --p)
5374 + /* empty */ ;
5377 + if (strncmp(p, "/jre/lib/", 9) != 0) {
5378 + // Look for JAVA_HOME in the environment.
5379 + char* java_home_var = ::getenv("JAVA_HOME");
5380 + if (java_home_var != NULL && java_home_var[0] != 0) {
5381 + char* jrelib_p;
5382 + int len;
5384 + // Check the current module name "libjvm.so".
5385 + p = strrchr(buf, '/');
5386 + assert(strstr(p, "/libjvm") == p, "invalid library name");
5388 + if (os::Posix::realpath(java_home_var, buf, buflen) == NULL) {
5389 + return;
5391 + // determine if this is a legacy image or modules image
5392 + // modules image doesn't have "jre" subdirectory
5393 + len = strlen(buf);
5394 + assert(len < buflen, "Ran out of buffer space");
5395 + jrelib_p = buf + len;
5396 + snprintf(jrelib_p, buflen-len, "/jre/lib");
5397 + if (0 != access(buf, F_OK)) {
5398 + snprintf(jrelib_p, buflen-len, "/lib");
5401 + if (0 == access(buf, F_OK)) {
5402 + // Use current module name "libjvm.so"
5403 + len = strlen(buf);
5404 + snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
5405 + } else {
5406 + // Go back to path of .so
5407 + if (os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen) == NULL) {
5408 + return;
5415 + strncpy(saved_jvm_path, buf, MAXPATHLEN);
5416 + saved_jvm_path[MAXPATHLEN - 1] = '\0';
5419 +////////////////////////////////////////////////////////////////////////////////
5420 +// Virtual Memory
5422 +static bool recoverable_mmap_error(int err) {
5423 + // See if the error is one we can let the caller handle. This
5424 + // list of errno values comes from the Solaris mmap(2) man page.
5425 + switch (err) {
5426 + case EBADF:
5427 + case EINVAL:
5428 + case ENOTSUP:
5429 + // let the caller deal with these errors
5430 + return true;
5432 + default:
5433 + // Any remaining errors on this OS can cause our reserved mapping
5434 + // to be lost. That can cause confusion where different data
5435 + // structures think they have the same memory mapped. The worst
5436 + // scenario is if both the VM and a library think they have the
5437 + // same memory mapped.
5438 + return false;
5442 +static void warn_fail_commit_memory(char* addr, size_t bytes, bool exec,
5443 + int err) {
5444 + warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT
5445 + ", %d) failed; error='%s' (errno=%d)", p2i(addr), bytes, exec,
5446 + os::strerror(err), err);
5449 +static void warn_fail_commit_memory(char* addr, size_t bytes,
5450 + size_t alignment_hint, bool exec,
5451 + int err) {
5452 + warning("INFO: os::commit_memory(" PTR_FORMAT ", " SIZE_FORMAT
5453 + ", " SIZE_FORMAT ", %d) failed; error='%s' (errno=%d)", p2i(addr),
5454 + bytes, alignment_hint, exec, os::strerror(err), err);
5457 +int os::Solaris::commit_memory_impl(char* addr, size_t bytes, bool exec) {
5458 + int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
5459 + size_t size = bytes;
5460 + char *res = Solaris::mmap_chunk(addr, size, MAP_PRIVATE|MAP_FIXED, prot);
5461 + if (res != NULL) {
5462 + if (UseNUMAInterleaving) {
5463 + numa_make_global(addr, bytes);
5465 + return 0;
5468 + int err = errno; // save errno from mmap() call in mmap_chunk()
5470 + if (!recoverable_mmap_error(err)) {
5471 + warn_fail_commit_memory(addr, bytes, exec, err);
5472 + vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "committing reserved memory.");
5475 + return err;
5478 +bool os::pd_commit_memory(char* addr, size_t bytes, bool exec) {
5479 + return Solaris::commit_memory_impl(addr, bytes, exec) == 0;
5482 +void os::pd_commit_memory_or_exit(char* addr, size_t bytes, bool exec,
5483 + const char* mesg) {
5484 + assert(mesg != NULL, "mesg must be specified");
5485 + int err = os::Solaris::commit_memory_impl(addr, bytes, exec);
5486 + if (err != 0) {
5487 + // the caller wants all commit errors to exit with the specified mesg:
5488 + warn_fail_commit_memory(addr, bytes, exec, err);
5489 + vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
5493 +size_t os::Solaris::page_size_for_alignment(size_t alignment) {
5494 + assert(is_aligned(alignment, (size_t) os::vm_page_size()),
5495 + SIZE_FORMAT " is not aligned to " SIZE_FORMAT,
5496 + alignment, (size_t) os::vm_page_size());
5498 + int page_sizes_max = 9;
5499 + size_t _illumos_page_sizes[page_sizes_max];
5500 + int n = getpagesizes(_illumos_page_sizes, page_sizes_max);
5501 + for (int i = 0; _illumos_page_sizes[i] != 0; i++) {
5502 + if (is_aligned(alignment, _illumos_page_sizes[i])) {
5503 + return _illumos_page_sizes[i];
5507 + return (size_t) os::vm_page_size();
5510 +int os::Solaris::commit_memory_impl(char* addr, size_t bytes,
5511 + size_t alignment_hint, bool exec) {
5512 + int err = Solaris::commit_memory_impl(addr, bytes, exec);
5513 + if (err == 0 && UseLargePages && alignment_hint > 0) {
5514 + assert(is_aligned(bytes, alignment_hint),
5515 + SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, alignment_hint);
5517 + // The syscall memcntl requires an exact page size (see man memcntl for details).
5518 + size_t page_size = page_size_for_alignment(alignment_hint);
5519 + if (page_size > (size_t) os::vm_page_size()) {
5520 + (void)Solaris::setup_large_pages(addr, bytes, page_size);
5523 + return err;
5526 +bool os::pd_commit_memory(char* addr, size_t bytes, size_t alignment_hint,
5527 + bool exec) {
5528 + return Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec) == 0;
5531 +void os::pd_commit_memory_or_exit(char* addr, size_t bytes,
5532 + size_t alignment_hint, bool exec,
5533 + const char* mesg) {
5534 + assert(mesg != NULL, "mesg must be specified");
5535 + int err = os::Solaris::commit_memory_impl(addr, bytes, alignment_hint, exec);
5536 + if (err != 0) {
5537 + // the caller wants all commit errors to exit with the specified mesg:
5538 + warn_fail_commit_memory(addr, bytes, alignment_hint, exec, err);
5539 + vm_exit_out_of_memory(bytes, OOM_MMAP_ERROR, "%s", mesg);
5543 +// Uncommit the pages in a specified region.
5544 +void os::pd_disclaim_memory(char* addr, size_t bytes) {
5545 + if (posix_madvise(addr, bytes, MADV_FREE) < 0) {
5546 + debug_only(warning("MADV_FREE failed."));
5547 + return;
5551 +size_t os::pd_pretouch_memory(void* first, void* last, size_t page_size) {
5552 + return page_size;
5555 +bool os::pd_create_stack_guard_pages(char* addr, size_t size) {
5556 + return os::commit_memory(addr, size, !ExecMem);
5559 +bool os::remove_stack_guard_pages(char* addr, size_t size) {
5560 + return os::uncommit_memory(addr, size);
5563 +// Change the page size in a given range.
5564 +void os::pd_realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
5565 + assert((intptr_t)addr % alignment_hint == 0, "Address should be aligned.");
5566 + assert((intptr_t)(addr + bytes) % alignment_hint == 0, "End should be aligned.");
5567 + if (UseLargePages) {
5568 + size_t page_size = Solaris::page_size_for_alignment(alignment_hint);
5569 + if (page_size > (size_t) os::vm_page_size()) {
5570 + Solaris::setup_large_pages(addr, bytes, page_size);
5575 +// Tell the OS to make the range local to the first-touching LWP
5576 +void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
5577 + assert((intptr_t)addr % os::vm_page_size() == 0, "Address should be page-aligned.");
5578 + if (posix_madvise(addr, bytes, MADV_ACCESS_LWP) < 0) {
5579 + debug_only(warning("MADV_ACCESS_LWP failed."));
5583 +// Tell the OS that this range would be accessed from different LWPs.
5584 +void os::numa_make_global(char *addr, size_t bytes) {
5585 + assert((intptr_t)addr % os::vm_page_size() == 0, "Address should be page-aligned.");
5586 + if (posix_madvise(addr, bytes, MADV_ACCESS_MANY) < 0) {
5587 + debug_only(warning("MADV_ACCESS_MANY failed."));
5591 +// Get the number of the locality groups.
5592 +size_t os::numa_get_groups_num() {
5593 + size_t n = Solaris::lgrp_nlgrps(Solaris::lgrp_cookie());
5594 + return n != -1 ? n : 1;
5597 +// Get a list of leaf locality groups. A leaf lgroup is group that
5598 +// doesn't have any children. Typical leaf group is a CPU or a CPU/memory
5599 +// board. An LWP is assigned to one of these groups upon creation.
5600 +size_t os::numa_get_leaf_groups(uint *ids, size_t size) {
5601 + if ((ids[0] = Solaris::lgrp_root(Solaris::lgrp_cookie())) == -1) {
5602 + ids[0] = 0;
5603 + return 1;
5605 + int result_size = 0, top = 1, bottom = 0, cur = 0;
5606 + for (unsigned int k = 0; k < size; k++) {
5607 + int r = Solaris::lgrp_children(Solaris::lgrp_cookie(), ids[cur],
5608 + (Solaris::lgrp_id_t*)&ids[top], size - top);
5609 + if (r == -1) {
5610 + ids[0] = 0;
5611 + return 1;
5613 + if (!r) {
5614 + // That's a leaf node.
5615 + assert(bottom <= cur, "Sanity check");
5616 + // Check if the node has memory
5617 + if (Solaris::lgrp_resources(Solaris::lgrp_cookie(), ids[cur],
5618 + NULL, 0, LGRP_RSRC_MEM) > 0) {
5619 + ids[bottom++] = ids[cur];
5622 + top += r;
5623 + cur++;
5625 + if (bottom == 0) {
5626 + // Handle a situation, when the OS reports no memory available.
5627 + // Assume UMA architecture.
5628 + ids[0] = 0;
5629 + return 1;
5631 + return bottom;
5634 +// Detect the topology change. Typically happens during CPU plugging-unplugging.
5635 +bool os::numa_topology_changed() {
5636 + int is_stale = Solaris::lgrp_cookie_stale(Solaris::lgrp_cookie());
5637 + if (is_stale != -1 && is_stale) {
5638 + Solaris::lgrp_fini(Solaris::lgrp_cookie());
5639 + Solaris::lgrp_cookie_t c = Solaris::lgrp_init(Solaris::LGRP_VIEW_CALLER);
5640 + assert(c != 0, "Failure to initialize LGRP API");
5641 + Solaris::set_lgrp_cookie(c);
5642 + return true;
5644 + return false;
5647 +// Get the group id of the current LWP.
5648 +int os::numa_get_group_id() {
5649 + int lgrp_id = Solaris::lgrp_home(P_LWPID, P_MYID);
5650 + if (lgrp_id == -1) {
5651 + return 0;
5653 + const int size = os::numa_get_groups_num();
5654 + int *ids = (int*)alloca(size * sizeof(int));
5656 + // Get the ids of all lgroups with memory; r is the count.
5657 + int r = Solaris::lgrp_resources(Solaris::lgrp_cookie(), lgrp_id,
5658 + (Solaris::lgrp_id_t*)ids, size, LGRP_RSRC_MEM);
5659 + if (r <= 0) {
5660 + return 0;
5662 + return ids[os::random() % r];
5665 +int os::numa_get_group_id_for_address(const void* address) {
5666 + return 0;
5669 +bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count) {
5670 + return false;
5673 +bool os::pd_uncommit_memory(char* addr, size_t bytes, bool exec) {
5674 + size_t size = bytes;
5675 + // Map uncommitted pages PROT_NONE so we fail early if we touch an
5676 + // uncommitted page. Otherwise, the read/write might succeed if we
5677 + // have enough swap space to back the physical page.
5678 + return
5679 + NULL != Solaris::mmap_chunk(addr, size,
5680 + MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE,
5681 + PROT_NONE);
5684 +char* os::Solaris::mmap_chunk(char *addr, size_t size, int flags, int prot) {
5685 + char *b = (char *)mmap(addr, size, prot, flags, os::Solaris::_dev_zero_fd, 0);
5687 + if (b == MAP_FAILED) {
5688 + return NULL;
5690 + return b;
5693 +char* os::Solaris::anon_mmap(char* requested_addr, size_t bytes) {
5694 + char* addr = requested_addr;
5695 + int flags = MAP_PRIVATE | MAP_NORESERVE;
5697 + // Map uncommitted pages PROT_NONE so we fail early if we touch an
5698 + // uncommitted page. Otherwise, the read/write might succeed if we
5699 + // have enough swap space to back the physical page.
5700 + return mmap_chunk(addr, bytes, flags, PROT_NONE);
5703 +char* os::pd_reserve_memory(size_t bytes, bool exec) {
5704 + char* addr = Solaris::anon_mmap(NULL, bytes);
5706 + return addr;
5709 +char* os::pd_attempt_map_memory_to_file_at(char* requested_addr, size_t bytes, int file_desc) {
5710 + assert(file_desc >= 0, "file_desc is not valid");
5711 + char* result = pd_attempt_reserve_memory_at(requested_addr, bytes, !ExecMem);
5712 + if (result != NULL) {
5713 + if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) {
5714 + vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
5717 + return result;
5720 +// Reserve memory at an arbitrary address, only if that area is
5721 +// available (and not reserved for something else).
5723 +char* os::pd_attempt_reserve_memory_at(char* requested_addr, size_t bytes, bool exec) {
5724 + // Assert only that the size is a multiple of the page size, since
5725 + // that's all that mmap requires, and since that's all we really know
5726 + // about at this low abstraction level. If we need higher alignment,
5727 + // we can either pass an alignment to this method or verify alignment
5728 + // in one of the methods further up the call chain. See bug 5044738.
5729 + assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block");
5731 + // Since snv_84, Solaris attempts to honor the address hint - see 5003415.
5732 + char* addr = Solaris::anon_mmap(requested_addr, bytes);
5734 + volatile int err = errno;
5735 + if (addr == requested_addr) {
5736 + return addr;
5739 + if (addr != NULL) {
5740 + pd_unmap_memory(addr, bytes);
5743 + return NULL;
5746 +bool os::pd_release_memory(char* addr, size_t bytes) {
5747 + size_t size = bytes;
5748 + return munmap(addr, size) == 0;
5751 +static bool solaris_mprotect(char* addr, size_t bytes, int prot) {
5752 + assert(addr == (char*)align_down((uintptr_t)addr, os::vm_page_size()),
5753 + "addr must be page aligned");
5754 + Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+bytes), prot);
5755 + int retVal = mprotect(addr, bytes, prot);
5756 + return retVal == 0;
5759 +// Protect memory (Used to pass readonly pages through
5760 +// JNI GetArray<type>Elements with empty arrays.)
5761 +// Also, used for serialization page and for compressed oops null pointer
5762 +// checking.
5763 +bool os::protect_memory(char* addr, size_t bytes, ProtType prot,
5764 + bool is_committed) {
5765 + unsigned int p = 0;
5766 + switch (prot) {
5767 + case MEM_PROT_NONE: p = PROT_NONE; break;
5768 + case MEM_PROT_READ: p = PROT_READ; break;
5769 + case MEM_PROT_RW: p = PROT_READ|PROT_WRITE; break;
5770 + case MEM_PROT_RWX: p = PROT_READ|PROT_WRITE|PROT_EXEC; break;
5771 + default:
5772 + ShouldNotReachHere();
5774 + // is_committed is unused.
5775 + return solaris_mprotect(addr, bytes, p);
5778 +// guard_memory and unguard_memory only happens within stack guard pages.
5779 +// Since ISM pertains only to the heap, guard and unguard memory should not
5780 +/// happen with an ISM region.
5781 +bool os::guard_memory(char* addr, size_t bytes) {
5782 + return solaris_mprotect(addr, bytes, PROT_NONE);
5785 +bool os::unguard_memory(char* addr, size_t bytes) {
5786 + return solaris_mprotect(addr, bytes, PROT_READ|PROT_WRITE);
5789 +// Large page support
5790 +static size_t _large_page_size = 0;
5792 +bool os::Solaris::mpss_sanity_check(bool warn, size_t* page_size) {
5793 + // Find the page sizes supported by the system
5794 + int page_sizes_max = 9;
5795 + size_t _illumos_page_sizes[page_sizes_max];
5796 + int n = getpagesizes(_illumos_page_sizes, page_sizes_max);
5797 + assert(n > 0, "illumos bug?");
5799 + if (n == 1) return false; // Only one page size available.
5801 + // Skip sizes larger than 4M (or LargePageSizeInBytes if it was set)
5802 + const size_t size_limit =
5803 + FLAG_IS_DEFAULT(LargePageSizeInBytes) ? 4 * M : LargePageSizeInBytes;
5804 + int beg;
5805 + for (beg = 0; beg < n; ++beg) {
5806 + if (_illumos_page_sizes[beg] <= size_limit) {
5807 + _page_sizes.add(_illumos_page_sizes[beg]);
5808 + if (_illumos_page_sizes[beg] > *page_size) {
5809 + *page_size = _illumos_page_sizes[beg];
5813 + // make sure we add the default
5814 + _page_sizes.add(os::vm_page_size());
5815 + return true;
5818 +void os::large_page_init() {
5819 + if (UseLargePages) {
5820 + // print a warning if any large page related flag is specified on command line
5821 + bool warn_on_failure = !FLAG_IS_DEFAULT(UseLargePages) ||
5822 + !FLAG_IS_DEFAULT(LargePageSizeInBytes);
5824 + UseLargePages = Solaris::mpss_sanity_check(warn_on_failure, &_large_page_size);
5828 +bool os::Solaris::is_valid_page_size(size_t bytes) {
5829 + return _page_sizes.contains(bytes);
5832 +bool os::Solaris::setup_large_pages(caddr_t start, size_t bytes, size_t align) {
5833 + assert(is_valid_page_size(align), SIZE_FORMAT " is not a valid page size", align);
5834 + assert(is_aligned((void*) start, align),
5835 + PTR_FORMAT " is not aligned to " SIZE_FORMAT, p2i((void*) start), align);
5836 + assert(is_aligned(bytes, align),
5837 + SIZE_FORMAT " is not aligned to " SIZE_FORMAT, bytes, align);
5839 + // Signal to OS that we want large pages for addresses
5840 + // from addr, addr + bytes
5841 + struct memcntl_mha mpss_struct;
5842 + mpss_struct.mha_cmd = MHA_MAPSIZE_VA;
5843 + mpss_struct.mha_pagesize = align;
5844 + mpss_struct.mha_flags = 0;
5845 + // Upon successful completion, memcntl() returns 0
5846 + if (memcntl(start, bytes, MC_HAT_ADVISE, (caddr_t) &mpss_struct, 0, 0)) {
5847 + debug_only(warning("Attempt to use MPSS failed."));
5848 + return false;
5850 + return true;
5853 +char* os::pd_reserve_memory_special(size_t size, size_t alignment, size_t page_size, char* addr, bool exec) {
5854 + fatal("os::reserve_memory_special should not be called on Solaris.");
5855 + return NULL;
5858 +bool os::pd_release_memory_special(char* base, size_t bytes) {
5859 + fatal("os::release_memory_special should not be called on Solaris.");
5860 + return false;
5863 +size_t os::large_page_size() {
5864 + return _large_page_size;
5867 +// MPSS allows application to commit large page memory on demand; with ISM
5868 +// the entire memory region must be allocated as shared memory.
5869 +bool os::can_commit_large_page_memory() {
5870 + return true;
5873 +size_t os::vm_min_address() {
5874 + return _vm_min_address_default;
5877 +// Interface for setting lwp priorities. We are using T2 libthread,
5878 +// which forces the use of bound threads, so all of our threads will
5879 +// be assigned to real lwp's. Using the thr_setprio function is
5880 +// meaningless in this mode so we must adjust the real lwp's priority.
5881 +// The routines below implement the getting and setting of lwp priorities.
5883 +// Note: There are three priority scales used on Solaris. Java priorities
5884 +// which range from 1 to 10, libthread "thr_setprio" scale which range
5885 +// from 0 to 127, and the current scheduling class of the process we
5886 +// are running in. This is typically from -60 to +60.
5887 +// The setting of the lwp priorities is done after a call to thr_setprio
5888 +// so Java priorities are mapped to libthread priorities and we map from
5889 +// the latter to lwp priorities. We don't keep priorities stored in
5890 +// Java priorities since some of our worker threads want to set priorities
5891 +// higher than all Java threads.
5893 +// For related information:
5894 +// (1) man -s 2 priocntl
5895 +// (2) man -s 4 priocntl
5896 +// (3) man dispadmin
5897 +// = librt.so
5898 +// = libthread/common/rtsched.c - thrp_setlwpprio().
5899 +// = ps -cL <pid> ... to validate priority.
5900 +// = sched_get_priority_min and _max
5901 +// pthread_create
5902 +// sched_setparam
5903 +// pthread_setschedparam
5905 +// Assumptions:
5906 +// + We assume that all threads in the process belong to the same
5907 +// scheduling class. IE. an homogenous process.
5908 +// + Must be root or in IA group to change change "interactive" attribute.
5909 +// Priocntl() will fail silently. The only indication of failure is when
5910 +// we read-back the value and notice that it hasn't changed.
5911 +// + Interactive threads enter the runq at the head, non-interactive at the tail.
5912 +// + For RT, change timeslice as well. Invariant:
5913 +// constant "priority integral"
5914 +// Konst == TimeSlice * (60-Priority)
5915 +// Given a priority, compute appropriate timeslice.
5916 +// + Higher numerical values have higher priority.
5918 +// sched class attributes
5919 +typedef struct {
5920 + int schedPolicy; // classID
5921 + int maxPrio;
5922 + int minPrio;
5923 +} SchedInfo;
5926 +static SchedInfo tsLimits, iaLimits, rtLimits, fxLimits;
5928 +#ifdef ASSERT
5929 +static int ReadBackValidate = 1;
5930 +#endif
5931 +static int myClass = 0;
5932 +static int myMin = 0;
5933 +static int myMax = 0;
5934 +static int myCur = 0;
5935 +static bool priocntl_enable = false;
5937 +static const int criticalPrio = FXCriticalPriority;
5938 +static int java_MaxPriority_to_os_priority = 0; // Saved mapping
5941 +// lwp_priocntl_init
5943 +// Try to determine the priority scale for our process.
5945 +// Return errno or 0 if OK.
5947 +static int lwp_priocntl_init() {
5948 + int rslt;
5949 + pcinfo_t ClassInfo;
5950 + pcparms_t ParmInfo;
5951 + int i;
5953 + if (!UseThreadPriorities) return 0;
5955 + // If ThreadPriorityPolicy is 1, switch tables
5956 + if (ThreadPriorityPolicy == 1) {
5957 + for (i = 0; i < CriticalPriority+1; i++)
5958 + os::java_to_os_priority[i] = prio_policy1[i];
5960 + if (UseCriticalJavaThreadPriority) {
5961 + // MaxPriority always maps to the FX scheduling class and criticalPrio.
5962 + // See set_native_priority() and set_lwp_class_and_priority().
5963 + // Save original MaxPriority mapping in case attempt to
5964 + // use critical priority fails.
5965 + java_MaxPriority_to_os_priority = os::java_to_os_priority[MaxPriority];
5966 + // Set negative to distinguish from other priorities
5967 + os::java_to_os_priority[MaxPriority] = -criticalPrio;
5970 + // Get IDs for a set of well-known scheduling classes.
5971 + // TODO-FIXME: GETCLINFO returns the current # of classes in the
5972 + // the system. We should have a loop that iterates over the
5973 + // classID values, which are known to be "small" integers.
5975 + strcpy(ClassInfo.pc_clname, "TS");
5976 + ClassInfo.pc_cid = -1;
5977 + rslt = priocntl(P_ALL, 0, PC_GETCID, (caddr_t)&ClassInfo);
5978 + if (rslt < 0) return errno;
5979 + assert(ClassInfo.pc_cid != -1, "cid for TS class is -1");
5980 + tsLimits.schedPolicy = ClassInfo.pc_cid;
5981 + tsLimits.maxPrio = ((tsinfo_t*)ClassInfo.pc_clinfo)->ts_maxupri;
5982 + tsLimits.minPrio = -tsLimits.maxPrio;
5984 + strcpy(ClassInfo.pc_clname, "IA");
5985 + ClassInfo.pc_cid = -1;
5986 + rslt = priocntl(P_ALL, 0, PC_GETCID, (caddr_t)&ClassInfo);
5987 + if (rslt < 0) return errno;
5988 + assert(ClassInfo.pc_cid != -1, "cid for IA class is -1");
5989 + iaLimits.schedPolicy = ClassInfo.pc_cid;
5990 + iaLimits.maxPrio = ((iainfo_t*)ClassInfo.pc_clinfo)->ia_maxupri;
5991 + iaLimits.minPrio = -iaLimits.maxPrio;
5993 + strcpy(ClassInfo.pc_clname, "RT");
5994 + ClassInfo.pc_cid = -1;
5995 + rslt = priocntl(P_ALL, 0, PC_GETCID, (caddr_t)&ClassInfo);
5996 + if (rslt < 0) return errno;
5997 + assert(ClassInfo.pc_cid != -1, "cid for RT class is -1");
5998 + rtLimits.schedPolicy = ClassInfo.pc_cid;
5999 + rtLimits.maxPrio = ((rtinfo_t*)ClassInfo.pc_clinfo)->rt_maxpri;
6000 + rtLimits.minPrio = 0;
6002 + strcpy(ClassInfo.pc_clname, "FX");
6003 + ClassInfo.pc_cid = -1;
6004 + rslt = priocntl(P_ALL, 0, PC_GETCID, (caddr_t)&ClassInfo);
6005 + if (rslt < 0) return errno;
6006 + assert(ClassInfo.pc_cid != -1, "cid for FX class is -1");
6007 + fxLimits.schedPolicy = ClassInfo.pc_cid;
6008 + fxLimits.maxPrio = ((fxinfo_t*)ClassInfo.pc_clinfo)->fx_maxupri;
6009 + fxLimits.minPrio = 0;
6011 + // Query our "current" scheduling class.
6012 + // This will normally be IA, TS or, rarely, FX or RT.
6013 + memset(&ParmInfo, 0, sizeof(ParmInfo));
6014 + ParmInfo.pc_cid = PC_CLNULL;
6015 + rslt = priocntl(P_PID, P_MYID, PC_GETPARMS, (caddr_t)&ParmInfo);
6016 + if (rslt < 0) return errno;
6017 + myClass = ParmInfo.pc_cid;
6019 + // We now know our scheduling classId, get specific information
6020 + // about the class.
6021 + ClassInfo.pc_cid = myClass;
6022 + ClassInfo.pc_clname[0] = 0;
6023 + rslt = priocntl((idtype)0, 0, PC_GETCLINFO, (caddr_t)&ClassInfo);
6024 + if (rslt < 0) return errno;
6026 + memset(&ParmInfo, 0, sizeof(pcparms_t));
6027 + ParmInfo.pc_cid = PC_CLNULL;
6028 + rslt = priocntl(P_PID, P_MYID, PC_GETPARMS, (caddr_t)&ParmInfo);
6029 + if (rslt < 0) return errno;
6031 + if (ParmInfo.pc_cid == rtLimits.schedPolicy) {
6032 + myMin = rtLimits.minPrio;
6033 + myMax = rtLimits.maxPrio;
6034 + } else if (ParmInfo.pc_cid == iaLimits.schedPolicy) {
6035 + iaparms_t *iaInfo = (iaparms_t*)ParmInfo.pc_clparms;
6036 + myMin = iaLimits.minPrio;
6037 + myMax = iaLimits.maxPrio;
6038 + myMax = MIN2(myMax, (int)iaInfo->ia_uprilim); // clamp - restrict
6039 + } else if (ParmInfo.pc_cid == tsLimits.schedPolicy) {
6040 + tsparms_t *tsInfo = (tsparms_t*)ParmInfo.pc_clparms;
6041 + myMin = tsLimits.minPrio;
6042 + myMax = tsLimits.maxPrio;
6043 + myMax = MIN2(myMax, (int)tsInfo->ts_uprilim); // clamp - restrict
6044 + } else if (ParmInfo.pc_cid == fxLimits.schedPolicy) {
6045 + fxparms_t *fxInfo = (fxparms_t*)ParmInfo.pc_clparms;
6046 + myMin = fxLimits.minPrio;
6047 + myMax = fxLimits.maxPrio;
6048 + myMax = MIN2(myMax, (int)fxInfo->fx_uprilim); // clamp - restrict
6049 + } else {
6050 + return EINVAL; // no clue, punt
6053 + priocntl_enable = true; // Enable changing priorities
6054 + return 0;
6057 +#define IAPRI(x) ((iaparms_t *)((x).pc_clparms))
6058 +#define RTPRI(x) ((rtparms_t *)((x).pc_clparms))
6059 +#define TSPRI(x) ((tsparms_t *)((x).pc_clparms))
6060 +#define FXPRI(x) ((fxparms_t *)((x).pc_clparms))
6063 +// scale_to_lwp_priority
6065 +// Convert from the libthread "thr_setprio" scale to our current
6066 +// lwp scheduling class scale.
6068 +static int scale_to_lwp_priority(int rMin, int rMax, int x) {
6069 + int v;
6071 + if (x == 127) return rMax; // avoid round-down
6072 + v = (((x*(rMax-rMin)))/128)+rMin;
6073 + return v;
6077 +// set_lwp_class_and_priority
6078 +int set_lwp_class_and_priority(int ThreadID, int lwpid,
6079 + int newPrio, int new_class, bool scale) {
6080 + int rslt;
6081 + int Actual, Expected, prv;
6082 + pcparms_t ParmInfo; // for GET-SET
6083 +#ifdef ASSERT
6084 + pcparms_t ReadBack; // for readback
6085 +#endif
6087 + // Set priority via PC_GETPARMS, update, PC_SETPARMS
6088 + // Query current values.
6089 + // TODO: accelerate this by eliminating the PC_GETPARMS call.
6090 + // Cache "pcparms_t" in global ParmCache.
6091 + // TODO: elide set-to-same-value
6093 + // If something went wrong on init, don't change priorities.
6094 + if (!priocntl_enable) {
6095 + return EINVAL;
6098 + // If lwp hasn't started yet, just return
6099 + // the _start routine will call us again.
6100 + if (lwpid <= 0) {
6101 + return 0;
6104 + memset(&ParmInfo, 0, sizeof(pcparms_t));
6105 + ParmInfo.pc_cid = PC_CLNULL;
6106 + rslt = priocntl(P_LWPID, lwpid, PC_GETPARMS, (caddr_t)&ParmInfo);
6107 + if (rslt < 0) return errno;
6109 + int cur_class = ParmInfo.pc_cid;
6110 + ParmInfo.pc_cid = (id_t)new_class;
6112 + if (new_class == rtLimits.schedPolicy) {
6113 + rtparms_t *rtInfo = (rtparms_t*)ParmInfo.pc_clparms;
6114 + rtInfo->rt_pri = scale ? scale_to_lwp_priority(rtLimits.minPrio,
6115 + rtLimits.maxPrio, newPrio)
6116 + : newPrio;
6117 + rtInfo->rt_tqsecs = RT_NOCHANGE;
6118 + rtInfo->rt_tqnsecs = RT_NOCHANGE;
6119 + } else if (new_class == iaLimits.schedPolicy) {
6120 + iaparms_t* iaInfo = (iaparms_t*)ParmInfo.pc_clparms;
6121 + int maxClamped = MIN2(iaLimits.maxPrio,
6122 + cur_class == new_class
6123 + ? (int)iaInfo->ia_uprilim : iaLimits.maxPrio);
6124 + iaInfo->ia_upri = scale ? scale_to_lwp_priority(iaLimits.minPrio,
6125 + maxClamped, newPrio)
6126 + : newPrio;
6127 + iaInfo->ia_uprilim = cur_class == new_class
6128 + ? IA_NOCHANGE : (pri_t)iaLimits.maxPrio;
6129 + iaInfo->ia_mode = IA_NOCHANGE;
6130 + } else if (new_class == tsLimits.schedPolicy) {
6131 + tsparms_t* tsInfo = (tsparms_t*)ParmInfo.pc_clparms;
6132 + int maxClamped = MIN2(tsLimits.maxPrio,
6133 + cur_class == new_class
6134 + ? (int)tsInfo->ts_uprilim : tsLimits.maxPrio);
6135 + tsInfo->ts_upri = scale ? scale_to_lwp_priority(tsLimits.minPrio,
6136 + maxClamped, newPrio)
6137 + : newPrio;
6138 + tsInfo->ts_uprilim = cur_class == new_class
6139 + ? TS_NOCHANGE : (pri_t)tsLimits.maxPrio;
6140 + } else if (new_class == fxLimits.schedPolicy) {
6141 + fxparms_t* fxInfo = (fxparms_t*)ParmInfo.pc_clparms;
6142 + int maxClamped = MIN2(fxLimits.maxPrio,
6143 + cur_class == new_class
6144 + ? (int)fxInfo->fx_uprilim : fxLimits.maxPrio);
6145 + fxInfo->fx_upri = scale ? scale_to_lwp_priority(fxLimits.minPrio,
6146 + maxClamped, newPrio)
6147 + : newPrio;
6148 + fxInfo->fx_uprilim = cur_class == new_class
6149 + ? FX_NOCHANGE : (pri_t)fxLimits.maxPrio;
6150 + fxInfo->fx_tqsecs = FX_NOCHANGE;
6151 + fxInfo->fx_tqnsecs = FX_NOCHANGE;
6152 + } else {
6153 + return EINVAL; // no clue, punt
6156 + rslt = priocntl(P_LWPID, lwpid, PC_SETPARMS, (caddr_t)&ParmInfo);
6157 + if (rslt < 0) return errno;
6159 +#ifdef ASSERT
6160 + // Sanity check: read back what we just attempted to set.
6161 + // In theory it could have changed in the interim ...
6162 + //
6163 + // The priocntl system call is tricky.
6164 + // Sometimes it'll validate the priority value argument and
6165 + // return EINVAL if unhappy. At other times it fails silently.
6166 + // Readbacks are prudent.
6168 + if (!ReadBackValidate) return 0;
6170 + memset(&ReadBack, 0, sizeof(pcparms_t));
6171 + ReadBack.pc_cid = PC_CLNULL;
6172 + rslt = priocntl(P_LWPID, lwpid, PC_GETPARMS, (caddr_t)&ReadBack);
6173 + assert(rslt >= 0, "priocntl failed");
6174 + Actual = Expected = 0xBAD;
6175 + assert(ParmInfo.pc_cid == ReadBack.pc_cid, "cid's don't match");
6176 + if (ParmInfo.pc_cid == rtLimits.schedPolicy) {
6177 + Actual = RTPRI(ReadBack)->rt_pri;
6178 + Expected = RTPRI(ParmInfo)->rt_pri;
6179 + } else if (ParmInfo.pc_cid == iaLimits.schedPolicy) {
6180 + Actual = IAPRI(ReadBack)->ia_upri;
6181 + Expected = IAPRI(ParmInfo)->ia_upri;
6182 + } else if (ParmInfo.pc_cid == tsLimits.schedPolicy) {
6183 + Actual = TSPRI(ReadBack)->ts_upri;
6184 + Expected = TSPRI(ParmInfo)->ts_upri;
6185 + } else if (ParmInfo.pc_cid == fxLimits.schedPolicy) {
6186 + Actual = FXPRI(ReadBack)->fx_upri;
6187 + Expected = FXPRI(ParmInfo)->fx_upri;
6189 +#endif
6191 + return 0;
6194 +// Solaris only gives access to 128 real priorities at a time,
6195 +// so we expand Java's ten to fill this range. This would be better
6196 +// if we dynamically adjusted relative priorities.
6198 +// The ThreadPriorityPolicy option allows us to select 2 different
6199 +// priority scales.
6201 +// ThreadPriorityPolicy=0
6202 +// Since the Solaris' default priority is MaximumPriority, we do not
6203 +// set a priority lower than Max unless a priority lower than
6204 +// NormPriority is requested.
6206 +// ThreadPriorityPolicy=1
6207 +// This mode causes the priority table to get filled with
6208 +// linear values. NormPriority get's mapped to 50% of the
6209 +// Maximum priority an so on. This will cause VM threads
6210 +// to get unfair treatment against other Solaris processes
6211 +// which do not explicitly alter their thread priorities.
6213 +int os::java_to_os_priority[CriticalPriority + 1] = {
6214 + -99999, // 0 Entry should never be used
6216 + 0, // 1 MinPriority
6217 + 32, // 2
6218 + 64, // 3
6220 + 96, // 4
6221 + 127, // 5 NormPriority
6222 + 127, // 6
6224 + 127, // 7
6225 + 127, // 8
6226 + 127, // 9 NearMaxPriority
6228 + 127, // 10 MaxPriority
6230 + -criticalPrio // 11 CriticalPriority
6233 +OSReturn os::set_native_priority(Thread* thread, int newpri) {
6234 + OSThread* osthread = thread->osthread();
6236 + // Save requested priority in case the thread hasn't been started
6237 + osthread->set_native_priority(newpri);
6239 + // Check for critical priority request
6240 + bool fxcritical = false;
6241 + if (newpri == -criticalPrio) {
6242 + fxcritical = true;
6243 + newpri = criticalPrio;
6246 + assert(newpri >= MinimumPriority && newpri <= MaximumPriority, "bad priority mapping");
6247 + if (!UseThreadPriorities) return OS_OK;
6249 + int status = 0;
6251 + if (!fxcritical) {
6252 + // Use thr_setprio only if we have a priority that thr_setprio understands
6253 + status = thr_setprio(thread->osthread()->thread_id(), newpri);
6256 + int lwp_status =
6257 + set_lwp_class_and_priority(osthread->thread_id(),
6258 + osthread->lwp_id(),
6259 + newpri,
6260 + fxcritical ? fxLimits.schedPolicy : myClass,
6261 + !fxcritical);
6262 + if (lwp_status != 0 && fxcritical) {
6263 + // Try again, this time without changing the scheduling class
6264 + newpri = java_MaxPriority_to_os_priority;
6265 + lwp_status = set_lwp_class_and_priority(osthread->thread_id(),
6266 + osthread->lwp_id(),
6267 + newpri, myClass, false);
6269 + status |= lwp_status;
6270 + return (status == 0) ? OS_OK : OS_ERR;
6274 +OSReturn os::get_native_priority(const Thread* const thread,
6275 + int *priority_ptr) {
6276 + int p;
6277 + if (!UseThreadPriorities) {
6278 + *priority_ptr = NormalPriority;
6279 + return OS_OK;
6281 + int status = thr_getprio(thread->osthread()->thread_id(), &p);
6282 + if (status != 0) {
6283 + return OS_ERR;
6285 + *priority_ptr = p;
6286 + return OS_OK;
6289 +////////////////////////////////////////////////////////////////////////////////
6291 +// This does not do anything on Solaris. This is basically a hook for being
6292 +// able to use structured exception handling (thread-local exception filters) on, e.g., Win32.
6293 +void os::os_exception_wrapper(java_call_t f, JavaValue* value,
6294 + const methodHandle& method, JavaCallArguments* args,
6295 + JavaThread* thread) {
6296 + f(value, method, args, thread);
6299 +void report_error(const char* file_name, int line_no, const char* title,
6300 + const char* format, ...);
6302 +// (Static) wrappers for the liblgrp API
6303 +os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home;
6304 +os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init;
6305 +os::Solaris::lgrp_fini_func_t os::Solaris::_lgrp_fini;
6306 +os::Solaris::lgrp_root_func_t os::Solaris::_lgrp_root;
6307 +os::Solaris::lgrp_children_func_t os::Solaris::_lgrp_children;
6308 +os::Solaris::lgrp_resources_func_t os::Solaris::_lgrp_resources;
6309 +os::Solaris::lgrp_nlgrps_func_t os::Solaris::_lgrp_nlgrps;
6310 +os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale;
6311 +os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0;
6313 +static address resolve_symbol_lazy(const char* name) {
6314 + address addr = (address) dlsym(RTLD_DEFAULT, name);
6315 + if (addr == NULL) {
6316 + // RTLD_DEFAULT was not defined on some early versions of 2.5.1
6317 + addr = (address) dlsym(RTLD_NEXT, name);
6319 + return addr;
6322 +static address resolve_symbol(const char* name) {
6323 + address addr = resolve_symbol_lazy(name);
6324 + if (addr == NULL) {
6325 + fatal("resolve_symbol failed (%s)", dlerror());
6327 + return addr;
6330 +void os::Solaris::libthread_init() {
6331 + address func = (address)dlsym(RTLD_DEFAULT, "_thr_suspend_allmutators");
6333 + lwp_priocntl_init();
6335 + // RTLD_DEFAULT was not defined on some early versions of 5.5.1
6336 + if (func == NULL) {
6337 + func = (address) dlsym(RTLD_NEXT, "_thr_suspend_allmutators");
6338 + // Guarantee that this VM is running on an new enough OS (5.6 or
6339 + // later) that it will have a new enough libthread.so.
6340 + guarantee(func != NULL, "libthread.so is too old.");
6343 + int size;
6344 + void (*handler_info_func)(address *, int *);
6345 + handler_info_func = CAST_TO_FN_PTR(void (*)(address *, int *), resolve_symbol("thr_sighndlrinfo"));
6346 + handler_info_func(&handler_start, &size);
6347 + handler_end = handler_start + size;
6351 +bool os::Solaris::_synchronization_initialized;
6353 +void os::Solaris::synchronization_init() {
6354 + _synchronization_initialized = true;
6357 +bool os::Solaris::liblgrp_init() {
6358 + void *handle = dlopen("liblgrp.so.1", RTLD_LAZY);
6359 + if (handle != NULL) {
6360 + os::Solaris::set_lgrp_home(CAST_TO_FN_PTR(lgrp_home_func_t, dlsym(handle, "lgrp_home")));
6361 + os::Solaris::set_lgrp_init(CAST_TO_FN_PTR(lgrp_init_func_t, dlsym(handle, "lgrp_init")));
6362 + os::Solaris::set_lgrp_fini(CAST_TO_FN_PTR(lgrp_fini_func_t, dlsym(handle, "lgrp_fini")));
6363 + os::Solaris::set_lgrp_root(CAST_TO_FN_PTR(lgrp_root_func_t, dlsym(handle, "lgrp_root")));
6364 + os::Solaris::set_lgrp_children(CAST_TO_FN_PTR(lgrp_children_func_t, dlsym(handle, "lgrp_children")));
6365 + os::Solaris::set_lgrp_resources(CAST_TO_FN_PTR(lgrp_resources_func_t, dlsym(handle, "lgrp_resources")));
6366 + os::Solaris::set_lgrp_nlgrps(CAST_TO_FN_PTR(lgrp_nlgrps_func_t, dlsym(handle, "lgrp_nlgrps")));
6367 + os::Solaris::set_lgrp_cookie_stale(CAST_TO_FN_PTR(lgrp_cookie_stale_func_t,
6368 + dlsym(handle, "lgrp_cookie_stale")));
6370 + lgrp_cookie_t c = lgrp_init(LGRP_VIEW_CALLER);
6371 + set_lgrp_cookie(c);
6372 + return true;
6374 + return false;
6377 +// int pset_getloadavg(psetid_t pset, double loadavg[], int nelem);
6378 +typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem);
6379 +static pset_getloadavg_type pset_getloadavg_ptr = NULL;
6381 +void init_pset_getloadavg_ptr(void) {
6382 + pset_getloadavg_ptr =
6383 + (pset_getloadavg_type)dlsym(RTLD_DEFAULT, "pset_getloadavg");
6384 + if (pset_getloadavg_ptr == NULL) {
6385 + log_warning(os)("pset_getloadavg function not found");
6389 +int os::Solaris::_dev_zero_fd = -1;
6391 +// this is called _before_ the global arguments have been parsed
6392 +void os::init(void) {
6393 + _initial_pid = getpid();
6395 + max_hrtime = first_hrtime = gethrtime();
6397 + init_random(1234567);
6399 + int page_size = sysconf(_SC_PAGESIZE);
6400 + OSInfo::set_vm_page_size(page_size);
6401 + OSInfo::set_vm_allocation_granularity(page_size);
6402 + if (os::vm_page_size() <= 0) {
6403 + fatal("os_solaris.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
6405 + _page_sizes.add(os::vm_page_size());
6407 + Solaris::initialize_system_info();
6409 + int fd = ::open("/dev/zero", O_RDWR);
6410 + if (fd < 0) {
6411 + fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno));
6412 + } else {
6413 + Solaris::set_dev_zero_fd(fd);
6415 + // Close on exec, child won't inherit.
6416 + fcntl(fd, F_SETFD, FD_CLOEXEC);
6419 + clock_tics_per_sec = CLK_TCK;
6421 + // main_thread points to the thread that created/loaded the JVM.
6422 + main_thread = thr_self();
6424 + // dynamic lookup of functions that may not be available in our lowest
6425 + // supported Solaris release
6426 + void * handle = dlopen("libc.so.1", RTLD_LAZY);
6427 + if (handle != NULL) {
6428 + Solaris::_pthread_setname_np = // from 11.3
6429 + (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np");
6432 + // Shared Posix initialization
6433 + os::Posix::init();
6436 +// To install functions for atexit system call
6437 +extern "C" {
6438 + static void perfMemory_exit_helper() {
6439 + perfMemory_exit();
6443 +// this is called _after_ the global arguments have been parsed
6444 +jint os::init_2(void) {
6445 + Solaris::libthread_init();
6447 + if (UseNUMA) {
6448 + if (!Solaris::liblgrp_init()) {
6449 + FLAG_SET_ERGO(UseNUMA, false);
6450 + } else {
6451 + size_t lgrp_limit = os::numa_get_groups_num();
6452 + uint *lgrp_ids = NEW_C_HEAP_ARRAY(uint, lgrp_limit, mtInternal);
6453 + size_t lgrp_num = os::numa_get_leaf_groups(lgrp_ids, lgrp_limit);
6454 + FREE_C_HEAP_ARRAY(uint, lgrp_ids);
6455 + if (lgrp_num < 2) {
6456 + // There's only one locality group, disable NUMA
6457 + UseNUMA = false;
6462 + // When NUMA requested, not-NUMA-aware allocations default to interleaving.
6463 + if (UseNUMA && !UseNUMAInterleaving) {
6464 + FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true);
6467 + if (PosixSignals::init() == JNI_ERR) {
6468 + return JNI_ERR;
6471 + // initialize synchronization primitives
6472 + Solaris::synchronization_init();
6473 + DEBUG_ONLY(os::set_mutex_init_done();)
6475 + if (MaxFDLimit) {
6476 + // set the number of file descriptors to max. print out error
6477 + // if getrlimit/setrlimit fails but continue regardless.
6478 + struct rlimit nbr_files;
6479 + int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
6480 + if (status != 0) {
6481 + log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
6482 + } else {
6483 + nbr_files.rlim_cur = nbr_files.rlim_max;
6484 + status = setrlimit(RLIMIT_NOFILE, &nbr_files);
6485 + if (status != 0) {
6486 + log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno));
6491 + // Calculate theoretical max. size of Threads to guard gainst
6492 + // artifical out-of-memory situations, where all available address-
6493 + // space has been reserved by thread stacks. Default stack size is 1Mb.
6494 + size_t pre_thread_stack_size = (JavaThread::stack_size_at_create()) ?
6495 + JavaThread::stack_size_at_create() : (1*K*K);
6496 + assert(pre_thread_stack_size != 0, "Must have a stack");
6497 + // Solaris has a maximum of 4Gb of user programs. Calculate the thread limit when
6498 + // we should start doing Virtual Memory banging. Currently when the threads will
6499 + // have used all but 200Mb of space.
6500 + size_t max_address_space = ((unsigned int)4 * K * K * K) - (200 * K * K);
6501 + Solaris::_os_thread_limit = max_address_space / pre_thread_stack_size;
6503 + // at-exit methods are called in the reverse order of their registration.
6504 + // In Solaris 7 and earlier, atexit functions are called on return from
6505 + // main or as a result of a call to exit(3C). There can be only 32 of
6506 + // these functions registered and atexit() does not set errno. In Solaris
6507 + // 8 and later, there is no limit to the number of functions registered
6508 + // and atexit() sets errno. In addition, in Solaris 8 and later, atexit
6509 + // functions are called upon dlclose(3DL) in addition to return from main
6510 + // and exit(3C).
6512 + if (PerfAllowAtExitRegistration) {
6513 + // only register atexit functions if PerfAllowAtExitRegistration is set.
6514 + // atexit functions can be delayed until process exit time, which
6515 + // can be problematic for embedded VM situations. Embedded VMs should
6516 + // call DestroyJavaVM() to assure that VM resources are released.
6518 + // note: perfMemory_exit_helper atexit function may be removed in
6519 + // the future if the appropriate cleanup code can be added to the
6520 + // VM_Exit VMOperation's doit method.
6521 + if (atexit(perfMemory_exit_helper) != 0) {
6522 + warning("os::init2 atexit(perfMemory_exit_helper) failed");
6526 + // Init pset_loadavg function pointer
6527 + init_pset_getloadavg_ptr();
6529 + // Shared Posix initialization
6530 + os::Posix::init_2();
6532 + return JNI_OK;
6535 +// This code originates from JDK's sysOpen and open64_w
6536 +// from src/solaris/hpi/src/system_md.c
6538 +int os::open(const char *path, int oflag, int mode) {
6539 + if (strlen(path) > MAX_PATH - 1) {
6540 + errno = ENAMETOOLONG;
6541 + return -1;
6543 + int fd;
6545 + fd = ::open64(path, oflag, mode);
6546 + if (fd == -1) return -1;
6548 + // If the open succeeded, the file might still be a directory
6550 + struct stat64 buf64;
6551 + int ret = ::fstat64(fd, &buf64);
6552 + int st_mode = buf64.st_mode;
6554 + if (ret != -1) {
6555 + if ((st_mode & S_IFMT) == S_IFDIR) {
6556 + errno = EISDIR;
6557 + ::close(fd);
6558 + return -1;
6560 + } else {
6561 + ::close(fd);
6562 + return -1;
6566 + // All file descriptors that are opened in the JVM and not
6567 + // specifically destined for a subprocess should have the
6568 + // close-on-exec flag set. If we don't set it, then careless 3rd
6569 + // party native code might fork and exec without closing all
6570 + // appropriate file descriptors (e.g. as we do in closeDescriptors in
6571 + // UNIXProcess.c), and this in turn might:
6572 + //
6573 + // - cause end-of-file to fail to be detected on some file
6574 + // descriptors, resulting in mysterious hangs, or
6575 + //
6576 + // - might cause an fopen in the subprocess to fail on a system
6577 + // suffering from bug 1085341.
6578 + //
6579 + // (Yes, the default setting of the close-on-exec flag is a Unix
6580 + // design flaw)
6581 + //
6582 + // See:
6583 + // 1085341: 32-bit stdio routines should support file descriptors >255
6584 + // 4843136: (process) pipe file descriptor from Runtime.exec not being closed
6585 + // 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9
6586 + //
6587 +#ifdef FD_CLOEXEC
6589 + int flags = ::fcntl(fd, F_GETFD);
6590 + if (flags != -1) {
6591 + ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
6594 +#endif
6596 + return fd;
6599 +// return current position of file pointer
6600 +jlong os::current_file_offset(int fd) {
6601 + return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR);
6604 +// move file pointer to the specified offset
6605 +jlong os::seek_to_file_offset(int fd, jlong offset) {
6606 + return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
6609 +const intptr_t thr_time_off = (intptr_t)(&((prusage_t *)(NULL))->pr_utime);
6610 +const intptr_t thr_time_size = (intptr_t)(&((prusage_t *)(NULL))->pr_ttime) -
6611 + (intptr_t)(&((prusage_t *)(NULL))->pr_utime);
6614 +// JVMTI & JVM monitoring and management support
6615 +// The thread_cpu_time() and current_thread_cpu_time() are only
6616 +// supported if is_thread_cpu_time_supported() returns true.
6617 +// They are not supported on Solaris T1.
6619 +// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
6620 +// are used by JVM M&M and JVMTI to get user+sys or user CPU time
6621 +// of a thread.
6623 +// current_thread_cpu_time() and thread_cpu_time(Thread *)
6624 +// returns the fast estimate available on the platform.
6626 +// hrtime_t gethrvtime() return value includes
6627 +// user time but does not include system time
6628 +jlong os::current_thread_cpu_time() {
6629 + return (jlong) gethrvtime();
6632 +jlong os::thread_cpu_time(Thread *thread) {
6633 + // return user level CPU time only to be consistent with
6634 + // what current_thread_cpu_time returns.
6635 + // thread_cpu_time_info() must be changed if this changes
6636 + return os::thread_cpu_time(thread, false /* user time only */);
6639 +jlong os::current_thread_cpu_time(bool user_sys_cpu_time) {
6640 + if (user_sys_cpu_time) {
6641 + return os::thread_cpu_time(Thread::current(), user_sys_cpu_time);
6642 + } else {
6643 + return os::current_thread_cpu_time();
6647 +jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
6648 + char proc_name[64];
6649 + int count;
6650 + prusage_t prusage;
6651 + jlong lwp_time;
6652 + int fd;
6654 + sprintf(proc_name, "/proc/%d/lwp/%d/lwpusage",
6655 + getpid(),
6656 + thread->osthread()->lwp_id());
6657 + fd = ::open(proc_name, O_RDONLY);
6658 + if (fd == -1) return -1;
6660 + do {
6661 + count = ::pread(fd,
6662 + (void *)&prusage.pr_utime,
6663 + thr_time_size,
6664 + thr_time_off);
6665 + } while (count < 0 && errno == EINTR);
6666 + ::close(fd);
6667 + if (count < 0) return -1;
6669 + if (user_sys_cpu_time) {
6670 + // user + system CPU time
6671 + lwp_time = (((jlong)prusage.pr_stime.tv_sec +
6672 + (jlong)prusage.pr_utime.tv_sec) * (jlong)1000000000) +
6673 + (jlong)prusage.pr_stime.tv_nsec +
6674 + (jlong)prusage.pr_utime.tv_nsec;
6675 + } else {
6676 + // user level CPU time only
6677 + lwp_time = ((jlong)prusage.pr_utime.tv_sec * (jlong)1000000000) +
6678 + (jlong)prusage.pr_utime.tv_nsec;
6681 + return (lwp_time);
6684 +void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
6685 + info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits
6686 + info_ptr->may_skip_backward = false; // elapsed time not wall time
6687 + info_ptr->may_skip_forward = false; // elapsed time not wall time
6688 + info_ptr->kind = JVMTI_TIMER_USER_CPU; // only user time is returned
6691 +void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
6692 + info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits
6693 + info_ptr->may_skip_backward = false; // elapsed time not wall time
6694 + info_ptr->may_skip_forward = false; // elapsed time not wall time
6695 + info_ptr->kind = JVMTI_TIMER_USER_CPU; // only user time is returned
6698 +bool os::is_thread_cpu_time_supported() {
6699 + return true;
6702 +// System loadavg support. Returns -1 if load average cannot be obtained.
6703 +// Return the load average for our processor set if the primitive exists
6704 +// (Solaris 9 and later). Otherwise just return system wide loadavg.
6705 +int os::loadavg(double loadavg[], int nelem) {
6706 + if (pset_getloadavg_ptr != NULL) {
6707 + return (*pset_getloadavg_ptr)(PS_MYID, loadavg, nelem);
6708 + } else {
6709 + return ::getloadavg(loadavg, nelem);
6713 +//---------------------------------------------------------------------------------
6715 +bool os::find(address addr, outputStream* st) {
6716 + Dl_info dlinfo;
6717 + memset(&dlinfo, 0, sizeof(dlinfo));
6718 + if (dladdr(addr, &dlinfo) != 0) {
6719 + st->print(PTR_FORMAT ": ", p2i(addr));
6720 + if (dlinfo.dli_sname != NULL && dlinfo.dli_saddr != NULL) {
6721 + st->print("%s+" PTR_FORMAT, dlinfo.dli_sname,
6722 + p2i(addr) - p2i(dlinfo.dli_saddr));
6723 + } else if (dlinfo.dli_fbase != NULL) {
6724 + st->print("<offset " PTR_FORMAT ">", p2i(addr) - p2i(dlinfo.dli_fbase));
6725 + } else {
6726 + st->print("<absolute address>");
6728 + if (dlinfo.dli_fname != NULL) {
6729 + st->print(" in %s", dlinfo.dli_fname);
6731 + if (dlinfo.dli_fbase != NULL) {
6732 + st->print(" at " PTR_FORMAT, p2i(dlinfo.dli_fbase));
6734 + st->cr();
6736 + if (Verbose) {
6737 + // decode some bytes around the PC
6738 + address begin = clamp_address_in_page(addr-40, addr, os::vm_page_size());
6739 + address end = clamp_address_in_page(addr+40, addr, os::vm_page_size());
6740 + address lowest = (address) dlinfo.dli_sname;
6741 + if (!lowest) lowest = (address) dlinfo.dli_fbase;
6742 + if (begin < lowest) begin = lowest;
6743 + Dl_info dlinfo2;
6744 + if (dladdr(end, &dlinfo2) != 0 && dlinfo2.dli_saddr != dlinfo.dli_saddr
6745 + && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin) {
6746 + end = (address) dlinfo2.dli_saddr;
6748 + Disassembler::decode(begin, end, st);
6750 + return true;
6752 + return false;
6755 +// Following function has been added to support HotSparc's libjvm.so running
6756 +// under Solaris production JDK 1.2.2 / 1.3.0. These came from
6757 +// src/solaris/hpi/native_threads in the EVM codebase.
6759 +// NOTE: This is no longer needed in the 1.3.1 and 1.4 production release
6760 +// libraries and should thus be removed. We will leave it behind for a while
6761 +// until we no longer want to able to run on top of 1.3.0 Solaris production
6762 +// JDK. See 4341971.
6764 +#define STACK_SLACK 0x800
6766 +extern "C" {
6767 + intptr_t sysThreadAvailableStackWithSlack() {
6768 + stack_t st;
6769 + intptr_t retval, stack_top;
6770 + retval = thr_stksegment(&st);
6771 + assert(retval == 0, "incorrect return value from thr_stksegment");
6772 + assert((address)&st < (address)st.ss_sp, "Invalid stack base returned");
6773 + assert((address)&st > (address)st.ss_sp-st.ss_size, "Invalid stack size returned");
6774 + stack_top=(intptr_t)st.ss_sp-st.ss_size;
6775 + return ((intptr_t)&stack_top - stack_top - STACK_SLACK);
6779 +// ObjectMonitor park-unpark infrastructure ...
6781 +// We implement Solaris and Linux PlatformEvents with the
6782 +// obvious condvar-mutex-flag triple.
6783 +// Another alternative that works quite well is pipes:
6784 +// Each PlatformEvent consists of a pipe-pair.
6785 +// The thread associated with the PlatformEvent
6786 +// calls park(), which reads from the input end of the pipe.
6787 +// Unpark() writes into the other end of the pipe.
6788 +// The write-side of the pipe must be set NDELAY.
6789 +// Unfortunately pipes consume a large # of handles.
6790 +// Native solaris lwp_park() and lwp_unpark() work nicely, too.
6791 +// Using pipes for the 1st few threads might be workable, however.
6793 +// park() is permitted to return spuriously.
6794 +// Callers of park() should wrap the call to park() in
6795 +// an appropriate loop. A litmus test for the correct
6796 +// usage of park is the following: if park() were modified
6797 +// to immediately return 0 your code should still work,
6798 +// albeit degenerating to a spin loop.
6800 +// In a sense, park()-unpark() just provides more polite spinning
6801 +// and polling with the key difference over naive spinning being
6802 +// that a parked thread needs to be explicitly unparked() in order
6803 +// to wake up and to poll the underlying condition.
6805 +// Assumption:
6806 +// Only one parker can exist on an event, which is why we allocate
6807 +// them per-thread. Multiple unparkers can coexist.
6809 +// _event transitions in park()
6810 +// -1 => -1 : illegal
6811 +// 1 => 0 : pass - return immediately
6812 +// 0 => -1 : block; then set _event to 0 before returning
6814 +// _event transitions in unpark()
6815 +// 0 => 1 : just return
6816 +// 1 => 1 : just return
6817 +// -1 => either 0 or 1; must signal target thread
6818 +// That is, we can safely transition _event from -1 to either
6819 +// 0 or 1.
6821 +// _event serves as a restricted-range semaphore.
6822 +// -1 : thread is blocked, i.e. there is a waiter
6823 +// 0 : neutral: thread is running or ready,
6824 +// could have been signaled after a wait started
6825 +// 1 : signaled - thread is running or ready
6827 +// Another possible encoding of _event would be with
6828 +// explicit "PARKED" == 01b and "SIGNALED" == 10b bits.
6830 +// TODO-FIXME: add DTRACE probes for:
6831 +// 1. Tx parks
6832 +// 2. Ty unparks Tx
6833 +// 3. Tx resumes from park
6835 +// JSR166
6836 +// -------------------------------------------------------
6838 +// The solaris and linux implementations of park/unpark are fairly
6839 +// conservative for now, but can be improved. They currently use a
6840 +// mutex/condvar pair, plus _counter.
6841 +// Park decrements _counter if > 0, else does a condvar wait. Unpark
6842 +// sets count to 1 and signals condvar. Only one thread ever waits
6843 +// on the condvar. Contention seen when trying to park implies that someone
6844 +// is unparking you, so don't wait. And spurious returns are fine, so there
6845 +// is no need to track notifications.
6847 +// Get the default path to the core file
6848 +// Returns the length of the string
6849 +int os::get_core_path(char* buffer, size_t bufferSize) {
6850 + const char* p = get_current_directory(buffer, bufferSize);
6852 + if (p == NULL) {
6853 + assert(p != NULL, "failed to get current directory");
6854 + return 0;
6857 + jio_snprintf(buffer, bufferSize, "%s/core or core.%d",
6858 + p, current_process_id());
6860 + return strlen(buffer);
6863 +bool os::supports_map_sync() {
6864 + return false;
6867 +#ifndef PRODUCT
6868 +void TestReserveMemorySpecial_test() {
6869 + // No tests available for this platform
6871 +#endif
6873 +bool os::start_debugging(char *buf, int buflen) {
6874 + int len = (int)strlen(buf);
6875 + char *p = &buf[len];
6877 + jio_snprintf(p, buflen-len,
6878 + "\n\n"
6879 + "Do you want to debug the problem?\n\n"
6880 + "To debug, run 'dbx - %d'; then switch to thread " INTX_FORMAT "\n"
6881 + "Enter 'yes' to launch dbx automatically (PATH must include dbx)\n"
6882 + "Otherwise, press RETURN to abort...",
6883 + os::current_process_id(), os::current_thread_id());
6885 + bool yes = os::message_box("Unexpected Error", buf);
6887 + if (yes) {
6888 + // yes, user asked VM to launch debugger
6889 + jio_snprintf(buf, sizeof(buf), "dbx - %d", os::current_process_id());
6891 + os::fork_and_exec(buf);
6892 + yes = false;
6894 + return yes;
6897 +void os::print_memory_mappings(char* addr, size_t bytes, outputStream* st) {}
6899 +#if INCLUDE_JFR
6901 +void os::jfr_report_memory_info() {}
6903 +#endif // INCLUDE_JFR
6905 +bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) {
6907 + if (ebuf && ebuflen > 0) {
6908 + ebuf[0] = '\0';
6909 + ebuf[ebuflen - 1] = '\0';
6912 + bool res = (0 == ::dlclose(libhandle));
6913 + if (!res) {
6914 + // error analysis when dlopen fails
6915 + const char* error_report = ::dlerror();
6916 + if (error_report == nullptr) {
6917 + error_report = "dlerror returned no error description";
6919 + if (ebuf != nullptr && ebuflen > 0) {
6920 + snprintf(ebuf, ebuflen - 1, "%s", error_report);
6924 + return res;
6925 +} // end: os::pd_dll_unload()
6926 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.hpp
6927 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
6928 +++ jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.hpp 2024-08-17 20:36:14.286507100 +0200
6929 @@ -0,0 +1,201 @@
6931 + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
6932 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6934 + * This code is free software; you can redistribute it and/or modify it
6935 + * under the terms of the GNU General Public License version 2 only, as
6936 + * published by the Free Software Foundation.
6938 + * This code is distributed in the hope that it will be useful, but WITHOUT
6939 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6940 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6941 + * version 2 for more details (a copy is included in the LICENSE file that
6942 + * accompanied this code).
6944 + * You should have received a copy of the GNU General Public License version
6945 + * 2 along with this work; if not, write to the Free Software Foundation,
6946 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6948 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6949 + * or visit www.oracle.com if you need additional information or have any
6950 + * questions.
6952 + */
6954 +#ifndef OS_SOLARIS_OS_SOLARIS_HPP
6955 +#define OS_SOLARIS_OS_SOLARIS_HPP
6957 +#include "runtime/os.hpp"
6959 +// Solaris_OS defines the interface to Solaris operating systems
6961 +// see thr_setprio(3T) for the basis of these numbers
6962 +#define MinimumPriority 0
6963 +#define NormalPriority 64
6964 +#define MaximumPriority 127
6966 +// FX/60 is critical thread class/priority on T4
6967 +#define FXCriticalPriority 60
6969 +class os::Solaris {
6970 + friend class os;
6972 + private:
6974 + static bool _synchronization_initialized;
6976 + typedef uintptr_t lgrp_cookie_t;
6977 + typedef id_t lgrp_id_t;
6978 + typedef int lgrp_rsrc_t;
6979 + typedef enum lgrp_view {
6980 + LGRP_VIEW_CALLER, // what's available to the caller
6981 + LGRP_VIEW_OS // what's available to operating system
6982 + } lgrp_view_t;
6984 + typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id);
6985 + typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view);
6986 + typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie);
6987 + typedef lgrp_id_t (*lgrp_root_func_t)(lgrp_cookie_t cookie);
6988 + typedef int (*lgrp_children_func_t)(lgrp_cookie_t cookie, lgrp_id_t parent,
6989 + lgrp_id_t *lgrp_array, uint_t lgrp_array_size);
6990 + typedef int (*lgrp_resources_func_t)(lgrp_cookie_t cookie, lgrp_id_t lgrp,
6991 + lgrp_id_t *lgrp_array, uint_t lgrp_array_size,
6992 + lgrp_rsrc_t type);
6993 + typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie);
6994 + typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie);
6996 + static lgrp_home_func_t _lgrp_home;
6997 + static lgrp_init_func_t _lgrp_init;
6998 + static lgrp_fini_func_t _lgrp_fini;
6999 + static lgrp_root_func_t _lgrp_root;
7000 + static lgrp_children_func_t _lgrp_children;
7001 + static lgrp_resources_func_t _lgrp_resources;
7002 + static lgrp_nlgrps_func_t _lgrp_nlgrps;
7003 + static lgrp_cookie_stale_func_t _lgrp_cookie_stale;
7004 + static lgrp_cookie_t _lgrp_cookie;
7006 + // Large Page Support
7007 + static bool is_valid_page_size(size_t bytes);
7008 + static size_t page_size_for_alignment(size_t alignment);
7009 + static bool setup_large_pages(caddr_t start, size_t bytes, size_t align);
7011 + typedef int (*pthread_setname_np_func_t)(pthread_t, const char*);
7012 + static pthread_setname_np_func_t _pthread_setname_np;
7014 + public:
7015 + // Large Page Support--ISM.
7016 + static bool largepage_range(char* addr, size_t size);
7018 + static address handler_start, handler_end; // start and end pc of thr_sighndlrinfo
7020 + static bool valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect);
7021 + static const ucontext_t* get_valid_uc_in_signal_handler(Thread* thread,
7022 + const ucontext_t* uc);
7024 + static intptr_t* ucontext_get_sp(const ucontext_t* uc);
7025 + // ucontext_get_fp() is only used by Solaris X86 (see note below)
7026 + static intptr_t* ucontext_get_fp(const ucontext_t* uc);
7028 + static bool get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr);
7030 + static void init_thread_fpu_state(void);
7032 + protected:
7033 + // Solaris-specific interface goes here
7034 + static julong available_memory();
7035 + static julong free_memory();
7036 + static julong physical_memory() { return _physical_memory; }
7037 + static julong _physical_memory;
7038 + static void initialize_system_info();
7039 + static int _dev_zero_fd;
7040 + static int get_dev_zero_fd() { return _dev_zero_fd; }
7041 + static void set_dev_zero_fd(int fd) { _dev_zero_fd = fd; }
7042 + static int commit_memory_impl(char* addr, size_t bytes, bool exec);
7043 + static int commit_memory_impl(char* addr, size_t bytes,
7044 + size_t alignment_hint, bool exec);
7045 + static char* mmap_chunk(char *addr, size_t size, int flags, int prot);
7046 + static char* anon_mmap(char* requested_addr, size_t bytes);
7047 + static bool mpss_sanity_check(bool warn, size_t * page_size);
7049 + static address current_stack_base();
7050 + static size_t current_stack_size();
7052 + // Workaround for 4352906. thr_stksegment sometimes returns
7053 + // a bad value for the primordial thread's stack base when
7054 + // it is called more than one time.
7055 + // Workaround is to cache the initial value to avoid further
7056 + // calls to thr_stksegment.
7057 + // It appears that someone (Hotspot?) is trashing the user's
7058 + // proc_t structure (note that this is a system struct).
7059 + static address _main_stack_base;
7061 + static void print_distro_info(outputStream* st);
7062 + static void print_libversion_info(outputStream* st);
7064 + public:
7065 + static void libthread_init();
7066 + static void synchronization_init();
7067 + static bool liblgrp_init();
7069 + // alignment with os_posix means we use pthreads
7070 + static int mutex_lock(pthread_mutex_t *mx) { return pthread_mutex_lock(mx); }
7071 + static int mutex_trylock(pthread_mutex_t *mx) { return pthread_mutex_trylock(mx); }
7072 + static int mutex_unlock(pthread_mutex_t *mx) { return pthread_mutex_unlock(mx); }
7073 + static int mutex_init(pthread_mutex_t *mx) { return pthread_mutex_init(mx, NULL); }
7074 + static int mutex_destroy(pthread_mutex_t *mx) { return pthread_mutex_destroy(mx); }
7076 + static int cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mx, timestruc_t *abst) { return pthread_cond_timedwait(cv, mx, abst); }
7077 + static int cond_wait(pthread_cond_t *cv, pthread_mutex_t *mx) { return pthread_cond_wait(cv, mx); }
7078 + static int cond_signal(pthread_cond_t *cv) { return pthread_cond_signal(cv); }
7079 + static int cond_broadcast(pthread_cond_t *cv) { return pthread_cond_broadcast(cv); }
7080 + static int cond_init(pthread_cond_t *cv) { return pthread_cond_init(cv, NULL); }
7081 + static int cond_destroy(pthread_cond_t *cv) { return pthread_cond_destroy(cv); }
7083 + static bool synchronization_initialized() { return _synchronization_initialized; }
7085 + static void set_lgrp_home(lgrp_home_func_t func) { _lgrp_home = func; }
7086 + static void set_lgrp_init(lgrp_init_func_t func) { _lgrp_init = func; }
7087 + static void set_lgrp_fini(lgrp_fini_func_t func) { _lgrp_fini = func; }
7088 + static void set_lgrp_root(lgrp_root_func_t func) { _lgrp_root = func; }
7089 + static void set_lgrp_children(lgrp_children_func_t func) { _lgrp_children = func; }
7090 + static void set_lgrp_resources(lgrp_resources_func_t func) { _lgrp_resources = func; }
7091 + static void set_lgrp_nlgrps(lgrp_nlgrps_func_t func) { _lgrp_nlgrps = func; }
7092 + static void set_lgrp_cookie_stale(lgrp_cookie_stale_func_t func) { _lgrp_cookie_stale = func; }
7093 + static void set_lgrp_cookie(lgrp_cookie_t cookie) { _lgrp_cookie = cookie; }
7095 + static id_t lgrp_home(idtype_t type, id_t id) { return _lgrp_home != NULL ? _lgrp_home(type, id) : -1; }
7096 + static lgrp_cookie_t lgrp_init(lgrp_view_t view) { return _lgrp_init != NULL ? _lgrp_init(view) : 0; }
7097 + static int lgrp_fini(lgrp_cookie_t cookie) { return _lgrp_fini != NULL ? _lgrp_fini(cookie) : -1; }
7098 + static lgrp_id_t lgrp_root(lgrp_cookie_t cookie) { return _lgrp_root != NULL ? _lgrp_root(cookie) : -1; }
7099 + static int lgrp_children(lgrp_cookie_t cookie, lgrp_id_t parent,
7100 + lgrp_id_t *lgrp_array, uint_t lgrp_array_size) {
7101 + return _lgrp_children != NULL ? _lgrp_children(cookie, parent, lgrp_array, lgrp_array_size) : -1;
7103 + static int lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp,
7104 + lgrp_id_t *lgrp_array, uint_t lgrp_array_size,
7105 + lgrp_rsrc_t type) {
7106 + return _lgrp_resources != NULL ? _lgrp_resources(cookie, lgrp, lgrp_array, lgrp_array_size, type) : -1;
7109 + static int lgrp_nlgrps(lgrp_cookie_t cookie) { return _lgrp_nlgrps != NULL ? _lgrp_nlgrps(cookie) : -1; }
7110 + static int lgrp_cookie_stale(lgrp_cookie_t cookie) {
7111 + return _lgrp_cookie_stale != NULL ? _lgrp_cookie_stale(cookie) : -1;
7113 + static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; }
7115 + static sigset_t* unblocked_signals();
7116 + static sigset_t* vm_signals();
7118 + // %%% Following should be promoted to os.hpp:
7119 + // Trace number of created threads
7120 + static jint _os_thread_limit;
7121 + static volatile jint _os_thread_count;
7123 + static void correct_stack_boundaries_for_primordial_thread(Thread* thr);
7125 + // Stack repair handling
7127 + // none present
7130 +#endif // OS_SOLARIS_OS_SOLARIS_HPP
7131 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.inline.hpp jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.inline.hpp
7132 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/os_solaris.inline.hpp 1970-01-01 01:00:00.000000000 +0100
7133 +++ jdk-jdk-24-11/src/hotspot/os/solaris/os_solaris.inline.hpp 2024-08-17 20:36:14.286806788 +0200
7134 @@ -0,0 +1,72 @@
7136 + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
7137 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7139 + * This code is free software; you can redistribute it and/or modify it
7140 + * under the terms of the GNU General Public License version 2 only, as
7141 + * published by the Free Software Foundation.
7143 + * This code is distributed in the hope that it will be useful, but WITHOUT
7144 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7145 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7146 + * version 2 for more details (a copy is included in the LICENSE file that
7147 + * accompanied this code).
7149 + * You should have received a copy of the GNU General Public License version
7150 + * 2 along with this work; if not, write to the Free Software Foundation,
7151 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7153 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7154 + * or visit www.oracle.com if you need additional information or have any
7155 + * questions.
7157 + */
7159 +#ifndef OS_SOLARIS_OS_SOLARIS_INLINE_HPP
7160 +#define OS_SOLARIS_OS_SOLARIS_INLINE_HPP
7162 +#include "os_solaris.hpp"
7164 +#include "runtime/os.hpp"
7165 +#include "os_posix.inline.hpp"
7167 +// System includes
7168 +#include <sys/param.h>
7169 +#include <dlfcn.h>
7170 +#include <sys/socket.h>
7171 +#include <poll.h>
7172 +#include <sys/filio.h>
7173 +#include <unistd.h>
7174 +#include <netdb.h>
7175 +#include <setjmp.h>
7177 +inline bool os::zero_page_read_protected() {
7178 + return true;
7181 +inline bool os::uses_stack_guard_pages() {
7182 + return true;
7185 +inline bool os::must_commit_stack_guard_pages() {
7186 + assert(uses_stack_guard_pages(), "sanity check");
7187 + int r = thr_main() ;
7188 + guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
7189 + return r;
7193 +// Bang the shadow pages if they need to be touched to be mapped.
7194 +inline void os::map_stack_shadow_pages(address sp) {
7197 +// stubbed-out trim-native support
7198 +inline bool os::can_trim_native_heap() { return false; }
7199 +inline bool os::trim_native_heap(os::size_change_t* rss_change) { return false; }
7201 +//////////////////////////////////////////////////////////////////////////////
7202 +////////////////////////////////////////////////////////////////////////////////
7204 +inline bool os::numa_has_group_homing() { return true; }
7206 +#endif // OS_SOLARIS_OS_SOLARIS_INLINE_HPP
7207 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/osThread_solaris.cpp jdk-jdk-24-11/src/hotspot/os/solaris/osThread_solaris.cpp
7208 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/osThread_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
7209 +++ jdk-jdk-24-11/src/hotspot/os/solaris/osThread_solaris.cpp 2024-08-17 20:36:14.283210293 +0200
7210 @@ -0,0 +1,47 @@
7212 + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
7213 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7215 + * This code is free software; you can redistribute it and/or modify it
7216 + * under the terms of the GNU General Public License version 2 only, as
7217 + * published by the Free Software Foundation.
7219 + * This code is distributed in the hope that it will be useful, but WITHOUT
7220 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7221 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7222 + * version 2 for more details (a copy is included in the LICENSE file that
7223 + * accompanied this code).
7225 + * You should have received a copy of the GNU General Public License version
7226 + * 2 along with this work; if not, write to the Free Software Foundation,
7227 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7229 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7230 + * or visit www.oracle.com if you need additional information or have any
7231 + * questions.
7233 + */
7235 +// no precompiled headers
7236 +#include "runtime/handles.inline.hpp"
7237 +#include "runtime/mutexLocker.hpp"
7238 +#include "runtime/os.hpp"
7239 +#include "runtime/osThread.hpp"
7240 +#include "runtime/safepoint.hpp"
7241 +#include "runtime/vmThread.hpp"
7243 +#include <signal.h>
7245 + // ***************************************************************
7246 + // Platform dependent initialization and cleanup
7247 + // ***************************************************************
7249 +void OSThread::pd_initialize() {
7250 + _thread_id = 0;
7251 + sigemptyset(&_caller_sigmask);
7253 + _vm_created_thread = false;
7256 +void OSThread::pd_destroy() {
7258 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/osThread_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/osThread_solaris.hpp
7259 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/osThread_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
7260 +++ jdk-jdk-24-11/src/hotspot/os/solaris/osThread_solaris.hpp 2024-08-17 20:36:14.283504573 +0200
7261 @@ -0,0 +1,93 @@
7263 + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
7264 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7266 + * This code is free software; you can redistribute it and/or modify it
7267 + * under the terms of the GNU General Public License version 2 only, as
7268 + * published by the Free Software Foundation.
7270 + * This code is distributed in the hope that it will be useful, but WITHOUT
7271 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7272 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7273 + * version 2 for more details (a copy is included in the LICENSE file that
7274 + * accompanied this code).
7276 + * You should have received a copy of the GNU General Public License version
7277 + * 2 along with this work; if not, write to the Free Software Foundation,
7278 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7280 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7281 + * or visit www.oracle.com if you need additional information or have any
7282 + * questions.
7284 + */
7286 +#ifndef OS_SOLARIS_OSTHREAD_SOLARIS_HPP
7287 +#define OS_SOLARIS_OSTHREAD_SOLARIS_HPP
7289 +// This is embedded via include into the class OSThread
7290 + public:
7291 + typedef thread_t thread_id_t;
7293 + private:
7294 + uint _lwp_id; // lwp ID, only used with bound threads
7295 + int _native_priority; // Saved native priority when starting
7296 + // a bound thread
7297 + sigset_t _caller_sigmask; // Caller's signal mask
7298 + bool _vm_created_thread; // true if the VM created this thread,
7299 + // false if primary thread or attached thread
7300 + public:
7301 + uint lwp_id() const { return _lwp_id; }
7302 + int native_priority() const { return _native_priority; }
7304 + // Set and get state of _vm_created_thread flag
7305 + void set_vm_created() { _vm_created_thread = true; }
7306 + bool is_vm_created() { return _vm_created_thread; }
7308 + // Methods to save/restore caller's signal mask
7309 + sigset_t caller_sigmask() const { return _caller_sigmask; }
7310 + void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
7312 +#ifndef PRODUCT
7313 + // Used for debugging, return a unique integer for each thread.
7314 + int thread_identifier() const { return _thread_id; }
7315 +#endif
7316 +#ifdef ASSERT
7317 + // On solaris reposition can fail in two ways:
7318 + // 1: a mismatched pc, because signal is delivered too late, target thread
7319 + // is resumed.
7320 + // 2: on a timeout where signal is lost, target thread is resumed.
7321 + bool valid_reposition_failure() {
7322 + // only 1 and 2 can happen and we can handle both of them
7323 + return true;
7325 +#endif
7326 + void set_lwp_id(uint id) { _lwp_id = id; }
7327 + void set_native_priority(int prio) { _native_priority = prio; }
7329 + public:
7330 + pthread_t pthread_id() const {
7331 + // Here: same as OSThread::thread_id()
7332 + return _thread_id;
7334 + SuspendResume sr;
7336 + private:
7337 + void* _siginfo;
7338 + ucontext_t* _ucontext;
7340 + public:
7341 + void set_siginfo(void* ptr) { _siginfo = ptr; }
7342 + ucontext_t* ucontext() const { return _ucontext; }
7343 + void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
7345 + // ***************************************************************
7346 + // Platform dependent initialization and cleanup
7347 + // ***************************************************************
7349 +private:
7351 + void pd_initialize();
7352 + void pd_destroy();
7354 +#endif // OS_SOLARIS_OSTHREAD_SOLARIS_HPP
7355 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os/solaris/vmStructs_solaris.hpp jdk-jdk-24-11/src/hotspot/os/solaris/vmStructs_solaris.hpp
7356 --- jdk-jdk-24-11.orig/src/hotspot/os/solaris/vmStructs_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
7357 +++ jdk-jdk-24-11/src/hotspot/os/solaris/vmStructs_solaris.hpp 2024-08-17 20:36:14.287064733 +0200
7358 @@ -0,0 +1,44 @@
7360 + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
7361 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7363 + * This code is free software; you can redistribute it and/or modify it
7364 + * under the terms of the GNU General Public License version 2 only, as
7365 + * published by the Free Software Foundation.
7367 + * This code is distributed in the hope that it will be useful, but WITHOUT
7368 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7369 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7370 + * version 2 for more details (a copy is included in the LICENSE file that
7371 + * accompanied this code).
7373 + * You should have received a copy of the GNU General Public License version
7374 + * 2 along with this work; if not, write to the Free Software Foundation,
7375 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7377 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7378 + * or visit www.oracle.com if you need additional information or have any
7379 + * questions.
7381 + */
7383 +#ifndef OS_SOLARIS_VMSTRUCTS_SOLARIS_HPP
7384 +#define OS_SOLARIS_VMSTRUCTS_SOLARIS_HPP
7386 +// These are the OS-specific fields, types and integer
7387 +// constants required by the Serviceability Agent. This file is
7388 +// referenced by vmStructs.cpp.
7390 +#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field) \
7391 + nonstatic_field(OSThread, _thread_id, OSThread::thread_id_t)
7393 +#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type) \
7394 + declare_unsigned_integer_type(OSThread::thread_id_t)
7396 +#define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
7398 +#define VM_LONG_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
7400 +#define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function)
7402 +#endif // OS_SOLARIS_VMSTRUCTS_SOLARIS_HPP
7403 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/assembler_solaris_x86.cpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/assembler_solaris_x86.cpp
7404 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/assembler_solaris_x86.cpp 1970-01-01 01:00:00.000000000 +0100
7405 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/assembler_solaris_x86.cpp 2024-08-17 20:36:14.287432045 +0200
7406 @@ -0,0 +1,37 @@
7408 + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
7409 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7411 + * This code is free software; you can redistribute it and/or modify it
7412 + * under the terms of the GNU General Public License version 2 only, as
7413 + * published by the Free Software Foundation.
7415 + * This code is distributed in the hope that it will be useful, but WITHOUT
7416 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7417 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7418 + * version 2 for more details (a copy is included in the LICENSE file that
7419 + * accompanied this code).
7421 + * You should have received a copy of the GNU General Public License version
7422 + * 2 along with this work; if not, write to the Free Software Foundation,
7423 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7425 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7426 + * or visit www.oracle.com if you need additional information or have any
7427 + * questions.
7429 + */
7431 +#include "precompiled.hpp"
7432 +#include "asm/macroAssembler.inline.hpp"
7433 +#include "runtime/os.hpp"
7435 +void MacroAssembler::int3() {
7436 + push(rax);
7437 + push(rdx);
7438 + push(rcx);
7439 + call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
7440 + pop(rcx);
7441 + pop(rdx);
7442 + pop(rax);
7444 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp
7445 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7446 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp 2024-08-17 20:36:14.287794793 +0200
7447 @@ -0,0 +1,182 @@
7449 + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
7450 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7452 + * This code is free software; you can redistribute it and/or modify it
7453 + * under the terms of the GNU General Public License version 2 only, as
7454 + * published by the Free Software Foundation.
7456 + * This code is distributed in the hope that it will be useful, but WITHOUT
7457 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7458 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7459 + * version 2 for more details (a copy is included in the LICENSE file that
7460 + * accompanied this code).
7462 + * You should have received a copy of the GNU General Public License version
7463 + * 2 along with this work; if not, write to the Free Software Foundation,
7464 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7466 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7467 + * or visit www.oracle.com if you need additional information or have any
7468 + * questions.
7470 + */
7472 +#ifndef OS_CPU_SOLARIS_X86_ATOMIC_SOLARIS_X86_HPP
7473 +#define OS_CPU_SOLARIS_X86_ATOMIC_SOLARIS_X86_HPP
7475 +inline int32_t _Atomic_add(int32_t add_value, volatile int32_t* dest) {
7476 + int32_t rv = add_value;
7477 + __asm__ volatile ("lock xaddl %0,(%2)"
7478 + : "=r" (rv)
7479 + : "0" (rv), "r" (dest)
7480 + : "cc", "memory");
7481 + return rv + add_value;
7483 +inline int64_t _Atomic_add_long(int64_t add_value, volatile int64_t* dest) {
7484 + int64_t rv = add_value;
7485 + __asm__ volatile ("lock xaddq %0,(%2)"
7486 + : "=r" (rv)
7487 + : "0" (rv), "r" (dest)
7488 + : "cc", "memory");
7489 + return rv + add_value;
7491 +inline int32_t _Atomic_xchg(int32_t exchange_value, volatile int32_t* dest) {
7492 + __asm__ __volatile__ ("xchgl (%2),%0"
7493 + : "=r" (exchange_value)
7494 + : "0" (exchange_value), "r" (dest)
7495 + : "memory");
7496 + return exchange_value;
7498 +inline int64_t _Atomic_xchg_long(int64_t exchange_value, volatile int64_t* dest) {
7499 + __asm__ __volatile__ ("xchgq (%2),%0"
7500 + : "=r" (exchange_value)
7501 + : "0" (exchange_value), "r" (dest)
7502 + : "memory");
7503 + return exchange_value;
7505 +inline int8_t _Atomic_cmpxchg_byte(int8_t exchange_value, volatile int8_t* dest, int8_t compare_value) {
7506 + __asm__ volatile ("lock cmpxchgb %1,(%3)"
7507 + : "=a" (exchange_value)
7508 + : "q" (exchange_value), "a" (compare_value), "r" (dest)
7509 + : "cc", "memory");
7510 + return exchange_value;
7512 +inline int32_t _Atomic_cmpxchg(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
7513 + __asm__ volatile ("lock cmpxchgl %1,(%3)"
7514 + : "=a" (exchange_value)
7515 + : "q" (exchange_value), "a" (compare_value), "r" (dest)
7516 + : "cc", "memory");
7517 + return exchange_value;
7519 +inline int64_t _Atomic_cmpxchg_long(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
7520 + __asm__ volatile ("lock cmpxchgq %1,(%3)"
7521 + : "=a" (exchange_value)
7522 + : "q" (exchange_value), "a" (compare_value), "r" (dest)
7523 + : "cc", "memory");
7524 + return exchange_value;
7527 +template<size_t byte_size>
7528 +struct Atomic::PlatformAdd {
7529 + template<typename D, typename I>
7530 + D add_then_fetch(D volatile* dest, I add_value, atomic_memory_order order) const;
7532 + template<typename D, typename I>
7533 + D fetch_then_add(D volatile* dest, I add_value, atomic_memory_order order) const {
7534 + return add_then_fetch(dest, add_value, order) - add_value;
7538 +// Not using add_using_helper; see comment for cmpxchg.
7539 +template<>
7540 +template<typename D, typename I>
7541 +inline D Atomic::PlatformAdd<4>::add_then_fetch(D volatile* dest, I add_value,
7542 + atomic_memory_order order) const {
7543 + STATIC_ASSERT(4 == sizeof(I));
7544 + STATIC_ASSERT(4 == sizeof(D));
7545 + return PrimitiveConversions::cast<D>(
7546 + _Atomic_add(PrimitiveConversions::cast<int32_t>(add_value),
7547 + reinterpret_cast<int32_t volatile*>(dest)));
7550 +// Not using add_using_helper; see comment for cmpxchg.
7551 +template<>
7552 +template<typename D, typename I>
7553 +inline D Atomic::PlatformAdd<8>::add_then_fetch(D volatile* dest, I add_value,
7554 + atomic_memory_order order) const {
7555 + STATIC_ASSERT(8 == sizeof(I));
7556 + STATIC_ASSERT(8 == sizeof(D));
7557 + return PrimitiveConversions::cast<D>(
7558 + _Atomic_add_long(PrimitiveConversions::cast<int64_t>(add_value),
7559 + reinterpret_cast<int64_t volatile*>(dest)));
7562 +template<>
7563 +template<typename T>
7564 +inline T Atomic::PlatformXchg<4>::operator()(T volatile* dest,
7565 + T exchange_value,
7566 + atomic_memory_order order) const {
7567 + STATIC_ASSERT(4 == sizeof(T));
7568 + return PrimitiveConversions::cast<T>(
7569 + _Atomic_xchg(PrimitiveConversions::cast<int32_t>(exchange_value),
7570 + reinterpret_cast<int32_t volatile*>(dest)));
7573 +template<>
7574 +template<typename T>
7575 +inline T Atomic::PlatformXchg<8>::operator()(T volatile* dest,
7576 + T exchange_value,
7577 + atomic_memory_order order) const {
7578 + STATIC_ASSERT(8 == sizeof(T));
7579 + return PrimitiveConversions::cast<T>(
7580 + _Atomic_xchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
7581 + reinterpret_cast<int64_t volatile*>(dest)));
7584 +// Not using cmpxchg_using_helper here, because some configurations of
7585 +// Solaris compiler don't deal well with passing a "defined in .il"
7586 +// function as an argument. We *should* switch to using gcc-style
7587 +// inline assembly, but attempting to do so with Studio 12.4 ran into
7588 +// segfaults.
7590 +template<>
7591 +template<typename T>
7592 +inline T Atomic::PlatformCmpxchg<1>::operator()(T volatile* dest,
7593 + T compare_value,
7594 + T exchange_value,
7595 + atomic_memory_order order) const {
7596 + STATIC_ASSERT(1 == sizeof(T));
7597 + return PrimitiveConversions::cast<T>(
7598 + _Atomic_cmpxchg_byte(PrimitiveConversions::cast<int8_t>(exchange_value),
7599 + reinterpret_cast<int8_t volatile*>(dest),
7600 + PrimitiveConversions::cast<int8_t>(compare_value)));
7603 +template<>
7604 +template<typename T>
7605 +inline T Atomic::PlatformCmpxchg<4>::operator()(T volatile* dest,
7606 + T compare_value,
7607 + T exchange_value,
7608 + atomic_memory_order order) const {
7609 + STATIC_ASSERT(4 == sizeof(T));
7610 + return PrimitiveConversions::cast<T>(
7611 + _Atomic_cmpxchg(PrimitiveConversions::cast<int32_t>(exchange_value),
7612 + reinterpret_cast<int32_t volatile*>(dest),
7613 + PrimitiveConversions::cast<int32_t>(compare_value)));
7616 +template<>
7617 +template<typename T>
7618 +inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
7619 + T compare_value,
7620 + T exchange_value,
7621 + atomic_memory_order order) const {
7622 + STATIC_ASSERT(8 == sizeof(T));
7623 + return PrimitiveConversions::cast<T>(
7624 + _Atomic_cmpxchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
7625 + reinterpret_cast<int64_t volatile*>(dest),
7626 + PrimitiveConversions::cast<int64_t>(compare_value)));
7629 +#endif // OS_CPU_SOLARIS_X86_ATOMIC_SOLARIS_X86_HPP
7630 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/bytes_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/bytes_solaris_x86.hpp
7631 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/bytes_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7632 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/bytes_solaris_x86.hpp 2024-08-17 20:36:14.288062047 +0200
7633 @@ -0,0 +1,60 @@
7635 + * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
7636 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7638 + * This code is free software; you can redistribute it and/or modify it
7639 + * under the terms of the GNU General Public License version 2 only, as
7640 + * published by the Free Software Foundation.
7642 + * This code is distributed in the hope that it will be useful, but WITHOUT
7643 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7644 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7645 + * version 2 for more details (a copy is included in the LICENSE file that
7646 + * accompanied this code).
7648 + * You should have received a copy of the GNU General Public License version
7649 + * 2 along with this work; if not, write to the Free Software Foundation,
7650 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7652 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7653 + * or visit www.oracle.com if you need additional information or have any
7654 + * questions.
7656 + */
7658 +#ifndef OS_CPU_SOLARIS_X86_BYTES_SOLARIS_X86_HPP
7659 +#define OS_CPU_SOLARIS_X86_BYTES_SOLARIS_X86_HPP
7661 +extern "C" {
7662 + inline u2 _raw_swap_u2(u2 x) {
7663 + unsigned short int __dest;
7664 + __asm__ ("rorw $8, %w0": "=r" (__dest): "0" (x): "cc");
7665 + return __dest;
7667 + inline u4 _raw_swap_u4(u4 x) {
7668 + unsigned int __dest;
7669 + __asm__ ("bswap %0" : "=r" (__dest) : "0" (x));
7670 + return __dest;
7672 + inline u8 _raw_swap_u8(u8 x) {
7673 + unsigned long __dest;
7674 + __asm__ ("bswap %q0" : "=r" (__dest) : "0" (x));
7675 + return __dest;
7679 +// Efficient swapping of data bytes from Java byte
7680 +// ordering to native byte ordering and vice versa.
7681 +inline u2 Bytes::swap_u2(u2 x) {
7682 + return _raw_swap_u2(x);
7685 +inline u4 Bytes::swap_u4(u4 x) {
7686 + return _raw_swap_u4(x);
7689 +inline u8 Bytes::swap_u8(u8 x) {
7690 + return _raw_swap_u8(x);
7693 +#endif // OS_CPU_SOLARIS_X86_BYTES_SOLARIS_X86_HPP
7694 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/copy_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/copy_solaris_x86.hpp
7695 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/copy_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7696 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/copy_solaris_x86.hpp 2024-08-17 20:36:14.288325400 +0200
7697 @@ -0,0 +1,30 @@
7699 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
7700 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7702 + * This code is free software; you can redistribute it and/or modify it
7703 + * under the terms of the GNU General Public License version 2 only, as
7704 + * published by the Free Software Foundation.
7706 + * This code is distributed in the hope that it will be useful, but WITHOUT
7707 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7708 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7709 + * version 2 for more details (a copy is included in the LICENSE file that
7710 + * accompanied this code).
7712 + * You should have received a copy of the GNU General Public License version
7713 + * 2 along with this work; if not, write to the Free Software Foundation,
7714 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7716 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7717 + * or visit www.oracle.com if you need additional information or have any
7718 + * questions.
7720 + */
7722 +#ifndef OS_CPU_SOLARIS_X86_COPY_SOLARIS_X86_HPP
7723 +#define OS_CPU_SOLARIS_X86_COPY_SOLARIS_X86_HPP
7725 +// now in central copy_x86.hpp
7727 +#endif // OS_CPU_SOLARIS_X86_COPY_SOLARIS_X86_HPP
7728 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/globals_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/globals_solaris_x86.hpp
7729 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/globals_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7730 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/globals_solaris_x86.hpp 2024-08-17 20:36:14.288621669 +0200
7731 @@ -0,0 +1,40 @@
7733 + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
7734 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7736 + * This code is free software; you can redistribute it and/or modify it
7737 + * under the terms of the GNU General Public License version 2 only, as
7738 + * published by the Free Software Foundation.
7740 + * This code is distributed in the hope that it will be useful, but WITHOUT
7741 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7742 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7743 + * version 2 for more details (a copy is included in the LICENSE file that
7744 + * accompanied this code).
7746 + * You should have received a copy of the GNU General Public License version
7747 + * 2 along with this work; if not, write to the Free Software Foundation,
7748 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7750 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7751 + * or visit www.oracle.com if you need additional information or have any
7752 + * questions.
7754 + */
7756 +#ifndef OS_CPU_SOLARIS_X86_GLOBALS_SOLARIS_X86_HPP
7757 +#define OS_CPU_SOLARIS_X86_GLOBALS_SOLARIS_X86_HPP
7759 +// Sets the default values for platform dependent flags used by the runtime system.
7760 +// (see globals.hpp)
7762 +define_pd_global(bool, DontYieldALot, true); // Determined in the design center
7763 +define_pd_global(intx, CompilerThreadStackSize, 1024);
7764 +define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default
7765 +define_pd_global(intx, VMThreadStackSize, 1024);
7766 +define_pd_global(size_t, JVMInvokeMethodSlack, 8*K);
7768 +// Used on 64 bit platforms for UseCompressedOops base address
7769 +define_pd_global(size_t, HeapBaseMinAddress, 2*G);
7771 +#endif // OS_CPU_SOLARIS_X86_GLOBALS_SOLARIS_X86_HPP
7772 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.cpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.cpp
7773 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.cpp 1970-01-01 01:00:00.000000000 +0100
7774 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.cpp 2024-08-17 20:36:14.290846159 +0200
7775 @@ -0,0 +1,97 @@
7777 + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
7778 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7780 + * This code is free software; you can redistribute it and/or modify it
7781 + * under the terms of the GNU General Public License version 2 only, as
7782 + * published by the Free Software Foundation.
7784 + * This code is distributed in the hope that it will be useful, but WITHOUT
7785 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7786 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7787 + * version 2 for more details (a copy is included in the LICENSE file that
7788 + * accompanied this code).
7790 + * You should have received a copy of the GNU General Public License version
7791 + * 2 along with this work; if not, write to the Free Software Foundation,
7792 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7794 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7795 + * or visit www.oracle.com if you need additional information or have any
7796 + * questions.
7798 + */
7800 +#include "precompiled.hpp"
7801 +#include "runtime/frame.inline.hpp"
7802 +#include "runtime/javaThread.hpp"
7804 +frame JavaThread::pd_last_frame() {
7805 + assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
7806 + vmassert(_anchor.last_Java_pc() != NULL, "not walkable");
7807 + return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
7810 +// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
7811 +// currently interrupted by SIGPROF
7812 +bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
7813 + void* ucontext, bool isInJava) {
7814 + assert(Thread::current() == this, "caller must be current thread");
7815 + return pd_get_top_frame(fr_addr, ucontext, isInJava);
7818 +bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr,
7819 + void* ucontext, bool isInJava) {
7820 + return pd_get_top_frame(fr_addr, ucontext, isInJava);
7823 +bool JavaThread::pd_get_top_frame(frame* fr_addr,
7824 + void* ucontext, bool isInJava) {
7825 + assert(this->is_Java_thread(), "must be JavaThread");
7826 + JavaThread* jt = (JavaThread *)this;
7828 + // There is small window where last_Java_frame is not walkable or safe
7829 + if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
7830 + *fr_addr = jt->pd_last_frame();
7831 + return true;
7834 + ucontext_t* uc = (ucontext_t*) ucontext;
7836 + // We always want to use the initial frame we create from the ucontext as
7837 + // it certainly signals where we currently are. However that frame may not
7838 + // be safe for calling sender. In that case if we have a last_Java_frame
7839 + // then the forte walker will switch to that frame as the virtual sender
7840 + // for the frame we create here which is not sender safe.
7842 + intptr_t* ret_fp;
7843 + intptr_t* ret_sp;
7844 + address addr = os::fetch_frame_from_context(uc, &ret_sp, &ret_fp);
7846 + // Something would really have to be screwed up to get a NULL pc
7848 + if (addr == NULL) {
7849 + // ucontext wasn't useful
7850 + return false;
7853 + // If sp and fp are nonsense just leave them out
7855 + if (!jt->is_in_full_stack((address)ret_sp)) {
7856 + ret_sp = NULL;
7857 + ret_fp = NULL;
7858 + } else {
7859 + // sp is reasonable is fp reasonable?
7860 + if (!jt->is_in_stack_range_incl((address)ret_fp, (address)ret_sp)) {
7861 + ret_fp = NULL;
7865 + frame ret_frame(ret_sp, ret_fp, addr);
7867 + *fr_addr = ret_frame;
7868 + return true;
7872 +void JavaThread::cache_global_variables() { }
7873 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.hpp
7874 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7875 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/javaThread_solaris_x86.hpp 2024-08-17 20:36:14.291106889 +0200
7876 @@ -0,0 +1,59 @@
7878 + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
7879 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7881 + * This code is free software; you can redistribute it and/or modify it
7882 + * under the terms of the GNU General Public License version 2 only, as
7883 + * published by the Free Software Foundation.
7885 + * This code is distributed in the hope that it will be useful, but WITHOUT
7886 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7887 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7888 + * version 2 for more details (a copy is included in the LICENSE file that
7889 + * accompanied this code).
7891 + * You should have received a copy of the GNU General Public License version
7892 + * 2 along with this work; if not, write to the Free Software Foundation,
7893 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7895 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7896 + * or visit www.oracle.com if you need additional information or have any
7897 + * questions.
7899 + */
7901 +#ifndef OS_CPU_SOLARIS_X86_JAVATHREAD_SOLARIS_X86_HPP
7902 +#define OS_CPU_SOLARIS_X86_JAVATHREAD_SOLARIS_X86_HPP
7904 + private:
7905 + void pd_initialize() { _anchor.clear(); }
7907 + frame pd_last_frame();
7909 + public:
7911 + void set_base_of_stack_pointer(intptr_t* base_sp) {}
7913 + static ByteSize last_Java_fp_offset() {
7914 + return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_fp_offset();
7917 + intptr_t* base_of_stack_pointer() { return NULL; }
7918 + void record_base_of_stack_pointer() {}
7920 + bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext,
7921 + bool isInJava);
7922 + bool pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
7923 + bool isInJava);
7924 +private:
7925 + bool pd_get_top_frame(frame* fr_addr, void* ucontext,
7926 + bool isInJava);
7927 +public:
7929 + // These routines are only used on cpu architectures that
7930 + // have separate register stacks (Itanium).
7931 + static bool register_stack_overflow() { return false; }
7932 + static void enable_register_stack_guard() {}
7933 + static void disable_register_stack_guard() {}
7935 +#endif // OS_CPU_SOLARIS_X86_JAVATHREAD_SOLARIS_X86_HPP
7936 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp
7937 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
7938 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp 2024-08-17 20:36:14.288877530 +0200
7939 @@ -0,0 +1,58 @@
7941 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
7942 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7944 + * This code is free software; you can redistribute it and/or modify it
7945 + * under the terms of the GNU General Public License version 2 only, as
7946 + * published by the Free Software Foundation.
7948 + * This code is distributed in the hope that it will be useful, but WITHOUT
7949 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7950 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7951 + * version 2 for more details (a copy is included in the LICENSE file that
7952 + * accompanied this code).
7954 + * You should have received a copy of the GNU General Public License version
7955 + * 2 along with this work; if not, write to the Free Software Foundation,
7956 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7958 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7959 + * or visit www.oracle.com if you need additional information or have any
7960 + * questions.
7962 + */
7964 +#ifndef OS_CPU_SOLARIS_X86_ORDERACCESS_SOLARIS_X86_HPP
7965 +#define OS_CPU_SOLARIS_X86_ORDERACCESS_SOLARIS_X86_HPP
7967 +// Included in orderAccess.hpp header file.
7969 +// Compiler version last used for testing: solaris studio 12u3
7970 +// Please update this information when this file changes
7972 +// Implementation of class OrderAccess.
7974 +// A compiler barrier, forcing the C++ compiler to invalidate all memory assumptions
7975 +inline void compiler_barrier() {
7976 + __asm__ volatile ("" : : : "memory");
7979 +inline void OrderAccess::loadload() { compiler_barrier(); }
7980 +inline void OrderAccess::storestore() { compiler_barrier(); }
7981 +inline void OrderAccess::loadstore() { compiler_barrier(); }
7982 +inline void OrderAccess::storeload() { fence(); }
7984 +inline void OrderAccess::acquire() { compiler_barrier(); }
7985 +inline void OrderAccess::release() { compiler_barrier(); }
7987 +inline void OrderAccess::fence() {
7988 + __asm__ volatile ("lock; addl $0,0(%%rsp)" : : : "cc", "memory");
7989 + compiler_barrier();
7992 +inline void OrderAccess::cross_modify_fence_impl() {
7993 + int idx = 0;
7994 + __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
7997 +#endif // OS_CPU_SOLARIS_X86_ORDERACCESS_SOLARIS_X86_HPP
7998 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp
7999 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp 1970-01-01 01:00:00.000000000 +0100
8000 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp 2024-08-17 20:36:14.289418243 +0200
8001 @@ -0,0 +1,660 @@
8003 + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
8004 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8006 + * This code is free software; you can redistribute it and/or modify it
8007 + * under the terms of the GNU General Public License version 2 only, as
8008 + * published by the Free Software Foundation.
8010 + * This code is distributed in the hope that it will be useful, but WITHOUT
8011 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8012 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8013 + * version 2 for more details (a copy is included in the LICENSE file that
8014 + * accompanied this code).
8016 + * You should have received a copy of the GNU General Public License version
8017 + * 2 along with this work; if not, write to the Free Software Foundation,
8018 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8020 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8021 + * or visit www.oracle.com if you need additional information or have any
8022 + * questions.
8024 + */
8026 +// no precompiled headers
8027 +#include "jvm.h"
8028 +#include "asm/macroAssembler.hpp"
8029 +#include "classfile/classLoader.hpp"
8030 +#include "classfile/systemDictionary.hpp"
8031 +#include "classfile/vmSymbols.hpp"
8032 +#include "code/codeCache.hpp"
8033 +#include "code/vtableStubs.hpp"
8034 +#include "interpreter/interpreter.hpp"
8035 +#include "logging/log.hpp"
8036 +#include "memory/allocation.inline.hpp"
8037 +#include "os_solaris.hpp"
8038 +#include "os_posix.hpp"
8039 +#include "prims/jniFastGetField.hpp"
8040 +#include "prims/jvm_misc.hpp"
8041 +#include "runtime/arguments.hpp"
8042 +#include "runtime/frame.inline.hpp"
8043 +#include "runtime/interfaceSupport.inline.hpp"
8044 +#include "runtime/java.hpp"
8045 +#include "runtime/javaCalls.hpp"
8046 +#include "runtime/mutexLocker.hpp"
8047 +#include "runtime/osThread.hpp"
8048 +#include "runtime/safepointMechanism.hpp"
8049 +#include "runtime/sharedRuntime.hpp"
8050 +#include "runtime/stubRoutines.hpp"
8051 +#include "runtime/thread.inline.hpp"
8052 +#include "runtime/timer.hpp"
8053 +#include "signals_posix.hpp"
8054 +#include "utilities/align.hpp"
8055 +#include "utilities/events.hpp"
8056 +#include "utilities/vmError.hpp"
8058 +// put OS-includes here
8059 +# include <sys/types.h>
8060 +# include <sys/mman.h>
8061 +# include <pthread.h>
8062 +# include <signal.h>
8063 +# include <setjmp.h>
8064 +# include <errno.h>
8065 +# include <dlfcn.h>
8066 +# include <stdio.h>
8067 +# include <unistd.h>
8068 +# include <sys/resource.h>
8069 +# include <thread.h>
8070 +# include <sys/stat.h>
8071 +# include <sys/time.h>
8072 +# include <sys/filio.h>
8073 +# include <sys/utsname.h>
8074 +# include <sys/systeminfo.h>
8075 +# include <sys/socket.h>
8076 +# include <sys/trap.h>
8077 +# include <sys/lwp.h>
8078 +# include <poll.h>
8079 +# include <sys/lwp.h>
8080 +# include <procfs.h>
8083 +#define MAX_PATH (2 * K)
8085 +// Minimum usable stack sizes required to get to user code. Space for
8086 +// HotSpot guard pages is added later.
8087 +#ifdef _LP64
8088 +// The adlc generated method 'State::MachNodeGenerator(int)' used by the C2 compiler
8089 +// threads requires a large stack with the Solaris Studio C++ compiler version 5.13
8090 +// and product VM builds (debug builds require significantly less stack space).
8091 +size_t os::_compiler_thread_min_stack_allowed = 325 * K;
8092 +size_t os::_java_thread_min_stack_allowed = 48 * K;
8093 +size_t os::_vm_internal_thread_min_stack_allowed = 224 * K;
8094 +#else
8095 +size_t os::_compiler_thread_min_stack_allowed = 32 * K;
8096 +size_t os::_java_thread_min_stack_allowed = 32 * K;
8097 +size_t os::_vm_internal_thread_min_stack_allowed = 64 * K;
8098 +#endif // _LP64
8100 +#ifdef AMD64
8101 +#define REG_SP REG_RSP
8102 +#define REG_PC REG_RIP
8103 +#define REG_FP REG_RBP
8104 +#else
8105 +#define REG_SP UESP
8106 +#define REG_PC EIP
8107 +#define REG_FP EBP
8108 +// 4900493 counter to prevent runaway LDTR refresh attempt
8110 +static volatile int ldtr_refresh = 0;
8111 +// the libthread instruction that faults because of the stale LDTR
8113 +static const unsigned char movlfs[] = { 0x8e, 0xe0 // movl %eax,%fs
8114 + };
8115 +#endif // AMD64
8117 +char* os::non_memory_address_word() {
8118 + // Must never look like an address returned by reserve_memory,
8119 + // even in its subfields (as defined by the CPU immediate fields,
8120 + // if the CPU splits constants across multiple instructions).
8121 + return (char*) -1;
8125 +// Validate a ucontext retrieved from walking a uc_link of a ucontext.
8126 +// There are issues with libthread giving out uc_links for different threads
8127 +// on the same uc_link chain and bad or circular links.
8129 +bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) {
8130 + if (valid >= suspect ||
8131 + valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags ||
8132 + valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp ||
8133 + valid->uc_stack.ss_size != suspect->uc_stack.ss_size) {
8134 + DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");)
8135 + return false;
8138 + if (thread->is_Java_thread()) {
8139 + if (!thread->is_in_full_stack_checked((address)suspect)) {
8140 + DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");)
8141 + return false;
8143 + if (!thread->is_in_full_stack_checked((address) suspect->uc_mcontext.gregs[REG_SP])) {
8144 + DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");)
8145 + return false;
8148 + return true;
8151 +// We will only follow one level of uc_link since there are libthread
8152 +// issues with ucontext linking and it is better to be safe and just
8153 +// let caller retry later.
8154 +const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread,
8155 + const ucontext_t *uc) {
8157 + const ucontext_t *retuc = NULL;
8159 + if (uc != NULL) {
8160 + if (uc->uc_link == NULL) {
8161 + // cannot validate without uc_link so accept current ucontext
8162 + retuc = uc;
8163 + } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {
8164 + // first ucontext is valid so try the next one
8165 + uc = uc->uc_link;
8166 + if (uc->uc_link == NULL) {
8167 + // cannot validate without uc_link so accept current ucontext
8168 + retuc = uc;
8169 + } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) {
8170 + // the ucontext one level down is also valid so return it
8171 + retuc = uc;
8175 + return retuc;
8178 +void os::Posix::ucontext_set_pc(ucontext_t* uc, address pc) {
8179 + uc->uc_mcontext.gregs [REG_PC] = (greg_t) pc;
8182 +// Assumes ucontext is valid
8183 +intptr_t* os::Solaris::ucontext_get_sp(const ucontext_t *uc) {
8184 + return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
8187 +// Assumes ucontext is valid
8188 +intptr_t* os::Solaris::ucontext_get_fp(const ucontext_t *uc) {
8189 + return (intptr_t*)uc->uc_mcontext.gregs[REG_FP];
8192 +address os::Posix::ucontext_get_pc(const ucontext_t *uc) {
8193 + return (address) uc->uc_mcontext.gregs[REG_PC];
8196 +address os::fetch_frame_from_context(const void* ucVoid,
8197 + intptr_t** ret_sp, intptr_t** ret_fp) {
8199 + address epc;
8200 + const ucontext_t *uc = (const ucontext_t*)ucVoid;
8202 + if (uc != NULL) {
8203 + epc = os::Posix::ucontext_get_pc(uc);
8204 + if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc);
8205 + if (ret_fp) *ret_fp = os::Solaris::ucontext_get_fp(uc);
8206 + } else {
8207 + epc = NULL;
8208 + if (ret_sp) *ret_sp = (intptr_t *)NULL;
8209 + if (ret_fp) *ret_fp = (intptr_t *)NULL;
8212 + return epc;
8215 +frame os::fetch_frame_from_context(const void* ucVoid) {
8216 + intptr_t* sp;
8217 + intptr_t* fp;
8218 + address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
8219 + return frame(sp, fp, epc);
8222 +bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
8223 + address pc = (address) os::Solaris::ucontext_get_pc(uc);
8224 + if (Interpreter::contains(pc)) {
8225 + // interpreter performs stack banging after the fixed frame header has
8226 + // been generated while the compilers perform it before. To maintain
8227 + // semantic consistency between interpreted and compiled frames, the
8228 + // method returns the Java sender of the current frame.
8229 + *fr = os::fetch_frame_from_context(uc);
8230 + if (!fr->is_first_java_frame()) {
8231 + // get_frame_at_stack_banging_point() is only called when we
8232 + // have well defined stacks so java_sender() calls do not need
8233 + // to assert safe_for_sender() first.
8234 + *fr = fr->java_sender();
8236 + } else {
8237 + // more complex code with compiled code
8238 + assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
8239 + CodeBlob* cb = CodeCache::find_blob(pc);
8240 + if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
8241 + // Not sure where the pc points to, fallback to default
8242 + // stack overflow handling
8243 + return false;
8244 + } else {
8245 + // in compiled code, the stack banging is performed just after the return pc
8246 + // has been pushed on the stack
8247 + intptr_t* fp = os::Solaris::ucontext_get_fp(uc);
8248 + intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
8249 + *fr = frame(sp + 1, fp, (address)*sp);
8250 + if (!fr->is_java_frame()) {
8251 + // See java_sender() comment above.
8252 + *fr = fr->java_sender();
8256 + assert(fr->is_java_frame(), "Safety check");
8257 + return true;
8260 +frame os::get_sender_for_C_frame(frame* fr) {
8261 + return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
8264 +extern "C" intptr_t *_get_current_sp() {
8265 + register intptr_t *rsp __asm__ ("rsp");
8266 + return rsp;
8269 +address os::current_stack_pointer() {
8270 + return (address)_get_current_sp();
8273 +extern "C" intptr_t *_get_current_fp() {
8274 + register intptr_t **rbp __asm__ ("rbp");
8275 + return (intptr_t*) *rbp;
8278 +frame os::current_frame() {
8279 + intptr_t* fp = _get_current_fp(); // it's inlined so want current fp
8280 + // fp is for os::current_frame. We want the fp for our caller.
8281 + frame myframe((intptr_t*)os::current_stack_pointer(),
8282 + (intptr_t*)fp,
8283 + CAST_FROM_FN_PTR(address, os::current_frame));
8284 + frame caller_frame = os::get_sender_for_C_frame(&myframe);
8286 + if (os::is_first_C_frame(&caller_frame)) {
8287 + // stack is not walkable
8288 + frame ret; // This will be a null useless frame
8289 + return ret;
8290 + } else {
8291 + // return frame for our caller's caller
8292 + return os::get_sender_for_C_frame(&caller_frame);
8297 +bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
8298 + ucontext_t* uc, JavaThread* thread) {
8300 + if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) {
8301 + // can't decode this kind of signal
8302 + info = NULL;
8303 + } else {
8304 + assert(sig == info->si_signo, "bad siginfo");
8307 + // decide if this trap can be handled by a stub
8308 + address stub = NULL;
8310 + address pc = NULL;
8312 + //%note os_trap_1
8313 + if (info != NULL && uc != NULL && thread != NULL) {
8314 + // factor me: getPCfromContext
8315 + pc = (address) uc->uc_mcontext.gregs[REG_PC];
8317 + // Handle ALL stack overflow variations here
8318 + if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) {
8319 + address addr = (address) info->si_addr;
8320 + if (thread->in_stack_yellow_reserved_zone(addr)) {
8321 + if (thread->thread_state() == _thread_in_Java) {
8322 + if (thread->in_stack_reserved_zone(addr)) {
8323 + frame fr;
8324 + if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) {
8325 + assert(fr.is_java_frame(), "Must be Java frame");
8326 + frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
8327 + if (activation.sp() != NULL) {
8328 + thread->disable_stack_reserved_zone();
8329 + if (activation.is_interpreted_frame()) {
8330 + thread->set_reserved_stack_activation((address)(
8331 + activation.fp() + frame::interpreter_frame_initial_sp_offset));
8332 + } else {
8333 + thread->set_reserved_stack_activation((address)activation.unextended_sp());
8335 + return true;
8339 + // Throw a stack overflow exception. Guard pages will be reenabled
8340 + // while unwinding the stack.
8341 + thread->disable_stack_yellow_reserved_zone();
8342 + stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
8343 + } else {
8344 + // Thread was in the vm or native code. Return and try to finish.
8345 + thread->disable_stack_yellow_reserved_zone();
8346 + return true;
8348 + } else if (thread->in_stack_red_zone(addr)) {
8349 + // Fatal red zone violation. Disable the guard pages and fall through
8350 + // to handle_unexpected_exception way down below.
8351 + thread->disable_stack_red_zone();
8352 + tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
8356 + if ((sig == SIGSEGV) && VM_Version::is_cpuinfo_segv_addr(pc)) {
8357 + // Verify that OS save/restore AVX registers.
8358 + stub = VM_Version::cpuinfo_cont_addr();
8361 + if (thread->thread_state() == _thread_in_vm ||
8362 + thread->thread_state() == _thread_in_native) {
8363 + if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) {
8364 + address next_pc = Assembler::locate_next_instruction(pc);
8365 + if (UnsafeMemoryAccess::contains_pc(pc)) {
8366 + next_pc = UnsafeMemoryAccess::page_error_continue_pc(pc);
8368 + stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
8372 + if (thread->thread_state() == _thread_in_Java) {
8373 + // Support Safepoint Polling
8374 + if ( sig == SIGSEGV && SafepointMechanism::is_poll_address((address)info->si_addr)) {
8375 + stub = SharedRuntime::get_poll_stub(pc);
8377 + else if (sig == SIGBUS && info->si_code == BUS_OBJERR) {
8378 + // BugId 4454115: A read from a MappedByteBuffer can fault
8379 + // here if the underlying file has been truncated.
8380 + // Do not crash the VM in such a case.
8381 + CodeBlob* cb = CodeCache::find_blob(pc);
8382 + if (cb != NULL) {
8383 + nmethod* nm = cb->as_nmethod_or_null();
8384 + bool is_unsafe_memory_access = thread->doing_unsafe_access() && UnsafeMemoryAccess::contains_pc(pc);
8385 + if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_memory_access) {
8386 + address next_pc = Assembler::locate_next_instruction(pc);
8387 + if (is_unsafe_memory_access) {
8388 + next_pc = UnsafeMemoryAccess::page_error_continue_pc(pc);
8390 + stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
8393 + } else
8394 + if (sig == SIGFPE && info->si_code == FPE_INTDIV) {
8395 + // integer divide by zero
8396 + stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
8398 +#ifndef AMD64
8399 + else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) {
8400 + // floating-point divide by zero
8401 + stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
8403 + else if (sig == SIGFPE && info->si_code == FPE_FLTINV) {
8404 + // The encoding of D2I in i486.ad can cause an exception prior
8405 + // to the fist instruction if there was an invalid operation
8406 + // pending. We want to dismiss that exception. From the win_32
8407 + // side it also seems that if it really was the fist causing
8408 + // the exception that we do the d2i by hand with different
8409 + // rounding. Seems kind of weird. QQQ TODO
8410 + // Note that we take the exception at the NEXT floating point instruction.
8411 + if (pc[0] == 0xDB) {
8412 + assert(pc[0] == 0xDB, "not a FIST opcode");
8413 + assert(pc[1] == 0x14, "not a FIST opcode");
8414 + assert(pc[2] == 0x24, "not a FIST opcode");
8415 + return true;
8416 + } else {
8417 + assert(pc[-3] == 0xDB, "not an flt invalid opcode");
8418 + assert(pc[-2] == 0x14, "not an flt invalid opcode");
8419 + assert(pc[-1] == 0x24, "not an flt invalid opcode");
8422 + else if (sig == SIGFPE ) {
8423 + tty->print_cr("caught SIGFPE, info 0x%x.", info->si_code);
8425 +#endif // !AMD64
8427 + // QQQ It doesn't seem that we need to do this on x86 because we should be able
8428 + // to return properly from the handler without this extra stuff on the back side.
8430 + else if (sig == SIGSEGV && info->si_code > 0 &&
8431 + MacroAssembler::uses_implicit_null_check(info->si_addr)) {
8432 + // Determination of interpreter/vtable stub/compiled code null exception
8433 + stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
8437 + // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
8438 + // and the heap gets shrunk before the field access.
8439 + if ((sig == SIGSEGV) || (sig == SIGBUS)) {
8440 + address addr = JNI_FastGetField::find_slowcase_pc(pc);
8441 + if (addr != (address)-1) {
8442 + stub = addr;
8447 + // Execution protection violation
8448 + //
8449 + // Preventative code for future versions of Solaris which may
8450 + // enable execution protection when running the 32-bit VM on AMD64.
8451 + //
8452 + // This should be kept as the last step in the triage. We don't
8453 + // have a dedicated trap number for a no-execute fault, so be
8454 + // conservative and allow other handlers the first shot.
8455 + //
8456 + // Note: We don't test that info->si_code == SEGV_ACCERR here.
8457 + // this si_code is so generic that it is almost meaningless; and
8458 + // the si_code for this condition may change in the future.
8459 + // Furthermore, a false-positive should be harmless.
8460 + if (UnguardOnExecutionViolation > 0 &&
8461 + (sig == SIGSEGV || sig == SIGBUS) &&
8462 + uc->uc_mcontext.gregs[TRAPNO] == T_PGFLT) { // page fault
8463 + int page_size = os::vm_page_size();
8464 + address addr = (address) info->si_addr;
8465 + address pc = (address) uc->uc_mcontext.gregs[REG_PC];
8466 + // Make sure the pc and the faulting address are sane.
8467 + //
8468 + // If an instruction spans a page boundary, and the page containing
8469 + // the beginning of the instruction is executable but the following
8470 + // page is not, the pc and the faulting address might be slightly
8471 + // different - we still want to unguard the 2nd page in this case.
8472 + //
8473 + // 15 bytes seems to be a (very) safe value for max instruction size.
8474 + bool pc_is_near_addr =
8475 + (pointer_delta((void*) addr, (void*) pc, sizeof(char)) < 15);
8476 + bool instr_spans_page_boundary =
8477 + (align_down((intptr_t) pc ^ (intptr_t) addr,
8478 + (intptr_t) page_size) > 0);
8480 + if (pc == addr || (pc_is_near_addr && instr_spans_page_boundary)) {
8481 + static volatile address last_addr =
8482 + (address) os::non_memory_address_word();
8484 + // In conservative mode, don't unguard unless the address is in the VM
8485 + if (addr != last_addr &&
8486 + (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) {
8488 + // Make memory rwx and retry
8489 + address page_start = align_down(addr, page_size);
8490 + bool res = os::protect_memory((char*) page_start, page_size,
8491 + os::MEM_PROT_RWX);
8493 + log_debug(os)("Execution protection violation "
8494 + "at " INTPTR_FORMAT
8495 + ", unguarding " INTPTR_FORMAT ": %s, errno=%d", p2i(addr),
8496 + p2i(page_start), (res ? "success" : "failed"), errno);
8497 + stub = pc;
8499 + // Set last_addr so if we fault again at the same address, we don't end
8500 + // up in an endless loop.
8501 + //
8502 + // There are two potential complications here. Two threads trapping at
8503 + // the same address at the same time could cause one of the threads to
8504 + // think it already unguarded, and abort the VM. Likely very rare.
8505 + //
8506 + // The other race involves two threads alternately trapping at
8507 + // different addresses and failing to unguard the page, resulting in
8508 + // an endless loop. This condition is probably even more unlikely than
8509 + // the first.
8510 + //
8511 + // Although both cases could be avoided by using locks or thread local
8512 + // last_addr, these solutions are unnecessary complication: this
8513 + // handler is a best-effort safety net, not a complete solution. It is
8514 + // disabled by default and should only be used as a workaround in case
8515 + // we missed any no-execute-unsafe VM code.
8517 + last_addr = addr;
8522 + if (stub != NULL) {
8523 + // save all thread context in case we need to restore it
8525 + if (thread != NULL) thread->set_saved_exception_pc(pc);
8526 + // 12/02/99: On Sparc it appears that the full context is also saved
8527 + // but as yet, no one looks at or restores that saved context
8528 + os::Posix::ucontext_set_pc(uc, stub);
8529 + return true;
8532 + return false;
8535 +void os::print_context(outputStream *st, const void *context) {
8536 + if (context == NULL) return;
8538 + const ucontext_t *uc = (const ucontext_t*)context;
8539 + st->print_cr("Registers:");
8540 +#ifdef AMD64
8541 + st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
8542 + st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
8543 + st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]);
8544 + st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]);
8545 + st->cr();
8546 + st->print( "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]);
8547 + st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]);
8548 + st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]);
8549 + st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]);
8550 + st->cr();
8551 + st->print( "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]);
8552 + st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]);
8553 + st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]);
8554 + st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]);
8555 + st->cr();
8556 + st->print( "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]);
8557 + st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]);
8558 + st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]);
8559 + st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]);
8560 + st->cr();
8561 + st->print( "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]);
8562 + st->print(", RFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RFL]);
8563 +#else
8564 + st->print( "EAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EAX]);
8565 + st->print(", EBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EBX]);
8566 + st->print(", ECX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[ECX]);
8567 + st->print(", EDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EDX]);
8568 + st->cr();
8569 + st->print( "ESP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[UESP]);
8570 + st->print(", EBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EBP]);
8571 + st->print(", ESI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[ESI]);
8572 + st->print(", EDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EDI]);
8573 + st->cr();
8574 + st->print( "EIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EIP]);
8575 + st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[EFL]);
8576 +#endif // AMD64
8577 + st->cr();
8578 + st->cr();
8581 +void os::print_tos_pc(outputStream *st, const void *context) {
8582 + if (context == NULL) return;
8584 + const ucontext_t* uc = (const ucontext_t*)context;
8586 + intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc);
8587 + st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);
8588 + print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
8589 + st->cr();
8591 + // Note: it may be unsafe to inspect memory near pc. For example, pc may
8592 + // point to garbage if entry point in an nmethod is corrupted. Leave
8593 + // this at the end, and hope for the best.
8594 + address pc = os::Posix::ucontext_get_pc(uc);
8595 + print_instructions(st, pc, sizeof(char));
8596 + st->cr();
8599 +void os::print_register_info(outputStream *st, const void *context, int& continuation) {
8600 + const int register_count = AMD64_ONLY(16) NOT_AMD64(8);
8601 + int n = continuation;
8602 + assert(n >= 0 && n <= register_count, "Invalid continuation value");
8603 + if (context == nullptr || n == register_count) {
8604 + return;
8607 + const ucontext_t *uc = (const ucontext_t*)context;
8608 + while (n < register_count) {
8609 + // Update continuation with next index before printing location
8610 + continuation = n + 1;
8611 +# define CASE_PRINT_REG(n, str, id) case n: st->print(str); print_location(st, uc->uc_mcontext.gregs[REG_##id]);
8612 + switch (n) {
8613 +#ifdef AMD64
8614 + CASE_PRINT_REG( 0, "RAX=", RAX); break;
8615 + CASE_PRINT_REG( 1, "RBX=", RBX); break;
8616 + CASE_PRINT_REG( 2, "RCX=", RCX); break;
8617 + CASE_PRINT_REG( 3, "RDX=", RDX); break;
8618 + CASE_PRINT_REG( 4, "RSP=", RSP); break;
8619 + CASE_PRINT_REG( 5, "RBP=", RBP); break;
8620 + CASE_PRINT_REG( 6, "RSI=", RSI); break;
8621 + CASE_PRINT_REG( 7, "RDI=", RDI); break;
8622 + CASE_PRINT_REG( 8, "R8 =", R8); break;
8623 + CASE_PRINT_REG( 9, "R9 =", R9); break;
8624 + CASE_PRINT_REG(10, "R10=", R10); break;
8625 + CASE_PRINT_REG(11, "R11=", R11); break;
8626 + CASE_PRINT_REG(12, "R12=", R12); break;
8627 + CASE_PRINT_REG(13, "R13=", R13); break;
8628 + CASE_PRINT_REG(14, "R14=", R14); break;
8629 + CASE_PRINT_REG(15, "R15=", R15); break;
8630 +#else
8631 + CASE_PRINT_REG(0, "EAX=", EAX); break;
8632 + CASE_PRINT_REG(1, "EBX=", EBX); break;
8633 + CASE_PRINT_REG(2, "ECX=", ECX); break;
8634 + CASE_PRINT_REG(3, "EDX=", EDX); break;
8635 + CASE_PRINT_REG(4, "ESP=", ESP); break;
8636 + CASE_PRINT_REG(5, "EBP=", EBP); break;
8637 + CASE_PRINT_REG(6, "ESI=", ESI); break;
8638 + CASE_PRINT_REG(7, "EDI=", EDI); break;
8639 +#endif // AMD64
8641 +# undef CASE_PRINT_REG
8642 + ++n;
8647 +void os::Solaris::init_thread_fpu_state(void) {
8648 + // Nothing to do
8650 +void os::setup_fpu() {}
8652 +#ifndef PRODUCT
8653 +void os::verify_stack_alignment() {
8654 + assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
8656 +#endif
8658 +int os::extra_bang_size_in_bytes() {
8659 + // JDK-8050147 requires the full cache line bang for x86.
8660 + return VM_Version::L1_line_size();
8662 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp
8663 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
8664 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp 2024-08-17 20:36:14.289691319 +0200
8665 @@ -0,0 +1,55 @@
8667 + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
8668 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8670 + * This code is free software; you can redistribute it and/or modify it
8671 + * under the terms of the GNU General Public License version 2 only, as
8672 + * published by the Free Software Foundation.
8674 + * This code is distributed in the hope that it will be useful, but WITHOUT
8675 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8676 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8677 + * version 2 for more details (a copy is included in the LICENSE file that
8678 + * accompanied this code).
8680 + * You should have received a copy of the GNU General Public License version
8681 + * 2 along with this work; if not, write to the Free Software Foundation,
8682 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8684 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8685 + * or visit www.oracle.com if you need additional information or have any
8686 + * questions.
8688 + */
8690 +#ifndef OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_HPP
8691 +#define OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_HPP
8693 + //
8694 + // NOTE: we are back in class os here, not Solaris
8695 + //
8696 +#ifdef AMD64
8697 + static void setup_fpu() {}
8698 +#else
8699 + static int32_t (*atomic_xchg_func) (int32_t, volatile int32_t*);
8700 + static int32_t (*atomic_cmpxchg_func) (int32_t, volatile int32_t*, int32_t);
8701 + static int64_t (*atomic_cmpxchg_long_func)(int64_t, volatile int64_t*, int64_t);
8702 + static int32_t (*atomic_add_func) (int32_t, volatile int32_t*);
8704 + static int32_t atomic_xchg_bootstrap (int32_t, volatile int32_t*);
8705 + static int32_t atomic_cmpxchg_bootstrap (int32_t, volatile int32_t*, int32_t);
8706 + static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
8707 + static int32_t atomic_add_bootstrap (int32_t, volatile int32_t*);
8709 + static void setup_fpu();
8710 +#endif // AMD64
8712 + static jlong rdtsc();
8714 + static bool is_allocatable(size_t bytes);
8716 + // Used to register dynamic code cache area with the OS
8717 + // Note: Currently only used in 64 bit Windows implementations
8718 + static bool register_code_area(char *low, char *high) { return true; }
8720 +#endif // OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_HPP
8721 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.inline.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.inline.hpp
8722 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.inline.hpp 1970-01-01 01:00:00.000000000 +0100
8723 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.inline.hpp 2024-08-17 20:36:14.289931392 +0200
8724 @@ -0,0 +1,39 @@
8726 + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
8727 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8729 + * This code is free software; you can redistribute it and/or modify it
8730 + * under the terms of the GNU General Public License version 2 only, as
8731 + * published by the Free Software Foundation.
8733 + * This code is distributed in the hope that it will be useful, but WITHOUT
8734 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8735 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8736 + * version 2 for more details (a copy is included in the LICENSE file that
8737 + * accompanied this code).
8739 + * You should have received a copy of the GNU General Public License version
8740 + * 2 along with this work; if not, write to the Free Software Foundation,
8741 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8743 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8744 + * or visit www.oracle.com if you need additional information or have any
8745 + * questions.
8747 + */
8749 +#ifndef OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_INLINE_HPP
8750 +#define OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_INLINE_HPP
8752 +#include "runtime/os.hpp"
8754 +// See http://www.technovelty.org/code/c/reading-rdtsc.htl for details
8755 +inline jlong os::rdtsc() {
8756 + uint64_t res;
8757 + uint32_t ts1, ts2;
8758 + __asm__ __volatile__ ("rdtsc" : "=a" (ts1), "=d" (ts2));
8759 + res = ((uint64_t)ts1 | (uint64_t)ts2 << 32);
8760 + return (jlong)res;
8763 +#endif // OS_CPU_SOLARIS_X86_OS_SOLARIS_X86_INLINE_HPP
8764 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/prefetch_solaris_x86.inline.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/prefetch_solaris_x86.inline.hpp
8765 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/prefetch_solaris_x86.inline.hpp 1970-01-01 01:00:00.000000000 +0100
8766 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/prefetch_solaris_x86.inline.hpp 2024-08-17 20:36:14.290176092 +0200
8767 @@ -0,0 +1,42 @@
8769 + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
8770 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8772 + * This code is free software; you can redistribute it and/or modify it
8773 + * under the terms of the GNU General Public License version 2 only, as
8774 + * published by the Free Software Foundation.
8776 + * This code is distributed in the hope that it will be useful, but WITHOUT
8777 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8778 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8779 + * version 2 for more details (a copy is included in the LICENSE file that
8780 + * accompanied this code).
8782 + * You should have received a copy of the GNU General Public License version
8783 + * 2 along with this work; if not, write to the Free Software Foundation,
8784 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8786 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8787 + * or visit www.oracle.com if you need additional information or have any
8788 + * questions.
8790 + */
8792 +#ifndef OS_CPU_SOLARIS_X86_PREFETCH_SOLARIS_X86_INLINE_HPP
8793 +#define OS_CPU_SOLARIS_X86_PREFETCH_SOLARIS_X86_INLINE_HPP
8795 +#include "runtime/prefetch.hpp"
8797 +inline void Prefetch::read (const void *loc, intx interval) {
8798 +#ifdef AMD64
8799 + __asm__ ("prefetcht0 (%0,%1,1)" : : "r" (loc), "r" (interval));
8800 +#endif // AMD64
8803 +inline void Prefetch::write(void *loc, intx interval) {
8804 +#ifdef AMD64
8805 + __asm__ ("prefetcht0 (%0,%1,1)" : : "r" (loc), "r" (interval));
8806 +#endif // AMD64
8809 +#endif // OS_CPU_SOLARIS_X86_PREFETCH_SOLARIS_X86_INLINE_HPP
8810 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.S jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.S
8811 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.S 1970-01-01 01:00:00.000000000 +0100
8812 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/solaris_x86_64.S 2024-08-17 20:36:14.290568941 +0200
8813 @@ -0,0 +1,386 @@
8815 +# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
8816 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8818 +# This code is free software; you can redistribute it and/or modify it
8819 +# under the terms of the GNU General Public License version 2 only, as
8820 +# published by the Free Software Foundation.
8822 +# This code is distributed in the hope that it will be useful, but WITHOUT
8823 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8824 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8825 +# version 2 for more details (a copy is included in the LICENSE file that
8826 +# accompanied this code).
8828 +# You should have received a copy of the GNU General Public License version
8829 +# 2 along with this work; if not, write to the Free Software Foundation,
8830 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8832 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8833 +# or visit www.oracle.com if you need additional information or have any
8834 +# questions.
8837 + .globl fs_load
8838 + .globl fs_thread
8840 + ## NOTE WELL! The _Copy functions are called directly
8841 + ## from server-compiler-generated code via CallLeafNoFP,
8842 + ## which means that they *must* either not use floating
8843 + ## point or use it in the same manner as does the server
8844 + ## compiler.
8846 + .globl _Copy_arrayof_conjoint_bytes
8847 + .globl _Copy_conjoint_jshorts_atomic
8848 + .globl _Copy_arrayof_conjoint_jshorts
8849 + .globl _Copy_conjoint_jints_atomic
8850 + .globl _Copy_arrayof_conjoint_jints
8851 + .globl _Copy_conjoint_jlongs_atomic
8852 + .globl _Copy_arrayof_conjoint_jlongs
8854 + .section .text,"ax"
8856 + # Fast thread accessors, used by threadLS_solaris_amd64.cpp
8857 + .align 16
8858 +fs_load:
8859 + movq %fs:(%rdi),%rax
8860 + ret
8862 + .align 16
8863 +fs_thread:
8864 + movq %fs:0x0,%rax
8865 + ret
8867 + .globl SpinPause
8868 + .align 16
8869 +SpinPause:
8870 + rep
8871 + nop
8872 + movq $1, %rax
8873 + ret
8876 + # Support for void Copy::arrayof_conjoint_bytes(void* from,
8877 + # void* to,
8878 + # size_t count)
8879 + # rdi - from
8880 + # rsi - to
8881 + # rdx - count, treated as ssize_t
8883 + .align 16
8884 +_Copy_arrayof_conjoint_bytes:
8885 + movq %rdx,%r8 # byte count
8886 + shrq $3,%rdx # qword count
8887 + cmpq %rdi,%rsi
8888 + leaq -1(%rdi,%r8,1),%rax # from + bcount*1 - 1
8889 + jbe acb_CopyRight
8890 + cmpq %rax,%rsi
8891 + jbe acb_CopyLeft
8892 +acb_CopyRight:
8893 + leaq -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
8894 + leaq -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
8895 + negq %rdx
8896 + jmp 7f
8897 + .align 16
8898 +1: movq 8(%rax,%rdx,8),%rsi
8899 + movq %rsi,8(%rcx,%rdx,8)
8900 + addq $1,%rdx
8901 + jnz 1b
8902 +2: testq $4,%r8 # check for trailing dword
8903 + jz 3f
8904 + movl 8(%rax),%esi # copy trailing dword
8905 + movl %esi,8(%rcx)
8906 + addq $4,%rax
8907 + addq $4,%rcx # original %rsi is trashed, so we
8908 + # can't use it as a base register
8909 +3: testq $2,%r8 # check for trailing word
8910 + jz 4f
8911 + movw 8(%rax),%si # copy trailing word
8912 + movw %si,8(%rcx)
8913 + addq $2,%rcx
8914 +4: testq $1,%r8 # check for trailing byte
8915 + jz 5f
8916 + movb -1(%rdi,%r8,1),%al # copy trailing byte
8917 + movb %al,8(%rcx)
8918 +5: ret
8919 + .align 16
8920 +6: movq -24(%rax,%rdx,8),%rsi
8921 + movq %rsi,-24(%rcx,%rdx,8)
8922 + movq -16(%rax,%rdx,8),%rsi
8923 + movq %rsi,-16(%rcx,%rdx,8)
8924 + movq -8(%rax,%rdx,8),%rsi
8925 + movq %rsi,-8(%rcx,%rdx,8)
8926 + movq (%rax,%rdx,8),%rsi
8927 + movq %rsi,(%rcx,%rdx,8)
8928 +7: addq $4,%rdx
8929 + jle 6b
8930 + subq $4,%rdx
8931 + jl 1b
8932 + jmp 2b
8933 +acb_CopyLeft:
8934 + testq $1,%r8 # check for trailing byte
8935 + jz 1f
8936 + movb -1(%rdi,%r8,1),%cl # copy trailing byte
8937 + movb %cl,-1(%rsi,%r8,1)
8938 + subq $1,%r8 # adjust for possible trailing word
8939 +1: testq $2,%r8 # check for trailing word
8940 + jz 2f
8941 + movw -2(%rdi,%r8,1),%cx # copy trailing word
8942 + movw %cx,-2(%rsi,%r8,1)
8943 +2: testq $4,%r8 # check for trailing dword
8944 + jz 5f
8945 + movl (%rdi,%rdx,8),%ecx # copy trailing dword
8946 + movl %ecx,(%rsi,%rdx,8)
8947 + jmp 5f
8948 + .align 16
8949 +3: movq -8(%rdi,%rdx,8),%rcx
8950 + movq %rcx,-8(%rsi,%rdx,8)
8951 + subq $1,%rdx
8952 + jnz 3b
8953 + ret
8954 + .align 16
8955 +4: movq 24(%rdi,%rdx,8),%rcx
8956 + movq %rcx,24(%rsi,%rdx,8)
8957 + movq 16(%rdi,%rdx,8),%rcx
8958 + movq %rcx,16(%rsi,%rdx,8)
8959 + movq 8(%rdi,%rdx,8),%rcx
8960 + movq %rcx,8(%rsi,%rdx,8)
8961 + movq (%rdi,%rdx,8),%rcx
8962 + movq %rcx,(%rsi,%rdx,8)
8963 +5: subq $4,%rdx
8964 + jge 4b
8965 + addq $4,%rdx
8966 + jg 3b
8967 + ret
8969 + # Support for void Copy::arrayof_conjoint_jshorts(void* from,
8970 + # void* to,
8971 + # size_t count)
8972 + # Equivalent to
8973 + # conjoint_jshorts_atomic
8975 + # If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
8976 + # let the hardware handle it. The tow or four words within dwords
8977 + # or qwords that span cache line boundaries will still be loaded
8978 + # and stored atomically.
8980 + # rdi - from
8981 + # rsi - to
8982 + # rdx - count, treated as ssize_t
8984 + .align 16
8985 +_Copy_arrayof_conjoint_jshorts:
8986 +_Copy_conjoint_jshorts_atomic:
8987 + movq %rdx,%r8 # word count
8988 + shrq $2,%rdx # qword count
8989 + cmpq %rdi,%rsi
8990 + leaq -2(%rdi,%r8,2),%rax # from + wcount*2 - 2
8991 + jbe acs_CopyRight
8992 + cmpq %rax,%rsi
8993 + jbe acs_CopyLeft
8994 +acs_CopyRight:
8995 + leaq -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
8996 + leaq -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
8997 + negq %rdx
8998 + jmp 6f
8999 +1: movq 8(%rax,%rdx,8),%rsi
9000 + movq %rsi,8(%rcx,%rdx,8)
9001 + addq $1,%rdx
9002 + jnz 1b
9003 +2: testq $2,%r8 # check for trailing dword
9004 + jz 3f
9005 + movl 8(%rax),%esi # copy trailing dword
9006 + movl %esi,8(%rcx)
9007 + addq $4,%rcx # original %rsi is trashed, so we
9008 + # can't use it as a base register
9009 +3: testq $1,%r8 # check for trailing word
9010 + jz 4f
9011 + movw -2(%rdi,%r8,2),%si # copy trailing word
9012 + movw %si,8(%rcx)
9013 +4: ret
9014 + .align 16
9015 +5: movq -24(%rax,%rdx,8),%rsi
9016 + movq %rsi,-24(%rcx,%rdx,8)
9017 + movq -16(%rax,%rdx,8),%rsi
9018 + movq %rsi,-16(%rcx,%rdx,8)
9019 + movq -8(%rax,%rdx,8),%rsi
9020 + movq %rsi,-8(%rcx,%rdx,8)
9021 + movq (%rax,%rdx,8),%rsi
9022 + movq %rsi,(%rcx,%rdx,8)
9023 +6: addq $4,%rdx
9024 + jle 5b
9025 + subq $4,%rdx
9026 + jl 1b
9027 + jmp 2b
9028 +acs_CopyLeft:
9029 + testq $1,%r8 # check for trailing word
9030 + jz 1f
9031 + movw -2(%rdi,%r8,2),%cx # copy trailing word
9032 + movw %cx,-2(%rsi,%r8,2)
9033 +1: testq $2,%r8 # check for trailing dword
9034 + jz 4f
9035 + movl (%rdi,%rdx,8),%ecx # copy trailing dword
9036 + movl %ecx,(%rsi,%rdx,8)
9037 + jmp 4f
9038 +2: movq -8(%rdi,%rdx,8),%rcx
9039 + movq %rcx,-8(%rsi,%rdx,8)
9040 + subq $1,%rdx
9041 + jnz 2b
9042 + ret
9043 + .align 16
9044 +3: movq 24(%rdi,%rdx,8),%rcx
9045 + movq %rcx,24(%rsi,%rdx,8)
9046 + movq 16(%rdi,%rdx,8),%rcx
9047 + movq %rcx,16(%rsi,%rdx,8)
9048 + movq 8(%rdi,%rdx,8),%rcx
9049 + movq %rcx,8(%rsi,%rdx,8)
9050 + movq (%rdi,%rdx,8),%rcx
9051 + movq %rcx,(%rsi,%rdx,8)
9052 +4: subq $4,%rdx
9053 + jge 3b
9054 + addq $4,%rdx
9055 + jg 2b
9056 + ret
9058 + # Support for void Copy::arrayof_conjoint_jints(jint* from,
9059 + # jint* to,
9060 + # size_t count)
9061 + # Equivalent to
9062 + # conjoint_jints_atomic
9064 + # If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
9065 + # the hardware handle it. The two dwords within qwords that span
9066 + # cache line boundaries will still be loaded and stored atomically.
9068 + # rdi - from
9069 + # rsi - to
9070 + # rdx - count, treated as ssize_t
9072 + .align 16
9073 +_Copy_arrayof_conjoint_jints:
9074 +_Copy_conjoint_jints_atomic:
9075 + movq %rdx,%r8 # dword count
9076 + shrq %rdx # qword count
9077 + cmpq %rdi,%rsi
9078 + leaq -4(%rdi,%r8,4),%rax # from + dcount*4 - 4
9079 + jbe aci_CopyRight
9080 + cmpq %rax,%rsi
9081 + jbe aci_CopyLeft
9082 +aci_CopyRight:
9083 + leaq -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
9084 + leaq -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
9085 + negq %rdx
9086 + jmp 5f
9087 + .align 16
9088 +1: movq 8(%rax,%rdx,8),%rsi
9089 + movq %rsi,8(%rcx,%rdx,8)
9090 + addq $1,%rdx
9091 + jnz 1b
9092 +2: testq $1,%r8 # check for trailing dword
9093 + jz 3f
9094 + movl 8(%rax),%esi # copy trailing dword
9095 + movl %esi,8(%rcx)
9096 +3: ret
9097 + .align 16
9098 +4: movq -24(%rax,%rdx,8),%rsi
9099 + movq %rsi,-24(%rcx,%rdx,8)
9100 + movq -16(%rax,%rdx,8),%rsi
9101 + movq %rsi,-16(%rcx,%rdx,8)
9102 + movq -8(%rax,%rdx,8),%rsi
9103 + movq %rsi,-8(%rcx,%rdx,8)
9104 + movq (%rax,%rdx,8),%rsi
9105 + movq %rsi,(%rcx,%rdx,8)
9106 +5: addq $4,%rdx
9107 + jle 4b
9108 + subq $4,%rdx
9109 + jl 1b
9110 + jmp 2b
9111 +aci_CopyLeft:
9112 + testq $1,%r8 # check for trailing dword
9113 + jz 3f
9114 + movl -4(%rdi,%r8,4),%ecx # copy trailing dword
9115 + movl %ecx,-4(%rsi,%r8,4)
9116 + jmp 3f
9117 +1: movq -8(%rdi,%rdx,8),%rcx
9118 + movq %rcx,-8(%rsi,%rdx,8)
9119 + subq $1,%rdx
9120 + jnz 1b
9121 + ret
9122 + .align 16
9123 +2: movq 24(%rdi,%rdx,8),%rcx
9124 + movq %rcx,24(%rsi,%rdx,8)
9125 + movq 16(%rdi,%rdx,8),%rcx
9126 + movq %rcx,16(%rsi,%rdx,8)
9127 + movq 8(%rdi,%rdx,8),%rcx
9128 + movq %rcx,8(%rsi,%rdx,8)
9129 + movq (%rdi,%rdx,8),%rcx
9130 + movq %rcx,(%rsi,%rdx,8)
9131 +3: subq $4,%rdx
9132 + jge 2b
9133 + addq $4,%rdx
9134 + jg 1b
9135 + ret
9137 + # Support for void Copy::arrayof_conjoint_jlongs(jlong* from,
9138 + # jlong* to,
9139 + # size_t count)
9140 + # Equivalent to
9141 + # conjoint_jlongs_atomic
9142 + # arrayof_conjoint_oops
9143 + # conjoint_oops_atomic
9145 + # rdi - from
9146 + # rsi - to
9147 + # rdx - count, treated as ssize_t
9149 + .align 16
9150 +_Copy_arrayof_conjoint_jlongs:
9151 +_Copy_conjoint_jlongs_atomic:
9152 + cmpq %rdi,%rsi
9153 + leaq -8(%rdi,%rdx,8),%rax # from + count*8 - 8
9154 + jbe acl_CopyRight
9155 + cmpq %rax,%rsi
9156 + jbe acl_CopyLeft
9157 +acl_CopyRight:
9158 + leaq -8(%rsi,%rdx,8),%rcx # to + count*8 - 8
9159 + negq %rdx
9160 + jmp 3f
9161 +1: movq 8(%rax,%rdx,8),%rsi
9162 + movq %rsi,8(%rcx,%rdx,8)
9163 + addq $1,%rdx
9164 + jnz 1b
9165 + ret
9166 + .align 16
9167 +2: movq -24(%rax,%rdx,8),%rsi
9168 + movq %rsi,-24(%rcx,%rdx,8)
9169 + movq -16(%rax,%rdx,8),%rsi
9170 + movq %rsi,-16(%rcx,%rdx,8)
9171 + movq -8(%rax,%rdx,8),%rsi
9172 + movq %rsi,-8(%rcx,%rdx,8)
9173 + movq (%rax,%rdx,8),%rsi
9174 + movq %rsi,(%rcx,%rdx,8)
9175 +3: addq $4,%rdx
9176 + jle 2b
9177 + subq $4,%rdx
9178 + jl 1b
9179 + ret
9180 +4: movq -8(%rdi,%rdx,8),%rcx
9181 + movq %rcx,-8(%rsi,%rdx,8)
9182 + subq $1,%rdx
9183 + jnz 4b
9184 + ret
9185 + .align 16
9186 +5: movq 24(%rdi,%rdx,8),%rcx
9187 + movq %rcx,24(%rsi,%rdx,8)
9188 + movq 16(%rdi,%rdx,8),%rcx
9189 + movq %rcx,16(%rsi,%rdx,8)
9190 + movq 8(%rdi,%rdx,8),%rcx
9191 + movq %rcx,8(%rsi,%rdx,8)
9192 + movq (%rdi,%rdx,8),%rcx
9193 + movq %rcx,(%rsi,%rdx,8)
9194 +acl_CopyLeft:
9195 + subq $4,%rdx
9196 + jge 5b
9197 + addq $4,%rdx
9198 + jg 4b
9199 + ret
9200 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/vm_version_solaris_x86.cpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/vm_version_solaris_x86.cpp
9201 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/vm_version_solaris_x86.cpp 1970-01-01 01:00:00.000000000 +0100
9202 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/vm_version_solaris_x86.cpp 2024-08-17 20:36:14.291635729 +0200
9203 @@ -0,0 +1,28 @@
9205 + * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
9206 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9208 + * This code is free software; you can redistribute it and/or modify it
9209 + * under the terms of the GNU General Public License version 2 only, as
9210 + * published by the Free Software Foundation.
9212 + * This code is distributed in the hope that it will be useful, but WITHOUT
9213 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9214 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9215 + * version 2 for more details (a copy is included in the LICENSE file that
9216 + * accompanied this code).
9218 + * You should have received a copy of the GNU General Public License version
9219 + * 2 along with this work; if not, write to the Free Software Foundation,
9220 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9222 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9223 + * or visit www.oracle.com if you need additional information or have any
9224 + * questions.
9226 + */
9228 +#include "precompiled.hpp"
9229 +#include "runtime/os.hpp"
9230 +#include "runtime/vm_version.hpp"
9232 diff -Nru jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/vmStructs_solaris_x86.hpp jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/vmStructs_solaris_x86.hpp
9233 --- jdk-jdk-24-11.orig/src/hotspot/os_cpu/solaris_x86/vmStructs_solaris_x86.hpp 1970-01-01 01:00:00.000000000 +0100
9234 +++ jdk-jdk-24-11/src/hotspot/os_cpu/solaris_x86/vmStructs_solaris_x86.hpp 2024-08-17 20:36:14.291362068 +0200
9235 @@ -0,0 +1,40 @@
9237 + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
9238 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9240 + * This code is free software; you can redistribute it and/or modify it
9241 + * under the terms of the GNU General Public License version 2 only, as
9242 + * published by the Free Software Foundation.
9244 + * This code is distributed in the hope that it will be useful, but WITHOUT
9245 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9246 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9247 + * version 2 for more details (a copy is included in the LICENSE file that
9248 + * accompanied this code).
9250 + * You should have received a copy of the GNU General Public License version
9251 + * 2 along with this work; if not, write to the Free Software Foundation,
9252 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9254 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9255 + * or visit www.oracle.com if you need additional information or have any
9256 + * questions.
9258 + */
9260 +#ifndef OS_CPU_SOLARIS_X86_VMSTRUCTS_SOLARIS_X86_HPP
9261 +#define OS_CPU_SOLARIS_X86_VMSTRUCTS_SOLARIS_X86_HPP
9263 +// These are the OS and CPU-specific fields, types and integer
9264 +// constants required by the Serviceability Agent. This file is
9265 +// referenced by vmStructs.cpp.
9267 +#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
9269 +#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
9271 +#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
9273 +#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
9275 +#endif // OS_CPU_SOLARIS_X86_VMSTRUCTS_SOLARIS_X86_HPP
9276 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/c1/c1_LIR.cpp jdk-jdk-24-11/src/hotspot/share/c1/c1_LIR.cpp
9277 --- jdk-jdk-24-11.orig/src/hotspot/share/c1/c1_LIR.cpp 2024-08-15 09:39:31.000000000 +0200
9278 +++ jdk-jdk-24-11/src/hotspot/share/c1/c1_LIR.cpp 2024-08-17 20:36:14.233351220 +0200
9279 @@ -452,6 +452,8 @@
9280 case lir_monaddr: // input and result always valid, info always invalid
9281 case lir_null_check: // input and info always valid, result always invalid
9282 case lir_move: // input and result always valid, may have info
9283 + case lir_pack64: // input and result always valid
9284 + case lir_unpack64: // input and result always valid
9286 assert(op->as_Op1() != nullptr, "must be");
9287 LIR_Op1* op1 = (LIR_Op1*)op;
9288 @@ -1736,6 +1738,8 @@
9289 case lir_convert: s = "convert"; break;
9290 case lir_alloc_object: s = "alloc_obj"; break;
9291 case lir_monaddr: s = "mon_addr"; break;
9292 + case lir_pack64: s = "pack64"; break;
9293 + case lir_unpack64: s = "unpack64"; break;
9294 // LIR_Op2
9295 case lir_cmp: s = "cmp"; break;
9296 case lir_cmp_l2i: s = "cmp_l2i"; break;
9297 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/c1/c1_LIR.hpp jdk-jdk-24-11/src/hotspot/share/c1/c1_LIR.hpp
9298 --- jdk-jdk-24-11.orig/src/hotspot/share/c1/c1_LIR.hpp 2024-08-15 09:39:31.000000000 +0200
9299 +++ jdk-jdk-24-11/src/hotspot/share/c1/c1_LIR.hpp 2024-08-17 20:36:14.234274875 +0200
9300 @@ -939,6 +939,8 @@
9301 , lir_monaddr
9302 , lir_roundfp
9303 , lir_safepoint
9304 + , lir_pack64
9305 + , lir_unpack64
9306 , lir_unwind
9307 , lir_load_klass
9308 , end_op1
9309 @@ -2237,6 +2239,9 @@
9310 void logical_or (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_or, left, right, dst)); }
9311 void logical_xor (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_xor, left, right, dst)); }
9313 + void pack64(LIR_Opr src, LIR_Opr dst) { append(new LIR_Op1(lir_pack64, src, dst, T_LONG, lir_patch_none, NULL)); }
9314 + void unpack64(LIR_Opr src, LIR_Opr dst) { append(new LIR_Op1(lir_unpack64, src, dst, T_LONG, lir_patch_none, NULL)); }
9316 void null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null = false);
9317 void throw_exception(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
9318 append(new LIR_Op2(lir_throw, exceptionPC, exceptionOop, LIR_OprFact::illegalOpr, info));
9319 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/cds/classListParser.cpp jdk-jdk-24-11/src/hotspot/share/cds/classListParser.cpp
9320 --- jdk-jdk-24-11.orig/src/hotspot/share/cds/classListParser.cpp 2024-08-15 09:39:31.000000000 +0200
9321 +++ jdk-jdk-24-11/src/hotspot/share/cds/classListParser.cpp 2024-08-17 20:36:14.234903172 +0200
9322 @@ -488,7 +488,7 @@
9323 // This function is used for loading classes for customized class loaders
9324 // during archive dumping.
9325 InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS) {
9326 -#if !(defined(_LP64) && (defined(LINUX) || defined(__APPLE__) || defined(_WINDOWS)))
9327 +#if !(defined(_LP64) && (defined(LINUX)|| defined(SOLARIS) || defined(__APPLE__) || defined(_WINDOWS)))
9328 // The only supported platforms are: (1) Linux/64-bit and (2) Solaris/64-bit and
9329 // (3) MacOSX/64-bit and (4) Windowss/64-bit
9330 // This #if condition should be in sync with the areCustomLoadersSupportedForCDS
9331 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/nmt/memTracker.cpp jdk-jdk-24-11/src/hotspot/share/nmt/memTracker.cpp
9332 --- jdk-jdk-24-11.orig/src/hotspot/share/nmt/memTracker.cpp 2024-08-15 09:39:31.000000000 +0200
9333 +++ jdk-jdk-24-11/src/hotspot/share/nmt/memTracker.cpp 2024-08-17 20:36:14.236402994 +0200
9334 @@ -48,6 +48,12 @@
9335 #include <windows.h>
9336 #endif
9338 +#ifdef SOLARIS
9339 + volatile bool NMT_stack_walkable = false;
9340 +#else
9341 + volatile bool NMT_stack_walkable = true;
9342 +#endif
9344 NMT_TrackingLevel MemTracker::_tracking_level = NMT_unknown;
9346 MemBaseline MemTracker::_baseline;
9347 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/nmt/memTracker.hpp jdk-jdk-24-11/src/hotspot/share/nmt/memTracker.hpp
9348 --- jdk-jdk-24-11.orig/src/hotspot/share/nmt/memTracker.hpp 2024-08-15 09:39:31.000000000 +0200
9349 +++ jdk-jdk-24-11/src/hotspot/share/nmt/memTracker.hpp 2024-08-17 20:36:14.236818249 +0200
9350 @@ -35,9 +35,11 @@
9351 #include "utilities/debug.hpp"
9352 #include "utilities/nativeCallStack.hpp"
9354 -#define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail) ? \
9355 +extern volatile bool NMT_stack_walkable;
9357 +#define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
9358 NativeCallStack(0) : FAKE_CALLSTACK)
9359 -#define CALLER_PC ((MemTracker::tracking_level() == NMT_detail) ? \
9360 +#define CALLER_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
9361 NativeCallStack(1) : FAKE_CALLSTACK)
9363 class MemBaseline;
9364 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/runtime/abstract_vm_version.cpp jdk-jdk-24-11/src/hotspot/share/runtime/abstract_vm_version.cpp
9365 --- jdk-jdk-24-11.orig/src/hotspot/share/runtime/abstract_vm_version.cpp 2024-08-15 09:39:31.000000000 +0200
9366 +++ jdk-jdk-24-11/src/hotspot/share/runtime/abstract_vm_version.cpp 2024-08-17 20:36:14.235538297 +0200
9367 @@ -171,6 +171,7 @@
9369 #define OS LINUX_ONLY("linux") \
9370 WINDOWS_ONLY("windows") \
9371 + SOLARIS_ONLY("solaris") \
9372 AIX_ONLY("aix") \
9373 BSD_ONLY("bsd")
9375 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/runtime/semaphore.hpp jdk-jdk-24-11/src/hotspot/share/runtime/semaphore.hpp
9376 --- jdk-jdk-24-11.orig/src/hotspot/share/runtime/semaphore.hpp 2024-08-15 09:39:31.000000000 +0200
9377 +++ jdk-jdk-24-11/src/hotspot/share/runtime/semaphore.hpp 2024-08-17 20:36:14.235947825 +0200
9378 @@ -28,7 +28,7 @@
9379 #include "memory/allocation.hpp"
9380 #include "utilities/globalDefinitions.hpp"
9382 -#if defined(LINUX) || defined(AIX)
9383 +#if defined(LINUX) || defined(SOLARIS) || defined(AIX)
9384 # include "semaphore_posix.hpp"
9385 #else
9386 # include OS_HEADER(semaphore)
9387 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/services/dtraceAttacher.cpp jdk-jdk-24-11/src/hotspot/share/services/dtraceAttacher.cpp
9388 --- jdk-jdk-24-11.orig/src/hotspot/share/services/dtraceAttacher.cpp 1970-01-01 01:00:00.000000000 +0100
9389 +++ jdk-jdk-24-11/src/hotspot/share/services/dtraceAttacher.cpp 2024-08-17 20:36:14.292009862 +0200
9390 @@ -0,0 +1,99 @@
9392 + * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
9393 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9395 + * This code is free software; you can redistribute it and/or modify it
9396 + * under the terms of the GNU General Public License version 2 only, as
9397 + * published by the Free Software Foundation.
9399 + * This code is distributed in the hope that it will be useful, but WITHOUT
9400 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9401 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9402 + * version 2 for more details (a copy is included in the LICENSE file that
9403 + * accompanied this code).
9405 + * You should have received a copy of the GNU General Public License version
9406 + * 2 along with this work; if not, write to the Free Software Foundation,
9407 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9409 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9410 + * or visit www.oracle.com if you need additional information or have any
9411 + * questions.
9413 + */
9415 +#include "precompiled.hpp"
9416 +#include "code/codeCache.hpp"
9417 +#include "memory/resourceArea.hpp"
9418 +#include "runtime/deoptimization.hpp"
9419 +#include "runtime/flags/jvmFlag.hpp"
9420 +#include "runtime/vmThread.hpp"
9421 +#include "runtime/vmOperations.hpp"
9422 +#include "services/dtraceAttacher.hpp"
9423 +#include "runtime/flags/jvmFlagAccess.hpp"
9425 +#ifdef SOLARIS
9427 +static void set_bool_flag(const char* name, bool value) {
9428 + JVMFlag* flag = JVMFlag::find_flag(name);
9429 + JVMFlagAccess::set_bool(flag, &value, JVMFlagOrigin::ATTACH_ON_DEMAND);
9432 +// Enable the "fine grained" flags.
9433 +void DTrace::enable_dprobes(int probes) {
9434 + bool changed = false;
9435 + if (!DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {
9436 + set_bool_flag("DTraceAllocProbes", true);
9437 + changed = true;
9439 + if (!DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {
9440 + set_bool_flag("DTraceMethodProbes", true);
9441 + changed = true;
9443 + if (!DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {
9444 + set_bool_flag("DTraceMonitorProbes", true);
9445 + changed = true;
9448 + if (changed) {
9449 + // one or more flags changed, need to deoptimize
9450 + DeoptimizationScope deopt_scope;
9451 + CodeCache::mark_all_nmethods_for_deoptimization(&deopt_scope);
9452 + deopt_scope.deoptimize_marked();
9456 +// Disable the "fine grained" flags.
9457 +void DTrace::disable_dprobes(int probes) {
9458 + bool changed = false;
9459 + if (DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {
9460 + set_bool_flag("DTraceAllocProbes", false);
9461 + changed = true;
9463 + if (DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {
9464 + set_bool_flag("DTraceMethodProbes", false);
9465 + changed = true;
9467 + if (DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {
9468 + set_bool_flag("DTraceMonitorProbes", false);
9469 + changed = true;
9471 + if (changed) {
9472 + // one or more flags changed, need to deoptimize
9473 + DeoptimizationScope deopt_scope;
9474 + CodeCache::mark_all_nmethods_for_deoptimization(&deopt_scope);
9475 + deopt_scope.deoptimize_marked();
9479 +// Do clean-up on "all door clients detached" event.
9480 +void DTrace::detach_all_clients() {
9481 + disable_dprobes(DTRACE_ALL_PROBES);
9484 +void DTrace::set_monitor_dprobes(bool flag) {
9485 + // explicit setting of DTraceMonitorProbes flag
9486 + set_bool_flag("DTraceMonitorProbes", flag);
9489 +#endif /* SOLARIS */
9490 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/utilities/debug.cpp jdk-jdk-24-11/src/hotspot/share/utilities/debug.cpp
9491 --- jdk-jdk-24-11.orig/src/hotspot/share/utilities/debug.cpp 2024-08-15 09:39:31.000000000 +0200
9492 +++ jdk-jdk-24-11/src/hotspot/share/utilities/debug.cpp 2024-08-17 20:36:14.237447995 +0200
9493 @@ -611,11 +611,12 @@
9494 tty->print_cr(" findm(intptr_t pc) - finds Method*");
9495 tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it");
9496 tty->print_cr(" pns(void* sp, void* fp, void* pc) - print native (i.e. mixed) stack trace. E.g.");
9497 - tty->print_cr(" pns($sp, $rbp, $pc) on Linux/amd64 or");
9498 + tty->print_cr(" pns($sp, $rbp, $pc) on Linux/amd64 and Solaris/amd64 or");
9499 tty->print_cr(" pns($sp, $ebp, $pc) on Linux/x86 or");
9500 tty->print_cr(" pns($sp, $fp, $pc) on Linux/AArch64 or");
9501 tty->print_cr(" pns($sp, 0, $pc) on Linux/ppc64 or");
9502 tty->print_cr(" pns($sp, $s8, $pc) on Linux/mips or");
9503 + tty->print_cr(" pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
9504 tty->print_cr(" - in gdb do 'set overload-resolution off' before calling pns()");
9505 tty->print_cr(" - in dbx do 'frame 1' before calling pns()");
9506 tty->print_cr("class metadata.");
9507 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/utilities/globalDefinitions_gcc.hpp jdk-jdk-24-11/src/hotspot/share/utilities/globalDefinitions_gcc.hpp
9508 --- jdk-jdk-24-11.orig/src/hotspot/share/utilities/globalDefinitions_gcc.hpp 2024-08-15 09:39:31.000000000 +0200
9509 +++ jdk-jdk-24-11/src/hotspot/share/utilities/globalDefinitions_gcc.hpp 2024-08-17 20:36:14.237950899 +0200
9510 @@ -50,15 +50,36 @@
9511 #endif
9512 #include <wchar.h>
9514 +#ifdef SOLARIS
9515 +#include <ieeefp.h>
9516 +#endif // SOLARIS
9518 #include <math.h>
9519 #include <time.h>
9520 #include <fcntl.h>
9521 #include <dlfcn.h>
9522 #include <pthread.h>
9524 +#ifdef SOLARIS
9525 +#include <thread.h>
9526 +#endif // SOLARIS
9528 #include <limits.h>
9529 #include <errno.h>
9531 +#ifdef SOLARIS
9532 +#include <sys/trap.h>
9533 +#include <sys/regset.h>
9534 +#include <sys/procset.h>
9535 +#include <ucontext.h>
9536 +#include <setjmp.h>
9537 +#include <inttypes.h>
9538 +#endif // SOLARIS
9540 +# ifdef SOLARIS_MUTATOR_LIBTHREAD
9541 +# include <sys/procfs.h>
9542 +# endif
9544 #if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(_AIX)
9545 #include <signal.h>
9546 #ifndef __OpenBSD__
9547 @@ -71,6 +92,34 @@
9548 #include <sys/time.h>
9549 #endif // LINUX || _ALLBSD_SOURCE
9551 +// 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
9552 +// When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
9553 +// system header files. On 32-bit architectures, there is no problem.
9554 +// On 64-bit architectures, defining NULL as a 32-bit constant can cause
9555 +// problems with varargs functions: C++ integral promotion rules say for
9556 +// varargs, we pass the argument 0 as an int. So, if NULL was passed to a
9557 +// varargs function it will remain 32-bits. Depending on the calling
9558 +// convention of the machine, if the argument is passed on the stack then
9559 +// only 32-bits of the "NULL" pointer may be initialized to zero. The
9560 +// other 32-bits will be garbage. If the varargs function is expecting a
9561 +// pointer when it extracts the argument, then we have a problem.
9563 +// Solution: For 64-bit architectures, redefine NULL as 64-bit constant 0.
9565 +// Note: this fix doesn't work well on Linux because NULL will be overwritten
9566 +// whenever a system header file is included. Linux handles NULL correctly
9567 +// through a special type '__null'.
9568 +#ifdef SOLARIS
9569 + #ifdef _LP64
9570 + #undef NULL
9571 + #define NULL 0L
9572 + #else
9573 + #ifndef NULL
9574 + #define NULL 0
9575 + #endif
9576 + #endif
9577 +#endif
9579 // NULL vs NULL_WORD:
9580 // On Linux NULL is defined as a special type '__null'. Assigning __null to
9581 // integer variable will cause gcc warning. Use NULL_WORD in places where a
9582 @@ -89,8 +138,51 @@
9583 #define NULL_WORD NULL
9584 #endif
9586 +#ifdef SOLARIS
9587 +// ANSI C++ fixes
9588 +// NOTE:In the ANSI committee's continuing attempt to make each version
9589 +// of C++ incompatible with the previous version, you can no longer cast
9590 +// pointers to functions without specifying linkage unless you want to get
9591 +// warnings.
9593 +// This also means that pointers to functions can no longer be "hidden"
9594 +// in opaque types like void * because at the invocation point warnings
9595 +// will be generated. While this makes perfect sense from a type safety
9596 +// point of view it causes a lot of warnings on old code using C header
9597 +// files. Here are some typedefs to make the job of silencing warnings
9598 +// a bit easier.
9600 +// The final kick in the teeth is that you can only have extern "C" linkage
9601 +// specified at file scope. So these typedefs are here rather than in the
9602 +// .hpp for the class (os:Solaris usually) that needs them.
9604 +extern "C" {
9605 + typedef int (*int_fnP_thread_t_iP_uP_stack_tP_gregset_t)(thread_t, int*, unsigned *, stack_t*, gregset_t);
9606 + typedef int (*int_fnP_thread_t_i_gregset_t)(thread_t, int, gregset_t);
9607 + typedef int (*int_fnP_thread_t_i)(thread_t, int);
9608 + typedef int (*int_fnP_thread_t)(thread_t);
9610 + typedef int (*int_fnP_cond_tP_mutex_tP_timestruc_tP)(cond_t *cv, mutex_t *mx, timestruc_t *abst);
9611 + typedef int (*int_fnP_cond_tP_mutex_tP)(cond_t *cv, mutex_t *mx);
9613 + // typedef for missing API in libc
9614 + typedef int (*int_fnP_mutex_tP_i_vP)(mutex_t *, int, void *);
9615 + typedef int (*int_fnP_mutex_tP)(mutex_t *);
9616 + typedef int (*int_fnP_cond_tP_i_vP)(cond_t *cv, int scope, void *arg);
9617 + typedef int (*int_fnP_cond_tP)(cond_t *cv);
9619 +#endif // SOLARIS
9621 // checking for nanness
9622 -#if defined(__APPLE__)
9623 +#ifdef SOLARIS
9624 +#ifdef SPARC
9625 +inline int g_isnan(float f) { return isnanf(f); }
9626 +#else
9627 +// isnanf() broken on Intel Solaris use isnand()
9628 +inline int g_isnan(float f) { return isnand(f); }
9629 +#endif
9630 +inline int g_isnan(double f) { return isnand(f); }
9631 +#elif defined(__APPLE__)
9632 inline int g_isnan(double f) { return isnan(f); }
9633 #elif defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(_AIX)
9634 inline int g_isnan(float f) { return isnan(f); }
9635 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/utilities/macros.hpp jdk-jdk-24-11/src/hotspot/share/utilities/macros.hpp
9636 --- jdk-jdk-24-11.orig/src/hotspot/share/utilities/macros.hpp 2024-08-15 09:39:31.000000000 +0200
9637 +++ jdk-jdk-24-11/src/hotspot/share/utilities/macros.hpp 2024-08-17 20:36:14.238382337 +0200
9638 @@ -401,6 +401,14 @@
9639 #define NOT_AIX(code) code
9640 #endif
9642 +#ifdef SOLARIS
9643 +#define SOLARIS_ONLY(code) code
9644 +#define NOT_SOLARIS(code)
9645 +#else
9646 +#define SOLARIS_ONLY(code)
9647 +#define NOT_SOLARIS(code) code
9648 +#endif
9650 #ifdef _WINDOWS
9651 #define WINDOWS_ONLY(code) code
9652 #define NOT_WINDOWS(code)
9653 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/utilities/ostream.cpp jdk-jdk-24-11/src/hotspot/share/utilities/ostream.cpp
9654 --- jdk-jdk-24-11.orig/src/hotspot/share/utilities/ostream.cpp 2024-08-15 09:39:31.000000000 +0200
9655 +++ jdk-jdk-24-11/src/hotspot/share/utilities/ostream.cpp 2024-08-17 20:36:14.238920975 +0200
9656 @@ -1074,7 +1074,7 @@
9658 #ifndef PRODUCT
9660 -#if defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE)
9661 +#if defined(SOLARIS) || defined(LINUX) || defined(AIX) || defined(_ALLBSD_SOURCE)
9662 #include <sys/types.h>
9663 #include <sys/socket.h>
9664 #include <netinet/in.h>
9665 diff -Nru jdk-jdk-24-11.orig/src/hotspot/share/utilities/vmError.cpp jdk-jdk-24-11/src/hotspot/share/utilities/vmError.cpp
9666 --- jdk-jdk-24-11.orig/src/hotspot/share/utilities/vmError.cpp 2024-08-15 09:39:31.000000000 +0200
9667 +++ jdk-jdk-24-11/src/hotspot/share/utilities/vmError.cpp 2024-08-17 20:36:14.239724444 +0200
9668 @@ -1915,6 +1915,8 @@
9669 out.print_raw ("# Executing ");
9670 #if defined(LINUX) || defined(_ALLBSD_SOURCE)
9671 out.print_raw ("/bin/sh -c ");
9672 +#elif defined(SOLARIS)
9673 + out.print_raw ("/usr/bin/sh -c ");
9674 #elif defined(_WINDOWS)
9675 out.print_raw ("cmd /C ");
9676 #endif
9677 @@ -1979,6 +1981,8 @@
9678 tty->print("# Executing ");
9679 #if defined(LINUX)
9680 tty->print ("/bin/sh -c ");
9681 +#elif defined(SOLARIS)
9682 + tty->print ("/usr/bin/sh -c ");
9683 #endif
9684 tty->print_cr("\"%s\"...", cmd);
9686 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/classes/sun/net/sdp/SdpSupport.java jdk-jdk-24-11/src/java.base/share/classes/sun/net/sdp/SdpSupport.java
9687 --- jdk-jdk-24-11.orig/src/java.base/share/classes/sun/net/sdp/SdpSupport.java 2024-08-15 09:39:31.000000000 +0200
9688 +++ jdk-jdk-24-11/src/java.base/share/classes/sun/net/sdp/SdpSupport.java 2024-08-17 20:36:14.240309408 +0200
9689 @@ -39,7 +39,7 @@
9692 public final class SdpSupport {
9693 - private static final boolean isSupported = OperatingSystem.isLinux();
9694 + private static final boolean isSupported = (OperatingSystem.isSolaris() || OperatingSystem.isLinux());
9695 private static final JavaIOFileDescriptorAccess fdAccess =
9696 SharedSecrets.getJavaIOFileDescriptorAccess();
9698 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/classes/sun/nio/ch/Net.java jdk-jdk-24-11/src/java.base/share/classes/sun/nio/ch/Net.java
9699 --- jdk-jdk-24-11.orig/src/java.base/share/classes/sun/nio/ch/Net.java 2024-08-15 09:39:31.000000000 +0200
9700 +++ jdk-jdk-24-11/src/java.base/share/classes/sun/nio/ch/Net.java 2024-08-17 20:36:14.240883520 +0200
9701 @@ -512,7 +512,7 @@
9702 private static native boolean isReusePortAvailable0();
9705 - * Returns 1 for Windows and -1 for Linux/Mac OS
9706 + * Returns 1 for Windows and -1 for Solaris/Linux/Mac OS
9708 private static native int isExclusiveBindAvailable();
9710 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template jdk-jdk-24-11/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template
9711 --- jdk-jdk-24-11.orig/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template 2024-08-15 09:39:31.000000000 +0200
9712 +++ jdk-jdk-24-11/src/java.base/share/classes/sun/nio/ch/SocketOptionRegistry.java.template 2024-08-17 20:36:14.241286068 +0200
9713 @@ -43,6 +43,8 @@
9714 #define SO_REUSEPORT 0
9715 #elif defined(__linux__)
9716 #define SO_REUSEPORT 15
9717 +#elif defined(__solaris__)
9718 +#define SO_REUSEPORT 0x100e
9719 #elif defined(AIX) || defined(MACOSX)
9720 #define SO_REUSEPORT 0x0200
9721 #else
9722 @@ -50,6 +52,10 @@
9723 #endif
9724 #endif
9726 +/* On Solaris, "sun" is defined as a macro. Undefine to make package
9727 + declaration valid */
9728 +#undef sun
9730 /* To be able to name the Java constants the same as the C constants without
9731 having the preprocessor rewrite those identifiers, add PREFIX_ to all
9732 identifiers matching a C constant. The PREFIX_ is filtered out in the
9733 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/conf/security/java.security jdk-jdk-24-11/src/java.base/share/conf/security/java.security
9734 --- jdk-jdk-24-11.orig/src/java.base/share/conf/security/java.security 2024-08-15 09:39:31.000000000 +0200
9735 +++ jdk-jdk-24-11/src/java.base/share/conf/security/java.security 2024-08-17 20:36:14.242000734 +0200
9736 @@ -83,7 +83,11 @@
9737 #ifdef macosx
9738 security.provider.tbd=Apple
9739 #endif
9740 +#ifdef solaris
9741 +security.provider.tbd=SunPKCS11 ${java.home}/conf/security/sunpkcs11-solaris.cfg
9742 +#else
9743 security.provider.tbd=SunPKCS11
9744 +#endif
9747 # A list of preferred providers for specific algorithms. These providers will
9748 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/native/libjli/jli_util.h jdk-jdk-24-11/src/java.base/share/native/libjli/jli_util.h
9749 --- jdk-jdk-24-11.orig/src/java.base/share/native/libjli/jli_util.h 2024-08-15 09:39:31.000000000 +0200
9750 +++ jdk-jdk-24-11/src/java.base/share/native/libjli/jli_util.h 2024-08-17 20:36:14.242421069 +0200
9751 @@ -100,7 +100,11 @@
9752 #define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2))
9753 #define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3))
9754 #define JLI_Open open
9755 +#ifdef __solaris__
9756 +#define JLI_Lseek llseek
9757 +#else
9758 #define JLI_Lseek lseek
9759 +#endif
9760 #endif /* _WIN32 */
9763 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/native/libnet/net_util.c jdk-jdk-24-11/src/java.base/share/native/libnet/net_util.c
9764 --- jdk-jdk-24-11.orig/src/java.base/share/native/libnet/net_util.c 2024-08-15 09:39:31.000000000 +0200
9765 +++ jdk-jdk-24-11/src/java.base/share/native/libnet/net_util.c 2024-08-17 20:36:14.242873860 +0200
9766 @@ -81,6 +81,7 @@
9768 /* check if SO_REUSEPORT is supported on this platform */
9769 REUSEPORT_available = reuseport_supported(IPv6_available);
9770 + parseExclusiveBindProperty(env);
9772 return JNI_VERSION_1_2;
9774 diff -Nru jdk-jdk-24-11.orig/src/java.base/share/native/libnet/net_util.h jdk-jdk-24-11/src/java.base/share/native/libnet/net_util.h
9775 --- jdk-jdk-24-11.orig/src/java.base/share/native/libnet/net_util.h 2024-08-15 09:39:31.000000000 +0200
9776 +++ jdk-jdk-24-11/src/java.base/share/native/libnet/net_util.h 2024-08-17 20:36:14.243215422 +0200
9777 @@ -142,6 +142,8 @@
9778 JNIEXPORT jobject JNICALL
9779 NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port);
9781 +void parseExclusiveBindProperty(JNIEnv *env);
9783 JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(SOCKETADDRESS *sa);
9785 JNIEXPORT jboolean JNICALL
9786 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
9787 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java 1970-01-01 01:00:00.000000000 +0100
9788 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java 2024-08-17 20:36:14.292495746 +0200
9789 @@ -0,0 +1,47 @@
9791 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
9792 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9794 + * This code is free software; you can redistribute it and/or modify it
9795 + * under the terms of the GNU General Public License version 2 only, as
9796 + * published by the Free Software Foundation. Oracle designates this
9797 + * particular file as subject to the "Classpath" exception as provided
9798 + * by Oracle in the LICENSE file that accompanied this code.
9800 + * This code is distributed in the hope that it will be useful, but WITHOUT
9801 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9802 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9803 + * version 2 for more details (a copy is included in the LICENSE file that
9804 + * accompanied this code).
9806 + * You should have received a copy of the GNU General Public License version
9807 + * 2 along with this work; if not, write to the Free Software Foundation,
9808 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9810 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9811 + * or visit www.oracle.com if you need additional information or have any
9812 + * questions.
9813 + */
9815 +package sun.nio.ch;
9817 +import java.nio.channels.spi.AsynchronousChannelProvider;
9819 +/**
9820 + * Creates this platform's default AsynchronousChannelProvider
9821 + */
9823 +public class DefaultAsynchronousChannelProvider {
9825 + /**
9826 + * Prevent instantiation.
9827 + */
9828 + private DefaultAsynchronousChannelProvider() { }
9830 + /**
9831 + * Returns the default AsynchronousChannelProvider.
9832 + */
9833 + public static AsynchronousChannelProvider create() {
9834 + return new SolarisAsynchronousChannelProvider();
9837 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java
9838 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java 1970-01-01 01:00:00.000000000 +0100
9839 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java 2024-08-17 20:36:14.292790927 +0200
9840 @@ -0,0 +1,54 @@
9842 + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
9843 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9845 + * This code is free software; you can redistribute it and/or modify it
9846 + * under the terms of the GNU General Public License version 2 only, as
9847 + * published by the Free Software Foundation. Oracle designates this
9848 + * particular file as subject to the "Classpath" exception as provided
9849 + * by Oracle in the LICENSE file that accompanied this code.
9851 + * This code is distributed in the hope that it will be useful, but WITHOUT
9852 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9853 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9854 + * version 2 for more details (a copy is included in the LICENSE file that
9855 + * accompanied this code).
9857 + * You should have received a copy of the GNU General Public License version
9858 + * 2 along with this work; if not, write to the Free Software Foundation,
9859 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9861 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9862 + * or visit www.oracle.com if you need additional information or have any
9863 + * questions.
9864 + */
9866 +package sun.nio.ch;
9868 +import java.security.AccessController;
9869 +import java.security.PrivilegedAction;
9871 +/**
9872 + * Creates this platform's default SelectorProvider
9873 + */
9875 +@SuppressWarnings("removal")
9876 +public class DefaultSelectorProvider {
9877 + private static final SelectorProviderImpl INSTANCE;
9878 + static {
9879 + PrivilegedAction<SelectorProviderImpl> pa = DevPollSelectorProvider::new;
9880 + INSTANCE = AccessController.doPrivileged(pa);
9883 + /**
9884 + * Prevent instantiation.
9885 + */
9886 + private DefaultSelectorProvider() { }
9888 + /**
9889 + * Returns the default SelectorProvider implementation.
9890 + */
9891 + public static SelectorProviderImpl get() {
9892 + return INSTANCE;
9895 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
9896 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java 1970-01-01 01:00:00.000000000 +0100
9897 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java 2024-08-17 20:36:14.293081364 +0200
9898 @@ -0,0 +1,127 @@
9900 + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
9901 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9903 + * This code is free software; you can redistribute it and/or modify it
9904 + * under the terms of the GNU General Public License version 2 only, as
9905 + * published by the Free Software Foundation. Oracle designates this
9906 + * particular file as subject to the "Classpath" exception as provided
9907 + * by Oracle in the LICENSE file that accompanied this code.
9909 + * This code is distributed in the hope that it will be useful, but WITHOUT
9910 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9911 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9912 + * version 2 for more details (a copy is included in the LICENSE file that
9913 + * accompanied this code).
9915 + * You should have received a copy of the GNU General Public License version
9916 + * 2 along with this work; if not, write to the Free Software Foundation,
9917 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9919 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9920 + * or visit www.oracle.com if you need additional information or have any
9921 + * questions.
9922 + */
9924 +package sun.nio.ch;
9926 +import java.io.IOException;
9928 +/**
9929 + * Manipulates a native array of pollfd structs on Solaris:
9931 + * typedef struct pollfd {
9932 + * int fd;
9933 + * short events;
9934 + * short revents;
9935 + * } pollfd_t;
9937 + * @author Mike McCloskey
9938 + * @since 1.4
9939 + */
9941 +class DevPollArrayWrapper {
9943 + // special event to remove a file descriptor from the driver
9944 + static final short POLLREMOVE = 0x0800;
9946 + // struct pollfd constants
9947 + static final short SIZE_POLLFD = 8;
9948 + static final short FD_OFFSET = 0;
9949 + static final short EVENT_OFFSET = 4;
9950 + static final short REVENT_OFFSET = 6;
9952 + // maximum number of pollfd structure to poll or update at a time
9953 + // dpwrite/ioctl(DP_POLL) allows up to file descriptor limit minus 1
9954 + static final int NUM_POLLFDS = Math.min(IOUtil.fdLimit()-1, 1024);
9956 + // The pollfd array for results from devpoll driver
9957 + private final AllocatedNativeObject pollArray;
9959 + // Base address of the native pollArray
9960 + private final long pollArrayAddress;
9962 + // The fd of the devpoll driver
9963 + private int wfd;
9965 + DevPollArrayWrapper() throws IOException {
9966 + this.wfd = init();
9968 + int allocationSize = NUM_POLLFDS * SIZE_POLLFD;
9969 + this.pollArray = new AllocatedNativeObject(allocationSize, true);
9970 + this.pollArrayAddress = pollArray.address();
9973 + void close() throws IOException {
9974 + FileDispatcherImpl.closeIntFD(wfd);
9975 + pollArray.free();
9978 + void register(int fd, int ops) throws IOException {
9979 + register(wfd, fd, ops);
9982 + void registerMultiple(int numfds) throws IOException {
9983 + registerMultiple(wfd, pollArrayAddress, numfds);
9986 + int poll(long timeout) throws IOException {
9987 + return poll0(pollArrayAddress, NUM_POLLFDS, timeout, wfd);
9990 + int getDescriptor(int i) {
9991 + int offset = SIZE_POLLFD * i + FD_OFFSET;
9992 + return pollArray.getInt(offset);
9995 + short getEventOps(int i) {
9996 + int offset = SIZE_POLLFD * i + EVENT_OFFSET;
9997 + return pollArray.getShort(offset);
10000 + short getReventOps(int i) {
10001 + int offset = SIZE_POLLFD * i + REVENT_OFFSET;
10002 + return pollArray.getShort(offset);
10005 + /**
10006 + * Updates the pollfd structure at the given index
10007 + */
10008 + void putPollFD(int index, int fd, short event) {
10009 + int structIndex = SIZE_POLLFD * index;
10010 + pollArray.putInt(structIndex + FD_OFFSET, fd);
10011 + pollArray.putShort(structIndex + EVENT_OFFSET, event);
10012 + pollArray.putShort(structIndex + REVENT_OFFSET, (short)0);
10015 + private native int init() throws IOException;
10016 + private native void register(int wfd, int fd, int mask) throws IOException;
10017 + private native void registerMultiple(int wfd, long address, int len)
10018 + throws IOException;
10019 + private native int poll0(long pollAddress, int numfds, long timeout, int wfd)
10020 + throws IOException;
10022 + static {
10023 + IOUtil.load();
10026 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java
10027 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java 1970-01-01 01:00:00.000000000 +0100
10028 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java 2024-08-17 20:36:14.293428756 +0200
10029 @@ -0,0 +1,263 @@
10031 + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
10032 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10034 + * This code is free software; you can redistribute it and/or modify it
10035 + * under the terms of the GNU General Public License version 2 only, as
10036 + * published by the Free Software Foundation. Oracle designates this
10037 + * particular file as subject to the "Classpath" exception as provided
10038 + * by Oracle in the LICENSE file that accompanied this code.
10040 + * This code is distributed in the hope that it will be useful, but WITHOUT
10041 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10042 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10043 + * version 2 for more details (a copy is included in the LICENSE file that
10044 + * accompanied this code).
10046 + * You should have received a copy of the GNU General Public License version
10047 + * 2 along with this work; if not, write to the Free Software Foundation,
10048 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10050 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10051 + * or visit www.oracle.com if you need additional information or have any
10052 + * questions.
10053 + */
10055 +package sun.nio.ch;
10057 +import java.io.IOException;
10058 +import java.nio.channels.ClosedSelectorException;
10059 +import java.nio.channels.SelectionKey;
10060 +import java.nio.channels.Selector;
10061 +import java.nio.channels.spi.SelectorProvider;
10062 +import java.util.ArrayDeque;
10063 +import java.util.Deque;
10064 +import java.util.HashMap;
10065 +import java.util.Map;
10066 +import java.util.concurrent.TimeUnit;
10067 +import java.util.function.Consumer;
10069 +import static sun.nio.ch.DevPollArrayWrapper.NUM_POLLFDS;
10070 +import static sun.nio.ch.DevPollArrayWrapper.POLLREMOVE;
10072 +/**
10073 + * Solaris /dev/poll based Selector implementation
10074 + */
10076 +class DevPollSelectorImpl
10077 + extends SelectorImpl
10079 + // provides access to /dev/poll driver
10080 + private final DevPollArrayWrapper pollWrapper;
10082 + // file descriptors used for interrupt
10083 + private final int fd0;
10084 + private final int fd1;
10086 + // maps file descriptor to selection key, synchronize on selector
10087 + private final Map<Integer, SelectionKeyImpl> fdToKey = new HashMap<>();
10089 + // pending new registrations/updates, queued by setEventOps
10090 + private final Object updateLock = new Object();
10091 + private final Deque<SelectionKeyImpl> updateKeys = new ArrayDeque<>();
10093 + // interrupt triggering and clearing
10094 + private final Object interruptLock = new Object();
10095 + private boolean interruptTriggered;
10097 + DevPollSelectorImpl(SelectorProvider sp) throws IOException {
10098 + super(sp);
10099 + this.pollWrapper = new DevPollArrayWrapper();
10100 + try {
10101 + long fds = IOUtil.makePipe(false);
10102 + this.fd0 = (int) (fds >>> 32);
10103 + this.fd1 = (int) fds;
10104 + } catch (IOException ioe) {
10105 + pollWrapper.close();
10106 + throw ioe;
10109 + // register one end of the socket pair for wakeups
10110 + pollWrapper.register(fd0, Net.POLLIN);
10113 + private void ensureOpen() {
10114 + if (!isOpen())
10115 + throw new ClosedSelectorException();
10118 + @Override
10119 + protected int doSelect(Consumer<SelectionKey> action, long timeout)
10120 + throws IOException
10122 + assert Thread.holdsLock(this);
10124 + long to = timeout;
10125 + boolean blocking = (to != 0);
10126 + boolean timedPoll = (to > 0);
10128 + int numEntries;
10129 + processUpdateQueue();
10130 + processDeregisterQueue();
10131 + try {
10132 + begin(blocking);
10134 + do {
10135 + long startTime = timedPoll ? System.nanoTime() : 0;
10136 + numEntries = pollWrapper.poll(to);
10137 + if (numEntries == IOStatus.INTERRUPTED && timedPoll) {
10138 + // timed poll interrupted so need to adjust timeout
10139 + long adjust = System.nanoTime() - startTime;
10140 + to -= TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS);
10141 + if (to <= 0) {
10142 + // timeout expired so no retry
10143 + numEntries = 0;
10146 + } while (numEntries == IOStatus.INTERRUPTED);
10147 + assert IOStatus.check(numEntries);
10149 + } finally {
10150 + end(blocking);
10152 + processDeregisterQueue();
10153 + return processEvents(numEntries, action);
10156 + /**
10157 + * Process changes to the interest ops.
10158 + */
10159 + private void processUpdateQueue() throws IOException {
10160 + assert Thread.holdsLock(this);
10162 + synchronized (updateLock) {
10163 + SelectionKeyImpl ski;
10165 + // Translate the queued updates to changes to the set of monitored
10166 + // file descriptors. The changes are written to the /dev/poll driver
10167 + // in bulk.
10168 + int index = 0;
10169 + while ((ski = updateKeys.pollFirst()) != null) {
10170 + if (ski.isValid()) {
10171 + int fd = ski.getFDVal();
10172 + // add to fdToKey if needed
10173 + SelectionKeyImpl previous = fdToKey.putIfAbsent(fd, ski);
10174 + assert (previous == null) || (previous == ski);
10176 + int newEvents = ski.translateInterestOps();
10177 + int registeredEvents = ski.registeredEvents();
10178 + if (newEvents != registeredEvents) {
10179 + if (registeredEvents != 0)
10180 + pollWrapper.putPollFD(index++, fd, POLLREMOVE);
10181 + if (newEvents != 0)
10182 + pollWrapper.putPollFD(index++, fd, (short)newEvents);
10183 + ski.registeredEvents(newEvents);
10185 + // write to /dev/poll
10186 + if (index > (NUM_POLLFDS-2)) {
10187 + pollWrapper.registerMultiple(index);
10188 + index = 0;
10194 + // write any remaining changes
10195 + if (index > 0)
10196 + pollWrapper.registerMultiple(index);
10200 + /**
10201 + * Process the polled events.
10202 + * If the interrupt fd has been selected, drain it and clear the interrupt.
10203 + */
10204 + private int processEvents(int numEntries, Consumer<SelectionKey> action)
10205 + throws IOException
10207 + assert Thread.holdsLock(this);
10209 + boolean interrupted = false;
10210 + int numKeysUpdated = 0;
10211 + for (int i=0; i<numEntries; i++) {
10212 + int fd = pollWrapper.getDescriptor(i);
10213 + if (fd == fd0) {
10214 + interrupted = true;
10215 + } else {
10216 + SelectionKeyImpl ski = fdToKey.get(fd);
10217 + if (ski != null) {
10218 + int rOps = pollWrapper.getReventOps(i);
10219 + numKeysUpdated += processReadyEvents(rOps, ski, action);
10224 + if (interrupted) {
10225 + clearInterrupt();
10228 + return numKeysUpdated;
10231 + @Override
10232 + protected void implClose() throws IOException {
10233 + assert !isOpen();
10234 + assert Thread.holdsLock(this);
10236 + // prevent further wakeup
10237 + synchronized (interruptLock) {
10238 + interruptTriggered = true;
10241 + pollWrapper.close();
10242 + FileDispatcherImpl.closeIntFD(fd0);
10243 + FileDispatcherImpl.closeIntFD(fd1);
10247 + @Override
10248 + protected void implDereg(SelectionKeyImpl ski) throws IOException {
10249 + assert !ski.isValid();
10250 + assert Thread.holdsLock(this);
10252 + int fd = ski.getFDVal();
10253 + if (fdToKey.remove(fd) != null) {
10254 + if (ski.registeredEvents() != 0) {
10255 + pollWrapper.register(fd, POLLREMOVE);
10256 + ski.registeredEvents(0);
10258 + } else {
10259 + assert ski.registeredEvents() == 0;
10263 + @Override
10264 + public void setEventOps(SelectionKeyImpl ski) {
10265 + ensureOpen();
10266 + synchronized (updateLock) {
10267 + updateKeys.addLast(ski);
10271 + @Override
10272 + public Selector wakeup() {
10273 + synchronized (interruptLock) {
10274 + if (!interruptTriggered) {
10275 + try {
10276 + IOUtil.write1(fd1, (byte)0);
10277 + } catch (IOException ioe) {
10278 + throw new InternalError(ioe);
10280 + interruptTriggered = true;
10283 + return this;
10286 + private void clearInterrupt() throws IOException {
10287 + synchronized (interruptLock) {
10288 + IOUtil.drain(fd0);
10289 + interruptTriggered = false;
10293 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java
10294 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java 1970-01-01 01:00:00.000000000 +0100
10295 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java 2024-08-17 20:36:14.293695007 +0200
10296 @@ -0,0 +1,42 @@
10298 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
10299 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10301 + * This code is free software; you can redistribute it and/or modify it
10302 + * under the terms of the GNU General Public License version 2 only, as
10303 + * published by the Free Software Foundation. Oracle designates this
10304 + * particular file as subject to the "Classpath" exception as provided
10305 + * by Oracle in the LICENSE file that accompanied this code.
10307 + * This code is distributed in the hope that it will be useful, but WITHOUT
10308 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10309 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10310 + * version 2 for more details (a copy is included in the LICENSE file that
10311 + * accompanied this code).
10313 + * You should have received a copy of the GNU General Public License version
10314 + * 2 along with this work; if not, write to the Free Software Foundation,
10315 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10317 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10318 + * or visit www.oracle.com if you need additional information or have any
10319 + * questions.
10320 + */
10322 +package sun.nio.ch;
10324 +import java.io.IOException;
10325 +import java.nio.channels.*;
10326 +import java.nio.channels.spi.*;
10328 +public class DevPollSelectorProvider
10329 + extends SelectorProviderImpl
10331 + public AbstractSelector openSelector() throws IOException {
10332 + return new DevPollSelectorImpl(this);
10335 + public Channel inheritedChannel() throws IOException {
10336 + return InheritedChannel.getChannel();
10339 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java
10340 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java 1970-01-01 01:00:00.000000000 +0100
10341 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java 2024-08-17 20:36:14.294073362 +0200
10342 @@ -0,0 +1,308 @@
10344 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
10345 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10347 + * This code is free software; you can redistribute it and/or modify it
10348 + * under the terms of the GNU General Public License version 2 only, as
10349 + * published by the Free Software Foundation. Oracle designates this
10350 + * particular file as subject to the "Classpath" exception as provided
10351 + * by Oracle in the LICENSE file that accompanied this code.
10353 + * This code is distributed in the hope that it will be useful, but WITHOUT
10354 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10355 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10356 + * version 2 for more details (a copy is included in the LICENSE file that
10357 + * accompanied this code).
10359 + * You should have received a copy of the GNU General Public License version
10360 + * 2 along with this work; if not, write to the Free Software Foundation,
10361 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10363 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10364 + * or visit www.oracle.com if you need additional information or have any
10365 + * questions.
10366 + */
10368 +package sun.nio.ch;
10370 +import java.io.IOException;
10371 +import java.nio.channels.ClosedSelectorException;
10372 +import java.nio.channels.SelectionKey;
10373 +import java.nio.channels.Selector;
10374 +import java.nio.channels.spi.SelectorProvider;
10375 +import java.util.ArrayDeque;
10376 +import java.util.Deque;
10377 +import java.util.HashMap;
10378 +import java.util.Map;
10379 +import java.util.concurrent.TimeUnit;
10380 +import java.util.function.Consumer;
10382 +import static sun.nio.ch.SolarisEventPort.PORT_SOURCE_FD;
10383 +import static sun.nio.ch.SolarisEventPort.PORT_SOURCE_USER;
10384 +import static sun.nio.ch.SolarisEventPort.SIZEOF_PORT_EVENT;
10385 +import static sun.nio.ch.SolarisEventPort.OFFSETOF_EVENTS;
10386 +import static sun.nio.ch.SolarisEventPort.OFFSETOF_SOURCE;
10387 +import static sun.nio.ch.SolarisEventPort.OFFSETOF_OBJECT;
10388 +import static sun.nio.ch.SolarisEventPort.port_create;
10389 +import static sun.nio.ch.SolarisEventPort.port_close;
10390 +import static sun.nio.ch.SolarisEventPort.port_associate;
10391 +import static sun.nio.ch.SolarisEventPort.port_dissociate;
10392 +import static sun.nio.ch.SolarisEventPort.port_getn;
10393 +import static sun.nio.ch.SolarisEventPort.port_send;
10395 +/**
10396 + * Selector implementation based on the Solaris event port mechanism.
10397 + */
10399 +class EventPortSelectorImpl
10400 + extends SelectorImpl
10402 + // maximum number of events to retrive in one call to port_getn
10403 + static final int MAX_EVENTS = Math.min(IOUtil.fdLimit()-1, 1024);
10405 + // port file descriptor
10406 + private final int pfd;
10408 + // the poll array (populated by port_getn)
10409 + private final long pollArrayAddress;
10410 + private final AllocatedNativeObject pollArray;
10412 + // maps file descriptor to selection key, synchronize on selector
10413 + private final Map<Integer, SelectionKeyImpl> fdToKey = new HashMap<>();
10415 + // the last update operation, incremented by processUpdateQueue
10416 + private int lastUpdate;
10418 + // pending new registrations/updates, queued by setEventOps and
10419 + // updateSelectedKeys
10420 + private final Object updateLock = new Object();
10421 + private final Deque<SelectionKeyImpl> updateKeys = new ArrayDeque<>();
10423 + // interrupt triggering and clearing
10424 + private final Object interruptLock = new Object();
10425 + private boolean interruptTriggered;
10427 + EventPortSelectorImpl(SelectorProvider sp) throws IOException {
10428 + super(sp);
10430 + this.pfd = port_create();
10432 + int allocationSize = MAX_EVENTS * SIZEOF_PORT_EVENT;
10433 + this.pollArray = new AllocatedNativeObject(allocationSize, false);
10434 + this.pollArrayAddress = pollArray.address();
10437 + private void ensureOpen() {
10438 + if (!isOpen())
10439 + throw new ClosedSelectorException();
10442 + @Override
10443 + protected int doSelect(Consumer<SelectionKey> action, long timeout)
10444 + throws IOException
10446 + assert Thread.holdsLock(this);
10448 + long to = timeout;
10449 + boolean blocking = (to != 0);
10450 + boolean timedPoll = (to > 0);
10452 + int numEvents;
10453 + processUpdateQueue();
10454 + processDeregisterQueue();
10455 + try {
10456 + begin(blocking);
10458 + do {
10459 + long startTime = timedPoll ? System.nanoTime() : 0;
10460 + numEvents = port_getn(pfd, pollArrayAddress, MAX_EVENTS, to);
10461 + if (numEvents == IOStatus.INTERRUPTED && timedPoll) {
10462 + // timed poll interrupted so need to adjust timeout
10463 + long adjust = System.nanoTime() - startTime;
10464 + to -= TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS);
10465 + if (to <= 0) {
10466 + // timeout also expired so no retry
10467 + numEvents = 0;
10470 + } while (numEvents == IOStatus.INTERRUPTED);
10471 + assert IOStatus.check(numEvents);
10473 + } finally {
10474 + end(blocking);
10476 + processDeregisterQueue();
10477 + return processPortEvents(numEvents, action);
10480 + /**
10481 + * Process new registrations and changes to the interest ops.
10482 + */
10483 + private void processUpdateQueue() throws IOException {
10484 + assert Thread.holdsLock(this);
10486 + // bump lastUpdate to ensure that the interest ops are changed at most
10487 + // once per bulk update
10488 + lastUpdate++;
10490 + synchronized (updateLock) {
10491 + SelectionKeyImpl ski;
10492 + while ((ski = updateKeys.pollFirst()) != null) {
10493 + if (ski.isValid()) {
10494 + int fd = ski.getFDVal();
10495 + // add to fdToKey if needed
10496 + SelectionKeyImpl previous = fdToKey.putIfAbsent(fd, ski);
10497 + assert (previous == null) || (previous == ski);
10499 + int newEvents = ski.translateInterestOps();
10500 + if (newEvents != ski.registeredEvents()) {
10501 + if (newEvents == 0) {
10502 + port_dissociate(pfd, PORT_SOURCE_FD, fd);
10503 + } else {
10504 + port_associate(pfd, PORT_SOURCE_FD, fd, newEvents);
10506 + ski.registeredEvents(newEvents);
10513 + /**
10514 + * Process the polled events and re-queue the selected keys so the file
10515 + * descriptors are re-associated at the next select operation.
10516 + */
10517 + private int processPortEvents(int numEvents, Consumer<SelectionKey> action)
10518 + throws IOException
10520 + assert Thread.holdsLock(this);
10522 + int numKeysUpdated = 0;
10523 + boolean interrupted = false;
10525 + // Process the polled events while holding the update lock. This allows
10526 + // keys to be queued for ready file descriptors so they can be
10527 + // re-associated at the next select. The selected-key can be updated
10528 + // in this pass.
10529 + synchronized (updateLock) {
10530 + for (int i = 0; i < numEvents; i++) {
10531 + short source = getSource(i);
10532 + if (source == PORT_SOURCE_FD) {
10533 + int fd = getDescriptor(i);
10534 + SelectionKeyImpl ski = fdToKey.get(fd);
10535 + if (ski != null) {
10536 + ski.registeredEvents(0);
10537 + updateKeys.addLast(ski);
10539 + // update selected-key set if no action specified
10540 + if (action == null) {
10541 + int rOps = getEventOps(i);
10542 + numKeysUpdated += processReadyEvents(rOps, ski, null);
10546 + } else if (source == PORT_SOURCE_USER) {
10547 + interrupted = true;
10548 + } else {
10549 + assert false;
10554 + // if an action specified then iterate over the polled events again so
10555 + // that the action is performed without holding the update lock.
10556 + if (action != null) {
10557 + for (int i = 0; i < numEvents; i++) {
10558 + short source = getSource(i);
10559 + if (source == PORT_SOURCE_FD) {
10560 + int fd = getDescriptor(i);
10561 + SelectionKeyImpl ski = fdToKey.get(fd);
10562 + if (ski != null) {
10563 + int rOps = getEventOps(i);
10564 + numKeysUpdated += processReadyEvents(rOps, ski, action);
10570 + if (interrupted) {
10571 + clearInterrupt();
10573 + return numKeysUpdated;
10576 + @Override
10577 + protected void implClose() throws IOException {
10578 + assert !isOpen();
10579 + assert Thread.holdsLock(this);
10581 + // prevent further wakeup
10582 + synchronized (interruptLock) {
10583 + interruptTriggered = true;
10586 + port_close(pfd);
10587 + pollArray.free();
10590 + @Override
10591 + protected void implDereg(SelectionKeyImpl ski) throws IOException {
10592 + assert !ski.isValid();
10593 + assert Thread.holdsLock(this);
10595 + int fd = ski.getFDVal();
10596 + if (fdToKey.remove(fd) != null) {
10597 + if (ski.registeredEvents() != 0) {
10598 + port_dissociate(pfd, PORT_SOURCE_FD, fd);
10599 + ski.registeredEvents(0);
10601 + } else {
10602 + assert ski.registeredEvents() == 0;
10606 + @Override
10607 + public void setEventOps(SelectionKeyImpl ski) {
10608 + ensureOpen();
10609 + synchronized (updateLock) {
10610 + updateKeys.addLast(ski);
10614 + @Override
10615 + public Selector wakeup() {
10616 + synchronized (interruptLock) {
10617 + if (!interruptTriggered) {
10618 + try {
10619 + port_send(pfd, 0);
10620 + } catch (IOException ioe) {
10621 + throw new InternalError(ioe);
10623 + interruptTriggered = true;
10626 + return this;
10629 + private void clearInterrupt() throws IOException {
10630 + synchronized (interruptLock) {
10631 + interruptTriggered = false;
10635 + private short getSource(int i) {
10636 + int offset = SIZEOF_PORT_EVENT * i + OFFSETOF_SOURCE;
10637 + return pollArray.getShort(offset);
10640 + private int getEventOps(int i) {
10641 + int offset = SIZEOF_PORT_EVENT * i + OFFSETOF_EVENTS;
10642 + return pollArray.getInt(offset);
10645 + private int getDescriptor(int i) {
10646 + //assert Unsafe.getUnsafe().addressSize() == 8;
10647 + int offset = SIZEOF_PORT_EVENT * i + OFFSETOF_OBJECT;
10648 + return (int) pollArray.getLong(offset);
10651 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorProvider.java
10652 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorProvider.java 1970-01-01 01:00:00.000000000 +0100
10653 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorProvider.java 2024-08-17 20:36:14.294331713 +0200
10654 @@ -0,0 +1,42 @@
10656 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
10657 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10659 + * This code is free software; you can redistribute it and/or modify it
10660 + * under the terms of the GNU General Public License version 2 only, as
10661 + * published by the Free Software Foundation. Oracle designates this
10662 + * particular file as subject to the "Classpath" exception as provided
10663 + * by Oracle in the LICENSE file that accompanied this code.
10665 + * This code is distributed in the hope that it will be useful, but WITHOUT
10666 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10667 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10668 + * version 2 for more details (a copy is included in the LICENSE file that
10669 + * accompanied this code).
10671 + * You should have received a copy of the GNU General Public License version
10672 + * 2 along with this work; if not, write to the Free Software Foundation,
10673 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10675 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10676 + * or visit www.oracle.com if you need additional information or have any
10677 + * questions.
10678 + */
10680 +package sun.nio.ch;
10682 +import java.io.IOException;
10683 +import java.nio.channels.*;
10684 +import java.nio.channels.spi.*;
10686 +public class EventPortSelectorProvider
10687 + extends SelectorProviderImpl
10689 + public AbstractSelector openSelector() throws IOException {
10690 + return new EventPortSelectorImpl(this);
10693 + public Channel inheritedChannel() throws IOException {
10694 + return InheritedChannel.getChannel();
10697 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java
10698 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java 1970-01-01 01:00:00.000000000 +0100
10699 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java 2024-08-17 20:36:14.294667007 +0200
10700 @@ -0,0 +1,93 @@
10702 + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
10703 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10705 + * This code is free software; you can redistribute it and/or modify it
10706 + * under the terms of the GNU General Public License version 2 only, as
10707 + * published by the Free Software Foundation. Oracle designates this
10708 + * particular file as subject to the "Classpath" exception as provided
10709 + * by Oracle in the LICENSE file that accompanied this code.
10711 + * This code is distributed in the hope that it will be useful, but WITHOUT
10712 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10713 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10714 + * version 2 for more details (a copy is included in the LICENSE file that
10715 + * accompanied this code).
10717 + * You should have received a copy of the GNU General Public License version
10718 + * 2 along with this work; if not, write to the Free Software Foundation,
10719 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10721 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10722 + * or visit www.oracle.com if you need additional information or have any
10723 + * questions.
10724 + */
10726 +package sun.nio.ch;
10728 +import java.nio.channels.*;
10729 +import java.nio.channels.spi.AsynchronousChannelProvider;
10730 +import java.util.concurrent.ExecutorService;
10731 +import java.util.concurrent.ThreadFactory;
10732 +import java.io.IOException;
10734 +public class SolarisAsynchronousChannelProvider
10735 + extends AsynchronousChannelProvider
10737 + private static volatile SolarisEventPort defaultEventPort;
10739 + private SolarisEventPort defaultEventPort() throws IOException {
10740 + if (defaultEventPort == null) {
10741 + synchronized (SolarisAsynchronousChannelProvider.class) {
10742 + if (defaultEventPort == null) {
10743 + defaultEventPort =
10744 + new SolarisEventPort(this, ThreadPool.getDefault()).start();
10748 + return defaultEventPort;
10751 + public SolarisAsynchronousChannelProvider() {
10754 + @Override
10755 + public AsynchronousChannelGroup openAsynchronousChannelGroup(int nThreads, ThreadFactory factory)
10756 + throws IOException
10758 + return new SolarisEventPort(this, ThreadPool.create(nThreads, factory)).start();
10761 + @Override
10762 + public AsynchronousChannelGroup openAsynchronousChannelGroup(ExecutorService executor, int initialSize)
10763 + throws IOException
10765 + return new SolarisEventPort(this, ThreadPool.wrap(executor, initialSize)).start();
10768 + private SolarisEventPort toEventPort(AsynchronousChannelGroup group)
10769 + throws IOException
10771 + if (group == null) {
10772 + return defaultEventPort();
10773 + } else {
10774 + if (!(group instanceof SolarisEventPort))
10775 + throw new IllegalChannelGroupException();
10776 + return (SolarisEventPort)group;
10780 + @Override
10781 + public AsynchronousServerSocketChannel openAsynchronousServerSocketChannel(AsynchronousChannelGroup group)
10782 + throws IOException
10784 + return new UnixAsynchronousServerSocketChannelImpl(toEventPort(group));
10787 + @Override
10788 + public AsynchronousSocketChannel openAsynchronousSocketChannel(AsynchronousChannelGroup group)
10789 + throws IOException
10791 + return new UnixAsynchronousSocketChannelImpl(toEventPort(group));
10794 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java
10795 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java 1970-01-01 01:00:00.000000000 +0100
10796 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java 2024-08-17 20:36:14.295212258 +0200
10797 @@ -0,0 +1,273 @@
10799 + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
10800 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10802 + * This code is free software; you can redistribute it and/or modify it
10803 + * under the terms of the GNU General Public License version 2 only, as
10804 + * published by the Free Software Foundation. Oracle designates this
10805 + * particular file as subject to the "Classpath" exception as provided
10806 + * by Oracle in the LICENSE file that accompanied this code.
10808 + * This code is distributed in the hope that it will be useful, but WITHOUT
10809 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10810 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10811 + * version 2 for more details (a copy is included in the LICENSE file that
10812 + * accompanied this code).
10814 + * You should have received a copy of the GNU General Public License version
10815 + * 2 along with this work; if not, write to the Free Software Foundation,
10816 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10818 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10819 + * or visit www.oracle.com if you need additional information or have any
10820 + * questions.
10821 + */
10823 +package sun.nio.ch;
10825 +import java.nio.channels.spi.AsynchronousChannelProvider;
10826 +import java.util.concurrent.RejectedExecutionException;
10827 +import java.io.IOException;
10828 +import jdk.internal.misc.Unsafe;
10830 +/**
10831 + * Provides an AsynchronousChannelGroup implementation based on the Solaris 10
10832 + * event port framework and also provides direct access to that framework.
10833 + */
10835 +class SolarisEventPort
10836 + extends Port
10838 + private static final Unsafe unsafe = Unsafe.getUnsafe();
10839 + private static final int addressSize = unsafe.addressSize();
10841 + private static int dependsArch(int value32, int value64) {
10842 + return (addressSize == 4) ? value32 : value64;
10845 + /*
10846 + * typedef struct port_event {
10847 + * int portev_events;
10848 + * ushort_t portev_source;
10849 + * ushort_t portev_pad;
10850 + * uintptr_t portev_object;
10851 + * void *portev_user;
10852 + * } port_event_t;
10853 + */
10854 + static final int SIZEOF_PORT_EVENT = dependsArch(16, 24);
10855 + static final int OFFSETOF_EVENTS = 0;
10856 + static final int OFFSETOF_SOURCE = 4;
10857 + static final int OFFSETOF_OBJECT = 8;
10859 + // port sources
10860 + static final short PORT_SOURCE_USER = 3;
10861 + static final short PORT_SOURCE_FD = 4;
10863 + // events (sys/poll.h)
10864 + static final int POLLIN = 0x0001;
10865 + static final int POLLOUT = 0x0004;
10867 + // file descriptor to event port.
10868 + private final int port;
10870 + // true when port is closed
10871 + private boolean closed;
10873 + SolarisEventPort(AsynchronousChannelProvider provider, ThreadPool pool)
10874 + throws IOException
10876 + super(provider, pool);
10878 + // create event port
10879 + this.port = port_create();
10882 + SolarisEventPort start() {
10883 + startThreads(new EventHandlerTask());
10884 + return this;
10887 + // releass resources
10888 + private void implClose() {
10889 + synchronized (this) {
10890 + if (closed)
10891 + return;
10892 + closed = true;
10894 + port_close(port);
10897 + private void wakeup() {
10898 + try {
10899 + port_send(port, 0);
10900 + } catch (IOException x) {
10901 + throw new AssertionError(x);
10905 + @Override
10906 + void executeOnHandlerTask(Runnable task) {
10907 + synchronized (this) {
10908 + if (closed)
10909 + throw new RejectedExecutionException();
10910 + offerTask(task);
10911 + wakeup();
10915 + @Override
10916 + void shutdownHandlerTasks() {
10917 + /*
10918 + * If no tasks are running then just release resources; otherwise
10919 + * write to the one end of the socketpair to wakeup any polling threads..
10920 + */
10921 + int nThreads = threadCount();
10922 + if (nThreads == 0) {
10923 + implClose();
10924 + } else {
10925 + // send user event to wakeup each thread
10926 + while (nThreads-- > 0) {
10927 + try {
10928 + port_send(port, 0);
10929 + } catch (IOException x) {
10930 + throw new AssertionError(x);
10936 + @Override
10937 + void startPoll(int fd, int events) {
10938 + // (re-)associate file descriptor
10939 + // no need to translate events
10940 + try {
10941 + port_associate(port, PORT_SOURCE_FD, fd, events);
10942 + } catch (IOException x) {
10943 + throw new AssertionError(); // should not happen
10947 + /*
10948 + * Task to read a single event from the port and dispatch it to the
10949 + * channel's onEvent handler.
10950 + */
10951 + private class EventHandlerTask implements Runnable {
10952 + public void run() {
10953 + Invoker.GroupAndInvokeCount myGroupAndInvokeCount =
10954 + Invoker.getGroupAndInvokeCount();
10955 + final boolean isPooledThread = (myGroupAndInvokeCount != null);
10956 + boolean replaceMe = false;
10957 + long address = unsafe.allocateMemory(SIZEOF_PORT_EVENT);
10958 + try {
10959 + for (;;) {
10960 + // reset invoke count
10961 + if (isPooledThread)
10962 + myGroupAndInvokeCount.resetInvokeCount();
10964 + // wait for I/O completion event
10965 + // A error here is fatal (thread will not be replaced)
10966 + replaceMe = false;
10967 + try {
10968 + int n;
10969 + do {
10970 + n = port_get(port, address);
10971 + } while (n == IOStatus.INTERRUPTED);
10972 + } catch (IOException x) {
10973 + x.printStackTrace();
10974 + return;
10977 + // event source
10978 + short source = unsafe.getShort(address + OFFSETOF_SOURCE);
10979 + if (source != PORT_SOURCE_FD) {
10980 + // user event is trigger to invoke task or shutdown
10981 + if (source == PORT_SOURCE_USER) {
10982 + Runnable task = pollTask();
10983 + if (task == null) {
10984 + // shutdown request
10985 + return;
10987 + // run task (may throw error/exception)
10988 + replaceMe = true;
10989 + task.run();
10991 + // ignore
10992 + continue;
10995 + // pe->portev_object is file descriptor
10996 + int fd = (int)unsafe.getAddress(address + OFFSETOF_OBJECT);
10997 + // pe->portev_events
10998 + int events = unsafe.getInt(address + OFFSETOF_EVENTS);
11000 + // lookup channel
11001 + PollableChannel ch;
11002 + fdToChannelLock.readLock().lock();
11003 + try {
11004 + ch = fdToChannel.get(fd);
11005 + } finally {
11006 + fdToChannelLock.readLock().unlock();
11009 + // notify channel
11010 + if (ch != null) {
11011 + replaceMe = true;
11012 + // no need to translate events
11013 + ch.onEvent(events, isPooledThread);
11016 + } finally {
11017 + // free per-thread resources
11018 + unsafe.freeMemory(address);
11019 + // last task to exit when shutdown release resources
11020 + int remaining = threadExit(this, replaceMe);
11021 + if (remaining == 0 && isShutdown())
11022 + implClose();
11027 + /**
11028 + * Creates an event port
11029 + */
11030 + static native int port_create() throws IOException;
11032 + /**
11033 + * Associates specific events of a given object with a port
11034 + */
11035 + static native boolean port_associate(int port, int source, long object, int events)
11036 + throws IOException;
11038 + /**
11039 + * Removes the association of an object with a port.
11040 + */
11041 + static native boolean port_dissociate(int port, int source, long object)
11042 + throws IOException;
11044 + /**
11045 + * Retrieves a single event from a port
11046 + */
11047 + static native int port_get(int port, long address) throws IOException;
11049 + /**
11050 + * Retrieves at most {@code max} events from a port. A time-out of {@code < 0} means
11051 + * never time-out.
11052 + */
11053 + static native int port_getn(int port, long address, int max, long timeout)
11054 + throws IOException;
11056 + /**
11057 + * Sends a user-defined eventto a specified port.
11058 + */
11059 + static native void port_send(int port, int events) throws IOException;
11061 + /**
11062 + * Closes a port.
11063 + */
11064 + static native void port_close(int port);
11067 + static {
11068 + IOUtil.load();
11071 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java
11072 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java 1970-01-01 01:00:00.000000000 +0100
11073 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java 2024-08-17 20:36:14.295573257 +0200
11074 @@ -0,0 +1,53 @@
11076 + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
11077 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11079 + * This code is free software; you can redistribute it and/or modify it
11080 + * under the terms of the GNU General Public License version 2 only, as
11081 + * published by the Free Software Foundation. Oracle designates this
11082 + * particular file as subject to the "Classpath" exception as provided
11083 + * by Oracle in the LICENSE file that accompanied this code.
11085 + * This code is distributed in the hope that it will be useful, but WITHOUT
11086 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11087 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11088 + * version 2 for more details (a copy is included in the LICENSE file that
11089 + * accompanied this code).
11091 + * You should have received a copy of the GNU General Public License version
11092 + * 2 along with this work; if not, write to the Free Software Foundation,
11093 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11095 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11096 + * or visit www.oracle.com if you need additional information or have any
11097 + * questions.
11098 + */
11100 +package sun.nio.fs;
11102 +import java.nio.file.FileSystem;
11104 +/**
11105 + * Creates this platform's default FileSystemProvider.
11106 + */
11108 +public class DefaultFileSystemProvider {
11109 + private static final SolarisFileSystemProvider INSTANCE
11110 + = new SolarisFileSystemProvider();
11112 + private DefaultFileSystemProvider() { }
11114 + /**
11115 + * Returns the platform's default file system provider.
11116 + */
11117 + public static SolarisFileSystemProvider instance() {
11118 + return INSTANCE;
11121 + /**
11122 + * Returns the platform's default file system.
11123 + */
11124 + public static FileSystem theFileSystem() {
11125 + return INSTANCE.theFileSystem();
11128 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java
11129 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java 1970-01-01 01:00:00.000000000 +0100
11130 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java 2024-08-17 20:36:14.296033905 +0200
11131 @@ -0,0 +1,414 @@
11133 + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
11134 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11136 + * This code is free software; you can redistribute it and/or modify it
11137 + * under the terms of the GNU General Public License version 2 only, as
11138 + * published by the Free Software Foundation. Oracle designates this
11139 + * particular file as subject to the "Classpath" exception as provided
11140 + * by Oracle in the LICENSE file that accompanied this code.
11142 + * This code is distributed in the hope that it will be useful, but WITHOUT
11143 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11144 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11145 + * version 2 for more details (a copy is included in the LICENSE file that
11146 + * accompanied this code).
11148 + * You should have received a copy of the GNU General Public License version
11149 + * 2 along with this work; if not, write to the Free Software Foundation,
11150 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11152 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11153 + * or visit www.oracle.com if you need additional information or have any
11154 + * questions.
11155 + */
11157 +package sun.nio.fs;
11159 +import java.nio.file.*;
11160 +import java.nio.file.attribute.*;
11161 +import java.util.*;
11162 +import java.io.IOException;
11163 +import jdk.internal.misc.Unsafe;
11165 +import static sun.nio.fs.UnixConstants.*;
11166 +import static sun.nio.fs.SolarisConstants.*;
11167 +import static sun.nio.fs.SolarisNativeDispatcher.*;
11170 +/**
11171 + * Solaris implementation of AclFileAttributeView with native support for
11172 + * NFSv4 ACLs on ZFS.
11173 + */
11175 +class SolarisAclFileAttributeView
11176 + extends AbstractAclFileAttributeView
11178 + private static final Unsafe unsafe = Unsafe.getUnsafe();
11180 + // Maximum number of entries allowed in an ACL
11181 + private static final int MAX_ACL_ENTRIES = 1024;
11183 + /**
11184 + * typedef struct ace {
11185 + * uid_t a_who;
11186 + * uint32_t a_access_mask;
11187 + * uint16_t a_flags;
11188 + * uint16_t a_type;
11189 + * } ace_t;
11190 + */
11191 + private static final short SIZEOF_ACE_T = 12;
11192 + private static final short OFFSETOF_UID = 0;
11193 + private static final short OFFSETOF_MASK = 4;
11194 + private static final short OFFSETOF_FLAGS = 8;
11195 + private static final short OFFSETOF_TYPE = 10;
11197 + private final UnixPath file;
11198 + private final boolean followLinks;
11200 + SolarisAclFileAttributeView(UnixPath file, boolean followLinks) {
11201 + this.file = file;
11202 + this.followLinks = followLinks;
11205 + /**
11206 + * Permission checks to access file
11207 + */
11208 + private void checkAccess(UnixPath file,
11209 + boolean checkRead,
11210 + boolean checkWrite)
11212 + @SuppressWarnings("removal")
11213 + SecurityManager sm = System.getSecurityManager();
11214 + if (sm != null) {
11215 + if (checkRead)
11216 + file.checkRead();
11217 + if (checkWrite)
11218 + file.checkWrite();
11219 + sm.checkPermission(new RuntimePermission("accessUserInformation"));
11223 + /**
11224 + * Encode the ACL to the given buffer
11225 + */
11226 + private static void encode(List<AclEntry> acl, long address) {
11227 + long offset = address;
11228 + for (AclEntry ace: acl) {
11229 + int flags = 0;
11231 + // map UserPrincipal to uid and flags
11232 + UserPrincipal who = ace.principal();
11233 + if (!(who instanceof UnixUserPrincipals.User))
11234 + throw new ProviderMismatchException();
11235 + UnixUserPrincipals.User user = (UnixUserPrincipals.User)who;
11236 + int uid;
11237 + if (user.isSpecial()) {
11238 + uid = -1;
11239 + if (who == UnixUserPrincipals.SPECIAL_OWNER)
11240 + flags |= ACE_OWNER;
11241 + else if (who == UnixUserPrincipals.SPECIAL_GROUP)
11242 + flags |= (ACE_GROUP | ACE_IDENTIFIER_GROUP);
11243 + else if (who == UnixUserPrincipals.SPECIAL_EVERYONE)
11244 + flags |= ACE_EVERYONE;
11245 + else
11246 + throw new AssertionError("Unable to map special identifier");
11247 + } else {
11248 + if (user instanceof UnixUserPrincipals.Group) {
11249 + uid = user.gid();
11250 + flags |= ACE_IDENTIFIER_GROUP;
11251 + } else {
11252 + uid = user.uid();
11256 + // map ACE type
11257 + int type;
11258 + switch (ace.type()) {
11259 + case ALLOW:
11260 + type = ACE_ACCESS_ALLOWED_ACE_TYPE;
11261 + break;
11262 + case DENY:
11263 + type = ACE_ACCESS_DENIED_ACE_TYPE;
11264 + break;
11265 + case AUDIT:
11266 + type = ACE_SYSTEM_AUDIT_ACE_TYPE;
11267 + break;
11268 + case ALARM:
11269 + type = ACE_SYSTEM_ALARM_ACE_TYPE;
11270 + break;
11271 + default:
11272 + throw new AssertionError("Unable to map ACE type");
11275 + // map permissions
11276 + Set<AclEntryPermission> aceMask = ace.permissions();
11277 + int mask = 0;
11278 + if (aceMask.contains(AclEntryPermission.READ_DATA))
11279 + mask |= ACE_READ_DATA;
11280 + if (aceMask.contains(AclEntryPermission.WRITE_DATA))
11281 + mask |= ACE_WRITE_DATA;
11282 + if (aceMask.contains(AclEntryPermission.APPEND_DATA))
11283 + mask |= ACE_APPEND_DATA;
11284 + if (aceMask.contains(AclEntryPermission.READ_NAMED_ATTRS))
11285 + mask |= ACE_READ_NAMED_ATTRS;
11286 + if (aceMask.contains(AclEntryPermission.WRITE_NAMED_ATTRS))
11287 + mask |= ACE_WRITE_NAMED_ATTRS;
11288 + if (aceMask.contains(AclEntryPermission.EXECUTE))
11289 + mask |= ACE_EXECUTE;
11290 + if (aceMask.contains(AclEntryPermission.DELETE_CHILD))
11291 + mask |= ACE_DELETE_CHILD;
11292 + if (aceMask.contains(AclEntryPermission.READ_ATTRIBUTES))
11293 + mask |= ACE_READ_ATTRIBUTES;
11294 + if (aceMask.contains(AclEntryPermission.WRITE_ATTRIBUTES))
11295 + mask |= ACE_WRITE_ATTRIBUTES;
11296 + if (aceMask.contains(AclEntryPermission.DELETE))
11297 + mask |= ACE_DELETE;
11298 + if (aceMask.contains(AclEntryPermission.READ_ACL))
11299 + mask |= ACE_READ_ACL;
11300 + if (aceMask.contains(AclEntryPermission.WRITE_ACL))
11301 + mask |= ACE_WRITE_ACL;
11302 + if (aceMask.contains(AclEntryPermission.WRITE_OWNER))
11303 + mask |= ACE_WRITE_OWNER;
11304 + if (aceMask.contains(AclEntryPermission.SYNCHRONIZE))
11305 + mask |= ACE_SYNCHRONIZE;
11307 + // FIXME - it would be desirable to know here if the file is a
11308 + // directory or not. Solaris returns EINVAL if an ACE has a directory
11309 + // -only flag and the file is not a directory.
11310 + Set<AclEntryFlag> aceFlags = ace.flags();
11311 + if (aceFlags.contains(AclEntryFlag.FILE_INHERIT))
11312 + flags |= ACE_FILE_INHERIT_ACE;
11313 + if (aceFlags.contains(AclEntryFlag.DIRECTORY_INHERIT))
11314 + flags |= ACE_DIRECTORY_INHERIT_ACE;
11315 + if (aceFlags.contains(AclEntryFlag.NO_PROPAGATE_INHERIT))
11316 + flags |= ACE_NO_PROPAGATE_INHERIT_ACE;
11317 + if (aceFlags.contains(AclEntryFlag.INHERIT_ONLY))
11318 + flags |= ACE_INHERIT_ONLY_ACE;
11320 + unsafe.putInt(offset + OFFSETOF_UID, uid);
11321 + unsafe.putInt(offset + OFFSETOF_MASK, mask);
11322 + unsafe.putShort(offset + OFFSETOF_FLAGS, (short)flags);
11323 + unsafe.putShort(offset + OFFSETOF_TYPE, (short)type);
11325 + offset += SIZEOF_ACE_T;
11329 + /**
11330 + * Decode the buffer, returning an ACL
11331 + */
11332 + private static List<AclEntry> decode(long address, int n) {
11333 + ArrayList<AclEntry> acl = new ArrayList<>(n);
11334 + for (int i=0; i<n; i++) {
11335 + long offset = address + i*SIZEOF_ACE_T;
11337 + int uid = unsafe.getInt(offset + OFFSETOF_UID);
11338 + int mask = unsafe.getInt(offset + OFFSETOF_MASK);
11339 + int flags = (int)unsafe.getShort(offset + OFFSETOF_FLAGS);
11340 + int type = (int)unsafe.getShort(offset + OFFSETOF_TYPE);
11342 + // map uid and flags to UserPrincipal
11343 + UnixUserPrincipals.User who = null;
11344 + if ((flags & ACE_OWNER) > 0) {
11345 + who = UnixUserPrincipals.SPECIAL_OWNER;
11346 + } else if ((flags & ACE_GROUP) > 0) {
11347 + who = UnixUserPrincipals.SPECIAL_GROUP;
11348 + } else if ((flags & ACE_EVERYONE) > 0) {
11349 + who = UnixUserPrincipals.SPECIAL_EVERYONE;
11350 + } else if ((flags & ACE_IDENTIFIER_GROUP) > 0) {
11351 + who = UnixUserPrincipals.fromGid(uid);
11352 + } else {
11353 + who = UnixUserPrincipals.fromUid(uid);
11356 + AclEntryType aceType = null;
11357 + switch (type) {
11358 + case ACE_ACCESS_ALLOWED_ACE_TYPE:
11359 + aceType = AclEntryType.ALLOW;
11360 + break;
11361 + case ACE_ACCESS_DENIED_ACE_TYPE:
11362 + aceType = AclEntryType.DENY;
11363 + break;
11364 + case ACE_SYSTEM_AUDIT_ACE_TYPE:
11365 + aceType = AclEntryType.AUDIT;
11366 + break;
11367 + case ACE_SYSTEM_ALARM_ACE_TYPE:
11368 + aceType = AclEntryType.ALARM;
11369 + break;
11370 + default:
11371 + assert false;
11374 + Set<AclEntryPermission> aceMask = EnumSet.noneOf(AclEntryPermission.class);
11375 + if ((mask & ACE_READ_DATA) > 0)
11376 + aceMask.add(AclEntryPermission.READ_DATA);
11377 + if ((mask & ACE_WRITE_DATA) > 0)
11378 + aceMask.add(AclEntryPermission.WRITE_DATA);
11379 + if ((mask & ACE_APPEND_DATA ) > 0)
11380 + aceMask.add(AclEntryPermission.APPEND_DATA);
11381 + if ((mask & ACE_READ_NAMED_ATTRS) > 0)
11382 + aceMask.add(AclEntryPermission.READ_NAMED_ATTRS);
11383 + if ((mask & ACE_WRITE_NAMED_ATTRS) > 0)
11384 + aceMask.add(AclEntryPermission.WRITE_NAMED_ATTRS);
11385 + if ((mask & ACE_EXECUTE) > 0)
11386 + aceMask.add(AclEntryPermission.EXECUTE);
11387 + if ((mask & ACE_DELETE_CHILD ) > 0)
11388 + aceMask.add(AclEntryPermission.DELETE_CHILD);
11389 + if ((mask & ACE_READ_ATTRIBUTES) > 0)
11390 + aceMask.add(AclEntryPermission.READ_ATTRIBUTES);
11391 + if ((mask & ACE_WRITE_ATTRIBUTES) > 0)
11392 + aceMask.add(AclEntryPermission.WRITE_ATTRIBUTES);
11393 + if ((mask & ACE_DELETE) > 0)
11394 + aceMask.add(AclEntryPermission.DELETE);
11395 + if ((mask & ACE_READ_ACL) > 0)
11396 + aceMask.add(AclEntryPermission.READ_ACL);
11397 + if ((mask & ACE_WRITE_ACL) > 0)
11398 + aceMask.add(AclEntryPermission.WRITE_ACL);
11399 + if ((mask & ACE_WRITE_OWNER) > 0)
11400 + aceMask.add(AclEntryPermission.WRITE_OWNER);
11401 + if ((mask & ACE_SYNCHRONIZE) > 0)
11402 + aceMask.add(AclEntryPermission.SYNCHRONIZE);
11404 + Set<AclEntryFlag> aceFlags = EnumSet.noneOf(AclEntryFlag.class);
11405 + if ((flags & ACE_FILE_INHERIT_ACE) > 0)
11406 + aceFlags.add(AclEntryFlag.FILE_INHERIT);
11407 + if ((flags & ACE_DIRECTORY_INHERIT_ACE) > 0)
11408 + aceFlags.add(AclEntryFlag.DIRECTORY_INHERIT);
11409 + if ((flags & ACE_NO_PROPAGATE_INHERIT_ACE) > 0)
11410 + aceFlags.add(AclEntryFlag.NO_PROPAGATE_INHERIT);
11411 + if ((flags & ACE_INHERIT_ONLY_ACE) > 0)
11412 + aceFlags.add(AclEntryFlag.INHERIT_ONLY);
11414 + // build the ACL entry and add it to the list
11415 + AclEntry ace = AclEntry.newBuilder()
11416 + .setType(aceType)
11417 + .setPrincipal(who)
11418 + .setPermissions(aceMask).setFlags(aceFlags).build();
11419 + acl.add(ace);
11422 + return acl;
11425 + // Returns true if NFSv4 ACLs not enabled on file system
11426 + private static boolean isAclsEnabled(int fd) {
11427 + try {
11428 + long enabled = fpathconf(fd, _PC_ACL_ENABLED);
11429 + if (enabled == _ACL_ACE_ENABLED)
11430 + return true;
11431 + } catch (UnixException x) {
11433 + return false;
11436 + @Override
11437 + public List<AclEntry> getAcl()
11438 + throws IOException
11440 + // permission check
11441 + checkAccess(file, true, false);
11443 + // open file (will fail if file is a link and not following links)
11444 + int fd = -1;
11445 + try {
11446 + fd = file.openForAttributeAccess(followLinks);
11447 + } catch (UnixException x) {
11448 + x.rethrowAsIOException(file);
11450 + try {
11451 + long address = unsafe.allocateMemory(SIZEOF_ACE_T * MAX_ACL_ENTRIES);
11452 + try {
11453 + // read ACL and decode it
11454 + int n = facl(fd, ACE_GETACL, MAX_ACL_ENTRIES, address);
11455 + assert n >= 0;
11456 + return decode(address, n);
11457 + } catch (UnixException x) {
11458 + if ((x.errno() == ENOSYS) || !isAclsEnabled(fd)) {
11459 + throw new FileSystemException(file.getPathForExceptionMessage(),
11460 + null, x.getMessage() + " (file system does not support NFSv4 ACLs)");
11462 + x.rethrowAsIOException(file);
11463 + return null; // keep compiler happy
11464 + } finally {
11465 + unsafe.freeMemory(address);
11467 + } finally {
11468 + close(fd, e -> null);
11472 + @Override
11473 + public void setAcl(List<AclEntry> acl) throws IOException {
11474 + // permission check
11475 + checkAccess(file, false, true);
11477 + // open file (will fail if file is a link and not following links)
11478 + int fd = -1;
11479 + try {
11480 + fd = file.openForAttributeAccess(followLinks);
11481 + } catch (UnixException x) {
11482 + x.rethrowAsIOException(file);
11484 + try {
11485 + // SECURITY: need to copy list as can change during processing
11486 + acl = new ArrayList<AclEntry>(acl);
11487 + int n = acl.size();
11489 + long address = unsafe.allocateMemory(SIZEOF_ACE_T * n);
11490 + try {
11491 + encode(acl, address);
11492 + facl(fd, ACE_SETACL, n, address);
11493 + } catch (UnixException x) {
11494 + if ((x.errno() == ENOSYS) || !isAclsEnabled(fd)) {
11495 + throw new FileSystemException(file.getPathForExceptionMessage(),
11496 + null, x.getMessage() + " (file system does not support NFSv4 ACLs)");
11498 + if (x.errno() == EINVAL && (n < 3))
11499 + throw new IOException("ACL must contain at least 3 entries");
11500 + x.rethrowAsIOException(file);
11501 + } finally {
11502 + unsafe.freeMemory(address);
11504 + } finally {
11505 + close(fd, e -> null);
11509 + @Override
11510 + public UserPrincipal getOwner()
11511 + throws IOException
11513 + checkAccess(file, true, false);
11515 + try {
11516 + UnixFileAttributes attrs =
11517 + UnixFileAttributes.get(file, followLinks);
11518 + return UnixUserPrincipals.fromUid(attrs.uid());
11519 + } catch (UnixException x) {
11520 + x.rethrowAsIOException(file);
11521 + return null; // keep compile happy
11525 + @Override
11526 + public void setOwner(UserPrincipal owner) throws IOException {
11527 + checkAccess(file, true, false);
11529 + if (!(owner instanceof UnixUserPrincipals.User))
11530 + throw new ProviderMismatchException();
11531 + if (owner instanceof UnixUserPrincipals.Group)
11532 + throw new IOException("'owner' parameter is a group");
11533 + int uid = ((UnixUserPrincipals.User)owner).uid();
11535 + try {
11536 + if (followLinks) {
11537 + lchown(file, uid, -1);
11538 + } else {
11539 + chown(file, uid, -1);
11541 + } catch (UnixException x) {
11542 + x.rethrowAsIOException(file);
11546 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template
11547 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template 1970-01-01 01:00:00.000000000 +0100
11548 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisConstants.java.template 2024-08-17 20:36:14.296323577 +0200
11549 @@ -0,0 +1,89 @@
11551 + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
11553 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11555 + * This code is free software; you can redistribute it and/or modify it
11556 + * under the terms of the GNU General Public License version 2 only, as
11557 + * published by the Free Software Foundation. Oracle designates this
11558 + * particular file as subject to the "Classpath" exception as provided
11559 + * by Oracle in the LICENSE file that accompanied this code.
11561 + * This code is distributed in the hope that it will be useful, but WITHOUT
11562 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11563 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11564 + * version 2 for more details (a copy is included in the LICENSE file that
11565 + * accompanied this code).
11567 + * You should have received a copy of the GNU General Public License version
11568 + * 2 along with this work; if not, write to the Free Software Foundation,
11569 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11571 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11572 + * or visit www.oracle.com if you need additional information or have any
11573 + * questions.
11574 + */
11576 +@@END_COPYRIGHT@@
11578 +#include <stdio.h>
11579 +#include <errno.h>
11580 +#include <unistd.h>
11581 +#include <sys/acl.h>
11582 +#include <fcntl.h>
11583 +#include <sys/stat.h>
11585 +/* On Solaris, "sun" is defined as a macro. Undefine to make package
11586 + declaration valid */
11587 +#undef sun
11589 +/* To be able to name the Java constants the same as the C constants without
11590 + having the preprocessor rewrite those identifiers, add PREFIX_ to all
11591 + identifiers matching a C constant. The PREFIX_ is filtered out in the
11592 + makefile. */
11594 +@@START_HERE@@
11596 +package sun.nio.fs;
11597 +class SolarisConstants {
11599 + private SolarisConstants() { }
11601 + static final int PREFIX_O_XATTR = O_XATTR;
11602 + static final int PREFIX__PC_XATTR_ENABLED = _PC_XATTR_ENABLED;
11603 + static final int PREFIX__PC_ACL_ENABLED = _PC_ACL_ENABLED;
11604 + static final int PREFIX__ACL_ACE_ENABLED = _ACL_ACE_ENABLED;
11605 + static final int PREFIX_ACE_GETACL = ACE_GETACL;
11606 + static final int PREFIX_ACE_SETACL = ACE_SETACL;
11607 + static final int PREFIX_ACE_ACCESS_ALLOWED_ACE_TYPE = ACE_ACCESS_ALLOWED_ACE_TYPE;
11608 + static final int PREFIX_ACE_ACCESS_DENIED_ACE_TYPE = ACE_ACCESS_DENIED_ACE_TYPE;
11609 + static final int PREFIX_ACE_SYSTEM_AUDIT_ACE_TYPE = ACE_SYSTEM_AUDIT_ACE_TYPE;
11610 + static final int PREFIX_ACE_SYSTEM_ALARM_ACE_TYPE = ACE_SYSTEM_ALARM_ACE_TYPE;
11611 + static final int PREFIX_ACE_READ_DATA = ACE_READ_DATA;
11612 + static final int PREFIX_ACE_LIST_DIRECTORY = ACE_LIST_DIRECTORY;
11613 + static final int PREFIX_ACE_WRITE_DATA = ACE_WRITE_DATA;
11614 + static final int PREFIX_ACE_ADD_FILE = ACE_ADD_FILE;
11615 + static final int PREFIX_ACE_APPEND_DATA = ACE_APPEND_DATA;
11616 + static final int PREFIX_ACE_ADD_SUBDIRECTORY = ACE_ADD_SUBDIRECTORY;
11617 + static final int PREFIX_ACE_READ_NAMED_ATTRS = ACE_READ_NAMED_ATTRS;
11618 + static final int PREFIX_ACE_WRITE_NAMED_ATTRS = ACE_WRITE_NAMED_ATTRS;
11619 + static final int PREFIX_ACE_EXECUTE = ACE_EXECUTE;
11620 + static final int PREFIX_ACE_DELETE_CHILD = ACE_DELETE_CHILD;
11621 + static final int PREFIX_ACE_READ_ATTRIBUTES = ACE_READ_ATTRIBUTES;
11622 + static final int PREFIX_ACE_WRITE_ATTRIBUTES = ACE_WRITE_ATTRIBUTES;
11623 + static final int PREFIX_ACE_DELETE = ACE_DELETE;
11624 + static final int PREFIX_ACE_READ_ACL = ACE_READ_ACL;
11625 + static final int PREFIX_ACE_WRITE_ACL = ACE_WRITE_ACL;
11626 + static final int PREFIX_ACE_WRITE_OWNER = ACE_WRITE_OWNER;
11627 + static final int PREFIX_ACE_SYNCHRONIZE = ACE_SYNCHRONIZE;
11628 + static final int PREFIX_ACE_FILE_INHERIT_ACE = ACE_FILE_INHERIT_ACE;
11629 + static final int PREFIX_ACE_DIRECTORY_INHERIT_ACE = ACE_DIRECTORY_INHERIT_ACE;
11630 + static final int PREFIX_ACE_NO_PROPAGATE_INHERIT_ACE = ACE_NO_PROPAGATE_INHERIT_ACE;
11631 + static final int PREFIX_ACE_INHERIT_ONLY_ACE = ACE_INHERIT_ONLY_ACE;
11632 + static final int PREFIX_ACE_SUCCESSFUL_ACCESS_ACE_FLAG = ACE_SUCCESSFUL_ACCESS_ACE_FLAG;
11633 + static final int PREFIX_ACE_FAILED_ACCESS_ACE_FLAG = ACE_FAILED_ACCESS_ACE_FLAG;
11634 + static final int PREFIX_ACE_IDENTIFIER_GROUP = ACE_IDENTIFIER_GROUP;
11635 + static final int PREFIX_ACE_OWNER = ACE_OWNER;
11636 + static final int PREFIX_ACE_GROUP = ACE_GROUP;
11637 + static final int PREFIX_ACE_EVERYONE = ACE_EVERYONE;
11639 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileStore.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileStore.java
11640 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileStore.java 1970-01-01 01:00:00.000000000 +0100
11641 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileStore.java 2024-08-17 20:36:14.296610456 +0200
11642 @@ -0,0 +1,111 @@
11644 + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
11645 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11647 + * This code is free software; you can redistribute it and/or modify it
11648 + * under the terms of the GNU General Public License version 2 only, as
11649 + * published by the Free Software Foundation. Oracle designates this
11650 + * particular file as subject to the "Classpath" exception as provided
11651 + * by Oracle in the LICENSE file that accompanied this code.
11653 + * This code is distributed in the hope that it will be useful, but WITHOUT
11654 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11655 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11656 + * version 2 for more details (a copy is included in the LICENSE file that
11657 + * accompanied this code).
11659 + * You should have received a copy of the GNU General Public License version
11660 + * 2 along with this work; if not, write to the Free Software Foundation,
11661 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11663 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11664 + * or visit www.oracle.com if you need additional information or have any
11665 + * questions.
11666 + */
11668 +package sun.nio.fs;
11670 +import java.nio.file.attribute.*;
11671 +import java.io.IOException;
11673 +import static sun.nio.fs.UnixNativeDispatcher.*;
11674 +import static sun.nio.fs.SolarisConstants.*;
11676 +/**
11677 + * Solaris implementation of FileStore
11678 + */
11680 +class SolarisFileStore
11681 + extends UnixFileStore
11683 + private final boolean xattrEnabled;
11685 + SolarisFileStore(UnixPath file) throws IOException {
11686 + super(file);
11687 + this.xattrEnabled = xattrEnabled();
11690 + SolarisFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException {
11691 + super(fs, entry);
11692 + this.xattrEnabled = xattrEnabled();
11695 + // returns true if extended attributes enabled
11696 + private boolean xattrEnabled() {
11697 + long res = 0L;
11698 + try {
11699 + res = pathconf(file(), _PC_XATTR_ENABLED);
11700 + } catch (UnixException x) {
11701 + // ignore
11703 + return (res != 0L);
11706 + @Override
11707 + UnixMountEntry findMountEntry() throws IOException {
11708 + // On Solaris iterate over the entries in the mount table to find device
11709 + for (UnixMountEntry entry: file().getFileSystem().getMountEntries()) {
11710 + if (entry.dev() == dev()) {
11711 + return entry;
11714 + throw new IOException("Device not found in mnttab");
11717 + @Override
11718 + public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
11719 + if (type == AclFileAttributeView.class) {
11720 + // lookup fstypes.properties
11721 + FeatureStatus status = checkIfFeaturePresent("nfsv4acl");
11722 + switch (status) {
11723 + case PRESENT : return true;
11724 + case NOT_PRESENT : return false;
11725 + default :
11726 + // AclFileAttributeView available on ZFS
11727 + return (type().equals("zfs"));
11730 + if (type == UserDefinedFileAttributeView.class) {
11731 + // lookup fstypes.properties
11732 + FeatureStatus status = checkIfFeaturePresent("xattr");
11733 + switch (status) {
11734 + case PRESENT : return true;
11735 + case NOT_PRESENT : return false;
11736 + default :
11737 + // UserDefinedFileAttributeView available if extended
11738 + // attributes supported
11739 + return xattrEnabled;
11742 + return super.supportsFileAttributeView(type);
11745 + @Override
11746 + public boolean supportsFileAttributeView(String name) {
11747 + if (name.equals("acl"))
11748 + return supportsFileAttributeView(AclFileAttributeView.class);
11749 + if (name.equals("user"))
11750 + return supportsFileAttributeView(UserDefinedFileAttributeView.class);
11751 + return super.supportsFileAttributeView(name);
11754 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystem.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystem.java
11755 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystem.java 1970-01-01 01:00:00.000000000 +0100
11756 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystem.java 2024-08-17 20:36:14.296911815 +0200
11757 @@ -0,0 +1,127 @@
11759 + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
11760 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11762 + * This code is free software; you can redistribute it and/or modify it
11763 + * under the terms of the GNU General Public License version 2 only, as
11764 + * published by the Free Software Foundation. Oracle designates this
11765 + * particular file as subject to the "Classpath" exception as provided
11766 + * by Oracle in the LICENSE file that accompanied this code.
11768 + * This code is distributed in the hope that it will be useful, but WITHOUT
11769 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11770 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11771 + * version 2 for more details (a copy is included in the LICENSE file that
11772 + * accompanied this code).
11774 + * You should have received a copy of the GNU General Public License version
11775 + * 2 along with this work; if not, write to the Free Software Foundation,
11776 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11778 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11779 + * or visit www.oracle.com if you need additional information or have any
11780 + * questions.
11781 + */
11783 +package sun.nio.fs;
11785 +import java.nio.file.*;
11786 +import java.io.IOException;
11787 +import java.util.*;
11788 +import sun.security.action.GetPropertyAction;
11789 +import static sun.nio.fs.SolarisNativeDispatcher.*;
11791 +/**
11792 + * Solaris implementation of FileSystem
11793 + */
11795 +class SolarisFileSystem extends UnixFileSystem {
11796 + private final boolean hasSolaris11Features;
11798 + SolarisFileSystem(UnixFileSystemProvider provider, String dir) {
11799 + super(provider, dir);
11801 + // check os.version
11802 + String osversion = GetPropertyAction.privilegedGetProperty("os.version");
11803 + String[] vers = Util.split(osversion, '.');
11804 + assert vers.length >= 2;
11805 + int majorVersion = Integer.parseInt(vers[0]);
11806 + int minorVersion = Integer.parseInt(vers[1]);
11807 + this.hasSolaris11Features =
11808 + (majorVersion > 5 || (majorVersion == 5 && minorVersion >= 11));
11811 + @Override
11812 + boolean isSolaris() {
11813 + return true;
11816 + @Override
11817 + public WatchService newWatchService()
11818 + throws IOException
11820 + // FEN available since Solaris 11
11821 + if (hasSolaris11Features) {
11822 + return new SolarisWatchService(this);
11823 + } else {
11824 + return new PollingWatchService();
11829 + // lazy initialization of the list of supported attribute views
11830 + private static class SupportedFileFileAttributeViewsHolder {
11831 + static final Set<String> supportedFileAttributeViews =
11832 + supportedFileAttributeViews();
11833 + private static Set<String> supportedFileAttributeViews() {
11834 + Set<String> result = new HashSet<>();
11835 + result.addAll(standardFileAttributeViews());
11836 + // additional Solaris-specific views
11837 + result.add("acl");
11838 + result.add("user");
11839 + return Collections.unmodifiableSet(result);
11843 + @Override
11844 + public Set<String> supportedFileAttributeViews() {
11845 + return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
11848 + @Override
11849 + void copyNonPosixAttributes(int ofd, int nfd) {
11850 + SolarisUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
11851 + // TDB: copy ACL from source to target
11854 + /**
11855 + * Returns object to iterate over entries in /etc/mnttab
11856 + */
11857 + @Override
11858 + Iterable<UnixMountEntry> getMountEntries() {
11859 + ArrayList<UnixMountEntry> entries = new ArrayList<>();
11860 + try {
11861 + UnixPath mnttab = new UnixPath(this, "/etc/mnttab");
11862 + long fp = fopen(mnttab, "r");
11863 + try {
11864 + for (;;) {
11865 + UnixMountEntry entry = new UnixMountEntry();
11866 + int res = getextmntent(fp, entry);
11867 + if (res < 0)
11868 + break;
11869 + entries.add(entry);
11871 + } finally {
11872 + fclose(fp);
11874 + } catch (UnixException x) {
11875 + // nothing we can do
11877 + return entries;
11880 + @Override
11881 + FileStore getFileStore(UnixMountEntry entry) throws IOException {
11882 + return new SolarisFileStore(this, entry);
11885 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
11886 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java 1970-01-01 01:00:00.000000000 +0100
11887 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java 2024-08-17 20:36:14.297199516 +0200
11888 @@ -0,0 +1,94 @@
11890 + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
11891 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11893 + * This code is free software; you can redistribute it and/or modify it
11894 + * under the terms of the GNU General Public License version 2 only, as
11895 + * published by the Free Software Foundation. Oracle designates this
11896 + * particular file as subject to the "Classpath" exception as provided
11897 + * by Oracle in the LICENSE file that accompanied this code.
11899 + * This code is distributed in the hope that it will be useful, but WITHOUT
11900 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11901 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11902 + * version 2 for more details (a copy is included in the LICENSE file that
11903 + * accompanied this code).
11905 + * You should have received a copy of the GNU General Public License version
11906 + * 2 along with this work; if not, write to the Free Software Foundation,
11907 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11909 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11910 + * or visit www.oracle.com if you need additional information or have any
11911 + * questions.
11912 + */
11914 +package sun.nio.fs;
11916 +import java.nio.file.*;
11917 +import java.nio.file.attribute.*;
11918 +import java.nio.file.spi.FileTypeDetector;
11919 +import java.io.IOException;
11920 +import jdk.internal.util.StaticProperty;
11921 +import sun.security.action.GetPropertyAction;
11923 +/**
11924 + * Solaris implementation of FileSystemProvider
11925 + */
11927 +class SolarisFileSystemProvider extends UnixFileSystemProvider {
11928 + public SolarisFileSystemProvider() {
11929 + super();
11932 + @Override
11933 + SolarisFileSystem newFileSystem(String dir) {
11934 + return new SolarisFileSystem(this, dir);
11937 + @Override
11938 + SolarisFileStore getFileStore(UnixPath path) throws IOException {
11939 + return new SolarisFileStore(path);
11943 + @Override
11944 + @SuppressWarnings("unchecked")
11945 + public <V extends FileAttributeView> V getFileAttributeView(Path obj,
11946 + Class<V> type,
11947 + LinkOption... options)
11949 + if (type == AclFileAttributeView.class) {
11950 + return (V) new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
11951 + Util.followLinks(options));
11953 + if (type == UserDefinedFileAttributeView.class) {
11954 + return(V) new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
11955 + Util.followLinks(options));
11957 + return super.getFileAttributeView(obj, type, options);
11960 + @Override
11961 + public DynamicFileAttributeView getFileAttributeView(Path obj,
11962 + String name,
11963 + LinkOption... options)
11965 + if (name.equals("acl"))
11966 + return new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
11967 + Util.followLinks(options));
11968 + if (name.equals("user"))
11969 + return new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
11970 + Util.followLinks(options));
11971 + return super.getFileAttributeView(obj, name, options);
11974 + @Override
11975 + FileTypeDetector getFileTypeDetector() {
11976 + Path userMimeTypes = Path.of(StaticProperty.userHome(), ".mime.types");
11977 + Path etcMimeTypes = Path.of("/etc/mime.types");
11979 + return chain(new MimeTypesFileTypeDetector(userMimeTypes),
11980 + new MimeTypesFileTypeDetector(etcMimeTypes));
11983 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java
11984 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java 1970-01-01 01:00:00.000000000 +0100
11985 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java 2024-08-17 20:36:14.297463494 +0200
11986 @@ -0,0 +1,55 @@
11988 + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
11989 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11991 + * This code is free software; you can redistribute it and/or modify it
11992 + * under the terms of the GNU General Public License version 2 only, as
11993 + * published by the Free Software Foundation. Oracle designates this
11994 + * particular file as subject to the "Classpath" exception as provided
11995 + * by Oracle in the LICENSE file that accompanied this code.
11997 + * This code is distributed in the hope that it will be useful, but WITHOUT
11998 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11999 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12000 + * version 2 for more details (a copy is included in the LICENSE file that
12001 + * accompanied this code).
12003 + * You should have received a copy of the GNU General Public License version
12004 + * 2 along with this work; if not, write to the Free Software Foundation,
12005 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12007 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12008 + * or visit www.oracle.com if you need additional information or have any
12009 + * questions.
12010 + */
12012 +package sun.nio.fs;
12014 +/**
12015 + * Solaris specific system calls.
12016 + */
12018 +class SolarisNativeDispatcher extends UnixNativeDispatcher {
12019 + private SolarisNativeDispatcher() { }
12021 + /**
12022 + * int getextmntent(FILE *fp, struct extmnttab *mp, int len);
12023 + */
12024 + static native int getextmntent(long fp, UnixMountEntry entry)
12025 + throws UnixException;
12027 + /**
12028 + * int facl(int filedes, int cmd, int nentries, void aclbufp)
12029 + */
12030 + static native int facl(int fd, int cmd, int nentries, long aclbufp)
12031 + throws UnixException;
12034 + // initialize
12035 + private static native void init();
12037 + static {
12038 + jdk.internal.loader.BootLoader.loadLibrary("nio");
12039 + init();
12042 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
12043 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java 1970-01-01 01:00:00.000000000 +0100
12044 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java 2024-08-17 20:36:14.297739758 +0200
12045 @@ -0,0 +1,41 @@
12047 + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
12048 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12050 + * This code is free software; you can redistribute it and/or modify it
12051 + * under the terms of the GNU General Public License version 2 only, as
12052 + * published by the Free Software Foundation. Oracle designates this
12053 + * particular file as subject to the "Classpath" exception as provided
12054 + * by Oracle in the LICENSE file that accompanied this code.
12056 + * This code is distributed in the hope that it will be useful, but WITHOUT
12057 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12058 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12059 + * version 2 for more details (a copy is included in the LICENSE file that
12060 + * accompanied this code).
12062 + * You should have received a copy of the GNU General Public License version
12063 + * 2 along with this work; if not, write to the Free Software Foundation,
12064 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12066 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12067 + * or visit www.oracle.com if you need additional information or have any
12068 + * questions.
12069 + */
12071 +package sun.nio.fs;
12073 +class SolarisUserDefinedFileAttributeView
12074 + extends UnixUserDefinedFileAttributeView
12077 + SolarisUserDefinedFileAttributeView(UnixPath file, boolean followLinks) {
12078 + super(file, followLinks);
12081 + @Override
12082 + protected int maxNameLength() {
12083 + return 255;
12087 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java
12088 --- jdk-jdk-24-11.orig/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java 1970-01-01 01:00:00.000000000 +0100
12089 +++ jdk-jdk-24-11/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java 2024-08-17 20:36:14.298349771 +0200
12090 @@ -0,0 +1,821 @@
12092 + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
12093 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12095 + * This code is free software; you can redistribute it and/or modify it
12096 + * under the terms of the GNU General Public License version 2 only, as
12097 + * published by the Free Software Foundation. Oracle designates this
12098 + * particular file as subject to the "Classpath" exception as provided
12099 + * by Oracle in the LICENSE file that accompanied this code.
12101 + * This code is distributed in the hope that it will be useful, but WITHOUT
12102 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12103 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12104 + * version 2 for more details (a copy is included in the LICENSE file that
12105 + * accompanied this code).
12107 + * You should have received a copy of the GNU General Public License version
12108 + * 2 along with this work; if not, write to the Free Software Foundation,
12109 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12111 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12112 + * or visit www.oracle.com if you need additional information or have any
12113 + * questions.
12114 + */
12116 +package sun.nio.fs;
12118 +import java.nio.file.*;
12119 +import java.util.*;
12120 +import java.io.IOException;
12121 +import jdk.internal.misc.Unsafe;
12123 +import static sun.nio.fs.UnixConstants.*;
12125 +/**
12126 + * Solaris implementation of WatchService based on file events notification
12127 + * facility.
12128 + */
12130 +class SolarisWatchService
12131 + extends AbstractWatchService
12133 + private static final Unsafe unsafe = Unsafe.getUnsafe();
12134 + private static int addressSize = unsafe.addressSize();
12136 + private static int dependsArch(int value32, int value64) {
12137 + return (addressSize == 4) ? value32 : value64;
12140 + /*
12141 + * typedef struct port_event {
12142 + * int portev_events;
12143 + * ushort_t portev_source;
12144 + * ushort_t portev_pad;
12145 + * uintptr_t portev_object;
12146 + * void *portev_user;
12147 + * } port_event_t;
12148 + */
12149 + private static final int SIZEOF_PORT_EVENT = dependsArch(16, 24);
12150 + private static final int OFFSETOF_EVENTS = 0;
12151 + private static final int OFFSETOF_SOURCE = 4;
12152 + private static final int OFFSETOF_OBJECT = 8;
12154 + /*
12155 + * typedef struct file_obj {
12156 + * timestruc_t fo_atime;
12157 + * timestruc_t fo_mtime;
12158 + * timestruc_t fo_ctime;
12159 + * uintptr_t fo_pad[3];
12160 + * char *fo_name;
12161 + * } file_obj_t;
12162 + */
12163 + private static final int SIZEOF_FILEOBJ = dependsArch(40, 80);
12164 + private static final int OFFSET_FO_NAME = dependsArch(36, 72);
12166 + // port sources
12167 + private static final short PORT_SOURCE_USER = 3;
12168 + private static final short PORT_SOURCE_FILE = 7;
12170 + // user-watchable events
12171 + private static final int FILE_MODIFIED = 0x00000002;
12172 + private static final int FILE_ATTRIB = 0x00000004;
12173 + private static final int FILE_NOFOLLOW = 0x10000000;
12175 + // exception events
12176 + private static final int FILE_DELETE = 0x00000010;
12177 + private static final int FILE_RENAME_TO = 0x00000020;
12178 + private static final int FILE_RENAME_FROM = 0x00000040;
12179 + private static final int UNMOUNTED = 0x20000000;
12180 + private static final int MOUNTEDOVER = 0x40000000;
12182 + // background thread to read change events
12183 + private final Poller poller;
12185 + SolarisWatchService(UnixFileSystem fs) throws IOException {
12186 + int port = -1;
12187 + try {
12188 + port = portCreate();
12189 + } catch (UnixException x) {
12190 + throw new IOException(x.errorString());
12193 + this.poller = new Poller(fs, this, port);
12194 + this.poller.start();
12197 + @Override
12198 + WatchKey register(Path dir,
12199 + WatchEvent.Kind<?>[] events,
12200 + WatchEvent.Modifier... modifiers)
12201 + throws IOException
12203 + // delegate to poller
12204 + return poller.register(dir, events, modifiers);
12207 + @Override
12208 + void implClose() throws IOException {
12209 + // delegate to poller
12210 + poller.close();
12213 + /**
12214 + * WatchKey implementation
12215 + */
12216 + private class SolarisWatchKey extends AbstractWatchKey
12217 + implements DirectoryNode
12219 + private final UnixFileKey fileKey;
12221 + // pointer to native file_obj object
12222 + private final long object;
12224 + // events (may be changed). set to null when watch key is invalid
12225 + private volatile Set<? extends WatchEvent.Kind<?>> events;
12227 + // map of entries in directory; created lazily; accessed only by
12228 + // poller thread.
12229 + private Map<Path,EntryNode> children = new HashMap<>();
12231 + SolarisWatchKey(SolarisWatchService watcher,
12232 + UnixPath dir,
12233 + UnixFileKey fileKey,
12234 + long object,
12235 + Set<? extends WatchEvent.Kind<?>> events)
12237 + super(dir, watcher);
12238 + this.fileKey = fileKey;
12239 + this.object = object;
12240 + this.events = events;
12243 + UnixPath getDirectory() {
12244 + return (UnixPath)watchable();
12247 + UnixFileKey getFileKey() {
12248 + return fileKey;
12251 + @Override
12252 + public long object() {
12253 + return object;
12256 + void invalidate() {
12257 + events = null;
12260 + Set<? extends WatchEvent.Kind<?>> events() {
12261 + return events;
12264 + void setEvents(Set<? extends WatchEvent.Kind<?>> events) {
12265 + this.events = events;
12268 + Map<Path,EntryNode> children() {
12269 + return children;
12272 + @Override
12273 + public boolean isValid() {
12274 + return events != null;
12277 + @Override
12278 + public void cancel() {
12279 + if (isValid()) {
12280 + // delegate to poller
12281 + poller.cancel(this);
12285 + @Override
12286 + public void addChild(Path name, EntryNode node) {
12287 + children.put(name, node);
12290 + @Override
12291 + public void removeChild(Path name) {
12292 + children.remove(name);
12295 + @Override
12296 + public EntryNode getChild(Path name) {
12297 + return children.get(name);
12301 + /**
12302 + * Background thread to read from port
12303 + */
12304 + private class Poller extends AbstractPoller {
12306 + // maximum number of events to read per call to port_getn
12307 + private static final int MAX_EVENT_COUNT = 128;
12309 + // events that map to ENTRY_DELETE
12310 + private static final int FILE_REMOVED =
12311 + (FILE_DELETE|FILE_RENAME_TO|FILE_RENAME_FROM);
12313 + // events that tell us not to re-associate the object
12314 + private static final int FILE_EXCEPTION =
12315 + (FILE_REMOVED|UNMOUNTED|MOUNTEDOVER);
12317 + // address of event buffers (used to receive events with port_getn)
12318 + private final long bufferAddress;
12320 + private final SolarisWatchService watcher;
12322 + // the I/O port
12323 + private final int port;
12325 + // maps file key (dev/inode) to WatchKey
12326 + private final Map<UnixFileKey,SolarisWatchKey> fileKey2WatchKey;
12328 + // maps file_obj object to Node
12329 + private final Map<Long,Node> object2Node;
12331 + /**
12332 + * Create a new instance
12333 + */
12334 + Poller(UnixFileSystem fs, SolarisWatchService watcher, int port) {
12335 + this.watcher = watcher;
12336 + this.port = port;
12337 + this.bufferAddress =
12338 + unsafe.allocateMemory(SIZEOF_PORT_EVENT * MAX_EVENT_COUNT);
12339 + this.fileKey2WatchKey = new HashMap<UnixFileKey,SolarisWatchKey>();
12340 + this.object2Node = new HashMap<Long,Node>();
12343 + @Override
12344 + void wakeup() throws IOException {
12345 + // write to port to wakeup polling thread
12346 + try {
12347 + portSend(port, 0);
12348 + } catch (UnixException x) {
12349 + throw new IOException(x.errorString());
12353 + @Override
12354 + Object implRegister(Path obj,
12355 + Set<? extends WatchEvent.Kind<?>> events,
12356 + WatchEvent.Modifier... modifiers)
12358 + // no modifiers supported at this time
12359 + if (modifiers.length > 0) {
12360 + for (WatchEvent.Modifier modifier: modifiers) {
12361 + if (modifier == null)
12362 + return new NullPointerException();
12363 + if (!ExtendedOptions.SENSITIVITY_HIGH.matches(modifier) &&
12364 + !ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier) &&
12365 + !ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) {
12366 + return new UnsupportedOperationException("Modifier not supported");
12371 + UnixPath dir = (UnixPath)obj;
12373 + // check file is directory
12374 + UnixFileAttributes attrs = null;
12375 + try {
12376 + attrs = UnixFileAttributes.get(dir, true);
12377 + } catch (UnixException x) {
12378 + return x.asIOException(dir);
12380 + if (!attrs.isDirectory()) {
12381 + return new NotDirectoryException(dir.getPathForExceptionMessage());
12384 + // if already registered then update the events and return existing key
12385 + UnixFileKey fileKey = attrs.fileKey();
12386 + SolarisWatchKey watchKey = fileKey2WatchKey.get(fileKey);
12387 + if (watchKey != null) {
12388 + try {
12389 + updateEvents(watchKey, events);
12390 + } catch (UnixException x) {
12391 + return x.asIOException(dir);
12393 + return watchKey;
12396 + // register directory
12397 + long object = 0L;
12398 + try {
12399 + object = registerImpl(dir, (FILE_MODIFIED | FILE_ATTRIB));
12400 + } catch (UnixException x) {
12401 + return x.asIOException(dir);
12404 + // create watch key and insert it into maps
12405 + watchKey = new SolarisWatchKey(watcher, dir, fileKey, object, events);
12406 + object2Node.put(object, watchKey);
12407 + fileKey2WatchKey.put(fileKey, watchKey);
12409 + // register all entries in directory
12410 + registerChildren(dir, watchKey, false, false);
12412 + return watchKey;
12415 + // release resources for single entry
12416 + void releaseChild(EntryNode node) {
12417 + long object = node.object();
12418 + if (object != 0L) {
12419 + object2Node.remove(object);
12420 + releaseObject(object, true);
12421 + node.setObject(0L);
12425 + // release resources for entries in directory
12426 + void releaseChildren(SolarisWatchKey key) {
12427 + for (EntryNode node: key.children().values()) {
12428 + releaseChild(node);
12432 + // cancel single key
12433 + @Override
12434 + void implCancelKey(WatchKey obj) {
12435 + SolarisWatchKey key = (SolarisWatchKey)obj;
12436 + if (key.isValid()) {
12437 + fileKey2WatchKey.remove(key.getFileKey());
12439 + // release resources for entries
12440 + releaseChildren(key);
12442 + // release resources for directory
12443 + long object = key.object();
12444 + object2Node.remove(object);
12445 + releaseObject(object, true);
12447 + // and finally invalidate the key
12448 + key.invalidate();
12452 + // close watch service
12453 + @Override
12454 + void implCloseAll() {
12455 + // release all native resources
12456 + for (Long object: object2Node.keySet()) {
12457 + releaseObject(object, true);
12460 + // invalidate all keys
12461 + for (Map.Entry<UnixFileKey,SolarisWatchKey> entry: fileKey2WatchKey.entrySet()) {
12462 + entry.getValue().invalidate();
12465 + // clean-up
12466 + object2Node.clear();
12467 + fileKey2WatchKey.clear();
12469 + // free global resources
12470 + unsafe.freeMemory(bufferAddress);
12471 + UnixNativeDispatcher.close(port, e -> null);
12474 + /**
12475 + * Poller main loop. Blocks on port_getn waiting for events and then
12476 + * processes them.
12477 + */
12478 + @Override
12479 + public void run() {
12480 + try {
12481 + for (;;) {
12482 + int n = portGetn(port, bufferAddress, MAX_EVENT_COUNT);
12483 + assert n > 0;
12485 + long address = bufferAddress;
12486 + for (int i=0; i<n; i++) {
12487 + boolean shutdown = processEvent(address);
12488 + if (shutdown)
12489 + return;
12490 + address += SIZEOF_PORT_EVENT;
12493 + } catch (UnixException x) {
12494 + x.printStackTrace();
12498 + /**
12499 + * Process a single port_event
12501 + * Returns true if poller thread is requested to shutdown.
12502 + */
12503 + boolean processEvent(long address) {
12504 + // pe->portev_source
12505 + short source = unsafe.getShort(address + OFFSETOF_SOURCE);
12506 + // pe->portev_object
12507 + long object = unsafe.getAddress(address + OFFSETOF_OBJECT);
12508 + // pe->portev_events
12509 + int events = unsafe.getInt(address + OFFSETOF_EVENTS);
12511 + // user event is trigger to process pending requests
12512 + if (source != PORT_SOURCE_FILE) {
12513 + if (source == PORT_SOURCE_USER) {
12514 + // process any pending requests
12515 + boolean shutdown = processRequests();
12516 + if (shutdown)
12517 + return true;
12519 + return false;
12522 + // lookup object to get Node
12523 + Node node = object2Node.get(object);
12524 + if (node == null) {
12525 + // should not happen
12526 + return false;
12529 + // As a workaround for 6642290 and 6636438/6636412 we don't use
12530 + // FILE_EXCEPTION events to tell use not to register the file.
12531 + // boolean reregister = (events & FILE_EXCEPTION) == 0;
12532 + boolean reregister = true;
12534 + // If node is EntryNode then event relates to entry in directory
12535 + // If node is a SolarisWatchKey (DirectoryNode) then event relates
12536 + // to a watched directory.
12537 + boolean isDirectory = (node instanceof SolarisWatchKey);
12538 + if (isDirectory) {
12539 + processDirectoryEvents((SolarisWatchKey)node, events);
12540 + } else {
12541 + boolean ignore = processEntryEvents((EntryNode)node, events);
12542 + if (ignore)
12543 + reregister = false;
12546 + // need to re-associate to get further events
12547 + if (reregister) {
12548 + try {
12549 + events = FILE_MODIFIED | FILE_ATTRIB;
12550 + if (!isDirectory) events |= FILE_NOFOLLOW;
12551 + portAssociate(port,
12552 + PORT_SOURCE_FILE,
12553 + object,
12554 + events);
12555 + } catch (UnixException x) {
12556 + // unable to re-register
12557 + reregister = false;
12561 + // object is not re-registered so release resources. If
12562 + // object is a watched directory then signal key
12563 + if (!reregister) {
12564 + // release resources
12565 + object2Node.remove(object);
12566 + releaseObject(object, false);
12568 + // if watch key then signal it
12569 + if (isDirectory) {
12570 + SolarisWatchKey key = (SolarisWatchKey)node;
12571 + fileKey2WatchKey.remove( key.getFileKey() );
12572 + key.invalidate();
12573 + key.signal();
12574 + } else {
12575 + // if entry then remove it from parent
12576 + EntryNode entry = (EntryNode)node;
12577 + SolarisWatchKey key = (SolarisWatchKey)entry.parent();
12578 + key.removeChild(entry.name());
12582 + return false;
12585 + /**
12586 + * Process directory events. If directory is modified then re-scan
12587 + * directory to register any new entries
12588 + */
12589 + void processDirectoryEvents(SolarisWatchKey key, int mask) {
12590 + if ((mask & (FILE_MODIFIED | FILE_ATTRIB)) != 0) {
12591 + registerChildren(key.getDirectory(), key,
12592 + key.events().contains(StandardWatchEventKinds.ENTRY_CREATE),
12593 + key.events().contains(StandardWatchEventKinds.ENTRY_DELETE));
12597 + /**
12598 + * Process events for entries in registered directories. Returns {@code
12599 + * true} if events are ignored because the watch key has been cancelled.
12600 + */
12601 + boolean processEntryEvents(EntryNode node, int mask) {
12602 + SolarisWatchKey key = (SolarisWatchKey)node.parent();
12603 + Set<? extends WatchEvent.Kind<?>> events = key.events();
12604 + if (events == null) {
12605 + // key has been cancelled so ignore event
12606 + return true;
12609 + // entry modified
12610 + if (((mask & (FILE_MODIFIED | FILE_ATTRIB)) != 0) &&
12611 + events.contains(StandardWatchEventKinds.ENTRY_MODIFY))
12613 + key.signalEvent(StandardWatchEventKinds.ENTRY_MODIFY, node.name());
12617 + return false;
12620 + /**
12621 + * Registers all entries in the given directory
12623 + * The {@code sendCreateEvents} and {@code sendDeleteEvents} parameters
12624 + * indicates if ENTRY_CREATE and ENTRY_DELETE events should be queued
12625 + * when new entries are found. When initially registering a directory
12626 + * they will always be false. When re-scanning a directory then it
12627 + * depends on if the events are enabled or not.
12628 + */
12629 + void registerChildren(UnixPath dir,
12630 + SolarisWatchKey parent,
12631 + boolean sendCreateEvents,
12632 + boolean sendDeleteEvents)
12634 + boolean isModifyEnabled =
12635 + parent.events().contains(StandardWatchEventKinds.ENTRY_MODIFY) ;
12637 + // reset visited flag on entries so that we can detect file deletes
12638 + for (EntryNode node: parent.children().values()) {
12639 + node.setVisited(false);
12642 + try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
12643 + for (Path entry: stream) {
12644 + Path name = entry.getFileName();
12646 + // skip entry if already registered
12647 + EntryNode node = parent.getChild(name);
12648 + if (node != null) {
12649 + node.setVisited(true);
12650 + continue;
12653 + // new entry found
12655 + long object = 0L;
12656 + int errno = 0;
12657 + boolean addNode = false;
12659 + // if ENTRY_MODIFY enabled then we register the entry for events
12660 + if (isModifyEnabled) {
12661 + try {
12662 + UnixPath path = (UnixPath)entry;
12663 + int events = (FILE_NOFOLLOW | FILE_MODIFIED | FILE_ATTRIB);
12664 + object = registerImpl(path, events);
12665 + addNode = true;
12666 + } catch (UnixException x) {
12667 + errno = x.errno();
12669 + } else {
12670 + addNode = true;
12673 + if (addNode) {
12674 + // create node
12675 + node = new EntryNode(object, (UnixPath)entry.getFileName(), parent);
12676 + node.setVisited(true);
12677 + // tell the parent about it
12678 + parent.addChild(entry.getFileName(), node);
12679 + if (object != 0L)
12680 + object2Node.put(object, node);
12683 + // send ENTRY_CREATE event for the new file
12684 + // send ENTRY_DELETE event for files that were deleted immediately
12685 + boolean deleted = (errno == ENOENT);
12686 + if (sendCreateEvents && (addNode || deleted))
12687 + parent.signalEvent(StandardWatchEventKinds.ENTRY_CREATE, name);
12688 + if (sendDeleteEvents && deleted)
12689 + parent.signalEvent(StandardWatchEventKinds.ENTRY_DELETE, name);
12692 + } catch (DirectoryIteratorException | IOException x) {
12693 + // queue OVERFLOW event so that user knows to re-scan directory
12694 + parent.signalEvent(StandardWatchEventKinds.OVERFLOW, null);
12695 + return;
12698 + // clean-up and send ENTRY_DELETE events for any entries that were
12699 + // not found
12700 + Iterator<Map.Entry<Path,EntryNode>> iterator =
12701 + parent.children().entrySet().iterator();
12702 + while (iterator.hasNext()) {
12703 + Map.Entry<Path,EntryNode> entry = iterator.next();
12704 + EntryNode node = entry.getValue();
12705 + if (!node.isVisited()) {
12706 + long object = node.object();
12707 + if (object != 0L) {
12708 + object2Node.remove(object);
12709 + releaseObject(object, true);
12711 + if (sendDeleteEvents)
12712 + parent.signalEvent(StandardWatchEventKinds.ENTRY_DELETE, node.name());
12713 + iterator.remove();
12718 + /**
12719 + * Update watch key's events. If ENTRY_MODIFY changes to be enabled
12720 + * then register each file in the directory; If ENTRY_MODIFY changed to
12721 + * be disabled then unregister each file.
12722 + */
12723 + void updateEvents(SolarisWatchKey key, Set<? extends WatchEvent.Kind<?>> events)
12724 + throws UnixException
12727 + // update events, remembering if ENTRY_MODIFY was previously
12728 + // enabled or disabled.
12729 + boolean oldModifyEnabled = key.events()
12730 + .contains(StandardWatchEventKinds.ENTRY_MODIFY);
12731 + key.setEvents(events);
12733 + // check if ENTRY_MODIFY has changed
12734 + boolean newModifyEnabled = events
12735 + .contains(StandardWatchEventKinds.ENTRY_MODIFY);
12736 + if (newModifyEnabled != oldModifyEnabled) {
12737 + UnixException ex = null;
12738 + for (EntryNode node: key.children().values()) {
12739 + if (newModifyEnabled) {
12740 + // register
12741 + UnixPath path = key.getDirectory().resolve(node.name());
12742 + int ev = (FILE_NOFOLLOW | FILE_MODIFIED | FILE_ATTRIB);
12743 + try {
12744 + long object = registerImpl(path, ev);
12745 + object2Node.put(object, node);
12746 + node.setObject(object);
12747 + } catch (UnixException x) {
12748 + // if file has been deleted then it will be detected
12749 + // as a FILE_MODIFIED event on the directory
12750 + if (x.errno() != ENOENT) {
12751 + ex = x;
12752 + break;
12755 + } else {
12756 + // unregister
12757 + releaseChild(node);
12761 + // an error occurred
12762 + if (ex != null) {
12763 + releaseChildren(key);
12764 + throw ex;
12769 + /**
12770 + * Calls port_associate to register the given path.
12771 + * Returns pointer to fileobj structure that is allocated for
12772 + * the registration.
12773 + */
12774 + long registerImpl(UnixPath dir, int events)
12775 + throws UnixException
12777 + // allocate memory for the path (file_obj->fo_name field)
12778 + byte[] path = dir.getByteArrayForSysCalls();
12779 + int len = path.length;
12780 + long name = unsafe.allocateMemory(len+1);
12781 + unsafe.copyMemory(path, Unsafe.ARRAY_BYTE_BASE_OFFSET, null,
12782 + name, (long)len);
12783 + unsafe.putByte(name + len, (byte)0);
12785 + // allocate memory for filedatanode structure - this is the object
12786 + // to port_associate
12787 + long object = unsafe.allocateMemory(SIZEOF_FILEOBJ);
12788 + unsafe.setMemory(null, object, SIZEOF_FILEOBJ, (byte)0);
12789 + unsafe.putAddress(object + OFFSET_FO_NAME, name);
12791 + // associate the object with the port
12792 + try {
12793 + portAssociate(port,
12794 + PORT_SOURCE_FILE,
12795 + object,
12796 + events);
12797 + } catch (UnixException x) {
12798 + // debugging
12799 + if (x.errno() == EAGAIN) {
12800 + System.err.println("The maximum number of objects associated "+
12801 + "with the port has been reached");
12804 + unsafe.freeMemory(name);
12805 + unsafe.freeMemory(object);
12806 + throw x;
12808 + return object;
12811 + /**
12812 + * Frees all resources for an file_obj object; optionally remove
12813 + * association from port
12814 + */
12815 + void releaseObject(long object, boolean dissociate) {
12816 + // remove association
12817 + if (dissociate) {
12818 + try {
12819 + portDissociate(port, PORT_SOURCE_FILE, object);
12820 + } catch (UnixException x) {
12821 + // ignore
12825 + // free native memory
12826 + long name = unsafe.getAddress(object + OFFSET_FO_NAME);
12827 + unsafe.freeMemory(name);
12828 + unsafe.freeMemory(object);
12832 + /**
12833 + * A node with native (file_obj) resources
12834 + */
12835 + private static interface Node {
12836 + long object();
12839 + /**
12840 + * A directory node with a map of the entries in the directory
12841 + */
12842 + private static interface DirectoryNode extends Node {
12843 + void addChild(Path name, EntryNode node);
12844 + void removeChild(Path name);
12845 + EntryNode getChild(Path name);
12848 + /**
12849 + * An implementation of a node that is an entry in a directory.
12850 + */
12851 + private static class EntryNode implements Node {
12852 + private long object;
12853 + private final UnixPath name;
12854 + private final DirectoryNode parent;
12855 + private boolean visited;
12857 + EntryNode(long object, UnixPath name, DirectoryNode parent) {
12858 + this.object = object;
12859 + this.name = name;
12860 + this.parent = parent;
12863 + @Override
12864 + public long object() {
12865 + return object;
12868 + void setObject(long ptr) {
12869 + this.object = ptr;
12872 + UnixPath name() {
12873 + return name;
12876 + DirectoryNode parent() {
12877 + return parent;
12880 + boolean isVisited() {
12881 + return visited;
12884 + void setVisited(boolean v) {
12885 + this.visited = v;
12889 + // -- native methods --
12891 + private static native void init();
12893 + private static native int portCreate() throws UnixException;
12895 + private static native void portAssociate(int port, int source, long object, int events)
12896 + throws UnixException;
12898 + private static native void portDissociate(int port, int source, long object)
12899 + throws UnixException;
12901 + private static native void portSend(int port, int events)
12902 + throws UnixException;
12904 + private static native int portGetn(int port, long address, int max)
12905 + throws UnixException;
12907 + static {
12908 + jdk.internal.loader.BootLoader.loadLibrary("nio");
12909 + init();
12912 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libjava/ProcessHandleImpl_solaris.c jdk-jdk-24-11/src/java.base/solaris/native/libjava/ProcessHandleImpl_solaris.c
12913 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libjava/ProcessHandleImpl_solaris.c 1970-01-01 01:00:00.000000000 +0100
12914 +++ jdk-jdk-24-11/src/java.base/solaris/native/libjava/ProcessHandleImpl_solaris.c 2024-08-17 20:36:14.298710976 +0200
12915 @@ -0,0 +1,51 @@
12917 + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
12918 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12920 + * This code is free software; you can redistribute it and/or modify it
12921 + * under the terms of the GNU General Public License version 2 only, as
12922 + * published by the Free Software Foundation. Oracle designates this
12923 + * particular file as subject to the "Classpath" exception as provided
12924 + * by Oracle in the LICENSE file that accompanied this code.
12926 + * This code is distributed in the hope that it will be useful, but WITHOUT
12927 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12928 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12929 + * version 2 for more details (a copy is included in the LICENSE file that
12930 + * accompanied this code).
12932 + * You should have received a copy of the GNU General Public License version
12933 + * 2 along with this work; if not, write to the Free Software Foundation,
12934 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12936 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12937 + * or visit www.oracle.com if you need additional information or have any
12938 + * questions.
12939 + */
12941 +#include "jni.h"
12943 +#include "ProcessHandleImpl_unix.h"
12945 +#include <procfs.h>
12948 + * Implementation of native ProcessHandleImpl functions for Solaris.
12949 + * See ProcessHandleImpl_unix.c for more details.
12950 + */
12952 +void os_initNative(JNIEnv *env, jclass clazz) {}
12954 +jint os_getChildren(JNIEnv *env, jlong jpid, jlongArray jarray,
12955 + jlongArray jparentArray, jlongArray jstimesArray) {
12956 + return unix_getChildren(env, jpid, jarray, jparentArray, jstimesArray);
12959 +pid_t os_getParentPidAndTimings(JNIEnv *env, pid_t pid, jlong *total, jlong *start) {
12960 + return unix_getParentPidAndTimings(env, pid, total, start);
12963 +void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) {
12964 + unix_getCmdlineAndUserInfo(env, jinfo, pid);
12967 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_db/libjvm_db.c jdk-jdk-24-11/src/java.base/solaris/native/libjvm_db/libjvm_db.c
12968 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_db/libjvm_db.c 1970-01-01 01:00:00.000000000 +0100
12969 +++ jdk-jdk-24-11/src/java.base/solaris/native/libjvm_db/libjvm_db.c 2024-08-17 20:36:14.299630209 +0200
12970 @@ -0,0 +1,1552 @@
12972 + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
12973 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12975 + * This code is free software; you can redistribute it and/or modify it
12976 + * under the terms of the GNU General Public License version 2 only, as
12977 + * published by the Free Software Foundation.
12979 + * This code is distributed in the hope that it will be useful, but WITHOUT
12980 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12981 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12982 + * version 2 for more details (a copy is included in the LICENSE file that
12983 + * accompanied this code).
12985 + * You should have received a copy of the GNU General Public License version
12986 + * 2 along with this work; if not, write to the Free Software Foundation,
12987 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12989 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12990 + * or visit www.oracle.com if you need additional information or have any
12991 + * questions.
12993 + */
12995 +#include <stdio.h>
12996 +#include <stdlib.h>
12997 +#include <string.h>
12998 +#include <errno.h>
12999 +#include <gelf.h>
13001 +#include "libjvm_db.h"
13002 +#include "JvmOffsets.h"
13004 +#define LIBJVM_SO "libjvm.so"
13006 +#if defined(i386) || defined(__i386) || defined(__amd64)
13007 +#ifdef COMPILER2
13008 +#define X86_COMPILER2
13009 +#endif /* COMPILER2 */
13010 +#endif /* i386 */
13012 +typedef struct {
13013 + short vf_cnt; /* number of recognized java vframes */
13014 + short bci; /* current frame method byte code index */
13015 + int line; /* current frame method source line */
13016 + uint64_t new_fp; /* fp for the next frame */
13017 + uint64_t new_pc; /* pc for the next frame */
13018 + uint64_t new_sp; /* "raw" sp for the next frame (includes extension by interpreter/adapter */
13019 + char locinf; /* indicates there is valid location info */
13020 +} Jframe_t;
13022 +int Jlookup_by_regs(jvm_agent_t* J, const prgregset_t regs, char *name,
13023 + size_t size, Jframe_t *jframe);
13025 +int main(int arg) { return arg; }
13027 +static int debug = 0;
13029 +static void failed(int err, const char * file, int line) {
13030 + if (debug) {
13031 + fprintf(stderr, "failed %d at %s:%d\n", err, file, line);
13035 +static void warn(const char * file, int line, const char * msg) {
13036 + if (debug) {
13037 + fprintf(stderr, "warning: %s at %s:%d\n", msg, file, line);
13041 +static void warn1(const char * file, int line, const char * msg, intptr_t arg1) {
13042 + if (debug) {
13043 + fprintf(stderr, "warning: ");
13044 + fprintf(stderr, msg, arg1);
13045 + fprintf(stderr, " at %s:%d\n", file, line);
13049 +#define CHECK_FAIL(err) \
13050 + if (err != PS_OK) { failed(err, __FILE__, __LINE__); goto fail; }
13051 +#define WARN(msg) warn(__FILE__, __LINE__, msg)
13052 +#define WARN1(msg, arg1) warn1(__FILE__, __LINE__, msg, arg1)
13054 +typedef struct VMStructEntry {
13055 + const char * typeName; /* The type name containing the given field (example: "Klass") */
13056 + const char * fieldName; /* The field name within the type (example: "_name") */
13057 + uint64_t address; /* Address of field; only used for static fields */
13058 + /* ("offset" can not be reused because of apparent solstudio compiler bug */
13059 + /* in generation of initializer data) */
13060 +} VMStructEntry;
13062 +/* Prototyping inlined methods */
13064 +int sprintf(char *s, const char *format, ...);
13066 +#define SZ16 sizeof(int16_t)
13067 +#define SZ32 sizeof(int32_t)
13069 +#define COMP_METHOD_SIGN '*'
13071 +#define MAX_VFRAMES_CNT 256
13073 +typedef struct vframe {
13074 + uint64_t method;
13075 + int32_t sender_decode_offset;
13076 + int32_t methodIdx;
13077 + int32_t bci;
13078 + int32_t line;
13079 +} Vframe_t;
13081 +typedef struct frame {
13082 + uintptr_t fp;
13083 + uintptr_t pc;
13084 + uintptr_t sp;
13085 + uintptr_t sender_sp; // The unextended sp of the caller
13086 +} Frame_t;
13088 +typedef struct Nmethod_t {
13089 + struct jvm_agent* J;
13090 + Jframe_t *jframe;
13092 + uint64_t nm; /* _nmethod */
13093 + uint64_t pc;
13094 + uint64_t pc_desc;
13096 + int32_t orig_pc_offset; /* _orig_pc_offset */
13097 + uint64_t instrs_beg; /* _code_offset */
13098 + uint64_t instrs_end;
13099 + uint64_t deopt_beg; /* _deoptimize_offset */
13100 + uint64_t scopes_data_beg; /* _scopes_data_begin */
13101 + int32_t scopes_data_end;
13102 + int32_t metadata_beg; /* _metadata_offset */
13103 + int32_t metadata_end;
13104 + int32_t scopes_pcs_beg; /* _scopes_pcs_offset */
13105 + int32_t scopes_pcs_end;
13107 + int vf_cnt;
13108 + Vframe_t vframes[MAX_VFRAMES_CNT];
13109 +} Nmethod_t;
13111 +struct jvm_agent {
13112 + struct ps_prochandle* P;
13114 + uint64_t nmethod_vtbl;
13115 + uint64_t CodeBlob_vtbl;
13116 + uint64_t BufferBlob_vtbl;
13117 + uint64_t RuntimeStub_vtbl;
13118 + uint64_t Method_vtbl;
13120 + uint64_t Use_Compressed_Oops_address;
13121 + uint64_t Universe_narrow_oop_base_address;
13122 + uint64_t Universe_narrow_oop_shift_address;
13123 + uint64_t CodeCache_heaps_address;
13125 + /* Volatiles */
13126 + uint8_t Use_Compressed_Oops;
13127 + uint64_t Universe_narrow_oop_base;
13128 + uint32_t Universe_narrow_oop_shift;
13129 + // Code cache heaps
13130 + int32_t Number_of_heaps;
13131 + uint64_t* Heap_low;
13132 + uint64_t* Heap_high;
13133 + uint64_t* Heap_segmap_low;
13134 + uint64_t* Heap_segmap_high;
13136 + int32_t SIZE_CodeCache_log2_segment;
13138 + uint64_t methodPtr;
13139 + uint64_t bcp;
13141 + Nmethod_t *N; /*Inlined methods support */
13142 + Frame_t prev_fr;
13143 + Frame_t curr_fr;
13146 +static int
13147 +read_string(struct ps_prochandle *P,
13148 + char *buf, /* caller's buffer */
13149 + size_t size, /* upper limit on bytes to read */
13150 + uintptr_t addr) /* address in process */
13152 + int err = PS_OK;
13153 + while (size-- > 1 && err == PS_OK) {
13154 + err = ps_pread(P, addr, buf, 1);
13155 + if (*buf == '\0') {
13156 + return PS_OK;
13158 + addr += 1;
13159 + buf += 1;
13161 + return -1;
13164 +static int read_compressed_pointer(jvm_agent_t* J, uint64_t base, uint32_t *ptr) {
13165 + int err = -1;
13166 + uint32_t ptr32;
13167 + err = ps_pread(J->P, base, &ptr32, sizeof(uint32_t));
13168 + *ptr = ptr32;
13169 + return err;
13172 +static int read_pointer(jvm_agent_t* J, uint64_t base, uint64_t* ptr) {
13173 + int err = -1;
13174 + uint32_t ptr32;
13176 + switch (DATA_MODEL) {
13177 + case PR_MODEL_LP64:
13178 + err = ps_pread(J->P, base, ptr, sizeof(uint64_t));
13179 + break;
13180 + case PR_MODEL_ILP32:
13181 + err = ps_pread(J->P, base, &ptr32, sizeof(uint32_t));
13182 + *ptr = ptr32;
13183 + break;
13186 + return err;
13189 +static int read_string_pointer(jvm_agent_t* J, uint64_t base, const char ** stringp) {
13190 + uint64_t ptr;
13191 + int err;
13192 + char buffer[1024];
13194 + *stringp = NULL;
13195 + err = read_pointer(J, base, &ptr);
13196 + CHECK_FAIL(err);
13197 + if (ptr != 0) {
13198 + err = read_string(J->P, buffer, sizeof(buffer), ptr);
13199 + CHECK_FAIL(err);
13200 + *stringp = strdup(buffer);
13202 + return PS_OK;
13204 + fail:
13205 + return err;
13208 +static int parse_vmstruct_entry(jvm_agent_t* J, uint64_t base, VMStructEntry* vmp) {
13209 + uint64_t ptr;
13210 + int err;
13212 + err = read_string_pointer(J, base + OFFSET_VMStructEntrytypeName, &vmp->typeName);
13213 + CHECK_FAIL(err);
13214 + err = read_string_pointer(J, base + OFFSET_VMStructEntryfieldName, &vmp->fieldName);
13215 + CHECK_FAIL(err);
13216 + err = read_pointer(J, base + OFFSET_VMStructEntryaddress, &vmp->address);
13217 + CHECK_FAIL(err);
13219 + return PS_OK;
13221 + fail:
13222 + if (vmp->typeName != NULL) free((void*)vmp->typeName);
13223 + if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
13224 + return err;
13227 +static int parse_vmstructs(jvm_agent_t* J) {
13228 + VMStructEntry vmVar;
13229 + VMStructEntry* vmp = &vmVar;
13230 + uint64_t gHotSpotVMStructs;
13231 + psaddr_t sym_addr;
13232 + uint64_t base;
13233 + int err;
13235 + /* Clear *vmp now in case we jump to fail: */
13236 + memset(vmp, 0, sizeof(VMStructEntry));
13238 + err = ps_pglobal_lookup(J->P, LIBJVM_SO, "gHotSpotVMStructs", &sym_addr);
13239 + CHECK_FAIL(err);
13240 + err = read_pointer(J, sym_addr, &gHotSpotVMStructs);
13241 + CHECK_FAIL(err);
13242 + base = gHotSpotVMStructs;
13244 + err = PS_OK;
13245 + while (err == PS_OK) {
13246 + memset(vmp, 0, sizeof(VMStructEntry));
13247 + err = parse_vmstruct_entry(J, base, vmp);
13248 + if (err != PS_OK || vmp->typeName == NULL) {
13249 + break;
13252 + if (vmp->typeName[0] == 'C' && strcmp("CodeCache", vmp->typeName) == 0) {
13253 + /* Read _heaps field of type GrowableArray<CodeHeaps*>* */
13254 + if (strcmp("_heaps", vmp->fieldName) == 0) {
13255 + err = read_pointer(J, vmp->address, &J->CodeCache_heaps_address);
13257 + } else if (vmp->typeName[0] == 'U' && strcmp("Universe", vmp->typeName) == 0) {
13258 + if (strcmp("_narrow_oop._base", vmp->fieldName) == 0) {
13259 + J->Universe_narrow_oop_base_address = vmp->address;
13261 + if (strcmp("_narrow_oop._shift", vmp->fieldName) == 0) {
13262 + J->Universe_narrow_oop_shift_address = vmp->address;
13265 + CHECK_FAIL(err);
13267 + base += SIZE_VMStructEntry;
13268 + if (vmp->typeName != NULL) free((void*)vmp->typeName);
13269 + if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
13272 + return PS_OK;
13274 + fail:
13275 + if (vmp->typeName != NULL) free((void*)vmp->typeName);
13276 + if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
13277 + return -1;
13280 +static int find_symbol(jvm_agent_t* J, const char *name, uint64_t* valuep) {
13281 + psaddr_t sym_addr;
13282 + int err;
13284 + err = ps_pglobal_lookup(J->P, LIBJVM_SO, name, &sym_addr);
13285 + if (err != PS_OK) goto fail;
13286 + *valuep = sym_addr;
13287 + return PS_OK;
13289 + fail:
13290 + return err;
13293 +static int read_volatiles(jvm_agent_t* J) {
13294 + int i;
13295 + uint64_t array_data;
13296 + uint64_t code_heap_address;
13297 + int err;
13299 + err = find_symbol(J, "UseCompressedOops", &J->Use_Compressed_Oops_address);
13300 + if (err == PS_OK) {
13301 + err = ps_pread(J->P, J->Use_Compressed_Oops_address, &J->Use_Compressed_Oops, sizeof(uint8_t));
13302 + CHECK_FAIL(err);
13303 + } else {
13304 + J->Use_Compressed_Oops = 0;
13307 + err = read_pointer(J, J->Universe_narrow_oop_base_address, &J->Universe_narrow_oop_base);
13308 + CHECK_FAIL(err);
13309 + err = ps_pread(J->P, J->Universe_narrow_oop_shift_address, &J->Universe_narrow_oop_shift, sizeof(uint32_t));
13310 + CHECK_FAIL(err);
13312 + /* CodeCache_heaps_address points to GrowableArray<CodeHeaps*>, read _data field
13313 + pointing to the first entry of type CodeCache* in the array */
13314 + err = read_pointer(J, J->CodeCache_heaps_address + OFFSET_GrowableArray_CodeHeap_data, &array_data);
13315 + /* Read _len field containing the number of code heaps */
13316 + err = ps_pread(J->P, J->CodeCache_heaps_address + OFFSET_GrowableArray_CodeHeap_len,
13317 + &J->Number_of_heaps, sizeof(J->Number_of_heaps));
13319 + /* Allocate memory for heap configurations */
13320 + J->Heap_low = (uint64_t*)calloc(J->Number_of_heaps, sizeof(uint64_t));
13321 + J->Heap_high = (uint64_t*)calloc(J->Number_of_heaps, sizeof(uint64_t));
13322 + J->Heap_segmap_low = (uint64_t*)calloc(J->Number_of_heaps, sizeof(uint64_t));
13323 + J->Heap_segmap_high = (uint64_t*)calloc(J->Number_of_heaps, sizeof(uint64_t));
13325 + /* Read code heap configurations */
13326 + for (i = 0; i < J->Number_of_heaps; ++i) {
13327 + /* Read address of heap */
13328 + err = read_pointer(J, array_data, &code_heap_address);
13329 + CHECK_FAIL(err);
13331 + err = read_pointer(J, code_heap_address + OFFSET_CodeHeap_memory +
13332 + OFFSET_VirtualSpace_low, &J->Heap_low[i]);
13333 + CHECK_FAIL(err);
13334 + err = read_pointer(J, code_heap_address + OFFSET_CodeHeap_memory +
13335 + OFFSET_VirtualSpace_high, &J->Heap_high[i]);
13336 + CHECK_FAIL(err);
13337 + err = read_pointer(J, code_heap_address + OFFSET_CodeHeap_segmap +
13338 + OFFSET_VirtualSpace_low, &J->Heap_segmap_low[i]);
13339 + CHECK_FAIL(err);
13340 + err = read_pointer(J, code_heap_address + OFFSET_CodeHeap_segmap +
13341 + OFFSET_VirtualSpace_high, &J->Heap_segmap_high[i]);
13342 + CHECK_FAIL(err);
13344 + /* Increment pointer to next entry */
13345 + array_data = array_data + POINTER_SIZE;
13348 + err = ps_pread(J->P, code_heap_address + OFFSET_CodeHeap_log2_segment_size,
13349 + &J->SIZE_CodeCache_log2_segment, sizeof(J->SIZE_CodeCache_log2_segment));
13350 + CHECK_FAIL(err);
13352 + return PS_OK;
13354 + fail:
13355 + return err;
13358 +static int codeheap_contains(int heap_num, jvm_agent_t* J, uint64_t ptr) {
13359 + return (J->Heap_low[heap_num] <= ptr && ptr < J->Heap_high[heap_num]);
13362 +static int codecache_contains(jvm_agent_t* J, uint64_t ptr) {
13363 + int i;
13364 + for (i = 0; i < J->Number_of_heaps; ++i) {
13365 + if (codeheap_contains(i, J, ptr)) {
13366 + return 1;
13369 + return 0;
13372 +static uint64_t segment_for(int heap_num, jvm_agent_t* J, uint64_t p) {
13373 + return (p - J->Heap_low[heap_num]) >> J->SIZE_CodeCache_log2_segment;
13376 +static uint64_t block_at(int heap_num, jvm_agent_t* J, int i) {
13377 + return J->Heap_low[heap_num] + (i << J->SIZE_CodeCache_log2_segment);
13380 +static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
13381 + int err;
13382 + int i;
13384 + for (i = 0; i < J->Number_of_heaps; ++i) {
13385 + *startp = 0;
13386 + if (codeheap_contains(i, J, ptr)) {
13387 + int32_t used;
13388 + uint64_t segment = segment_for(i, J, ptr);
13389 + uint64_t block = J->Heap_segmap_low[i];
13390 + uint8_t tag;
13391 + err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
13392 + CHECK_FAIL(err);
13393 + if (tag == 0xff)
13394 + return PS_OK;
13395 + while (tag > 0) {
13396 + err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
13397 + CHECK_FAIL(err);
13398 + segment -= tag;
13400 + block = block_at(i, J, segment);
13401 + err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
13402 + CHECK_FAIL(err);
13403 + if (used) {
13404 + *startp = block + SIZE_HeapBlockHeader;
13407 + return PS_OK;
13410 + fail:
13411 + return -1;
13414 +static int find_jlong_constant(jvm_agent_t* J, const char *name, uint64_t* valuep) {
13415 + psaddr_t sym_addr;
13416 + int err = ps_pglobal_lookup(J->P, LIBJVM_SO, name, &sym_addr);
13417 + if (err == PS_OK) {
13418 + err = ps_pread(J->P, sym_addr, valuep, sizeof(uint64_t));
13419 + return err;
13421 + *valuep = -1;
13422 + return -1;
13425 +jvm_agent_t *Jagent_create(struct ps_prochandle *P, int vers) {
13426 + jvm_agent_t* J;
13427 + int err;
13429 + if (vers != JVM_DB_VERSION) {
13430 + errno = ENOTSUP;
13431 + return NULL;
13434 + J = (jvm_agent_t*)calloc(sizeof(struct jvm_agent), 1);
13436 + debug = getenv("LIBJVMDB_DEBUG") != NULL;
13437 + if (debug) debug = 3;
13439 + if (debug) {
13440 + fprintf(stderr, "Jagent_create: debug=%d\n", debug);
13441 +#ifdef X86_COMPILER2
13442 + fprintf(stderr, "Jagent_create: R_SP=%d, R_FP=%d, POINTER_SIZE=%d\n", R_SP, R_FP, POINTER_SIZE);
13443 +#endif /* X86_COMPILER2 */
13446 + J->P = P;
13448 + // Initialize the initial previous frame
13450 + J->prev_fr.fp = 0;
13451 + J->prev_fr.pc = 0;
13452 + J->prev_fr.sp = 0;
13453 + J->prev_fr.sender_sp = 0;
13455 + err = find_symbol(J, "__1cHnmethodG__vtbl_", &J->nmethod_vtbl);
13456 + CHECK_FAIL(err);
13457 + err = find_symbol(J, "__1cKBufferBlobG__vtbl_", &J->BufferBlob_vtbl);
13458 + if (err != PS_OK) J->BufferBlob_vtbl = 0;
13459 + err = find_symbol(J, "__1cICodeBlobG__vtbl_", &J->CodeBlob_vtbl);
13460 + CHECK_FAIL(err);
13461 + err = find_symbol(J, "__1cLRuntimeStubG__vtbl_", &J->RuntimeStub_vtbl);
13462 + CHECK_FAIL(err);
13463 + err = find_symbol(J, "__1cGMethodG__vtbl_", &J->Method_vtbl);
13464 + CHECK_FAIL(err);
13466 + err = parse_vmstructs(J);
13467 + CHECK_FAIL(err);
13468 + err = read_volatiles(J);
13469 + CHECK_FAIL(err);
13471 + return J;
13473 + fail:
13474 + Jagent_destroy(J);
13475 + return NULL;
13478 +void Jagent_destroy(jvm_agent_t *J) {
13479 + if (J != NULL) {
13480 + free(J);
13484 +static int is_method(jvm_agent_t* J, uint64_t methodPtr) {
13485 + uint64_t klass;
13486 + int err = read_pointer(J, methodPtr, &klass);
13487 + if (err != PS_OK) goto fail;
13488 + return klass == J->Method_vtbl;
13490 + fail:
13491 + return 0;
13494 +static int
13495 +name_for_methodPtr(jvm_agent_t* J, uint64_t methodPtr, char * result, size_t size)
13497 + short nameIndex;
13498 + short signatureIndex;
13499 + uint64_t constantPool;
13500 + uint64_t constMethod;
13501 + uint64_t nameSymbol;
13502 + uint64_t signatureSymbol;
13503 + uint64_t klassPtr;
13504 + uint64_t klassSymbol;
13505 + short klassSymbolLength;
13506 + short nameSymbolLength;
13507 + short signatureSymbolLength;
13508 + char * nameString = NULL;
13509 + char * klassString = NULL;
13510 + char * signatureString = NULL;
13511 + int err;
13513 + err = read_pointer(J, methodPtr + OFFSET_Method_constMethod, &constMethod);
13514 + CHECK_FAIL(err);
13515 + err = read_pointer(J, constMethod + OFFSET_ConstMethod_constants, &constantPool);
13516 + CHECK_FAIL(err);
13518 + /* To get name string */
13519 + err = ps_pread(J->P, constMethod + OFFSET_ConstMethod_name_index, &nameIndex, 2);
13520 + CHECK_FAIL(err);
13521 + err = read_pointer(J, constantPool + nameIndex * POINTER_SIZE + SIZE_ConstantPool, &nameSymbol);
13522 + CHECK_FAIL(err);
13523 + // The symbol is a CPSlot and has lower bit set to indicate metadata
13524 + nameSymbol &= (~1); // remove metadata lsb
13525 + err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_length, &nameSymbolLength, 2);
13526 + CHECK_FAIL(err);
13527 + nameString = (char*)calloc(nameSymbolLength + 1, 1);
13528 + err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_body, nameString, nameSymbolLength);
13529 + CHECK_FAIL(err);
13531 + /* To get signature string */
13532 + err = ps_pread(J->P, constMethod + OFFSET_ConstMethod_signature_index, &signatureIndex, 2);
13533 + CHECK_FAIL(err);
13534 + err = read_pointer(J, constantPool + signatureIndex * POINTER_SIZE + SIZE_ConstantPool, &signatureSymbol);
13535 + CHECK_FAIL(err);
13536 + signatureSymbol &= (~1); // remove metadata lsb
13537 + err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_length, &signatureSymbolLength, 2);
13538 + CHECK_FAIL(err);
13539 + signatureString = (char*)calloc(signatureSymbolLength + 1, 1);
13540 + err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_body, signatureString, signatureSymbolLength);
13541 + CHECK_FAIL(err);
13543 + /* To get klass string */
13544 + err = read_pointer(J, constantPool + OFFSET_ConstantPool_pool_holder, &klassPtr);
13545 + CHECK_FAIL(err);
13546 + err = read_pointer(J, klassPtr + OFFSET_Klass_name, &klassSymbol);
13547 + CHECK_FAIL(err);
13548 + err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_length, &klassSymbolLength, 2);
13549 + CHECK_FAIL(err);
13550 + klassString = (char*)calloc(klassSymbolLength + 1, 1);
13551 + err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_body, klassString, klassSymbolLength);
13552 + CHECK_FAIL(err);
13554 + result[0] = '\0';
13555 + if (snprintf(result, size,
13556 + "%s.%s%s",
13557 + klassString,
13558 + nameString,
13559 + signatureString) >= size) {
13560 + // truncation
13561 + goto fail;
13564 + if (nameString != NULL) free(nameString);
13565 + if (klassString != NULL) free(klassString);
13566 + if (signatureString != NULL) free(signatureString);
13568 + return PS_OK;
13570 + fail:
13571 + if (debug) {
13572 + fprintf(stderr, "name_for_methodPtr: FAIL \n\n");
13574 + if (nameString != NULL) free(nameString);
13575 + if (klassString != NULL) free(klassString);
13576 + if (signatureString != NULL) free(signatureString);
13577 + return -1;
13580 +static int nmethod_info(Nmethod_t *N)
13582 + jvm_agent_t *J = N->J;
13583 + uint64_t nm = N->nm;
13584 + int32_t err;
13586 + if (debug > 2 )
13587 + fprintf(stderr, "\t nmethod_info: BEGIN \n");
13589 + /* Instructions */
13590 + err = read_pointer(J, nm + OFFSET_CodeBlob_code_begin, &N->instrs_beg);
13591 + CHECK_FAIL(err);
13592 + err = read_pointer(J, nm + OFFSET_CodeBlob_code_end, &N->instrs_end);
13593 + CHECK_FAIL(err);
13594 + err = read_pointer(J, nm + OFFSET_nmethod_deopt_handler_begin, &N->deopt_beg);
13595 + CHECK_FAIL(err);
13596 + err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32);
13597 + CHECK_FAIL(err);
13599 + /* Metadata */
13600 + err = ps_pread(J->P, nm + OFFSET_nmethod_metadata_offset, &N->metadata_beg, SZ32);
13601 + CHECK_FAIL(err);
13602 + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->metadata_end, SZ32);
13603 + CHECK_FAIL(err);
13605 + /* scopes_pcs */
13606 + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_pcs_offset, &N->scopes_pcs_beg, SZ32);
13607 + CHECK_FAIL(err);
13608 + err = ps_pread(J->P, nm + OFFSET_nmethod_dependencies_offset, &N->scopes_pcs_end, SZ32);
13609 + CHECK_FAIL(err);
13611 + /* scopes_data */
13612 + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->scopes_data_beg, POINTER_SIZE);
13613 + CHECK_FAIL(err);
13615 + if (debug > 2 ) {
13616 + N->scopes_data_end = N->scopes_pcs_beg;
13618 + fprintf(stderr, "\t nmethod_info: instrs_beg: %#x, instrs_end: %#x\n",
13619 + N->instrs_beg, N->instrs_end);
13621 + fprintf(stderr, "\t nmethod_info: deopt_beg: %#x \n",
13622 + N->deopt_beg);
13624 + fprintf(stderr, "\t nmethod_info: orig_pc_offset: %#x \n",
13625 + N->orig_pc_offset);
13627 + fprintf(stderr, "\t nmethod_info: metadata_beg: %#x, metadata_end: %#x\n",
13628 + N->metadata_beg, N->metadata_end);
13630 + fprintf(stderr, "\t nmethod_info: scopes_data_beg: %#x, scopes_data_end: %#x\n",
13631 + N->scopes_data_beg, N->scopes_data_end);
13633 + fprintf(stderr, "\t nmethod_info: scopes_pcs_beg: %#x, scopes_pcs_end: %#x\n",
13634 + N->scopes_pcs_beg, N->scopes_pcs_end);
13636 + fprintf(stderr, "\t nmethod_info: END \n\n");
13638 + return PS_OK;
13640 + fail:
13641 + return err;
13644 +static int
13645 +raw_read_int(jvm_agent_t* J, uint64_t *buffer, int32_t *val)
13647 + int shift = 0;
13648 + int value = 0;
13649 + uint8_t ch = 0;
13650 + int32_t err;
13651 + int32_t sum;
13652 + // Constants for UNSIGNED5 coding of Pack200
13653 + // see compressedStream.hpp
13654 + enum {
13655 + lg_H = 6,
13656 + H = 1<<lg_H,
13657 + BitsPerByte = 8,
13658 + L = (1<<BitsPerByte)-H,
13659 + };
13660 + int i;
13662 + err = ps_pread(J->P, (*buffer)++, &ch, sizeof(uint8_t));
13663 + CHECK_FAIL(err);
13664 + if (debug > 2)
13665 + fprintf(stderr, "\t\t\t raw_read_int: *buffer: %#llx, ch: %#x\n", *buffer, ch);
13667 + sum = ch;
13668 + if ( sum >= L ) {
13669 + int32_t lg_H_i = lg_H;
13670 + // Read maximum of 5 total bytes (we've already read 1).
13671 + // See CompressedReadStream::read_int_mb
13672 + for ( i = 0; i < 4; i++) {
13673 + err = ps_pread(J->P, (*buffer)++, &ch, sizeof(uint8_t));
13674 + CHECK_FAIL(err);
13675 + sum += ch << lg_H_i;
13676 + if (ch < L ) {
13677 + *val = sum;
13678 + return PS_OK;
13680 + lg_H_i += lg_H;
13683 + *val = sum;
13684 + return PS_OK;
13686 + fail:
13687 + return err;
13690 +static int
13691 +read_pair(jvm_agent_t* J, uint64_t *buffer, int32_t *bci, int32_t *line)
13693 + uint8_t next = 0;
13694 + int32_t bci_delta;
13695 + int32_t line_delta;
13696 + int32_t err;
13698 + if (debug > 2)
13699 + fprintf(stderr, "\t\t read_pair: BEGIN\n");
13701 + err = ps_pread(J->P, (*buffer)++, &next, sizeof(uint8_t));
13702 + CHECK_FAIL(err);
13704 + if (next == 0) {
13705 + if (debug > 2)
13706 + fprintf(stderr, "\t\t read_pair: END: next == 0\n");
13707 + return 1; /* stream terminated */
13709 + if (next == 0xFF) {
13710 + if (debug > 2)
13711 + fprintf(stderr, "\t\t read_pair: END: next == 0xFF\n");
13713 + /* Escape character, regular compression used */
13715 + err = raw_read_int(J, buffer, &bci_delta);
13716 + CHECK_FAIL(err);
13718 + err = raw_read_int(J, buffer, &line_delta);
13719 + CHECK_FAIL(err);
13721 + *bci += bci_delta;
13722 + *line += line_delta;
13724 + if (debug > 2) {
13725 + fprintf(stderr, "\t\t read_pair: delta = (line %d: %d)\n",
13726 + line_delta, bci_delta);
13727 + fprintf(stderr, "\t\t read_pair: unpack= (line %d: %d)\n",
13728 + *line, *bci);
13730 + } else {
13731 + /* Single byte compression used */
13732 + *bci += next >> 3;
13733 + *line += next & 0x7;
13734 + if (debug > 2) {
13735 + fprintf(stderr, "\t\t read_pair: delta = (line %d: %d)\n",
13736 + next & 0x7, next >> 3);
13737 + fprintf(stderr, "\t\t read_pair: unpack= (line %d: %d)\n",
13738 + *line, *bci);
13741 + if (debug > 2)
13742 + fprintf(stderr, "\t\t read_pair: END\n");
13743 + return PS_OK;
13745 + fail:
13746 + if (debug)
13747 + fprintf(stderr, "\t\t read_pair: FAIL\n");
13748 + return err;
13751 +static int
13752 +line_number_from_bci(jvm_agent_t* J, Vframe_t *vf)
13754 + uint64_t buffer;
13755 + uint16_t code_size;
13756 + uint64_t code_end_delta;
13757 + uint64_t constMethod;
13758 + int8_t access_flags;
13759 + int32_t best_bci = 0;
13760 + int32_t stream_bci = 0;
13761 + int32_t stream_line = 0;
13762 + int32_t err;
13764 + if (debug > 2) {
13765 + char name[256];
13766 + err = name_for_methodPtr(J, vf->method, name, 256);
13767 + CHECK_FAIL(err);
13768 + fprintf(stderr, "\t line_number_from_bci: BEGIN, method name: %s, targ bci: %d\n",
13769 + name, vf->bci);
13772 + err = read_pointer(J, vf->method + OFFSET_Method_constMethod, &constMethod);
13773 + CHECK_FAIL(err);
13775 + vf->line = 0;
13776 + err = ps_pread(J->P, constMethod + OFFSET_ConstMethod_flags, &access_flags, sizeof(int8_t));
13777 + CHECK_FAIL(err);
13779 + if (!(access_flags & ConstMethod_has_linenumber_table)) {
13780 + if (debug > 2)
13781 + fprintf(stderr, "\t line_number_from_bci: END: !HAS_LINE_NUMBER_TABLE \n\n");
13782 + return PS_OK;
13785 + /* The line numbers are a short array of 2-tuples [start_pc, line_number].
13786 + * Not necessarily sorted and not necessarily one-to-one.
13787 + */
13789 + err = ps_pread(J->P, constMethod + OFFSET_ConstMethod_code_size, &code_size, SZ16);
13790 + CHECK_FAIL(err);
13792 + /* inlined_table_start() */
13793 + code_end_delta = (uint64_t) (access_flags & AccessFlags_NATIVE) ? 2*POINTER_SIZE : 0;
13794 + buffer = constMethod + (uint64_t) SIZE_ConstMethod + (uint64_t) code_size + code_end_delta;
13796 + if (debug > 2) {
13797 + fprintf(stderr, "\t\t line_number_from_bci: method: %#llx, native: %d\n",
13798 + vf->method, (access_flags & AccessFlags_NATIVE));
13799 + fprintf(stderr, "\t\t line_number_from_bci: buffer: %#llx, code_size: %d\n",
13800 + buffer, (int) code_size);
13803 + while (read_pair(J, &buffer, &stream_bci, &stream_line) == 0) {
13804 + if (stream_bci == vf->bci) {
13805 + /* perfect match */
13806 + if (debug > 2)
13807 + fprintf(stderr, "\t line_number_from_bci: END: exact line: %d \n\n", vf->line);
13808 + vf->line = stream_line;
13809 + return PS_OK;
13810 + } else {
13811 + /* update best_bci/line */
13812 + if (stream_bci < vf->bci && stream_bci >= best_bci) {
13813 + best_bci = stream_bci;
13814 + vf->line = stream_line;
13815 + if (debug > 2) {
13816 + fprintf(stderr, "\t line_number_from_bci: best_bci: %d, best_line: %d\n",
13817 + best_bci, vf->line);
13822 + if (debug > 2)
13823 + fprintf(stderr, "\t line_number_from_bci: END: line: %d \n\n", vf->line);
13824 + return PS_OK;
13826 + fail:
13827 + if (debug)
13828 + fprintf(stderr, "\t line_number_from_bci: FAIL\n");
13829 + return err;
13832 +static int
13833 +get_real_pc(Nmethod_t *N, uint64_t pc_desc, uint64_t *real_pc)
13835 + int32_t pc_offset;
13836 + int32_t err;
13838 + err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32);
13839 + CHECK_FAIL(err);
13841 + *real_pc = N->instrs_beg + pc_offset;
13842 + if (debug > 2) {
13843 + fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n",
13844 + pc_offset, *real_pc);
13846 + return PS_OK;
13848 + fail:
13849 + return err;
13852 +/* Finds a PcDesc with real-pc equal to N->pc */
13853 +static int pc_desc_at(Nmethod_t *N)
13855 + uint64_t pc_diff = 999;
13856 + int32_t offs;
13857 + int32_t err;
13859 + if (debug > 2)
13860 + fprintf(stderr, "\t pc_desc_at: BEGIN\n");
13862 + N->vf_cnt = 0;
13863 + N->pc_desc = 0;
13865 + for (offs = N->scopes_pcs_beg; offs < N->scopes_pcs_end; offs += SIZE_PcDesc) {
13866 + uint64_t pd;
13867 + uint64_t best_pc_diff = 16; /* some approximation */
13868 + uint64_t real_pc = 0;
13870 + pd = N->nm + offs;
13871 + err = get_real_pc(N, pd, &real_pc);
13872 + CHECK_FAIL(err);
13874 + pc_diff = real_pc - N->pc;
13876 + /* In general, this fragment should work */
13877 + if (pc_diff == 0) {
13878 + N->pc_desc = pd;
13879 + if (debug) {
13880 + fprintf(stderr, "\t pc_desc_at: END: pc_desc: FOUND: %#lx \n\n", pd);
13882 + return PS_OK;
13884 + /* This fragment is to be able to find out an appropriate
13885 + * pc_desc entry even if pc_desc info is inaccurate.
13886 + */
13887 + if (best_pc_diff > pc_diff && pc_diff > 0) {
13888 + best_pc_diff = pc_diff;
13889 + N->pc_desc = pd;
13892 + if (debug) {
13893 + fprintf(stderr, "\t pc_desc_at: END: pc_desc NOT FOUND");
13894 + if (pc_diff < 20)
13895 + fprintf(stderr, ", best pc_diff: %d\n\n", pc_diff);
13896 + else
13897 + fprintf(stderr, "\n\n");
13899 + return PS_OK;
13901 + fail:
13902 + return err;
13905 +static int
13906 +scope_desc_at(Nmethod_t *N, int32_t decode_offset, Vframe_t *vf)
13908 + uint64_t buffer;
13909 + int32_t err;
13911 + if (debug > 2) {
13912 + fprintf(stderr, "\t\t scope_desc_at: BEGIN \n");
13915 + buffer = N->scopes_data_beg + decode_offset;
13917 + err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset);
13918 + CHECK_FAIL(err);
13920 + err = raw_read_int(N->J, &buffer, &vf->methodIdx);
13921 + CHECK_FAIL(err);
13923 + err = raw_read_int(N->J, &buffer, &vf->bci);
13924 + CHECK_FAIL(err);
13926 + if (debug > 2) {
13927 + fprintf(stderr, "\t\t scope_desc_at: sender_decode_offset: %#x\n",
13928 + vf->sender_decode_offset);
13929 + fprintf(stderr, "\t\t scope_desc_at: methodIdx: %d\n", vf->methodIdx);
13930 + fprintf(stderr, "\t\t scope_desc_at: bci: %d\n", vf->bci);
13932 + fprintf(stderr, "\t\t scope_desc_at: END \n\n");
13934 + return PS_OK;
13936 + fail:
13937 + return err;
13940 +static int scopeDesc_chain(Nmethod_t *N) {
13941 + int32_t decode_offset = 0;
13942 + int32_t err;
13944 + if (debug > 2) {
13945 + fprintf(stderr, "\t scopeDesc_chain: BEGIN\n");
13948 + err = ps_pread(N->J->P, N->pc_desc + OFFSET_PcDesc_scope_decode_offset,
13949 + &decode_offset, SZ32);
13950 + CHECK_FAIL(err);
13952 + while (decode_offset > 0) {
13953 + Vframe_t *vf = &N->vframes[N->vf_cnt];
13955 + if (debug > 2) {
13956 + fprintf(stderr, "\t scopeDesc_chain: decode_offset: %#x\n", decode_offset);
13959 + err = scope_desc_at(N, decode_offset, vf);
13960 + CHECK_FAIL(err);
13962 + if (vf->methodIdx > ((N->metadata_end - N->metadata_beg) / POINTER_SIZE)) {
13963 + fprintf(stderr, "\t scopeDesc_chain: (methodIdx > metadata length) !\n");
13964 + return -1;
13966 + err = read_pointer(N->J, N->nm + N->metadata_beg + (vf->methodIdx-1)*POINTER_SIZE,
13967 + &vf->method);
13968 + CHECK_FAIL(err);
13970 + if (vf->method) {
13971 + N->vf_cnt++;
13972 + err = line_number_from_bci(N->J, vf);
13973 + CHECK_FAIL(err);
13974 + if (debug > 2) {
13975 + fprintf(stderr, "\t scopeDesc_chain: method: %#8llx, line: %d\n",
13976 + vf->method, vf->line);
13979 + decode_offset = vf->sender_decode_offset;
13981 + if (debug > 2) {
13982 + fprintf(stderr, "\t scopeDesc_chain: END \n\n");
13984 + return PS_OK;
13986 + fail:
13987 + if (debug) {
13988 + fprintf(stderr, "\t scopeDesc_chain: FAIL \n\n");
13990 + return err;
13994 +static int
13995 +name_for_nmethod(jvm_agent_t* J,
13996 + uint64_t nm,
13997 + uint64_t pc,
13998 + uint64_t method,
13999 + char *result,
14000 + size_t size,
14001 + Jframe_t *jframe
14002 +) {
14003 + Nmethod_t *N;
14004 + Vframe_t *vf;
14005 + int32_t err;
14006 + int deoptimized = 0;
14008 + if (debug) {
14009 + fprintf(stderr, "name_for_nmethod: BEGIN: nmethod: %#llx, pc: %#llx\n", nm, pc);
14011 + if (J->N == NULL) {
14012 + J->N = (Nmethod_t *) malloc(sizeof(Nmethod_t));
14014 + memset(J->N, 0, sizeof(Nmethod_t)); /* Initial stat: all values are zeros */
14015 + N = J->N;
14016 + N->J = J;
14017 + N->nm = nm;
14018 + N->pc = pc;
14019 + N->jframe = jframe;
14021 + err = nmethod_info(N);
14022 + CHECK_FAIL(err);
14023 + if (debug) {
14024 + fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc: %#llx\n",
14025 + pc, N->deopt_beg);
14028 + /* check for a deoptimized frame */
14029 + if ( pc == N->deopt_beg) {
14030 + uint64_t base;
14031 + if (debug) {
14032 + fprintf(stderr, "name_for_nmethod: found deoptimized frame\n");
14034 + if (J->prev_fr.sender_sp != 0) {
14035 + base = J->prev_fr.sender_sp + N->orig_pc_offset;
14036 + } else {
14037 + base = J->curr_fr.sp + N->orig_pc_offset;
14039 + err = read_pointer(J, base, &N->pc);
14040 + CHECK_FAIL(err);
14041 + if (debug) {
14042 + fprintf(stderr, "name_for_nmethod: found deoptimized frame converting pc from %#8llx to %#8llx\n",
14043 + pc, N->pc);
14045 + deoptimized = 1;
14048 + err = pc_desc_at(N);
14049 + CHECK_FAIL(err);
14051 + if (N->pc_desc > 0) {
14052 + jframe->locinf = 1;
14053 + err = scopeDesc_chain(N);
14054 + CHECK_FAIL(err);
14056 + result[0] = COMP_METHOD_SIGN;
14057 + vf = &N->vframes[0];
14058 + if (N->vf_cnt > 0) {
14059 + jframe->vf_cnt = N->vf_cnt;
14060 + jframe->bci = vf->bci;
14061 + jframe->line = vf->line;
14062 + err = name_for_methodPtr(J, N->vframes[0].method, result+1, size-1);
14063 + CHECK_FAIL(err);
14064 + } else {
14065 + err = name_for_methodPtr(J, method, result+1, size-1);
14066 + CHECK_FAIL(err);
14068 + if (deoptimized) {
14069 + strncat(result, " [deoptimized frame]; ", size - strlen(result) - 1);
14070 + } else {
14071 + strncat(result, " [compiled] ", size - strlen(result) - 1);
14073 + if (debug)
14074 + fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n",
14075 + result, N->vf_cnt);
14076 + return PS_OK;
14078 + fail:
14079 + if (debug)
14080 + fprintf(stderr, "name_for_nmethod: FAIL \n\n");
14081 + return err;
14084 +static int
14085 +name_for_imethod(jvm_agent_t* J,
14086 + uint64_t bcp,
14087 + uint64_t method,
14088 + char *result,
14089 + size_t size,
14090 + Jframe_t *jframe
14091 +) {
14092 + uint64_t bci;
14093 + uint64_t constMethod;
14094 + Vframe_t vframe = {0};
14095 + Vframe_t *vf = &vframe;
14096 + int32_t err;
14098 + err = read_pointer(J, method + OFFSET_Method_constMethod, &constMethod);
14099 + CHECK_FAIL(err);
14101 + bci = bcp - (constMethod + (uint64_t) SIZE_ConstMethod);
14103 + if (debug)
14104 + fprintf(stderr, "\t name_for_imethod: BEGIN: method: %#llx\n", method);
14106 + err = name_for_methodPtr(J, method, result, size);
14107 + CHECK_FAIL(err);
14108 + if (debug)
14109 + fprintf(stderr, "\t name_for_imethod: method name: %s\n", result);
14111 + if (bci > 0) {
14112 + vf->method = method;
14113 + vf->bci = bci;
14114 + err = line_number_from_bci(J, vf);
14115 + CHECK_FAIL(err);
14117 + jframe->bci = vf->bci;
14118 + jframe->line = vf->line;
14119 + jframe->locinf = 1;
14121 + if (debug) {
14122 + fprintf(stderr, "\t name_for_imethod: END: bci: %d, line: %d\n\n",
14123 + vf->bci, vf->line);
14125 + return PS_OK;
14127 + fail:
14128 + if (debug)
14129 + fprintf(stderr, "\t name_for_imethod: FAIL\n");
14130 + return err;
14133 +static int
14134 +name_for_codecache(jvm_agent_t* J, uint64_t fp, uint64_t pc, char * result,
14135 + size_t size, Jframe_t *jframe, int* is_interpreted)
14137 + uint64_t start;
14138 + uint64_t vtbl;
14139 + int32_t err;
14140 + *is_interpreted = 0;
14142 + result[0] = '\0';
14144 + err = find_start(J, pc, &start);
14145 + CHECK_FAIL(err);
14147 + err = read_pointer(J, start, &vtbl);
14148 + CHECK_FAIL(err);
14150 + if (vtbl == J->nmethod_vtbl) {
14151 + uint64_t method;
14153 + err = read_pointer(J, start + OFFSET_nmethod_method, &method);
14154 + CHECK_FAIL(err);
14156 + if (debug) {
14157 + fprintf(stderr, "name_for_codecache: start: %#8llx, pc: %#8llx, method: %#8llx \n",
14158 + start, pc, method);
14160 + err = name_for_nmethod(J, start, pc, method, result, size, jframe);
14161 + CHECK_FAIL(err);
14162 + } else if (vtbl == J->BufferBlob_vtbl) {
14163 + const char * name;
14165 + err = read_string_pointer(J, start + OFFSET_CodeBlob_name, &name);
14167 + /*
14168 + * Temporary usage of string "Interpreter".
14169 + * We need some other way to distinguish "StubRoutines"
14170 + * and regular interpreted frames.
14171 + */
14172 + if (err == PS_OK && strncmp(name, "Interpreter", 11) == 0) {
14173 + *is_interpreted = 1;
14174 + if (is_method(J, J->methodPtr)) {
14175 + return name_for_imethod(J, J->bcp, J->methodPtr, result, size, jframe);
14179 + if (err == PS_OK) {
14180 + strncpy(result, name, size);
14181 + free((void*)name);
14182 + } else {
14183 + strncpy(result, "<unknown BufferBlob>", size);
14185 + /* return PS_OK; */
14186 + } else {
14187 + const char * name;
14189 + err = read_string_pointer(J, start + OFFSET_CodeBlob_name, &name);
14190 + if (err == PS_OK) {
14191 + strncpy(result, name, size);
14192 + free((void*)name);
14193 + } else {
14194 + strncpy(result, "<unknown CodeBlob>", size);
14195 + WARN1("unknown CodeBlob: vtbl = 0x%x", vtbl);
14198 + result[size-1] = '\0';
14200 +#ifdef X86_COMPILER2
14201 + if (vtbl != J->RuntimeStub_vtbl) {
14202 + uint64_t trial_pc;
14203 + int frame_size;
14204 + err = ps_pread(J->P, start + OFFSET_CodeBlob_frame_size,
14205 + &frame_size, SZ32);
14206 + CHECK_FAIL(err);
14208 + // frame_size is in words, we want bytes.
14209 + frame_size *= POINTER_SIZE; /* word => byte conversion */
14211 + /*
14212 + Because c2 doesn't use FP as a framepointer the value of sp/fp we receive
14213 + in the initial entry to a set of stack frames containing server frames
14214 + will pretty much be nonsense. We can detect that nonsense by looking to
14215 + see if the PC we received is correct if we look at the expected storage
14216 + location in relation to the FP (ie. POINTER_SIZE(FP) )
14217 + */
14219 + err = read_pointer(J, fp + POINTER_SIZE , &trial_pc);
14220 + if ( (err != PS_OK || trial_pc != pc) && frame_size > 0 ) {
14221 + // Either we couldn't even read at the "fp" or the pc didn't match
14222 + // both are sure clues that the fp is bogus. We no search the stack
14223 + // for a reasonable number of words trying to find the bogus fp
14224 + // and the current pc in adjacent words. The we will be able to
14225 + // deduce an approximation of the frame pointer and actually get
14226 + // the correct stack pointer. Which we can then unwind for the
14227 + // next frame.
14228 + int i;
14229 + uint64_t check;
14230 + uint64_t base = J->curr_fr.sp;
14231 + uint64_t prev_fp = 0;
14232 + for ( i = 0; i < frame_size * 5 ; i++, base += POINTER_SIZE ) {
14233 + err = read_pointer(J, base , &check);
14234 + CHECK_FAIL(err);
14235 + if (check == fp) {
14236 + base += POINTER_SIZE;
14237 + err = read_pointer(J, base , &check);
14238 + CHECK_FAIL(err);
14239 + if (check == pc) {
14240 + if (debug) {
14241 + fprintf(stderr, "name_for_codecache: found matching fp/pc combo at 0x%llx\n", base - POINTER_SIZE);
14243 + prev_fp = base - 2 * POINTER_SIZE;
14244 + break;
14248 + if ( prev_fp != 0 ) {
14249 + // real_sp is the sp we should have received for this frame
14250 + uint64_t real_sp = prev_fp + 2 * POINTER_SIZE;
14251 + // +POINTER_SIZE because callee owns the return address so caller's sp is +1 word
14252 + jframe->new_sp = real_sp + frame_size + POINTER_SIZE;
14253 + err = read_pointer(J, jframe->new_sp - POINTER_SIZE , &jframe->new_pc);
14254 + CHECK_FAIL(err);
14255 + err = read_pointer(J, jframe->new_sp - 2*POINTER_SIZE, &jframe->new_fp);
14256 + CHECK_FAIL(err);
14257 + return PS_OK;
14261 + /* A prototype to workaround FP absence */
14262 + /*
14263 + * frame_size can be 0 for StubRoutines (1) frame.
14264 + * In this case it should work with fp as usual.
14265 + */
14266 + if (frame_size > 0) {
14267 + jframe->new_fp = J->prev_fr.fp + frame_size;
14268 + jframe->new_sp = jframe->new_fp + 2 * POINTER_SIZE;
14269 + } else {
14270 + memset(&J->curr_fr, 0, sizeof(Frame_t));
14271 + err = read_pointer(J, fp, &jframe->new_fp);
14272 + CHECK_FAIL(err);
14274 + err = read_pointer(J, jframe->new_fp + POINTER_SIZE, &jframe->new_pc);
14275 + CHECK_FAIL(err);
14277 + if (debug) {
14278 + fprintf(stderr, "name_for_codecache: %s, frame_size=%#lx\n",
14279 + result, frame_size);
14280 + fprintf(stderr, "name_for_codecache: prev_fr.fp=%#lx, fp=%#lx\n",
14281 + J->prev_fr.fp, jframe->new_fp);
14284 +#endif /* X86_COMPILER2 */
14286 + return PS_OK;
14288 + fail:
14289 + return err;
14292 +int Jget_vframe(jvm_agent_t* J, int vframe_no,
14293 + char *name, size_t size, Jframe_t *jframe)
14295 + Nmethod_t *N = J->N;
14296 + Vframe_t *vf;
14297 + int32_t err;
14299 + if (vframe_no >= N->vf_cnt) {
14300 + (void) sprintf(name, "Wrong inlinedMethod%1d()", vframe_no);
14301 + return -1;
14303 + vf = N->vframes + vframe_no;
14304 + name[0] = COMP_METHOD_SIGN;
14305 + err = name_for_methodPtr(J, vf->method, name + 1, size);
14306 + CHECK_FAIL(err);
14308 + jframe->bci = vf->bci;
14309 + jframe->line = vf->line;
14310 + if (debug) {
14311 + fprintf(stderr, "\t Jget_vframe: method name: %s, line: %d\n",
14312 + name, vf->line);
14314 + return PS_OK;
14316 + fail:
14317 + if (debug) {
14318 + fprintf(stderr, "\t Jget_vframe: FAIL\n");
14320 + return err;
14323 +#define MAX_SYM_SIZE 256
14325 +int Jlookup_by_regs(jvm_agent_t* J, const prgregset_t regs, char *name,
14326 + size_t size, Jframe_t *jframe) {
14327 + uintptr_t fp;
14328 + uintptr_t pc;
14329 + /* arguments given to read_pointer need to be worst case sized */
14330 + uint64_t methodPtr = 0;
14331 + uint64_t sender_sp;
14332 + uint64_t bcp = 0;
14333 + int is_interpreted = 0;
14334 + int result = PS_OK;
14335 + int err = PS_OK;
14337 + if (J == NULL) {
14338 + return -1;
14341 + jframe->vf_cnt = 1;
14342 + jframe->new_fp = 0;
14343 + jframe->new_pc = 0;
14344 + jframe->line = 0;
14345 + jframe->bci = 0;
14346 + jframe->locinf = 0;
14348 + read_volatiles(J);
14349 + pc = (uintptr_t) regs[R_PC];
14350 + J->curr_fr.pc = pc;
14351 + J->curr_fr.fp = regs[R_FP];
14352 + J->curr_fr.sp = regs[R_SP];
14354 + if (debug)
14355 + fprintf(stderr, "Jlookup_by_regs: BEGINs: fp=%#lx, pc=%#lx\n", regs[R_FP], pc);
14357 +#if defined(i386) || defined(__i386) || defined(__amd64)
14359 + fp = (uintptr_t) regs[R_FP];
14360 + if (J->prev_fr.fp == 0) {
14361 +#ifdef X86_COMPILER2
14362 + /* A workaround for top java frames */
14363 + J->prev_fr.fp = (uintptr_t)(regs[R_SP] - 2 * POINTER_SIZE);
14364 +#else
14365 + J->prev_fr.fp = (uintptr_t)(regs[R_SP] - POINTER_SIZE);
14366 +#endif /* COMPILER2 */
14368 + if (debug > 2) {
14369 + printf("Jlookup_by_regs: J->prev_fr.fp = %#lx\n", J->prev_fr.fp);
14372 + if (read_pointer(J, fp + OFFSET_interpreter_frame_method, &methodPtr) != PS_OK) {
14373 + methodPtr = 0;
14375 + if (read_pointer(J, fp + OFFSET_interpreter_frame_sender_sp, &sender_sp) != PS_OK) {
14376 + sender_sp = 0;
14378 + if (read_pointer(J, fp + OFFSET_interpreter_frame_bcp_offset, &bcp) != PS_OK) {
14379 + bcp = 0;
14381 +#endif /* i386 */
14383 + J->methodPtr = methodPtr;
14384 + J->bcp = bcp;
14386 + /* On x86 with C2 JVM: native frame may have wrong regs[R_FP]
14387 + * For example: JVM_SuspendThread frame poins to the top interpreted frame.
14388 + * If we call is_method(J, methodPtr) before codecache_contains(J, pc)
14389 + * then we go over and omit both: nmethod and I2CAdapter frames.
14390 + * Note, that regs[R_PC] is always correct if frame defined correctly.
14391 + * So it is better to call codecache_contains(J, pc) from the beginning.
14392 + */
14393 +#ifndef X86_COMPILER2
14394 + if (is_method(J, J->methodPtr)) {
14395 + result = name_for_imethod(J, bcp, J->methodPtr, name, size, jframe);
14396 + /* If the methodPtr is a method then this is highly likely to be
14397 + an interpreter frame */
14398 + if (result >= 0) {
14399 + is_interpreted = 1;
14401 + } else
14402 +#endif /* ! X86_COMPILER2 */
14404 + if (codecache_contains(J, pc)) {
14405 + result = name_for_codecache(J, fp, pc, name, size, jframe, &is_interpreted);
14407 +#ifdef X86_COMPILER2
14408 + else if (is_method(J, J->methodPtr)) {
14409 + result = name_for_imethod(J, bcp, J->methodPtr, name, size, jframe);
14410 + /* If the methodPtr is a method then this is highly likely to be
14411 + an interpreter frame */
14412 + if (result >= 0) {
14413 + is_interpreted = 1;
14416 +#endif /* X86_COMPILER2 */
14417 + else {
14418 + if (debug) {
14419 + fprintf(stderr, "Jlookup_by_regs: END with -1\n\n");
14421 + result = -1;
14423 + if (!is_interpreted) {
14424 + sender_sp = 0;
14426 + J->curr_fr.sender_sp = sender_sp;
14428 +#ifdef X86_COMPILER2
14429 + if (!J->curr_fr.fp) {
14430 + J->curr_fr.fp = (jframe->new_fp) ? jframe->new_fp : (uintptr_t)regs[R_FP];
14432 + if (!jframe->new_pc && jframe->new_fp) {
14433 + // This seems dubious
14434 + read_pointer(J, jframe->new_fp + POINTER_SIZE, &jframe->new_pc);
14435 + CHECK_FAIL(err);
14436 + if (debug > 2) {
14437 + printf("Jlookup_by_regs: (update pc) jframe->new_fp: %#llx, jframe->new_pc: %#llx\n",
14438 + jframe->new_fp, jframe->new_pc);
14442 +#endif /* X86_COMPILER2 */
14443 + J->prev_fr = J->curr_fr;
14445 + if (debug)
14446 + fprintf(stderr, "Jlookup_by_regs: END\n\n");
14448 + return result;
14450 + fail:
14451 + return err;
14454 +void update_gregs(prgregset_t gregs, Jframe_t jframe) {
14455 +#ifdef X86_COMPILER2
14456 + if (debug > 0) {
14457 + fprintf(stderr, "update_gregs: before update sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
14459 + /*
14460 + * A workaround for java C2 frames with unconventional FP.
14461 + * may have to modify regset with new values for FP/PC/SP when needed.
14462 + */
14463 + if (jframe.new_sp) {
14464 + *((uintptr_t *) &gregs[R_SP]) = (uintptr_t) jframe.new_sp;
14465 + } else {
14466 + // *((uintptr_t *) &gregs[R_SP]) = (uintptr_t) gregs[R_FP] + 2 * POINTER_SIZE;
14469 + if (jframe.new_fp) {
14470 + *((uintptr_t *) &gregs[R_FP]) = (uintptr_t) jframe.new_fp;
14472 + if (jframe.new_pc) {
14473 + *((uintptr_t *) &gregs[R_PC]) = (uintptr_t) jframe.new_pc;
14475 + if (debug > 0) {
14476 + fprintf(stderr, "update_gregs: after update sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
14478 +#endif /* X86_COMPILER2 */
14482 + * Iterates over java frames at current location given by 'gregs'.
14484 + * Returns -1 if no java frames are present or if an error is encountered.
14485 + * Returns the result of calling 'func' if the return value is non-zero.
14486 + * Returns 0 otherwise.
14487 + */
14488 +int Jframe_iter(jvm_agent_t *J, prgregset_t gregs, java_stack_f *func, void* cld) {
14489 + char buf[MAX_SYM_SIZE + 1];
14490 + Jframe_t jframe;
14491 + int i = 0, res;
14492 +#ifdef X86_COMPILER2
14493 + if (debug > 0) {
14494 + fprintf(stderr, "Jframe_iter: Entry sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
14496 +#endif /* X86_COMPILER2 */
14498 + memset(&jframe, 0, sizeof(Jframe_t));
14499 + memset(buf, 0, sizeof(buf));
14500 + res = Jlookup_by_regs(J, gregs, buf, sizeof(buf), &jframe);
14501 + if (res != PS_OK)
14502 + return (-1);
14505 + res = func(cld, gregs, buf, (jframe.locinf)? jframe.bci : -1,
14506 + jframe.line, NULL);
14507 + if (res != 0) {
14508 + update_gregs(gregs, jframe);
14509 + return (res);
14511 + for (i = 1; i < jframe.vf_cnt; i++) {
14512 + Jget_vframe(J, i, buf, sizeof(buf), &jframe);
14513 + res = func(cld, gregs, buf, (jframe.locinf)? jframe.bci : -1,
14514 + jframe.line, NULL);
14515 + if (res != 0) {
14516 + update_gregs(gregs, jframe);
14517 + return (res);
14520 + update_gregs(gregs, jframe);
14521 + return (0);
14523 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_db/libjvm_db.h jdk-jdk-24-11/src/java.base/solaris/native/libjvm_db/libjvm_db.h
14524 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_db/libjvm_db.h 1970-01-01 01:00:00.000000000 +0100
14525 +++ jdk-jdk-24-11/src/java.base/solaris/native/libjvm_db/libjvm_db.h 2024-08-17 20:36:14.299893039 +0200
14526 @@ -0,0 +1,69 @@
14528 + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
14529 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14531 + * This code is free software; you can redistribute it and/or modify it
14532 + * under the terms of the GNU General Public License version 2 only, as
14533 + * published by the Free Software Foundation.
14535 + * This code is distributed in the hope that it will be useful, but WITHOUT
14536 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14537 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14538 + * version 2 for more details (a copy is included in the LICENSE file that
14539 + * accompanied this code).
14541 + * You should have received a copy of the GNU General Public License version
14542 + * 2 along with this work; if not, write to the Free Software Foundation,
14543 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14545 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14546 + * or visit www.oracle.com if you need additional information or have any
14547 + * questions.
14549 + */
14551 +#ifndef OS_SOLARIS_DTRACE_LIBJVM_DB_H
14552 +#define OS_SOLARIS_DTRACE_LIBJVM_DB_H
14554 +#include <proc_service.h>
14555 +#include "jni.h"
14557 +#ifdef __cplusplus
14558 +extern "C" {
14559 +#endif
14561 +typedef struct jvm_agent jvm_agent_t;
14563 +#define JVM_DB_VERSION 1
14565 +JNIEXPORT jvm_agent_t *Jagent_create(struct ps_prochandle *P, int vers);
14568 + * Called from Jframe_iter() for each java frame. If it returns 0, then
14569 + * Jframe_iter() proceeds to the next frame. Otherwise, the return value is
14570 + * immediately returned to the caller of Jframe_iter().
14572 + * Parameters:
14573 + * 'cld' is client supplied data (to maintain iterator state, if any).
14574 + * 'name' is java method name.
14575 + * 'bci' is byte code index. it will be -1 if not available.
14576 + * 'line' is java source line number. it will be 0 if not available.
14577 + * 'handle' is an abstract client handle, reserved for future expansions
14578 + */
14580 +typedef int java_stack_f(void *cld, const prgregset_t regs, const char* name, int bci, int line, void *handle);
14583 + * Iterates over the java frames at the current location. Returns -1 if no java
14584 + * frames were found, or if there was some unrecoverable error. Otherwise,
14585 + * returns the last value returned from 'func'.
14586 + */
14587 +JNIEXPORT int Jframe_iter(jvm_agent_t *agent, prgregset_t gregs, java_stack_f *func, void* cld);
14589 +JNIEXPORT void Jagent_destroy(jvm_agent_t *J);
14591 +#ifdef __cplusplus
14592 +} /* extern "C" */
14593 +#endif /* __cplusplus */
14595 +#endif // OS_SOLARIS_DTRACE_LIBJVM_DB_H
14596 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.c jdk-jdk-24-11/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.c
14597 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.c 1970-01-01 01:00:00.000000000 +0100
14598 +++ jdk-jdk-24-11/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.c 2024-08-17 20:36:14.300539255 +0200
14599 @@ -0,0 +1,562 @@
14601 + * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
14602 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14604 + * This code is free software; you can redistribute it and/or modify it
14605 + * under the terms of the GNU General Public License version 2 only, as
14606 + * published by the Free Software Foundation.
14608 + * This code is distributed in the hope that it will be useful, but WITHOUT
14609 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14610 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14611 + * version 2 for more details (a copy is included in the LICENSE file that
14612 + * accompanied this code).
14614 + * You should have received a copy of the GNU General Public License version
14615 + * 2 along with this work; if not, write to the Free Software Foundation,
14616 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14618 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14619 + * or visit www.oracle.com if you need additional information or have any
14620 + * questions.
14622 + */
14624 +#include <door.h>
14625 +#include <errno.h>
14626 +#include <fcntl.h>
14627 +#include <limits.h>
14628 +#include <poll.h>
14629 +#include <signal.h>
14630 +#include <stdarg.h>
14631 +#include <stdio.h>
14632 +#include <stdlib.h>
14633 +#include <string.h>
14634 +#include <sys/types.h>
14635 +#include <sys/stat.h>
14636 +#include <thread.h>
14637 +#include <unistd.h>
14638 +#include "jvm_dtrace.h"
14640 +// NOTE: These constants are used in JVM code as well.
14641 +// KEEP JVM CODE IN SYNC if you are going to change these...
14643 +#define DTRACE_ALLOC_PROBES 0x1
14644 +#define DTRACE_METHOD_PROBES 0x2
14645 +#define DTRACE_MONITOR_PROBES 0x4
14646 +#define DTRACE_ALL_PROBES -1
14648 +// generic error messages
14649 +#define JVM_ERR_OUT_OF_MEMORY "out of memory (native heap)"
14650 +#define JVM_ERR_INVALID_PARAM "invalid input parameter(s)"
14651 +#define JVM_ERR_NULL_PARAM "input paramater is NULL"
14653 +// error messages for attach
14654 +#define JVM_ERR_CANT_OPEN_DOOR "cannot open door file"
14655 +#define JVM_ERR_CANT_CREATE_ATTACH_FILE "cannot create attach file"
14656 +#define JVM_ERR_DOOR_FILE_PERMISSION "door file is not secure"
14657 +#define JVM_ERR_CANT_SIGNAL "cannot send SIGQUIT to target"
14659 +// error messages for enable probe
14660 +#define JVM_ERR_DOOR_CMD_SEND "door command send failed"
14661 +#define JVM_ERR_DOOR_CANT_READ_STATUS "cannot read door command status"
14662 +#define JVM_ERR_DOOR_CMD_STATUS "door command error status"
14664 +// error message for detach
14665 +#define JVM_ERR_CANT_CLOSE_DOOR "cannot close door file"
14667 +#define RESTARTABLE(_cmd, _result) do { \
14668 + do { \
14669 + _result = _cmd; \
14670 + } while((_result == -1) && (errno == EINTR)); \
14671 +} while(0)
14673 +struct _jvm_t {
14674 + pid_t pid;
14675 + int door_fd;
14678 +static int libjvm_dtrace_debug;
14679 +static void print_debug(const char* fmt,...) {
14680 + if (libjvm_dtrace_debug) {
14681 + va_list alist;
14682 + va_start(alist, fmt);
14683 + fputs("libjvm_dtrace DEBUG: ", stderr);
14684 + vfprintf(stderr, fmt, alist);
14685 + va_end(alist);
14689 +/* Key for thread local error message */
14690 +static thread_key_t jvm_error_key;
14692 +/* init function for this library */
14693 +static void init_jvm_dtrace() {
14694 + /* check for env. var for debug mode */
14695 + libjvm_dtrace_debug = getenv("LIBJVM_DTRACE_DEBUG") != NULL;
14696 + /* create key for thread local error message */
14697 + if (thr_keycreate(&jvm_error_key, NULL) != 0) {
14698 + print_debug("can't create thread_key_t for jvm error key\n");
14699 + // exit(1); ?
14703 +#pragma init(init_jvm_dtrace)
14705 +/* set thread local error message */
14706 +static void set_jvm_error(const char* msg) {
14707 + thr_setspecific(jvm_error_key, (void*)msg);
14710 +/* clear thread local error message */
14711 +static void clear_jvm_error() {
14712 + thr_setspecific(jvm_error_key, NULL);
14715 +/* file handling functions that can handle interrupt */
14717 +static int file_open(const char* path, int flag) {
14718 + int ret;
14719 + RESTARTABLE(open(path, flag), ret);
14720 + return ret;
14723 +static int file_close(int fd) {
14724 + return close(fd);
14727 +static int file_read(int fd, char* buf, int len) {
14728 + int ret;
14729 + RESTARTABLE(read(fd, buf, len), ret);
14730 + return ret;
14733 +/* send SIGQUIT signal to given process */
14734 +static int send_sigquit(pid_t pid) {
14735 + int ret;
14736 + RESTARTABLE(kill(pid, SIGQUIT), ret);
14737 + return ret;
14740 +/* called to check permissions on attach file */
14741 +static int check_permission(const char* path) {
14742 + struct stat64 sb;
14743 + uid_t uid, gid;
14744 + int res;
14746 + /*
14747 + * Check that the path is owned by the effective uid/gid of this
14748 + * process. Also check that group/other access is not allowed.
14749 + */
14750 + uid = geteuid();
14751 + gid = getegid();
14753 + res = stat64(path, &sb);
14754 + if (res != 0) {
14755 + print_debug("stat failed for %s\n", path);
14756 + return -1;
14759 + if ((sb.st_uid != uid) || (sb.st_gid != gid) ||
14760 + ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0)) {
14761 + print_debug("well-known file %s is not secure\n", path);
14762 + return -1;
14764 + return 0;
14767 +#define ATTACH_FILE_PATTERN "/tmp/.attach_pid%d"
14769 +/* fill-in the name of attach file name in given buffer */
14770 +static void fill_attach_file_name(char* path, int len, pid_t pid) {
14771 + memset(path, 0, len);
14772 + sprintf(path, ATTACH_FILE_PATTERN, pid);
14775 +#define DOOR_FILE_PATTERN "/tmp/.java_pid%d"
14777 +/* open door file for the given JVM */
14778 +static int open_door(pid_t pid) {
14779 + char path[PATH_MAX + 1];
14780 + int fd;
14782 + sprintf(path, DOOR_FILE_PATTERN, pid);
14783 + fd = file_open(path, O_RDONLY);
14784 + if (fd < 0) {
14785 + set_jvm_error(JVM_ERR_CANT_OPEN_DOOR);
14786 + print_debug("cannot open door file %s\n", path);
14787 + return -1;
14789 + print_debug("opened door file %s\n", path);
14790 + if (check_permission(path) != 0) {
14791 + set_jvm_error(JVM_ERR_DOOR_FILE_PERMISSION);
14792 + print_debug("check permission failed for %s\n", path);
14793 + file_close(fd);
14794 + fd = -1;
14796 + return fd;
14799 +/* create attach file for given process */
14800 +static int create_attach_file(pid_t pid) {
14801 + char path[PATH_MAX + 1];
14802 + int fd;
14803 + fill_attach_file_name(path, sizeof(path), pid);
14804 + fd = file_open(path, O_CREAT | O_RDWR);
14805 + if (fd < 0) {
14806 + set_jvm_error(JVM_ERR_CANT_CREATE_ATTACH_FILE);
14807 + print_debug("cannot create file %s\n", path);
14808 + } else {
14809 + print_debug("created attach file %s\n", path);
14811 + return fd;
14814 +/* delete attach file for given process */
14815 +static void delete_attach_file(pid_t pid) {
14816 + char path[PATH_MAX + 1];
14817 + fill_attach_file_name(path, sizeof(path), pid);
14818 + int res = unlink(path);
14819 + if (res) {
14820 + print_debug("cannot delete attach file %s\n", path);
14821 + } else {
14822 + print_debug("deleted attach file %s\n", path);
14826 +/* attach to given JVM */
14827 +jvm_t* jvm_attach(pid_t pid) {
14828 + jvm_t* jvm;
14829 + int door_fd, attach_fd, i = 0;
14831 + jvm = (jvm_t*) calloc(1, sizeof(jvm_t));
14832 + if (jvm == NULL) {
14833 + set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
14834 + print_debug("calloc failed in %s at %d\n", __FILE__, __LINE__);
14835 + return NULL;
14837 + jvm->pid = pid;
14838 + attach_fd = -1;
14840 + door_fd = open_door(pid);
14841 + if (door_fd < 0) {
14842 + print_debug("trying to create attach file\n");
14843 + if ((attach_fd = create_attach_file(pid)) < 0) {
14844 + goto quit;
14847 + /* send QUIT signal to the target so that it will
14848 + * check for the attach file.
14849 + */
14850 + if (send_sigquit(pid) != 0) {
14851 + set_jvm_error(JVM_ERR_CANT_SIGNAL);
14852 + print_debug("sending SIGQUIT failed\n");
14853 + goto quit;
14856 + /* give the target VM time to start the attach mechanism */
14857 + do {
14858 + int res;
14859 + RESTARTABLE(poll(0, 0, 200), res);
14860 + door_fd = open_door(pid);
14861 + i++;
14862 + } while (i <= 50 && door_fd == -1);
14863 + if (door_fd < 0) {
14864 + print_debug("Unable to open door to process %d\n", pid);
14865 + goto quit;
14869 +quit:
14870 + if (attach_fd >= 0) {
14871 + file_close(attach_fd);
14872 + delete_attach_file(jvm->pid);
14874 + if (door_fd >= 0) {
14875 + jvm->door_fd = door_fd;
14876 + clear_jvm_error();
14877 + } else {
14878 + free(jvm);
14879 + jvm = NULL;
14881 + return jvm;
14884 +/* return the last thread local error message */
14885 +const char* jvm_get_last_error() {
14886 + const char* res = NULL;
14887 + thr_getspecific(jvm_error_key, (void**)&res);
14888 + return res;
14891 +/* detach the givenb JVM */
14892 +int jvm_detach(jvm_t* jvm) {
14893 + if (jvm) {
14894 + int res = 0;
14895 + if (jvm->door_fd != -1) {
14896 + if (file_close(jvm->door_fd) != 0) {
14897 + set_jvm_error(JVM_ERR_CANT_CLOSE_DOOR);
14898 + res = -1;
14899 + } else {
14900 + clear_jvm_error();
14903 + free(jvm);
14904 + return res;
14905 + } else {
14906 + set_jvm_error(JVM_ERR_NULL_PARAM);
14907 + print_debug("jvm_t* is NULL\n");
14908 + return -1;
14913 + * A simple table to translate some known errors into reasonable
14914 + * error messages
14915 + */
14916 +static struct {
14917 + int err;
14918 + const char* msg;
14919 +} const error_messages[] = {
14920 + { 100, "Bad request" },
14921 + { 101, "Protocol mismatch" },
14922 + { 102, "Resource failure" },
14923 + { 103, "Internal error" },
14924 + { 104, "Permission denied" },
14928 + * Lookup the given error code and return the appropriate
14929 + * message. If not found return NULL.
14930 + */
14931 +static const char* translate_error(int err) {
14932 + int table_size = sizeof(error_messages) / sizeof(error_messages[0]);
14933 + int i;
14935 + for (i=0; i<table_size; i++) {
14936 + if (err == error_messages[i].err) {
14937 + return error_messages[i].msg;
14940 + return NULL;
14944 + * Current protocol version
14945 + */
14946 +static const char* PROTOCOL_VERSION = "1";
14948 +#define RES_BUF_SIZE 128
14951 + * Enqueue attach-on-demand command to the given JVM
14952 + */
14953 +static
14954 +int enqueue_command(jvm_t* jvm, const char* cstr, int arg_count, const char** args) {
14955 + size_t size;
14956 + door_arg_t door_args;
14957 + char res_buffer[RES_BUF_SIZE];
14958 + int rc, i;
14959 + char* buf = NULL;
14960 + int result = -1;
14962 + /*
14963 + * First we get the command string and create the start of the
14964 + * argument string to send to the target VM:
14965 + * <ver>\0<cmd>\0
14966 + */
14967 + if (cstr == NULL) {
14968 + print_debug("command name is NULL\n");
14969 + goto quit;
14971 + size = strlen(PROTOCOL_VERSION) + strlen(cstr) + 2;
14972 + buf = (char*)malloc(size);
14973 + if (buf != NULL) {
14974 + char* pos = buf;
14975 + strcpy(buf, PROTOCOL_VERSION);
14976 + pos += strlen(PROTOCOL_VERSION)+1;
14977 + strcpy(pos, cstr);
14978 + } else {
14979 + set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
14980 + print_debug("malloc failed at %d in %s\n", __LINE__, __FILE__);
14981 + goto quit;
14984 + /*
14985 + * Next we iterate over the arguments and extend the buffer
14986 + * to include them.
14987 + */
14988 + for (i=0; i<arg_count; i++) {
14989 + cstr = args[i];
14990 + if (cstr != NULL) {
14991 + size_t len = strlen(cstr);
14992 + char* newbuf = (char*)realloc(buf, size+len+1);
14993 + if (newbuf == NULL) {
14994 + set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
14995 + print_debug("realloc failed in %s at %d\n", __FILE__, __LINE__);
14996 + goto quit;
14998 + buf = newbuf;
14999 + strcpy(buf+size, cstr);
15000 + size += len+1;
15004 + /*
15005 + * The arguments to the door function are in 'buf' so we now
15006 + * do the door call
15007 + */
15008 + door_args.data_ptr = buf;
15009 + door_args.data_size = size;
15010 + door_args.desc_ptr = NULL;
15011 + door_args.desc_num = 0;
15012 + door_args.rbuf = (char*)&res_buffer;
15013 + door_args.rsize = sizeof(res_buffer);
15015 + RESTARTABLE(door_call(jvm->door_fd, &door_args), rc);
15017 + /*
15018 + * door_call failed
15019 + */
15020 + if (rc == -1) {
15021 + print_debug("door_call failed\n");
15022 + } else {
15023 + /*
15024 + * door_call succeeded but the call didn't return the expected jint.
15025 + */
15026 + if (door_args.data_size < sizeof(int)) {
15027 + print_debug("Enqueue error - reason unknown as result is truncated!");
15028 + } else {
15029 + int* res = (int*)(door_args.data_ptr);
15030 + if (*res != 0) {
15031 + const char* msg = translate_error(*res);
15032 + if (msg == NULL) {
15033 + print_debug("Unable to enqueue command to target VM: %d\n", *res);
15034 + } else {
15035 + print_debug("Unable to enqueue command to target VM: %s\n", msg);
15037 + } else {
15038 + /*
15039 + * The door call should return a file descriptor to one end of
15040 + * a socket pair
15041 + */
15042 + if ((door_args.desc_ptr != NULL) &&
15043 + (door_args.desc_num == 1) &&
15044 + (door_args.desc_ptr->d_attributes & DOOR_DESCRIPTOR)) {
15045 + result = door_args.desc_ptr->d_data.d_desc.d_descriptor;
15046 + } else {
15047 + print_debug("Reply from enqueue missing descriptor!\n");
15053 +quit:
15054 + if (buf) free(buf);
15055 + return result;
15058 +/* read status code for a door command */
15059 +static int read_status(int fd) {
15060 + char ch, buf[16];
15061 + int index = 0;
15063 + while (1) {
15064 + if (file_read(fd, &ch, sizeof(ch)) != sizeof(ch)) {
15065 + set_jvm_error(JVM_ERR_DOOR_CANT_READ_STATUS);
15066 + print_debug("door cmd status: read status failed\n");
15067 + return -1;
15069 + buf[index++] = ch;
15070 + if (ch == '\n') {
15071 + buf[index - 1] = '\0';
15072 + return atoi(buf);
15074 + if (index == sizeof(buf)) {
15075 + set_jvm_error(JVM_ERR_DOOR_CANT_READ_STATUS);
15076 + print_debug("door cmd status: read status overflow\n");
15077 + return -1;
15082 +static const char* ENABLE_DPROBES_CMD = "enabledprobes";
15084 +/* enable one or more DTrace probes for a given JVM */
15085 +int jvm_enable_dtprobes(jvm_t* jvm, int num_probe_types, const char** probe_types) {
15086 + int fd, status = 0;
15087 + char ch;
15088 + const char* args[1];
15089 + char buf[16];
15090 + int probe_type = 0, index;
15091 + int count = 0;
15093 + if (jvm == NULL) {
15094 + set_jvm_error(JVM_ERR_NULL_PARAM);
15095 + print_debug("jvm_t* is NULL\n");
15096 + return -1;
15099 + if (num_probe_types == 0 || probe_types == NULL ||
15100 + probe_types[0] == NULL) {
15101 + set_jvm_error(JVM_ERR_INVALID_PARAM);
15102 + print_debug("invalid probe type argument(s)\n");
15103 + return -1;
15106 + for (index = 0; index < num_probe_types; index++) {
15107 + const char* p = probe_types[index];
15108 + if (strcmp(p, JVM_DTPROBE_OBJECT_ALLOC) == 0) {
15109 + probe_type |= DTRACE_ALLOC_PROBES;
15110 + count++;
15111 + } else if (strcmp(p, JVM_DTPROBE_METHOD_ENTRY) == 0 ||
15112 + strcmp(p, JVM_DTPROBE_METHOD_RETURN) == 0) {
15113 + probe_type |= DTRACE_METHOD_PROBES;
15114 + count++;
15115 + } else if (strcmp(p, JVM_DTPROBE_MONITOR_ENTER) == 0 ||
15116 + strcmp(p, JVM_DTPROBE_MONITOR_ENTERED) == 0 ||
15117 + strcmp(p, JVM_DTPROBE_MONITOR_EXIT) == 0 ||
15118 + strcmp(p, JVM_DTPROBE_MONITOR_WAIT) == 0 ||
15119 + strcmp(p, JVM_DTPROBE_MONITOR_WAITED) == 0 ||
15120 + strcmp(p, JVM_DTPROBE_MONITOR_NOTIFY) == 0 ||
15121 + strcmp(p, JVM_DTPROBE_MONITOR_NOTIFYALL) == 0) {
15122 + probe_type |= DTRACE_MONITOR_PROBES;
15123 + count++;
15124 + } else if (strcmp(p, JVM_DTPROBE_ALL) == 0) {
15125 + probe_type |= DTRACE_ALL_PROBES;
15126 + count++;
15130 + if (count == 0) {
15131 + return count;
15133 + sprintf(buf, "%d", probe_type);
15134 + args[0] = buf;
15136 + fd = enqueue_command(jvm, ENABLE_DPROBES_CMD, 1, args);
15137 + if (fd < 0) {
15138 + set_jvm_error(JVM_ERR_DOOR_CMD_SEND);
15139 + return -1;
15142 + status = read_status(fd);
15143 + // non-zero status is error
15144 + if (status) {
15145 + set_jvm_error(JVM_ERR_DOOR_CMD_STATUS);
15146 + print_debug("%s command failed (status: %d) in target JVM\n",
15147 + ENABLE_DPROBES_CMD, status);
15148 + file_close(fd);
15149 + return -1;
15151 + // read from stream until EOF
15152 + while (file_read(fd, &ch, sizeof(ch)) == sizeof(ch)) {
15153 + if (libjvm_dtrace_debug) {
15154 + printf("%c", ch);
15158 + file_close(fd);
15159 + clear_jvm_error();
15160 + return count;
15162 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.h jdk-jdk-24-11/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.h
15163 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.h 1970-01-01 01:00:00.000000000 +0100
15164 +++ jdk-jdk-24-11/src/java.base/solaris/native/libjvm_dtrace/jvm_dtrace.h 2024-08-17 20:36:14.300828074 +0200
15165 @@ -0,0 +1,86 @@
15167 + * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
15168 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15170 + * This code is free software; you can redistribute it and/or modify it
15171 + * under the terms of the GNU General Public License version 2 only, as
15172 + * published by the Free Software Foundation.
15174 + * This code is distributed in the hope that it will be useful, but WITHOUT
15175 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15176 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15177 + * version 2 for more details (a copy is included in the LICENSE file that
15178 + * accompanied this code).
15180 + * You should have received a copy of the GNU General Public License version
15181 + * 2 along with this work; if not, write to the Free Software Foundation,
15182 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15184 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15185 + * or visit www.oracle.com if you need additional information or have any
15186 + * questions.
15188 + */
15190 +#ifndef _JVM_DTRACE_H_
15191 +#define _JVM_DTRACE_H_
15194 + * Interface to dynamically turn on probes in Hotspot JVM. Currently,
15195 + * this interface can be used to dynamically enable certain DTrace
15196 + * probe points that are costly to have "always on".
15197 + */
15199 +#ifdef __cplusplus
15200 +extern "C" {
15201 +#endif
15203 +#include <sys/types.h>
15204 +#include "jni.h"
15206 +struct _jvm_t;
15207 +typedef struct _jvm_t jvm_t;
15210 +/* Attach to the given JVM process. Returns NULL on failure.
15211 + jvm_get_last_error() returns last error message. */
15212 +JNIEXPORT jvm_t* jvm_attach(pid_t pid);
15214 +/* Returns the last error message from this library or NULL if none. */
15215 +JNIEXPORT const char* jvm_get_last_error();
15217 +/* few well-known probe type constants for 'probe_types' param below */
15219 +#define JVM_DTPROBE_METHOD_ENTRY "method-entry"
15220 +#define JVM_DTPROBE_METHOD_RETURN "method-return"
15221 +#define JVM_DTPROBE_MONITOR_ENTER "monitor-contended-enter"
15222 +#define JVM_DTPROBE_MONITOR_ENTERED "monitor-contended-entered"
15223 +#define JVM_DTPROBE_MONITOR_EXIT "monitor-contended-exit"
15224 +#define JVM_DTPROBE_MONITOR_WAIT "monitor-wait"
15225 +#define JVM_DTPROBE_MONITOR_WAITED "monitor-waited"
15226 +#define JVM_DTPROBE_MONITOR_NOTIFY "monitor-notify"
15227 +#define JVM_DTPROBE_MONITOR_NOTIFYALL "monitor-notifyall"
15228 +#define JVM_DTPROBE_OBJECT_ALLOC "object-alloc"
15229 +#define JVM_DTPROBE_ALL "*"
15231 +/* Enable the specified DTrace probes of given probe types on
15232 + * the specified JVM. Returns >= 0 on success, -1 on failure.
15233 + * On success, this returns number of probe_types enabled.
15234 + * On failure, jvm_get_last_error() returns the last error message.
15235 + */
15236 +JNIEXPORT int jvm_enable_dtprobes(jvm_t* jvm, int num_probe_types, const char** probe_types);
15238 +/* Note: There is no jvm_disable_dtprobes function. Probes are automatically
15239 + * disabled when there are no more clients requiring those probes.
15240 + */
15242 +/* Detach the given JVM. Returns 0 on success, -1 on failure.
15243 + * jvm_get_last_error() returns the last error message.
15244 + */
15245 +JNIEXPORT int jvm_detach(jvm_t* jvm);
15247 +#ifdef __cplusplus
15249 +#endif
15251 +#endif /* _JVM_DTRACE_H_ */
15252 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libnet/solaris_close.c jdk-jdk-24-11/src/java.base/solaris/native/libnet/solaris_close.c
15253 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libnet/solaris_close.c 1970-01-01 01:00:00.000000000 +0100
15254 +++ jdk-jdk-24-11/src/java.base/solaris/native/libnet/solaris_close.c 2024-08-17 20:36:14.301165568 +0200
15255 @@ -0,0 +1,107 @@
15257 + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
15258 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15260 + * This code is free software; you can redistribute it and/or modify it
15261 + * under the terms of the GNU General Public License version 2 only, as
15262 + * published by the Free Software Foundation. Oracle designates this
15263 + * particular file as subject to the "Classpath" exception as provided
15264 + * by Oracle in the LICENSE file that accompanied this code.
15266 + * This code is distributed in the hope that it will be useful, but WITHOUT
15267 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15268 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15269 + * version 2 for more details (a copy is included in the LICENSE file that
15270 + * accompanied this code).
15272 + * You should have received a copy of the GNU General Public License version
15273 + * 2 along with this work; if not, write to the Free Software Foundation,
15274 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15276 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15277 + * or visit www.oracle.com if you need additional information or have any
15278 + * questions.
15279 + */
15281 +#include <errno.h>
15282 +#include <sys/socket.h>
15283 +#include <stropts.h>
15284 +#include <unistd.h>
15285 +#include "jvm.h"
15286 +#include "net_util.h"
15288 +/* Support for restartable system calls on Solaris. */
15290 +#define RESTARTABLE_RETURN_INT(_cmd) do { \
15291 + int _result; \
15292 + if (1) { \
15293 + do { \
15294 + _result = _cmd; \
15295 + } while((_result == -1) && (errno == EINTR)); \
15296 + return _result; \
15297 + } \
15298 +} while(0)
15300 +int NET_Read(int s, void* buf, size_t len) {
15301 + RESTARTABLE_RETURN_INT(recv(s, buf, len, 0));
15304 +int NET_NonBlockingRead(int s, void* buf, size_t len) {
15305 + RESTARTABLE_RETURN_INT(recv(s, buf, len, MSG_DONTWAIT));
15308 +int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
15309 + struct sockaddr *from, socklen_t *fromlen) {
15310 + RESTARTABLE_RETURN_INT(recvfrom(s, buf, len, flags, from, fromlen));
15313 +int NET_Send(int s, void *msg, int len, unsigned int flags) {
15314 + RESTARTABLE_RETURN_INT(send(s, msg, len, flags));
15317 +int NET_SendTo(int s, const void *msg, int len, unsigned int flags,
15318 + const struct sockaddr *to, int tolen) {
15319 + RESTARTABLE_RETURN_INT(sendto(s, msg, len, flags, to, tolen));
15322 +int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
15323 + RESTARTABLE_RETURN_INT(connect(s, addr, addrlen));
15326 +int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
15327 + RESTARTABLE_RETURN_INT(accept(s, addr, addrlen));
15330 +int NET_SocketClose(int fd) {
15331 + return close(fd);
15334 +int NET_Dup2(int fd, int fd2) {
15335 + return dup2(fd, fd2);
15338 +int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
15339 + RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
15342 +int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
15343 + int result;
15344 + jlong prevNanoTime = nanoTimeStamp;
15345 + jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
15346 + struct pollfd pfd;
15347 + pfd.fd = s;
15348 + pfd.events = POLLIN;
15350 + for(;;) {
15351 + result = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
15352 + if (result < 0 && errno == EINTR) {
15353 + jlong newNanoTime = JVM_NanoTime(env, 0);
15354 + nanoTimeout -= newNanoTime - prevNanoTime;
15355 + if (nanoTimeout < NET_NSEC_PER_MSEC)
15356 + return 0;
15357 + prevNanoTime = newNanoTime;
15358 + } else {
15359 + return result;
15363 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/ch/DevPollArrayWrapper.c jdk-jdk-24-11/src/java.base/solaris/native/libnio/ch/DevPollArrayWrapper.c
15364 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/ch/DevPollArrayWrapper.c 1970-01-01 01:00:00.000000000 +0100
15365 +++ jdk-jdk-24-11/src/java.base/solaris/native/libnio/ch/DevPollArrayWrapper.c 2024-08-17 20:36:14.301579776 +0200
15366 @@ -0,0 +1,112 @@
15368 + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
15369 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15371 + * This code is free software; you can redistribute it and/or modify it
15372 + * under the terms of the GNU General Public License version 2 only, as
15373 + * published by the Free Software Foundation. Oracle designates this
15374 + * particular file as subject to the "Classpath" exception as provided
15375 + * by Oracle in the LICENSE file that accompanied this code.
15377 + * This code is distributed in the hope that it will be useful, but WITHOUT
15378 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15379 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15380 + * version 2 for more details (a copy is included in the LICENSE file that
15381 + * accompanied this code).
15383 + * You should have received a copy of the GNU General Public License version
15384 + * 2 along with this work; if not, write to the Free Software Foundation,
15385 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15387 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15388 + * or visit www.oracle.com if you need additional information or have any
15389 + * questions.
15390 + */
15392 +#include <sys/types.h>
15393 +#include <sys/stat.h>
15394 +#include <devpoll.h>
15395 +#include <fcntl.h>
15396 +#include <poll.h>
15398 +#include "jni.h"
15399 +#include "jni_util.h"
15400 +#include "jvm.h"
15401 +#include "jlong.h"
15402 +#include "nio.h"
15403 +#include "nio_util.h"
15405 +#include "sun_nio_ch_DevPollArrayWrapper.h"
15407 +JNIEXPORT jint JNICALL
15408 +Java_sun_nio_ch_DevPollArrayWrapper_init(JNIEnv *env, jobject this)
15410 + int wfd = open("/dev/poll", O_RDWR);
15411 + if (wfd < 0) {
15412 + JNU_ThrowIOExceptionWithLastError(env, "Error opening driver");
15413 + return -1;
15415 + return wfd;
15418 +JNIEXPORT void JNICALL
15419 +Java_sun_nio_ch_DevPollArrayWrapper_register(JNIEnv *env, jobject this,
15420 + jint wfd, jint fd, jint mask)
15422 + struct pollfd a[1];
15423 + int n;
15425 + a[0].fd = fd;
15426 + a[0].events = mask;
15427 + a[0].revents = 0;
15429 + n = write(wfd, &a[0], sizeof(a));
15430 + if (n != sizeof(a)) {
15431 + if (n < 0) {
15432 + JNU_ThrowIOExceptionWithLastError(env, "Error writing pollfds");
15433 + } else {
15434 + JNU_ThrowIOException(env, "Unexpected number of bytes written");
15439 +JNIEXPORT void JNICALL
15440 +Java_sun_nio_ch_DevPollArrayWrapper_registerMultiple(JNIEnv *env, jobject this,
15441 + jint wfd, jlong address,
15442 + jint len)
15444 + unsigned char *pollBytes = (unsigned char *)jlong_to_ptr(address);
15445 + unsigned char *pollEnd = pollBytes + sizeof(struct pollfd) * len;
15446 + while (pollBytes < pollEnd) {
15447 + int bytesWritten = write(wfd, pollBytes, (int)(pollEnd - pollBytes));
15448 + if (bytesWritten < 0) {
15449 + JNU_ThrowIOExceptionWithLastError(env, "Error writing pollfds");
15450 + return;
15452 + pollBytes += bytesWritten;
15456 +JNIEXPORT jint JNICALL
15457 +Java_sun_nio_ch_DevPollArrayWrapper_poll0(JNIEnv *env, jobject this,
15458 + jlong address, jint numfds,
15459 + jlong timeout, jint wfd)
15461 + struct dvpoll a;
15462 + void *pfd = (void *) jlong_to_ptr(address);
15463 + int result;
15465 + a.dp_fds = pfd;
15466 + a.dp_nfds = numfds;
15467 + a.dp_timeout = (int)timeout;
15468 + result = ioctl(wfd, DP_POLL, &a);
15469 + if (result < 0) {
15470 + if (errno == EINTR) {
15471 + return IOS_INTERRUPTED;
15472 + } else {
15473 + JNU_ThrowIOExceptionWithLastError(env, "Error reading driver");
15474 + return IOS_THROWN;
15477 + return result;
15479 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/ch/SolarisEventPort.c jdk-jdk-24-11/src/java.base/solaris/native/libnio/ch/SolarisEventPort.c
15480 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/ch/SolarisEventPort.c 1970-01-01 01:00:00.000000000 +0100
15481 +++ jdk-jdk-24-11/src/java.base/solaris/native/libnio/ch/SolarisEventPort.c 2024-08-17 20:36:14.301887099 +0200
15482 @@ -0,0 +1,147 @@
15484 + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
15485 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15487 + * This code is free software; you can redistribute it and/or modify it
15488 + * under the terms of the GNU General Public License version 2 only, as
15489 + * published by the Free Software Foundation. Oracle designates this
15490 + * particular file as subject to the "Classpath" exception as provided
15491 + * by Oracle in the LICENSE file that accompanied this code.
15493 + * This code is distributed in the hope that it will be useful, but WITHOUT
15494 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15495 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15496 + * version 2 for more details (a copy is included in the LICENSE file that
15497 + * accompanied this code).
15499 + * You should have received a copy of the GNU General Public License version
15500 + * 2 along with this work; if not, write to the Free Software Foundation,
15501 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15503 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15504 + * or visit www.oracle.com if you need additional information or have any
15505 + * questions.
15506 + */
15508 +#include <stdlib.h>
15509 +#include <dlfcn.h>
15510 +#include <sys/types.h>
15511 +#include <port.h>
15513 +#include "jni.h"
15514 +#include "jni_util.h"
15515 +#include "jvm.h"
15516 +#include "jlong.h"
15517 +#include "nio.h"
15518 +#include "nio_util.h"
15520 +#include "sun_nio_ch_SolarisEventPort.h"
15522 +JNIEXPORT jint JNICALL
15523 +Java_sun_nio_ch_SolarisEventPort_port_1create
15524 + (JNIEnv* env, jclass clazz)
15526 + int port = port_create();
15527 + if (port == -1) {
15528 + JNU_ThrowIOExceptionWithLastError(env, "port_create");
15530 + return (jint)port;
15533 +JNIEXPORT void JNICALL
15534 +Java_sun_nio_ch_SolarisEventPort_port_1close
15535 + (JNIEnv* env, jclass clazz, jint port)
15537 + int res = close(port);
15538 + if (res < 0 && res != EINTR) {
15539 + JNU_ThrowIOExceptionWithLastError(env, "close failed");
15543 +JNIEXPORT jboolean JNICALL
15544 +Java_sun_nio_ch_SolarisEventPort_port_1associate
15545 + (JNIEnv* env, jclass clazz, jint port, jint source, jlong objectAddress, jint events)
15547 + uintptr_t object = (uintptr_t)jlong_to_ptr(objectAddress);
15548 + if (port_associate((int)port, (int)source, object, (int)events, NULL) == 0) {
15549 + return JNI_TRUE;
15550 + } else {
15551 + if (errno != EBADFD)
15552 + JNU_ThrowIOExceptionWithLastError(env, "port_associate");
15553 + return JNI_FALSE;
15557 +JNIEXPORT jboolean JNICALL
15558 +Java_sun_nio_ch_SolarisEventPort_port_1dissociate
15559 + (JNIEnv* env, jclass clazz, jint port, jint source, jlong objectAddress)
15561 + uintptr_t object = (uintptr_t)jlong_to_ptr(objectAddress);
15563 + if (port_dissociate((int)port, (int)source, object) == 0) {
15564 + return JNI_TRUE;
15565 + } else {
15566 + if (errno != ENOENT)
15567 + JNU_ThrowIOExceptionWithLastError(env, "port_dissociate");
15568 + return JNI_FALSE;
15572 +JNIEXPORT void JNICALL
15573 +Java_sun_nio_ch_SolarisEventPort_port_1send(JNIEnv* env, jclass clazz,
15574 + jint port, jint events)
15576 + if (port_send((int)port, (int)events, NULL) == -1) {
15577 + JNU_ThrowIOExceptionWithLastError(env, "port_send");
15581 +JNIEXPORT jint JNICALL
15582 +Java_sun_nio_ch_SolarisEventPort_port_1get(JNIEnv* env, jclass clazz,
15583 + jint port, jlong eventAddress)
15585 + int res;
15586 + port_event_t* ev = (port_event_t*)jlong_to_ptr(eventAddress);
15588 + res = port_get((int)port, ev, NULL);
15589 + if (res == -1) {
15590 + if (errno == EINTR) {
15591 + return IOS_INTERRUPTED;
15592 + } else {
15593 + JNU_ThrowIOExceptionWithLastError(env, "port_get failed");
15594 + return IOS_THROWN;
15597 + return res;
15600 +JNIEXPORT jint JNICALL
15601 +Java_sun_nio_ch_SolarisEventPort_port_1getn(JNIEnv* env, jclass clazz,
15602 + jint port, jlong arrayAddress, jint max, jlong timeout)
15604 + int res;
15605 + uint_t n = 1;
15606 + port_event_t* list = (port_event_t*)jlong_to_ptr(arrayAddress);
15607 + timespec_t ts;
15608 + timespec_t* tsp;
15610 + if (timeout >= 0L) {
15611 + ts.tv_sec = timeout / 1000;
15612 + ts.tv_nsec = 1000000 * (timeout % 1000);
15613 + tsp = &ts;
15614 + } else {
15615 + tsp = NULL;
15618 + res = port_getn((int)port, list, (uint_t)max, &n, tsp);
15619 + if (res == -1 && errno != ETIME) {
15620 + if (errno == EINTR) {
15621 + return IOS_INTERRUPTED;
15622 + } else {
15623 + JNU_ThrowIOExceptionWithLastError(env, "port_getn failed");
15624 + return IOS_THROWN;
15628 + return (jint)n;
15630 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/fs/SolarisNativeDispatcher.c jdk-jdk-24-11/src/java.base/solaris/native/libnio/fs/SolarisNativeDispatcher.c
15631 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/fs/SolarisNativeDispatcher.c 1970-01-01 01:00:00.000000000 +0100
15632 +++ jdk-jdk-24-11/src/java.base/solaris/native/libnio/fs/SolarisNativeDispatcher.c 2024-08-17 20:36:14.302239266 +0200
15633 @@ -0,0 +1,143 @@
15635 + * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
15636 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15638 + * This code is free software; you can redistribute it and/or modify it
15639 + * under the terms of the GNU General Public License version 2 only, as
15640 + * published by the Free Software Foundation. Oracle designates this
15641 + * particular file as subject to the "Classpath" exception as provided
15642 + * by Oracle in the LICENSE file that accompanied this code.
15644 + * This code is distributed in the hope that it will be useful, but WITHOUT
15645 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15646 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15647 + * version 2 for more details (a copy is included in the LICENSE file that
15648 + * accompanied this code).
15650 + * You should have received a copy of the GNU General Public License version
15651 + * 2 along with this work; if not, write to the Free Software Foundation,
15652 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15654 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15655 + * or visit www.oracle.com if you need additional information or have any
15656 + * questions.
15657 + */
15659 +#include "jni.h"
15660 +#include "jni_util.h"
15661 +#include "jvm.h"
15662 +#include "jlong.h"
15664 +#include <strings.h>
15665 +#include <errno.h>
15666 +#include <sys/acl.h>
15667 +#include <sys/mnttab.h>
15668 +#include <sys/mkdev.h>
15670 +#include "jni.h"
15672 +#include "sun_nio_fs_SolarisNativeDispatcher.h"
15674 +static jfieldID entry_name;
15675 +static jfieldID entry_dir;
15676 +static jfieldID entry_fstype;
15677 +static jfieldID entry_options;
15678 +static jfieldID entry_dev;
15680 +static void throwUnixException(JNIEnv* env, int errnum) {
15681 + jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
15682 + "(I)V", errnum);
15683 + if (x != NULL) {
15684 + (*env)->Throw(env, x);
15688 +JNIEXPORT void JNICALL
15689 +Java_sun_nio_fs_SolarisNativeDispatcher_init(JNIEnv *env, jclass clazz) {
15690 + clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
15691 + CHECK_NULL(clazz);
15692 + entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
15693 + CHECK_NULL(entry_name);
15694 + entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
15695 + CHECK_NULL(entry_dir);
15696 + entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
15697 + CHECK_NULL(entry_fstype);
15698 + entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
15699 + CHECK_NULL(entry_options);
15700 + entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
15701 + CHECK_NULL(entry_dev);
15704 +JNIEXPORT jint JNICALL
15705 +Java_sun_nio_fs_SolarisNativeDispatcher_facl(JNIEnv* env, jclass this, jint fd,
15706 + jint cmd, jint nentries, jlong address)
15708 + void* aclbufp = jlong_to_ptr(address);
15709 + int n = -1;
15711 + n = facl((int)fd, (int)cmd, (int)nentries, aclbufp);
15712 + if (n == -1) {
15713 + throwUnixException(env, errno);
15715 + return (jint)n;
15718 +JNIEXPORT jint JNICALL
15719 +Java_sun_nio_fs_SolarisNativeDispatcher_getextmntent(JNIEnv* env, jclass this,
15720 + jlong value, jobject entry)
15722 + struct extmnttab ent;
15723 + FILE* fp = jlong_to_ptr(value);
15724 + jsize len;
15725 + jbyteArray bytes;
15726 + char* name;
15727 + char* dir;
15728 + char* fstype;
15729 + char* options;
15730 + dev_t dev;
15732 + if (getextmntent(fp, &ent, 0))
15733 + return -1;
15734 + name = ent.mnt_special;
15735 + dir = ent.mnt_mountp;
15736 + fstype = ent.mnt_fstype;
15737 + options = ent.mnt_mntopts;
15738 + dev = makedev(ent.mnt_major, ent.mnt_minor);
15739 + if (dev == NODEV) {
15740 + throwUnixException(env, errno);
15741 + return -1;
15744 + len = strlen(name);
15745 + bytes = (*env)->NewByteArray(env, len);
15746 + if (bytes == NULL)
15747 + return -1;
15748 + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
15749 + (*env)->SetObjectField(env, entry, entry_name, bytes);
15751 + len = strlen(dir);
15752 + bytes = (*env)->NewByteArray(env, len);
15753 + if (bytes == NULL)
15754 + return -1;
15755 + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
15756 + (*env)->SetObjectField(env, entry, entry_dir, bytes);
15758 + len = strlen(fstype);
15759 + bytes = (*env)->NewByteArray(env, len);
15760 + if (bytes == NULL)
15761 + return -1;
15762 + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
15763 + (*env)->SetObjectField(env, entry, entry_fstype, bytes);
15765 + len = strlen(options);
15766 + bytes = (*env)->NewByteArray(env, len);
15767 + if (bytes == NULL)
15768 + return -1;
15769 + (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
15770 + (*env)->SetObjectField(env, entry, entry_options, bytes);
15772 + if (dev != 0)
15773 + (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
15775 + return 0;
15777 diff -Nru jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/fs/SolarisWatchService.c jdk-jdk-24-11/src/java.base/solaris/native/libnio/fs/SolarisWatchService.c
15778 --- jdk-jdk-24-11.orig/src/java.base/solaris/native/libnio/fs/SolarisWatchService.c 1970-01-01 01:00:00.000000000 +0100
15779 +++ jdk-jdk-24-11/src/java.base/solaris/native/libnio/fs/SolarisWatchService.c 2024-08-17 20:36:14.302512284 +0200
15780 @@ -0,0 +1,104 @@
15782 + * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
15783 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15785 + * This code is free software; you can redistribute it and/or modify it
15786 + * under the terms of the GNU General Public License version 2 only, as
15787 + * published by the Free Software Foundation. Oracle designates this
15788 + * particular file as subject to the "Classpath" exception as provided
15789 + * by Oracle in the LICENSE file that accompanied this code.
15791 + * This code is distributed in the hope that it will be useful, but WITHOUT
15792 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15793 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15794 + * version 2 for more details (a copy is included in the LICENSE file that
15795 + * accompanied this code).
15797 + * You should have received a copy of the GNU General Public License version
15798 + * 2 along with this work; if not, write to the Free Software Foundation,
15799 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15801 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15802 + * or visit www.oracle.com if you need additional information or have any
15803 + * questions.
15804 + */
15806 +#include "jni.h"
15807 +#include "jni_util.h"
15808 +#include "jvm.h"
15809 +#include "jlong.h"
15811 +#include <stdlib.h>
15812 +#include <dlfcn.h>
15813 +#include <sys/types.h>
15814 +#include <port.h> // Solaris 10
15816 +#include "sun_nio_fs_SolarisWatchService.h"
15818 +static void throwUnixException(JNIEnv* env, int errnum) {
15819 + jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
15820 + "(I)V", errnum);
15821 + if (x != NULL) {
15822 + (*env)->Throw(env, x);
15826 +JNIEXPORT void JNICALL
15827 +Java_sun_nio_fs_SolarisWatchService_init(JNIEnv *env, jclass clazz)
15831 +JNIEXPORT jint JNICALL
15832 +Java_sun_nio_fs_SolarisWatchService_portCreate
15833 + (JNIEnv* env, jclass clazz)
15835 + int port = port_create();
15836 + if (port == -1) {
15837 + throwUnixException(env, errno);
15839 + return (jint)port;
15842 +JNIEXPORT void JNICALL
15843 +Java_sun_nio_fs_SolarisWatchService_portAssociate
15844 + (JNIEnv* env, jclass clazz, jint port, jint source, jlong objectAddress, jint events)
15846 + uintptr_t object = (uintptr_t)jlong_to_ptr(objectAddress);
15848 + if (port_associate((int)port, (int)source, object, (int)events, NULL) == -1) {
15849 + throwUnixException(env, errno);
15853 +JNIEXPORT void JNICALL
15854 +Java_sun_nio_fs_SolarisWatchService_portDissociate
15855 + (JNIEnv* env, jclass clazz, jint port, jint source, jlong objectAddress)
15857 + uintptr_t object = (uintptr_t)jlong_to_ptr(objectAddress);
15859 + if (port_dissociate((int)port, (int)source, object) == -1) {
15860 + throwUnixException(env, errno);
15864 +JNIEXPORT void JNICALL
15865 +Java_sun_nio_fs_SolarisWatchService_portSend(JNIEnv* env, jclass clazz,
15866 + jint port, jint events)
15868 + if (port_send((int)port, (int)events, NULL) == -1) {
15869 + throwUnixException(env, errno);
15873 +JNIEXPORT jint JNICALL
15874 +Java_sun_nio_fs_SolarisWatchService_portGetn(JNIEnv* env, jclass clazz,
15875 + jint port, jlong arrayAddress, jint max)
15877 + uint_t n = 1;
15878 + port_event_t* list = (port_event_t*)jlong_to_ptr(arrayAddress);
15880 + if (port_getn((int)port, list, (uint_t)max, &n, NULL) == -1) {
15881 + throwUnixException(env, errno);
15883 + return (jint)n;
15885 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/java/lang/ProcessImpl.java jdk-jdk-24-11/src/java.base/unix/classes/java/lang/ProcessImpl.java
15886 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/java/lang/ProcessImpl.java 2024-08-15 09:39:31.000000000 +0200
15887 +++ jdk-jdk-24-11/src/java.base/unix/classes/java/lang/ProcessImpl.java 2024-08-17 20:36:14.243968363 +0200
15888 @@ -83,6 +83,9 @@
15889 private /* final */ InputStream stdout;
15890 private /* final */ InputStream stderr;
15892 + // only used on Solaris
15893 + private /* final */ DeferredCloseInputStream stdout_inner_stream;
15895 private static enum LaunchMechanism {
15896 // order IS important!
15897 FORK,
15898 @@ -108,6 +111,7 @@
15899 return lm; // All options are valid for Linux
15900 case AIX:
15901 case MACOS:
15902 + case SOLARIS:
15903 if (lm != LaunchMechanism.VFORK) {
15904 return lm; // All but VFORK are valid
15906 @@ -364,6 +368,44 @@
15908 break;
15910 + case SOLARIS:
15911 + stdin = (fds[0] == -1) ?
15912 + ProcessBuilder.NullOutputStream.INSTANCE :
15913 + new BufferedOutputStream(
15914 + new FileOutputStream(newFileDescriptor(fds[0])));
15916 + stdout = (fds[1] == -1 || forceNullOutputStream) ?
15917 + ProcessBuilder.NullInputStream.INSTANCE :
15918 + new BufferedInputStream(
15919 + stdout_inner_stream =
15920 + new DeferredCloseInputStream(
15921 + newFileDescriptor(fds[1])));
15923 + stderr = (fds[2] == -1) ?
15924 + ProcessBuilder.NullInputStream.INSTANCE :
15925 + new DeferredCloseInputStream(newFileDescriptor(fds[2]));
15927 + /*
15928 + * For each subprocess forked a corresponding reaper task
15929 + * is submitted. That task is the only thread which waits
15930 + * for the subprocess to terminate and it doesn't hold any
15931 + * locks while doing so. This design allows waitFor() and
15932 + * exitStatus() to be safely executed in parallel (and they
15933 + * need no native code).
15934 + */
15935 + ProcessHandleImpl.completion(pid, true).handle((exitcode, throwable) -> {
15936 + lock.lock();
15937 + try {
15938 + this.exitcode = (exitcode == null) ? -1 : exitcode.intValue();
15939 + this.hasExited = true;
15940 + condition.signalAll();
15941 + } finally {
15942 + lock.unlock();
15944 + return null;
15945 + });
15946 + break;
15948 case AIX:
15949 stdin = (fds[0] == -1) ?
15950 ProcessBuilder.NullOutputStream.INSTANCE :
15951 @@ -480,6 +522,32 @@
15952 try { stderr.close(); } catch (IOException ignored) {}
15953 break;
15955 + case SOLARIS:
15956 + // There is a risk that pid will be recycled, causing us to
15957 + // kill the wrong process! So we only terminate processes
15958 + // that appear to still be running. Even with this check,
15959 + // there is an unavoidable race condition here, but the window
15960 + // is very small, and OSes try hard to not recycle pids too
15961 + // soon, so this is quite safe.
15962 + lock.lock();
15963 + try {
15964 + if (!hasExited)
15965 + processHandle.destroyProcess(force);
15966 + } finally {
15967 + lock.unlock();
15969 + try {
15970 + stdin.close();
15971 + if (stdout_inner_stream != null)
15972 + stdout_inner_stream.closeDeferred(stdout);
15973 + if (stderr instanceof DeferredCloseInputStream)
15974 + ((DeferredCloseInputStream) stderr)
15975 + .closeDeferred(stderr);
15976 + } catch (IOException e) {
15977 + // ignore
15979 + break;
15981 default: throw new AssertionError("Unsupported platform: " + OperatingSystem.current());
15984 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/net/PortConfig.java jdk-jdk-24-11/src/java.base/unix/classes/sun/net/PortConfig.java
15985 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/net/PortConfig.java 2024-08-15 09:39:31.000000000 +0200
15986 +++ jdk-jdk-24-11/src/java.base/unix/classes/sun/net/PortConfig.java 2024-08-17 20:36:14.244387163 +0200
15987 @@ -48,6 +48,10 @@
15988 defaultLower = 32768;
15989 defaultUpper = 61000;
15990 break;
15991 + case SOLARIS:
15992 + defaultLower = 32768;
15993 + defaultUpper = 65535;
15994 + break;
15995 case MACOS:
15996 defaultLower = 49152;
15997 defaultUpper = 65535;
15998 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
15999 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template 2024-08-15 09:39:31.000000000 +0200
16000 +++ jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template 2024-08-17 20:36:14.244825004 +0200
16001 @@ -35,6 +35,10 @@
16002 #include <sys/clonefile.h>
16003 #endif
16005 +/* On Solaris, "sun" is defined as a macro. Undefine to make package
16006 + declaration valid */
16007 +#undef sun
16009 /* To be able to name the Java constants the same as the C constants without
16010 having the preprocessor rewrite those identifiers, add PREFIX_ to all
16011 identifiers matching a C constant. The PREFIX_ is filtered out in the
16012 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java
16013 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java 2024-08-15 09:39:31.000000000 +0200
16014 +++ jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java 2024-08-17 20:36:14.245313863 +0200
16015 @@ -127,6 +127,10 @@
16016 return rootDirectory;
16019 + boolean isSolaris() {
16020 + return false;
16023 static List<String> standardFileAttributeViews() {
16024 return Arrays.asList("basic", "posix", "unix", "owner");
16026 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixPath.java jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixPath.java
16027 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/nio/fs/UnixPath.java 2024-08-15 09:39:31.000000000 +0200
16028 +++ jdk-jdk-24-11/src/java.base/unix/classes/sun/nio/fs/UnixPath.java 2024-08-17 20:36:14.245870168 +0200
16029 @@ -830,7 +830,15 @@
16030 ("NOFOLLOW_LINKS is not supported on this platform");
16031 flags |= O_NOFOLLOW;
16033 - return open(this, flags, 0);
16034 + try {
16035 + return open(this, flags, 0);
16036 + } catch (UnixException x) {
16037 + // HACK: EINVAL instead of ELOOP on Solaris 10 prior to u4 (see 6460380)
16038 + if (getFileSystem().isSolaris() && x.errno() == EINVAL)
16039 + x.setError(ELOOP);
16041 + throw x;
16045 void checkRead() {
16046 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/security/provider/NativePRNG.java jdk-jdk-24-11/src/java.base/unix/classes/sun/security/provider/NativePRNG.java
16047 --- jdk-jdk-24-11.orig/src/java.base/unix/classes/sun/security/provider/NativePRNG.java 2024-08-15 09:39:31.000000000 +0200
16048 +++ jdk-jdk-24-11/src/java.base/unix/classes/sun/security/provider/NativePRNG.java 2024-08-17 20:36:14.246381288 +0200
16049 @@ -33,7 +33,7 @@
16050 import sun.security.util.Debug;
16053 - * Native PRNG implementation for Linux/MacOS.
16054 + * Native PRNG implementation for Solaris/Linux/MacOS.
16055 * <p>
16056 * It obtains seed and random numbers by reading system files such as
16057 * the special device files /dev/random and /dev/urandom. This
16058 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/io_util_md.c jdk-jdk-24-11/src/java.base/unix/native/libjava/io_util_md.c
16059 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/io_util_md.c 2024-08-15 09:39:31.000000000 +0200
16060 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/io_util_md.c 2024-08-17 20:36:14.249661764 +0200
16061 @@ -30,6 +30,10 @@
16062 #include <string.h>
16063 #include <unistd.h>
16065 +#ifdef __solaris__
16066 +#include <sys/filio.h>
16067 +#endif
16069 #if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
16070 #include <sys/ioctl.h>
16071 #endif
16072 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/java_props_md.c jdk-jdk-24-11/src/java.base/unix/native/libjava/java_props_md.c
16073 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/java_props_md.c 2024-08-15 09:39:31.000000000 +0200
16074 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/java_props_md.c 2024-08-17 20:36:14.250096752 +0200
16075 @@ -323,6 +323,27 @@
16077 #endif
16079 +#ifdef __solaris__
16080 + if (strcmp(p,"eucJP") == 0) {
16081 + /* For Solaris use customized vendor defined character
16082 + * customized EUC-JP converter
16083 + */
16084 + *std_encoding = "eucJP-open";
16085 + } else if (strcmp(p, "Big5") == 0 || strcmp(p, "BIG5") == 0) {
16086 + /*
16087 + * Remap the encoding string to Big5_Solaris which augments
16088 + * the default converter for Solaris Big5 locales to include
16089 + * seven additional ideographic characters beyond those included
16090 + * in the Java "Big5" converter.
16091 + */
16092 + *std_encoding = "Big5_Solaris";
16093 + } else if (strcmp(p, "Big5-HKSCS") == 0) {
16094 + /*
16095 + * Solaris uses HKSCS2001
16096 + */
16097 + *std_encoding = "Big5-HKSCS-2001";
16099 +#endif
16100 #ifdef MACOSX
16102 * For the case on MacOS X where encoding is set to US-ASCII, but we
16103 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/jlong_md.h jdk-jdk-24-11/src/java.base/unix/native/libjava/jlong_md.h
16104 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/jlong_md.h 2024-08-15 09:39:31.000000000 +0200
16105 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/jlong_md.h 2024-08-17 20:36:14.250490143 +0200
16106 @@ -23,8 +23,8 @@
16107 * questions.
16110 -#ifndef _UNIX_JLONG_MD_H_
16111 -#define _UNIX_JLONG_MD_H_
16112 +#ifndef _SOLARIS_JLONG_MD_H_
16113 +#define _SOLARIS_JLONG_MD_H_
16115 /* Make sure ptrdiff_t is defined */
16116 #include <stddef.h>
16117 @@ -97,4 +97,4 @@
16118 #define size_to_jlong(a) ((jlong)(a))
16119 #define long_to_jlong(a) ((jlong)(a))
16121 -#endif /* !_UNIX_JLONG_MD_H_ */
16122 +#endif /* !_SOLARIS_JLONG_MD_H_ */
16123 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c
16124 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c 2024-08-15 09:39:31.000000000 +0200
16125 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c 2024-08-17 20:36:14.247178570 +0200
16126 @@ -44,8 +44,16 @@
16127 #include <sys/stat.h>
16128 #include <sys/wait.h>
16130 +/* For POSIX-compliant getpwuid_r on Solaris */
16131 +#if defined(__solaris__)
16132 +#define _POSIX_PTHREAD_SEMANTICS
16133 +#endif
16134 #include <pwd.h>
16136 +#ifdef __solaris__
16137 +#include <procfs.h>
16138 +#endif
16140 #if defined(_AIX)
16141 #include <sys/procfs.h>
16142 #endif
16143 @@ -122,13 +130,18 @@
16144 #define WTERMSIG(status) ((status)&0x7F)
16145 #endif
16147 +#ifdef __solaris__
16148 /* The child exited because of a signal.
16149 * The best value to return is 0x80 + signal number,
16150 * because that is what all Unix shells do, and because
16151 * it allows callers to distinguish between process exit and
16152 * process death by signal.
16153 - */
16154 + * Unfortunately, the historical behavior on Solaris is to return
16155 + * the signal number, and we preserve this for compatibility. */
16156 +#define WTERMSIG_RETURN(status) WTERMSIG(status)
16157 +#else
16158 #define WTERMSIG_RETURN(status) (WTERMSIG(status) + 0x80)
16159 +#endif
16161 /* Field id for jString 'command' in java.lang.ProcessHandleImpl.Info */
16162 jfieldID ProcessHandleImpl_Info_commandID;
16163 @@ -469,7 +482,7 @@
16164 * The following functions are for Linux
16167 -#if defined (__linux__)
16168 +#if defined(__solaris__) || defined (__linux__)
16171 * Return pids of active processes, and optionally parent pids and
16172 @@ -598,13 +611,13 @@
16173 return count;
16176 -#endif // defined (__linux__)
16177 +#endif // defined(__solaris__) || defined (__linux__)
16180 - * The following functions are for AIX.
16181 + * The following functions are common on Solaris and AIX.
16184 -#if defined(_AIX)
16185 +#if defined(__solaris__) || defined(_AIX)
16188 * Helper function to get the 'psinfo_t' data from "/proc/%d/psinfo".
16189 @@ -668,6 +681,19 @@
16190 int ret;
16193 + * On Solaris, the full path to the executable command is the link in
16194 + * /proc/<pid>/paths/a.out. But it is only readable for processes we own.
16195 + */
16196 +#if defined(__solaris__)
16197 + snprintf(fn, sizeof fn, "/proc/%d/path/a.out", pid);
16198 + if ((ret = readlink(fn, exePath, PATH_MAX - 1)) > 0) {
16199 + // null terminate and create String to store for command
16200 + exePath[ret] = '\0';
16201 + CHECK_NULL(cmdexe = JNU_NewStringPlatform(env, exePath));
16203 +#endif
16205 + /*
16206 * Now try to open /proc/%d/psinfo
16208 if (getPsinfo(pid, &psinfo) < 0) {
16209 @@ -696,4 +722,4 @@
16210 prargs[0] == '\0' ? NULL : prargs);
16213 -#endif // defined(_AIX)
16214 +#endif // defined(__solaris__) || defined(_AIX)
16215 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h
16216 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h 2024-08-15 09:39:31.000000000 +0200
16217 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.h 2024-08-17 20:36:14.247538356 +0200
16218 @@ -29,7 +29,7 @@
16219 * Declaration of ProcessHandleImpl functions common on all Unix platforms.
16220 * 'unix_' functions have a single implementation in ProcessHandleImpl_unix.c
16221 * 'os_' prefixed functions have different, os-specific implementations in the
16222 - * various ProcessHandleImpl_{linux,macosx,aix}.c files.
16223 + * various ProcessHandleImpl_{linux,macosx,solaris,aix}.c files.
16224 * See ProcessHandleImpl_unix.c for more details.
16227 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessImpl_md.c jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessImpl_md.c
16228 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/ProcessImpl_md.c 2024-08-15 09:39:31.000000000 +0200
16229 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/ProcessImpl_md.c 2024-08-17 20:36:14.248140458 +0200
16230 @@ -230,7 +230,14 @@
16231 static const char*
16232 defaultPath(void)
16234 - return ":/bin:/usr/bin";
16235 +#ifdef __solaris__
16236 + /* These really are the Solaris defaults! */
16237 + return (geteuid() == 0 || getuid() == 0) ?
16238 + "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" :
16239 + "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:";
16240 +#else
16241 + return ":/bin:/usr/bin"; /* glibc */
16242 +#endif
16245 static const char*
16246 @@ -447,7 +454,7 @@
16247 #endif
16249 /* vfork(2) is deprecated on Darwin */
16250 -#ifndef __APPLE__
16251 +#ifndef __solaris__
16252 static pid_t
16253 vforkChild(ChildStuff *c) {
16254 volatile pid_t resultPid;
16255 @@ -611,7 +618,7 @@
16256 startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) {
16257 switch (c->mode) {
16258 /* vfork(2) is deprecated on Darwin*/
16259 - #ifndef __APPLE__
16260 + #ifndef __solaris__
16261 case MODE_VFORK:
16262 return vforkChild(c);
16263 #endif
16264 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/TimeZone_md.c jdk-jdk-24-11/src/java.base/unix/native/libjava/TimeZone_md.c
16265 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/TimeZone_md.c 2024-08-15 09:39:31.000000000 +0200
16266 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/TimeZone_md.c 2024-08-17 20:36:14.248878904 +0200
16267 @@ -35,6 +35,9 @@
16268 #include <string.h>
16269 #include <dirent.h>
16270 #include <unistd.h>
16271 +#if defined(__solaris__)
16272 +#include <libscf.h>
16273 +#endif
16275 #include "jvm.h"
16276 #include "jni_util.h"
16277 @@ -43,9 +46,11 @@
16279 static char *isFileIdentical(char* buf, size_t size, char *pathname);
16281 +#if !defined(__solaris__) || defined(__sparcv9) || defined(amd64)
16282 #define fileopen fopen
16283 #define filegets fgets
16284 #define fileclose fclose
16285 +#endif
16287 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
16288 static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
16289 @@ -63,7 +68,7 @@
16290 static const char *ETC_ENVIRONMENT_FILE = "/etc/environment";
16291 #endif
16293 -#if defined(__linux__) || defined(MACOSX)
16294 +#if defined(__linux__) || defined(MACOSX) || defined(__solaris__)
16297 * remove repeated path separators ('/') in the given 'path'.
16298 @@ -173,6 +178,13 @@
16300 if ((strcmp(dp->d_name, "ROC") == 0)
16301 || (strcmp(dp->d_name, "posixrules") == 0)
16302 +#if defined(__solaris__)
16303 + /*
16304 + * Skip the "src" and "tab" directories on Solaris.
16305 + */
16306 + || (strcmp(dp->d_name, "src") == 0)
16307 + || (strcmp(dp->d_name, "tab") == 0)
16308 +#endif
16309 || (strcmp(dp->d_name, "localtime") == 0)) {
16310 continue;
16312 @@ -244,6 +256,8 @@
16313 return possibleMatch;
16316 +#if defined(__linux__) || defined(MACOSX)
16319 * Performs Linux specific mapping and returns a zone ID
16320 * if found. Otherwise, NULL is returned.
16321 @@ -355,6 +369,183 @@
16322 return tz;
16325 +#elif defined(__solaris__)
16328 + * Performs Solaris dependent mapping. Returns a zone ID if
16329 + * found. Otherwise, NULL is returned. Solaris libc looks up
16330 + * "/etc/default/init" to get the default TZ value if TZ is not defined
16331 + * as an environment variable.
16332 + */
16333 +static char *
16334 +getPlatformTimeZoneID()
16336 + char *tz = NULL;
16337 + FILE *fp;
16339 + /*
16340 + * Try the TZ entry in /etc/default/init.
16341 + */
16342 + if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) {
16343 + char line[256];
16344 + char quote = '\0';
16346 + while (filegets(line, sizeof(line), fp) != NULL) {
16347 + char *p = line;
16348 + char *s;
16349 + char c;
16351 + /* quick check for comment lines */
16352 + if (*p == '#') {
16353 + continue;
16355 + if (strncmp(p, "TZ=", 3) == 0) {
16356 + p += 3;
16357 + while (*p == ' ' || *p == '\t') p++;
16358 + c = *p;
16359 + if (c == '"' || c == '\'') {
16360 + quote = c;
16361 + p++;
16364 + /*
16365 + * PSARC/2001/383: quoted string support
16366 + */
16367 + for (s = p; (c = *s) != '\0' && c != '\n'; s++) {
16368 + /* No '\\' is supported here. */
16369 + if (c == quote) {
16370 + quote = '\0';
16371 + break;
16373 + if (c == ' ' && quote == '\0') {
16374 + break;
16377 + if (quote != '\0') {
16378 + jio_fprintf(stderr, "ZoneInfo: unterminated time zone name in /etc/TIMEZONE\n");
16380 + *s = '\0';
16381 + tz = strdup(p);
16382 + break;
16385 + (void) fileclose(fp);
16387 + return tz;
16390 +#define TIMEZONE_FMRI "svc:/system/timezone:default"
16391 +#define TIMEZONE_PG "timezone"
16392 +#define LOCALTIME_PROP "localtime"
16394 +static void
16395 +cleanupScf(scf_handle_t *h,
16396 + scf_snapshot_t *snap,
16397 + scf_instance_t *inst,
16398 + scf_propertygroup_t *pg,
16399 + scf_property_t *prop,
16400 + scf_value_t *val,
16401 + char *buf) {
16402 + if (buf != NULL) {
16403 + free(buf);
16405 + if (snap != NULL) {
16406 + scf_snapshot_destroy(snap);
16408 + if (val != NULL) {
16409 + scf_value_destroy(val);
16411 + if (prop != NULL) {
16412 + scf_property_destroy(prop);
16414 + if (pg != NULL) {
16415 + scf_pg_destroy(pg);
16417 + if (inst != NULL) {
16418 + scf_instance_destroy(inst);
16420 + if (h != NULL) {
16421 + scf_handle_destroy(h);
16426 + * Returns a zone ID of Solaris when the TZ value is "localtime".
16427 + * First, it tries scf. If scf fails, it looks for the same file as
16428 + * /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/.
16429 + */
16430 +static char *
16431 +getSolarisDefaultZoneID() {
16432 + char *tz = NULL;
16433 + struct stat64 statbuf;
16434 + size_t size;
16435 + char *buf;
16436 + int fd;
16437 + int res;
16438 + /* scf specific variables */
16439 + scf_handle_t *h = NULL;
16440 + scf_snapshot_t *snap = NULL;
16441 + scf_instance_t *inst = NULL;
16442 + scf_propertygroup_t *pg = NULL;
16443 + scf_property_t *prop = NULL;
16444 + scf_value_t *val = NULL;
16446 + if ((h = scf_handle_create(SCF_VERSION)) != NULL
16447 + && scf_handle_bind(h) == 0
16448 + && (inst = scf_instance_create(h)) != NULL
16449 + && (snap = scf_snapshot_create(h)) != NULL
16450 + && (pg = scf_pg_create(h)) != NULL
16451 + && (prop = scf_property_create(h)) != NULL
16452 + && (val = scf_value_create(h)) != NULL
16453 + && scf_handle_decode_fmri(h, TIMEZONE_FMRI, NULL, NULL, inst,
16454 + NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == 0
16455 + && scf_instance_get_snapshot(inst, "running", snap) == 0
16456 + && scf_instance_get_pg_composed(inst, snap, TIMEZONE_PG, pg) == 0
16457 + && scf_pg_get_property(pg, LOCALTIME_PROP, prop) == 0
16458 + && scf_property_get_value(prop, val) == 0) {
16459 + ssize_t len;
16461 + /* Gets the length of the zone ID string */
16462 + len = scf_value_get_astring(val, NULL, 0);
16463 + if (len != -1) {
16464 + tz = malloc(++len); /* +1 for a null byte */
16465 + if (tz != NULL && scf_value_get_astring(val, tz, len) != -1) {
16466 + cleanupScf(h, snap, inst, pg, prop, val, NULL);
16467 + return tz;
16471 + cleanupScf(h, snap, inst, pg, prop, val, tz);
16473 + RESTARTABLE(stat64(DEFAULT_ZONEINFO_FILE, &statbuf), res);
16474 + if (res == -1) {
16475 + return NULL;
16477 + size = (size_t) statbuf.st_size;
16478 + buf = malloc(size);
16479 + if (buf == NULL) {
16480 + return NULL;
16482 + RESTARTABLE(open(DEFAULT_ZONEINFO_FILE, O_RDONLY), fd);
16483 + if (fd == -1) {
16484 + free((void *) buf);
16485 + return NULL;
16488 + RESTARTABLE(read(fd, buf, size), res);
16489 + if (res != (ssize_t) size) {
16490 + (void) close(fd);
16491 + free((void *) buf);
16492 + return NULL;
16494 + (void) close(fd);
16495 + tz = findZoneinfoFile(buf, size, ZONEINFO_DIR);
16496 + free((void *) buf);
16497 + return tz;
16500 +#endif /* defined(__solaris__) */
16502 #elif defined(_AIX)
16504 static char *
16505 @@ -520,6 +711,15 @@
16506 free((void *) freetz);
16508 #else
16509 +#if defined(__solaris__)
16510 + /* Solaris might use localtime, so handle it here. */
16511 + if (strcmp(tz, "localtime") == 0) {
16512 + javatz = getSolarisDefaultZoneID();
16513 + if (freetz != NULL) {
16514 + free((void *) freetz);
16516 + } else
16517 +#endif
16518 if (freetz == NULL) {
16519 /* strdup if we are still working on getenv result. */
16520 javatz = strdup(tz);
16521 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/UnixFileSystem_md.c jdk-jdk-24-11/src/java.base/unix/native/libjava/UnixFileSystem_md.c
16522 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjava/UnixFileSystem_md.c 2024-08-15 09:39:31.000000000 +0200
16523 +++ jdk-jdk-24-11/src/java.base/unix/native/libjava/UnixFileSystem_md.c 2024-08-17 20:36:14.249261141 +0200
16524 @@ -57,6 +57,11 @@
16525 #endif
16526 #define statvfs statvfs64
16527 #endif
16529 +#if defined(__solaris__) && !defined(NAME_MAX)
16530 + #define NAME_MAX MAXNAMLEN
16531 +#endif
16533 /* -- Field IDs -- */
16535 static struct {
16536 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libjsig/jsig.c jdk-jdk-24-11/src/java.base/unix/native/libjsig/jsig.c
16537 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libjsig/jsig.c 2024-08-15 09:39:31.000000000 +0200
16538 +++ jdk-jdk-24-11/src/java.base/unix/native/libjsig/jsig.c 2024-08-17 20:36:14.251226315 +0200
16539 @@ -35,6 +35,16 @@
16541 #include "jni.h"
16543 +#ifdef SOLARIS
16544 +/* Our redeclarations of the system functions must not have a less
16545 + * restrictive linker scoping, so we have to declare them as JNIEXPORT
16546 + * before including signal.h */
16547 +#include "sys/signal.h"
16548 +JNIEXPORT void (*signal(int sig, void (*disp)(int)))(int);
16549 +JNIEXPORT void (*sigset(int sig, void (*disp)(int)))(int);
16550 +JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *oact);
16551 +#endif
16553 #include <dlfcn.h>
16554 #include <errno.h>
16555 #include <pthread.h>
16556 @@ -51,9 +61,16 @@
16557 #define false 0
16558 #endif
16560 +#ifdef SOLARIS
16561 +#define MAX_SIGNALS (SIGRTMAX+1)
16563 +/* On solaris, MAX_SIGNALS is a macro, not a constant, so we must allocate sact dynamically. */
16564 +static struct sigaction *sact = (struct sigaction *)NULL; /* saved signal handlers */
16565 +#else
16566 #define MAX_SIGNALS NSIG
16568 static struct sigaction sact[MAX_SIGNALS]; /* saved signal handlers */
16569 +#endif
16571 static sigset_t jvmsigs; /* Signals used by jvm. */
16573 @@ -78,6 +95,20 @@
16574 static bool jvm_signal_installed = false;
16577 +/* assume called within signal_lock */
16578 +static void allocate_sact() {
16579 +#ifdef SOLARIS
16580 + if (sact == NULL) {
16581 + sact = (struct sigaction *)malloc((MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
16582 + if (sact == NULL) {
16583 + printf("%s\n", "libjsig.so unable to allocate memory");
16584 + exit(0);
16586 + memset(sact, 0, (MAX_SIGNALS) * (size_t)sizeof(struct sigaction));
16588 +#endif
16591 static void signal_lock() {
16592 pthread_mutex_lock(&mutex);
16593 /* When the jvm is installing its set of signal handlers, threads
16594 @@ -137,7 +168,18 @@
16595 sact[sig].sa_handler = disp;
16596 sigemptyset(&set);
16597 sact[sig].sa_mask = set;
16598 - sact[sig].sa_flags = 0;
16599 + if (!is_sigset) {
16600 +#ifdef SOLARIS
16601 + sact[sig].sa_flags = SA_NODEFER;
16602 + if (sig != SIGILL && sig != SIGTRAP && sig != SIGPWR) {
16603 + sact[sig].sa_flags |= SA_RESETHAND;
16605 +#else
16606 + sact[sig].sa_flags = 0;
16607 +#endif
16608 + } else {
16609 + sact[sig].sa_flags = 0;
16613 static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
16614 @@ -146,6 +188,7 @@
16615 bool sigblocked;
16617 signal_lock();
16618 + allocate_sact();
16620 sigused = sigismember(&jvmsigs, sig);
16621 if (jvm_signal_installed && sigused) {
16622 @@ -157,6 +200,13 @@
16623 oldhandler = sact[sig].sa_handler;
16624 save_signal_handler(sig, disp, is_sigset);
16626 +#ifdef SOLARIS
16627 + if (is_sigset && sigblocked) {
16628 + /* We won't honor the SIG_HOLD request to change the signal mask */
16629 + oldhandler = SIG_HOLD;
16631 +#endif
16633 signal_unlock();
16634 return oldhandler;
16635 } else if (jvm_signal_installing) {
16636 @@ -234,6 +284,7 @@
16638 signal_lock();
16640 + allocate_sact();
16641 sigused = sigismember(&jvmsigs, sig);
16642 if (jvm_signal_installed && sigused) {
16643 /* jvm has installed its signal handler for this signal. */
16644 @@ -300,6 +351,7 @@
16647 JNIEXPORT struct sigaction *JVM_get_signal_action(int sig) {
16648 + allocate_sact();
16649 /* Does race condition make sense here? */
16650 if (sigismember(&jvmsigs, sig)) {
16651 return &sact[sig];
16652 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/Inet4AddressImpl.c jdk-jdk-24-11/src/java.base/unix/native/libnet/Inet4AddressImpl.c
16653 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/Inet4AddressImpl.c 2024-08-15 09:39:31.000000000 +0200
16654 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/Inet4AddressImpl.c 2024-08-17 20:36:14.251703535 +0200
16655 @@ -66,8 +66,27 @@
16656 if (gethostname(hostname, sizeof(hostname)) != 0) {
16657 strcpy(hostname, "localhost");
16658 } else {
16659 +#if defined(__solaris__)
16660 + // try to resolve hostname via nameservice
16661 + // if it is known but getnameinfo fails, hostname will still be the
16662 + // value from gethostname
16663 + struct addrinfo hints, *res;
16665 // make sure string is null-terminated
16666 hostname[NI_MAXHOST] = '\0';
16667 + memset(&hints, 0, sizeof(hints));
16668 + hints.ai_flags = AI_CANONNAME;
16669 + hints.ai_family = AF_INET;
16671 + if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
16672 + getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
16673 + NULL, 0, NI_NAMEREQD);
16674 + freeaddrinfo(res);
16676 +#else
16677 + // make sure string is null-terminated
16678 + hostname[NI_MAXHOST] = '\0';
16679 +#endif
16681 return (*env)->NewStringUTF(env, hostname);
16683 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/Inet6AddressImpl.c jdk-jdk-24-11/src/java.base/unix/native/libnet/Inet6AddressImpl.c
16684 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/Inet6AddressImpl.c 2024-08-15 09:39:31.000000000 +0200
16685 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/Inet6AddressImpl.c 2024-08-17 20:36:14.252150669 +0200
16686 @@ -67,8 +67,27 @@
16687 if (gethostname(hostname, sizeof(hostname)) != 0) {
16688 strcpy(hostname, "localhost");
16689 } else {
16690 +#if defined(__solaris__)
16691 + // try to resolve hostname via nameservice
16692 + // if it is known but getnameinfo fails, hostname will still be the
16693 + // value from gethostname
16694 + struct addrinfo hints, *res;
16696 // make sure string is null-terminated
16697 hostname[NI_MAXHOST] = '\0';
16698 + memset(&hints, 0, sizeof(hints));
16699 + hints.ai_flags = AI_CANONNAME;
16700 + hints.ai_family = AF_UNSPEC;
16702 + if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
16703 + getnameinfo(res->ai_addr, res->ai_addrlen, hostname, sizeof(hostname),
16704 + NULL, 0, NI_NAMEREQD);
16705 + freeaddrinfo(res);
16707 +#else
16708 + // make sure string is null-terminated
16709 + hostname[NI_MAXHOST] = '\0';
16710 +#endif
16712 return (*env)->NewStringUTF(env, hostname);
16714 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/net_util_md.c jdk-jdk-24-11/src/java.base/unix/native/libnet/net_util_md.c
16715 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/net_util_md.c 2024-08-15 09:39:31.000000000 +0200
16716 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/net_util_md.c 2024-08-17 20:36:14.254427343 +0200
16717 @@ -36,6 +36,14 @@
16718 #include <sys/utsname.h>
16719 #endif
16721 +#if defined(__solaris__)
16722 +#include <inet/nd.h>
16723 +#include <limits.h>
16724 +#include <stropts.h>
16725 +#include <sys/filio.h>
16726 +#include <sys/sockio.h>
16727 +#endif
16729 #if defined(MACOSX)
16730 #include <sys/sysctl.h>
16731 #endif
16732 @@ -50,12 +58,114 @@
16733 #define IPV6_FLOWINFO_SEND 33
16734 #endif
16736 +#if defined(__solaris__) && !defined(MAXINT)
16737 +#define MAXINT INT_MAX
16738 +#endif
16741 + * EXCLBIND socket options only on Solaris
16742 + */
16743 +#if defined(__solaris__) && !defined(TCP_EXCLBIND)
16744 +#define TCP_EXCLBIND 0x21
16745 +#endif
16746 +#if defined(__solaris__) && !defined(UDP_EXCLBIND)
16747 +#define UDP_EXCLBIND 0x0101
16748 +#endif
16750 void
16751 NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
16752 const char *defaultDetail) {
16753 JNU_ThrowByNameWithMessageAndLastError(env, name, defaultDetail);
16756 +#ifdef __solaris__
16757 +static int init_tcp_max_buf, init_udp_max_buf;
16758 +static int tcp_max_buf;
16759 +static int udp_max_buf;
16760 +static int useExclBind = 0;
16763 + * Get the specified parameter from the specified driver. The value
16764 + * of the parameter is assumed to be an 'int'. If the parameter
16765 + * cannot be obtained return -1
16766 + */
16767 +int net_getParam(char *driver, char *param)
16769 + struct strioctl stri;
16770 + char buf [64];
16771 + int s;
16772 + int value;
16774 + s = open (driver, O_RDWR);
16775 + if (s < 0) {
16776 + return -1;
16778 + strncpy (buf, param, sizeof(buf));
16779 + stri.ic_cmd = ND_GET;
16780 + stri.ic_timout = 0;
16781 + stri.ic_dp = buf;
16782 + stri.ic_len = sizeof(buf);
16783 + if (ioctl (s, I_STR, &stri) < 0) {
16784 + value = -1;
16785 + } else {
16786 + value = atoi(buf);
16788 + close (s);
16789 + return value;
16793 + * Iterative way to find the max value that SO_SNDBUF or SO_RCVBUF
16794 + * for Solaris versions that do not support the ioctl() in net_getParam().
16795 + * Ugly, but only called once (for each sotype).
16797 + * As an optimization, we make a guess using the default values for Solaris
16798 + * assuming they haven't been modified with ndd.
16799 + */
16801 +#define MAX_TCP_GUESS 1024 * 1024
16802 +#define MAX_UDP_GUESS 2 * 1024 * 1024
16804 +#define FAIL_IF_NOT_ENOBUFS if (errno != ENOBUFS) return -1
16806 +static int findMaxBuf(int fd, int opt, int sotype) {
16807 + int a = 0;
16808 + int b = MAXINT;
16809 + int initial_guess;
16810 + int limit = -1;
16812 + if (sotype == SOCK_DGRAM) {
16813 + initial_guess = MAX_UDP_GUESS;
16814 + } else {
16815 + initial_guess = MAX_TCP_GUESS;
16818 + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess, sizeof(int)) == 0) {
16819 + initial_guess++;
16820 + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess,sizeof(int)) < 0) {
16821 + FAIL_IF_NOT_ENOBUFS;
16822 + return initial_guess - 1;
16824 + a = initial_guess;
16825 + } else {
16826 + FAIL_IF_NOT_ENOBUFS;
16827 + b = initial_guess - 1;
16829 + do {
16830 + int mid = a + (b-a)/2;
16831 + if (setsockopt(fd, SOL_SOCKET, opt, &mid, sizeof(int)) == 0) {
16832 + limit = mid;
16833 + a = mid + 1;
16834 + } else {
16835 + FAIL_IF_NOT_ENOBUFS;
16836 + b = mid - 1;
16838 + } while (b >= a);
16840 + return limit;
16842 +#endif
16844 void
16845 NET_ThrowNew(JNIEnv *env, int errorNumber, char *msg) {
16846 char fullMsg[512];
16847 @@ -133,6 +243,50 @@
16849 #endif
16851 + /**
16852 + * On Solaris 8 it's possible to create INET6 sockets even
16853 + * though IPv6 is not enabled on all interfaces. Thus we
16854 + * query the number of IPv6 addresses to verify that IPv6
16855 + * has been configured on at least one interface.
16857 + * On Linux it doesn't matter - if IPv6 is built-in the
16858 + * kernel then IPv6 addresses will be bound automatically
16859 + * to all interfaces.
16860 + */
16861 +#ifdef __solaris__
16863 +#ifdef SIOCGLIFNUM
16865 + struct lifnum numifs;
16867 + numifs.lifn_family = AF_INET6;
16868 + numifs.lifn_flags = 0;
16869 + if (ioctl(fd, SIOCGLIFNUM, (char *)&numifs) < 0) {
16870 + /**
16871 + * SIOCGLIFNUM failed - assume IPv6 not configured
16872 + */
16873 + close(fd);
16874 + return JNI_FALSE;
16876 + /**
16877 + * If no IPv6 addresses then return false. If count > 0
16878 + * it's possible that all IPv6 addresses are "down" but
16879 + * that's okay as they may be brought "up" while the
16880 + * VM is running.
16881 + */
16882 + if (numifs.lifn_count == 0) {
16883 + close(fd);
16884 + return JNI_FALSE;
16887 +#else
16888 + /* SIOCGLIFNUM not defined in build environment ??? */
16889 + close(fd);
16890 + return JNI_FALSE;
16891 +#endif
16893 +#endif /* __solaris */
16896 * OK we may have the stack available in the kernel,
16897 * we should also check if the APIs are available.
16898 @@ -197,6 +351,26 @@
16902 +void parseExclusiveBindProperty(JNIEnv *env) {
16903 +#ifdef __solaris__
16904 + jstring s, flagSet;
16905 + jclass iCls;
16906 + jmethodID mid;
16908 + s = (*env)->NewStringUTF(env, "sun.net.useExclusiveBind");
16909 + CHECK_NULL(s);
16910 + iCls = (*env)->FindClass(env, "java/lang/System");
16911 + CHECK_NULL(iCls);
16912 + mid = (*env)->GetStaticMethodID(env, iCls, "getProperty",
16913 + "(Ljava/lang/String;)Ljava/lang/String;");
16914 + CHECK_NULL(mid);
16915 + flagSet = (*env)->CallStaticObjectMethod(env, iCls, mid, s);
16916 + if (flagSet != NULL) {
16917 + useExclBind = 1;
16919 +#endif
16922 JNIEXPORT jint JNICALL
16923 NET_EnableFastTcpLoopback(int fd) {
16924 return 0;
16925 @@ -438,6 +612,65 @@
16926 *iptos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
16929 + /*
16930 + * SOL_SOCKET/{SO_SNDBUF,SO_RCVBUF} - On Solaris we may need to clamp
16931 + * the value when it exceeds the system limit.
16932 + */
16933 +#ifdef __solaris__
16934 + if (level == SOL_SOCKET) {
16935 + if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
16936 + int sotype=0;
16937 + socklen_t arglen;
16938 + int *bufsize, maxbuf;
16939 + int ret;
16941 + /* Attempt with the original size */
16942 + ret = setsockopt(fd, level, opt, arg, len);
16943 + if ((ret == 0) || (ret == -1 && errno != ENOBUFS))
16944 + return ret;
16946 + /* Exceeded system limit so clamp and retry */
16948 + arglen = sizeof(sotype);
16949 + if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype,
16950 + &arglen) < 0) {
16951 + return -1;
16954 + /*
16955 + * We try to get tcp_maxbuf (and udp_max_buf) using
16956 + * an ioctl() that isn't available on all versions of Solaris.
16957 + * If that fails, we use the search algorithm in findMaxBuf()
16958 + */
16959 + if (!init_tcp_max_buf && sotype == SOCK_STREAM) {
16960 + tcp_max_buf = net_getParam("/dev/tcp", "tcp_max_buf");
16961 + if (tcp_max_buf == -1) {
16962 + tcp_max_buf = findMaxBuf(fd, opt, SOCK_STREAM);
16963 + if (tcp_max_buf == -1) {
16964 + return -1;
16967 + init_tcp_max_buf = 1;
16968 + } else if (!init_udp_max_buf && sotype == SOCK_DGRAM) {
16969 + udp_max_buf = net_getParam("/dev/udp", "udp_max_buf");
16970 + if (udp_max_buf == -1) {
16971 + udp_max_buf = findMaxBuf(fd, opt, SOCK_DGRAM);
16972 + if (udp_max_buf == -1) {
16973 + return -1;
16976 + init_udp_max_buf = 1;
16979 + maxbuf = (sotype == SOCK_STREAM) ? tcp_max_buf : udp_max_buf;
16980 + bufsize = (int *)arg;
16981 + if (*bufsize > maxbuf) {
16982 + *bufsize = maxbuf;
16986 +#endif
16988 #ifdef _AIX
16989 if (level == SOL_SOCKET) {
16990 if (opt == SO_SNDBUF || opt == SO_RCVBUF) {
16991 @@ -552,10 +785,20 @@
16993 * Linux allows a socket to bind to 127.0.0.255 which must be
16994 * caught.
16996 + * On Solaris with IPv6 enabled we must use an exclusive
16997 + * bind to guarantee a unique port number across the IPv4 and
16998 + * IPv6 port spaces.
17002 NET_Bind(int fd, SOCKETADDRESS *sa, int len)
17004 +#if defined(__solaris__)
17005 + int level = -1;
17006 + int exclbind = -1;
17007 + int arg, alen;
17008 +#endif
17009 int rv;
17011 #ifdef __linux__
17012 @@ -572,8 +815,61 @@
17014 #endif
17016 +#if defined(__solaris__)
17017 + /*
17018 + * Solaris has separate IPv4 and IPv6 port spaces so we
17019 + * use an exclusive bind when SO_REUSEADDR is not used to
17020 + * give the illusion of a unified port space.
17021 + * This also avoids problems with IPv6 sockets connecting
17022 + * to IPv4 mapped addresses whereby the socket conversion
17023 + * results in a late bind that fails because the
17024 + * corresponding IPv4 port is in use.
17025 + */
17026 + alen = sizeof(arg);
17028 + if (useExclBind ||
17029 + getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg, &alen) == 0)
17031 + if (useExclBind || arg == 0) {
17032 + /*
17033 + * SO_REUSEADDR is disabled or sun.net.useExclusiveBind
17034 + * property is true so enable TCP_EXCLBIND or
17035 + * UDP_EXCLBIND
17036 + */
17037 + alen = sizeof(arg);
17038 + if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, &alen) == 0)
17040 + if (arg == SOCK_STREAM) {
17041 + level = IPPROTO_TCP;
17042 + exclbind = TCP_EXCLBIND;
17043 + } else {
17044 + level = IPPROTO_UDP;
17045 + exclbind = UDP_EXCLBIND;
17049 + arg = 1;
17050 + setsockopt(fd, level, exclbind, (char *)&arg, sizeof(arg));
17054 +#endif
17056 rv = bind(fd, &sa->sa, len);
17058 +#if defined(__solaris__)
17059 + if (rv < 0) {
17060 + int en = errno;
17061 + /* Restore *_EXCLBIND if the bind fails */
17062 + if (exclbind != -1) {
17063 + int arg = 0;
17064 + setsockopt(fd, level, exclbind, (char *)&arg,
17065 + sizeof(arg));
17067 + errno = en;
17069 +#endif
17071 return rv;
17074 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/net_util_md.h jdk-jdk-24-11/src/java.base/unix/native/libnet/net_util_md.h
17075 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/net_util_md.h 2024-08-15 09:39:31.000000000 +0200
17076 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/net_util_md.h 2024-08-17 20:36:14.254852485 +0200
17077 @@ -47,6 +47,8 @@
17078 #ifndef SO_REUSEPORT
17079 #ifdef __linux__
17080 #define SO_REUSEPORT 15
17081 +#elif defined(__solaris__)
17082 +#define SO_REUSEPORT 0x100e
17083 #elif defined(AIX) || defined(MACOSX)
17084 #define SO_REUSEPORT 0x0200
17085 #else
17086 @@ -80,4 +82,8 @@
17087 void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
17088 const char *defaultDetail);
17090 +#ifdef __solaris__
17091 +int net_getParam(char *driver, char *param);
17092 +#endif
17094 #endif /* NET_UTILS_MD_H */
17095 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/NetworkInterface.c jdk-jdk-24-11/src/java.base/unix/native/libnet/NetworkInterface.c
17096 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/NetworkInterface.c 2024-08-15 09:39:31.000000000 +0200
17097 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/NetworkInterface.c 2024-08-17 20:36:14.253127751 +0200
17098 @@ -37,6 +37,12 @@
17099 #include <strings.h>
17100 #endif
17102 +#if defined(__solaris__)
17103 +#include <stropts.h>
17104 +#include <sys/dlpi.h>
17105 +#include <sys/sockio.h>
17106 +#endif
17108 #if defined(_ALLBSD_SOURCE)
17109 #include <net/ethernet.h>
17110 #include <net/if_dl.h>
17111 @@ -49,6 +55,11 @@
17113 #if defined(__linux__)
17114 #define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
17115 +#elif defined(__solaris__)
17116 + #ifndef SIOCGLIFHWADDR
17117 + #define SIOCGLIFHWADDR _IOWR('i', 192, struct lifreq)
17118 + #endif
17119 + #define DEV_PREFIX "/dev/"
17120 #endif
17122 #ifdef LIFNAMSIZ
17123 @@ -135,6 +146,11 @@
17124 const struct in_addr *addr, unsigned char *buf);
17125 static int getMTU(JNIEnv *env, int sock, const char *ifname);
17127 +#if defined(__solaris__)
17128 +static int getMacFromDevice(JNIEnv *env, const char *ifname,
17129 + unsigned char *retbuf);
17130 +#endif
17132 /******************* Java entry points *****************************/
17135 @@ -1658,6 +1674,372 @@
17137 #endif /* _AIX */
17139 +/** Solaris **/
17140 +#if defined(__solaris__)
17143 + * Opens a socket for further ioctl calls. Tries AF_INET socket first and
17144 + * if it fails return AF_INET6 socket.
17145 + */
17146 +static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
17147 + int sock, alreadyV6 = 0;
17148 + struct lifreq if2;
17150 + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
17151 + if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) {
17152 + if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
17153 + JNU_ThrowByNameWithMessageAndLastError
17154 + (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
17155 + return -1;
17157 + alreadyV6 = 1;
17158 + } else { // errno is not NOSUPPORT
17159 + JNU_ThrowByNameWithMessageAndLastError
17160 + (env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
17161 + return -1;
17165 + // Solaris requires that we have an IPv6 socket to query an interface
17166 + // without an IPv4 address - check it here. POSIX 1 require the kernel to
17167 + // return ENOTTY if the call is inappropriate for a device e.g. the NETMASK
17168 + // for a device having IPv6 only address but not all devices follow the
17169 + // standard so fall back on any error. It's not an ecologically friendly
17170 + // gesture but more reliable.
17171 + if (!alreadyV6) {
17172 + memset((char *)&if2, 0, sizeof(if2));
17173 + strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
17174 + if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
17175 + close(sock);
17176 + if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
17177 + JNU_ThrowByNameWithMessageAndLastError
17178 + (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
17179 + return -1;
17184 + return sock;
17188 + * Enumerates and returns all IPv4 interfaces on Solaris.
17189 + */
17190 +static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
17191 + struct lifconf ifc;
17192 + struct lifreq *ifreqP;
17193 + struct lifnum numifs;
17194 + char *buf = NULL;
17195 + unsigned i;
17197 + // call SIOCGLIFNUM to get the interface count
17198 + numifs.lifn_family = AF_INET;
17199 + numifs.lifn_flags = 0;
17200 + if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
17201 + JNU_ThrowByNameWithMessageAndLastError
17202 + (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
17203 + return ifs;
17206 + // call SIOCGLIFCONF to enumerate the interfaces
17207 + ifc.lifc_len = numifs.lifn_count * sizeof(struct lifreq);
17208 + CHECKED_MALLOC3(buf, char *, ifc.lifc_len);
17209 + ifc.lifc_buf = buf;
17210 + ifc.lifc_family = AF_INET;
17211 + ifc.lifc_flags = 0;
17212 + if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
17213 + JNU_ThrowByNameWithMessageAndLastError
17214 + (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
17215 + free(buf);
17216 + return ifs;
17219 + // iterate through each interface
17220 + ifreqP = ifc.lifc_req;
17221 + for (i = 0; i < numifs.lifn_count; i++, ifreqP++) {
17222 + struct sockaddr addr, *broadaddrP = NULL;
17224 + // ignore non IPv4 addresses
17225 + if (ifreqP->lifr_addr.ss_family != AF_INET) {
17226 + continue;
17229 + // save socket address
17230 + memcpy(&addr, &(ifreqP->lifr_addr), sizeof(struct sockaddr));
17232 + // determine broadcast address, if applicable
17233 + if ((ioctl(sock, SIOCGLIFFLAGS, ifreqP) == 0) &&
17234 + ifreqP->lifr_flags & IFF_BROADCAST) {
17236 + // restore socket address to ifreqP
17237 + memcpy(&(ifreqP->lifr_addr), &addr, sizeof(struct sockaddr));
17239 + // query broadcast address and set pointer to it
17240 + if (ioctl(sock, SIOCGLIFBRDADDR, ifreqP) == 0) {
17241 + broadaddrP = (struct sockaddr *)&(ifreqP->lifr_broadaddr);
17245 + // add to the list
17246 + ifs = addif(env, sock, ifreqP->lifr_name, ifs,
17247 + &addr, broadaddrP, AF_INET, (short)ifreqP->lifr_addrlen);
17249 + // if an exception occurred we return immediately
17250 + if ((*env)->ExceptionOccurred(env)) {
17251 + free(buf);
17252 + return ifs;
17256 + // free buffer
17257 + free(buf);
17258 + return ifs;
17262 + * Enumerates and returns all IPv6 interfaces on Solaris.
17263 + */
17264 +static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
17265 + struct lifconf ifc;
17266 + struct lifreq *ifreqP;
17267 + struct lifnum numifs;
17268 + char *buf = NULL;
17269 + unsigned i;
17271 + // call SIOCGLIFNUM to get the interface count
17272 + numifs.lifn_family = AF_INET6;
17273 + numifs.lifn_flags = 0;
17274 + if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
17275 + JNU_ThrowByNameWithMessageAndLastError
17276 + (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
17277 + return ifs;
17280 + // call SIOCGLIFCONF to enumerate the interfaces
17281 + ifc.lifc_len = numifs.lifn_count * sizeof(struct lifreq);
17282 + CHECKED_MALLOC3(buf, char *, ifc.lifc_len);
17283 + ifc.lifc_buf = buf;
17284 + ifc.lifc_family = AF_INET6;
17285 + ifc.lifc_flags = 0;
17286 + if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
17287 + JNU_ThrowByNameWithMessageAndLastError
17288 + (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
17289 + free(buf);
17290 + return ifs;
17293 + // iterate through each interface
17294 + ifreqP = ifc.lifc_req;
17295 + for (i = 0; i < numifs.lifn_count; i++, ifreqP++) {
17297 + // ignore non IPv6 addresses
17298 + if (ifreqP->lifr_addr.ss_family != AF_INET6) {
17299 + continue;
17302 + // set scope ID to interface index
17303 + ((struct sockaddr_in6 *)&(ifreqP->lifr_addr))->sin6_scope_id =
17304 + getIndex(sock, ifreqP->lifr_name);
17306 + // add to the list
17307 + ifs = addif(env, sock, ifreqP->lifr_name, ifs,
17308 + (struct sockaddr *)&(ifreqP->lifr_addr),
17309 + NULL, AF_INET6, (short)ifreqP->lifr_addrlen);
17311 + // if an exception occurred we return immediately
17312 + if ((*env)->ExceptionOccurred(env)) {
17313 + free(buf);
17314 + return ifs;
17318 + // free buffer
17319 + free(buf);
17320 + return ifs;
17324 + * Try to get the interface index.
17325 + * (Not supported on Solaris 2.6 or 7)
17326 + */
17327 +static int getIndex(int sock, const char *name) {
17328 + struct lifreq if2;
17329 + memset((char *)&if2, 0, sizeof(if2));
17330 + strncpy(if2.lifr_name, name, sizeof(if2.lifr_name) - 1);
17332 + if (ioctl(sock, SIOCGLIFINDEX, (char *)&if2) < 0) {
17333 + return -1;
17336 + return if2.lifr_index;
17340 + * Solaris specific DLPI code to get hardware address from a device.
17341 + * Unfortunately, at least up to Solaris X, you have to have special
17342 + * privileges (i.e. be root).
17343 + */
17344 +static int getMacFromDevice
17345 + (JNIEnv *env, const char *ifname, unsigned char *retbuf)
17347 + char style1dev[MAXPATHLEN];
17348 + int fd;
17349 + dl_phys_addr_req_t dlpareq;
17350 + dl_phys_addr_ack_t *dlpaack;
17351 + dl_error_ack_t *dlerack;
17352 + struct strbuf msg;
17353 + char buf[128];
17354 + int flags = 0;
17356 + // Device is in /dev. e.g.: /dev/bge0
17357 + strcpy(style1dev, DEV_PREFIX);
17358 + strcat(style1dev, ifname);
17359 + if ((fd = open(style1dev, O_RDWR)) < 0) {
17360 + // Can't open it. We probably are missing the privilege.
17361 + // We'll have to try something else
17362 + return 0;
17365 + dlpareq.dl_primitive = DL_PHYS_ADDR_REQ;
17366 + dlpareq.dl_addr_type = DL_CURR_PHYS_ADDR;
17368 + msg.buf = (char *)&dlpareq;
17369 + msg.len = DL_PHYS_ADDR_REQ_SIZE;
17371 + if (putmsg(fd, &msg, NULL, 0) < 0) {
17372 + JNU_ThrowByNameWithMessageAndLastError
17373 + (env, JNU_JAVANETPKG "SocketException", "putmsg() failed");
17374 + return -1;
17377 + dlpaack = (dl_phys_addr_ack_t *)buf;
17379 + msg.buf = (char *)buf;
17380 + msg.len = 0;
17381 + msg.maxlen = sizeof (buf);
17382 + if (getmsg(fd, &msg, NULL, &flags) < 0) {
17383 + JNU_ThrowByNameWithMessageAndLastError
17384 + (env, JNU_JAVANETPKG "SocketException", "getmsg() failed");
17385 + return -1;
17388 + if (dlpaack->dl_primitive == DL_ERROR_ACK) {
17389 + dlerack = (dl_error_ack_t *)buf;
17390 + if (dlerack->dl_error_primitive != DL_PHYS_ADDR_REQ) {
17391 + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
17392 + "Couldn't obtain physical address\n");
17393 + return -1;
17395 + if (dlerack->dl_errno == DL_UNSUPPORTED) {
17396 + // fallback to lookup in the ARP table
17397 + return 0;
17401 + if (msg.len < DL_PHYS_ADDR_ACK_SIZE || dlpaack->dl_primitive != DL_PHYS_ADDR_ACK) {
17402 + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
17403 + "Couldn't obtain phys addr\n");
17404 + return -1;
17407 + memcpy(retbuf, &buf[dlpaack->dl_addr_offset], dlpaack->dl_addr_length);
17408 + return dlpaack->dl_addr_length;
17412 + * Gets the Hardware address (usually MAC address) for the named interface.
17413 + * On return puts the data in buf, and returns the length, in byte, of the
17414 + * MAC address. Returns -1 if there is no hardware address on that interface.
17415 + */
17416 +static int getMacAddress
17417 + (JNIEnv *env, const char *ifname, const struct in_addr *addr,
17418 + unsigned char *buf)
17420 + struct lifreq if2;
17421 + int len, i, sock;
17423 + if ((sock = openSocketWithFallback(env, ifname)) < 0) {
17424 + return -1;
17427 + // First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails
17428 + // try the old way.
17429 + memset((char *)&if2, 0, sizeof(if2));
17430 + strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
17432 + if (ioctl(sock, SIOCGLIFHWADDR, &if2) != -1) {
17433 + struct sockaddr_dl *sp;
17434 + sp = (struct sockaddr_dl *)&if2.lifr_addr;
17435 + memcpy(buf, &sp->sdl_data[0], sp->sdl_alen);
17436 + close(sock);
17437 + return sp->sdl_alen;
17440 + // On Solaris we have to use DLPI, but it will only work if we have
17441 + // privileged access (i.e. root). If that fails, we try a lookup
17442 + // in the ARP table, which requires an IPv4 address.
17443 + if (((len = getMacFromDevice(env, ifname, buf)) == 0) && (addr != NULL)) {
17444 + struct arpreq arpreq;
17445 + struct sockaddr_in *sin;
17446 + struct sockaddr_in ipAddr;
17448 + len = 6; //???
17450 + sin = (struct sockaddr_in *)&arpreq.arp_pa;
17451 + memset((char *)&arpreq, 0, sizeof(struct arpreq));
17452 + ipAddr.sin_port = 0;
17453 + ipAddr.sin_family = AF_INET;
17454 + memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr));
17455 + memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
17456 + arpreq.arp_flags= ATF_PUBL;
17458 + if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
17459 + close(sock);
17460 + return -1;
17463 + memcpy(buf, &arpreq.arp_ha.sa_data[0], len);
17465 + close(sock);
17467 + // all bytes to 0 means no hardware address
17468 + for (i = 0; i < len; i++) {
17469 + if (buf[i] != 0)
17470 + return len;
17473 + return -1;
17476 +static int getMTU(JNIEnv *env, int sock, const char *ifname) {
17477 + struct lifreq if2;
17478 + memset((char *)&if2, 0, sizeof(if2));
17479 + strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
17481 + if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
17482 + JNU_ThrowByNameWithMessageAndLastError
17483 + (env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFMTU) failed");
17484 + return -1;
17487 + return if2.lifr_mtu;
17490 +static int getFlags(int sock, const char *ifname, int *flags) {
17491 + struct lifreq if2;
17492 + memset((char *)&if2, 0, sizeof(if2));
17493 + strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
17495 + if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2) < 0) {
17496 + return -1;
17499 + *flags = if2.lifr_flags;
17500 + return 0;
17503 +#endif /* __solaris__ */
17505 /** BSD **/
17506 #if defined(_ALLBSD_SOURCE)
17508 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/portconfig.c jdk-jdk-24-11/src/java.base/unix/native/libnet/portconfig.c
17509 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/portconfig.c 2024-08-15 09:39:31.000000000 +0200
17510 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/portconfig.c 2024-08-17 20:36:14.255246124 +0200
17511 @@ -60,6 +60,13 @@
17513 return -1;
17516 +#elif defined(__solaris__)
17518 + range->higher = net_getParam("/dev/tcp", "tcp_largest_anon_port");
17519 + range->lower = net_getParam("/dev/tcp", "tcp_smallest_anon_port");
17520 + return 0;
17522 #elif defined(_ALLBSD_SOURCE)
17524 int ret;
17525 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/SdpSupport.c jdk-jdk-24-11/src/java.base/unix/native/libnet/SdpSupport.c
17526 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnet/SdpSupport.c 2024-08-15 09:39:31.000000000 +0200
17527 +++ jdk-jdk-24-11/src/java.base/unix/native/libnet/SdpSupport.c 2024-08-17 20:36:14.253532658 +0200
17528 @@ -27,7 +27,11 @@
17529 #include <sys/socket.h>
17530 #include <errno.h>
17532 -#if defined(__linux__)
17533 +#if defined(__solaris__)
17534 + #if !defined(PROTO_SDP)
17535 + #define PROTO_SDP 257
17536 + #endif
17537 +#elif defined(__linux__)
17538 #if !defined(AF_INET_SDP)
17539 #define AF_INET_SDP 27
17540 #endif
17541 @@ -44,7 +48,10 @@
17543 int s;
17545 -#if defined(__linux__)
17546 +#if defined(__solaris__)
17547 + int domain = ipv6_available() ? AF_INET6 : AF_INET;
17548 + s = socket(domain, SOCK_STREAM, PROTO_SDP);
17549 +#elif defined(__linux__)
17551 * IPv6 not supported by SDP on Linux
17553 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c
17554 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c 2024-08-15 09:39:31.000000000 +0200
17555 +++ jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c 2024-08-17 20:36:14.255763650 +0200
17556 @@ -50,6 +50,9 @@
17557 jint fd = fdval(env, fdo);
17558 int rv;
17560 +#if defined(__solaris__)
17561 + rv = connect(fd, 0, 0);
17562 +#else
17563 #if defined(__APPLE__)
17564 // On macOS systems we use disconnectx
17565 rv = disconnectx(fd, SAE_ASSOCID_ANY, SAE_CONNID_ANY);
17566 @@ -83,6 +86,8 @@
17567 rv = errno = 0;
17568 #endif // defined(_ALLBSD_SOURCE) || defined(_AIX)
17570 +#endif // defined(__solaris__)
17572 if (rv < 0)
17573 handleSocketError(env, errno);
17575 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/NativeThread.c jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/NativeThread.c
17576 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/NativeThread.c 2024-08-15 09:39:31.000000000 +0200
17577 +++ jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/NativeThread.c 2024-08-17 20:36:14.256176744 +0200
17578 @@ -40,6 +40,9 @@
17579 #elif defined(_AIX)
17580 /* Also defined in net/aix_close.c */
17581 #define INTERRUPT_SIGNAL (SIGRTMAX - 1)
17582 +#elif defined(__solaris__)
17583 + #include <thread.h>
17584 + #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
17585 #elif defined(_ALLBSD_SOURCE)
17586 /* Also defined in net/bsd_close.c */
17587 #define INTERRUPT_SIGNAL SIGIO
17588 @@ -73,14 +76,22 @@
17589 JNIEXPORT jlong JNICALL
17590 Java_sun_nio_ch_NativeThread_current0(JNIEnv *env, jclass cl)
17592 +#ifdef __solaris__
17593 + return (jlong)thr_self();
17594 +#else
17595 return (jlong)pthread_self();
17596 +#endif
17599 JNIEXPORT void JNICALL
17600 Java_sun_nio_ch_NativeThread_signal0(JNIEnv *env, jclass cl, jlong thread)
17602 int ret;
17603 +#ifdef __solaris__
17604 + ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
17605 +#else
17606 ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
17607 +#endif
17608 #ifdef MACOSX
17609 if (ret != 0 && ret != ESRCH)
17610 #else
17611 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/Net.c jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/Net.c
17612 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/Net.c 2024-08-15 09:39:31.000000000 +0200
17613 +++ jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/Net.c 2024-08-17 20:36:14.256750588 +0200
17614 @@ -25,6 +25,7 @@
17616 #include <poll.h>
17617 #include <sys/ioctl.h>
17618 +#include <sys/filio.h>
17619 #include <sys/types.h>
17620 #include <sys/socket.h>
17621 #include <string.h>
17622 @@ -220,7 +221,7 @@
17623 JNIEXPORT jboolean JNICALL
17624 Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0(JNIEnv* env, jclass cl)
17626 -#if defined(__linux__) || defined(__APPLE__)
17627 +#if defined(__linux__) || defined(__APPLE__) || defined(__solaris__)
17628 /* IPv6 sockets can join IPv4 multicast groups */
17629 return JNI_TRUE;
17630 #else
17631 @@ -232,7 +233,7 @@
17632 JNIEXPORT jboolean JNICALL
17633 Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
17635 -#if defined(__APPLE__)
17636 +#if defined(__APPLE__) || defined(__solaris__)
17637 /* IPV6_ADD_MEMBERSHIP can be used to join IPv4 multicast groups */
17638 return JNI_TRUE;
17639 #else
17640 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/nio_util.h jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/nio_util.h
17641 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/ch/nio_util.h 2024-08-15 09:39:31.000000000 +0200
17642 +++ jdk-jdk-24-11/src/java.base/unix/native/libnio/ch/nio_util.h 2024-08-17 20:36:14.257133999 +0200
17643 @@ -35,6 +35,8 @@
17644 #ifndef SO_REUSEPORT
17645 #ifdef __linux__
17646 #define SO_REUSEPORT 15
17647 +#elif defined(__solaris__)
17648 +#define SO_REUSEPORT 0x100e
17649 #elif defined(AIX) || defined(MACOSX)
17650 #define SO_REUSEPORT 0x0200
17651 #else
17652 diff -Nru jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c jdk-jdk-24-11/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
17653 --- jdk-jdk-24-11.orig/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2024-08-15 09:39:31.000000000 +0200
17654 +++ jdk-jdk-24-11/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2024-08-17 20:36:14.257811113 +0200
17655 @@ -46,10 +46,17 @@
17656 #include <sys/xattr.h>
17657 #endif
17659 -/* For POSIX-compliant getpwuid_r */
17660 +/* For POSIX-compliant getpwuid_r, getgrgid_r on Solaris */
17661 +#if defined(__solaris__)
17662 +#define _POSIX_PTHREAD_SEMANTICS
17663 +#endif
17664 #include <pwd.h>
17665 #include <grp.h>
17667 +#ifdef __solaris__
17668 +#include <strings.h>
17669 +#endif
17671 #ifdef __linux__
17672 #include <sys/syscall.h>
17673 #include <sys/sysmacros.h> // makedev macros
17674 @@ -341,7 +348,8 @@
17676 /* system calls that might not be available at run time */
17678 -#if defined(_ALLBSD_SOURCE)
17679 +#if defined(__solaris__) || defined(_ALLBSD_SOURCE)
17680 + /* Solaris 64-bit does not have openat64/fstatat64 */
17681 my_openat_func = (openat_func*)dlsym(RTLD_DEFAULT, "openat");
17682 my_fstatat_func = (fstatat_func*)dlsym(RTLD_DEFAULT, "fstatat");
17683 #else
17684 diff -Nru jdk-jdk-24-11.orig/src/java.base/windows/native/libnet/net_util_md.c jdk-jdk-24-11/src/java.base/windows/native/libnet/net_util_md.c
17685 --- jdk-jdk-24-11.orig/src/java.base/windows/native/libnet/net_util_md.c 2024-08-15 09:39:31.000000000 +0200
17686 +++ jdk-jdk-24-11/src/java.base/windows/native/libnet/net_util_md.c 2024-08-17 20:36:14.258339057 +0200
17687 @@ -125,6 +125,8 @@
17689 return TRUE;
17692 +void parseExclusiveBindProperty(JNIEnv *env) {}
17695 * Since winsock doesn't have the equivalent of strerror(errno)
17696 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/awt/FontConfiguration.java jdk-jdk-24-11/src/java.desktop/share/classes/sun/awt/FontConfiguration.java
17697 --- jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/awt/FontConfiguration.java 2024-08-15 09:39:31.000000000 +0200
17698 +++ jdk-jdk-24-11/src/java.desktop/share/classes/sun/awt/FontConfiguration.java 2024-08-17 20:36:14.259429103 +0200
17699 @@ -1422,6 +1422,22 @@
17703 + if (OSInfo.getOSType() == OSInfo.OSType.SOLARIS) {
17704 + for (int ii = 0; ii < table_awtfontpaths.length; ii++) {
17705 + if (table_awtfontpaths[ii] == 0) {
17706 + String script = getString(table_scriptIDs[ii]);
17707 + if (script.contains("dingbats") ||
17708 + script.contains("symbol")) {
17709 + continue;
17711 + System.err.println("\nError: "
17712 + + "<awtfontpath."
17713 + + script
17714 + + "> entry is missing!!!");
17715 + errors++;
17719 if (errors != 0) {
17720 System.err.println("!!THERE ARE " + errors + " ERROR(S) IN "
17721 + "THE FONTCONFIG FILE, PLEASE CHECK ITS CONTENT!!\n");
17722 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/awt/OSInfo.java jdk-jdk-24-11/src/java.desktop/share/classes/sun/awt/OSInfo.java
17723 --- jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/awt/OSInfo.java 2024-08-15 09:39:31.000000000 +0200
17724 +++ jdk-jdk-24-11/src/java.desktop/share/classes/sun/awt/OSInfo.java 2024-08-17 20:36:14.259864574 +0200
17725 @@ -39,6 +39,7 @@
17726 public static enum OSType {
17727 WINDOWS,
17728 LINUX,
17729 + SOLARIS,
17730 MACOSX,
17731 AIX,
17732 UNKNOWN
17733 @@ -95,6 +96,7 @@
17734 // Map OperatingSystem enum values to OSType enum values.
17735 case WINDOWS -> WINDOWS;
17736 case LINUX -> LINUX;
17737 + case SOLARIS -> SOLARIS;
17738 case MACOS -> MACOSX;
17739 case AIX -> AIX;
17740 default -> UNKNOWN;
17741 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/font/FontUtilities.java jdk-jdk-24-11/src/java.desktop/share/classes/sun/font/FontUtilities.java
17742 --- jdk-jdk-24-11.orig/src/java.desktop/share/classes/sun/font/FontUtilities.java 2024-08-15 09:39:31.000000000 +0200
17743 +++ jdk-jdk-24-11/src/java.desktop/share/classes/sun/font/FontUtilities.java 2024-08-17 20:36:14.260469648 +0200
17744 @@ -41,6 +41,8 @@
17746 public final class FontUtilities {
17748 + public static boolean isSolaris;
17750 public static boolean isLinux;
17752 public static boolean isMacOSX;
17753 @@ -66,6 +68,8 @@
17754 @Override
17755 public Object run() {
17757 + isSolaris = OSInfo.getOSType() == OSInfo.OSType.SOLARIS;
17759 isLinux = OSInfo.getOSType() == OSInfo.OSType.LINUX;
17761 isMacOSX = OSInfo.getOSType() == OSInfo.OSType.MACOSX;
17762 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/share/native/libjsound/SoundDefs.h jdk-jdk-24-11/src/java.desktop/share/native/libjsound/SoundDefs.h
17763 --- jdk-jdk-24-11.orig/src/java.desktop/share/native/libjsound/SoundDefs.h 2024-08-15 09:39:31.000000000 +0200
17764 +++ jdk-jdk-24-11/src/java.desktop/share/native/libjsound/SoundDefs.h 2024-08-17 20:36:14.260990956 +0200
17765 @@ -29,9 +29,10 @@
17767 // types for X_PLATFORM
17768 #define X_WINDOWS 1
17769 -#define X_LINUX 2
17770 -#define X_BSD 3
17771 -#define X_MACOSX 4
17772 +#define X_SOLARIS 2
17773 +#define X_LINUX 3
17774 +#define X_BSD 4
17775 +#define X_MACOSX 5
17777 // **********************************
17778 // Make sure you set X_PLATFORM defines correctly.
17779 @@ -44,7 +45,7 @@
17782 // following is needed for _LP64
17783 -#if ((X_PLATFORM == X_LINUX) || (X_PLATFORM == X_MACOSX))
17784 +#if ((X_PLATFORM == X_SOLARIS) || (X_PLATFORM == X_LINUX) || (X_PLATFORM == X_MACOSX))
17785 #include <sys/types.h>
17786 #endif
17788 @@ -114,6 +115,11 @@
17789 #endif
17792 +#if X_PLATFORM == X_SOLARIS
17793 +#define INLINE
17794 +#endif
17797 #if X_PLATFORM == X_LINUX
17798 #define INLINE inline
17799 #endif
17800 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643.java jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643.java
17801 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643.java 1970-01-01 01:00:00.000000000 +0100
17802 +++ jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643.java 2024-08-17 20:36:14.302977215 +0200
17803 @@ -0,0 +1,178 @@
17805 + * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
17806 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17808 + * This code is free software; you can redistribute it and/or modify it
17809 + * under the terms of the GNU General Public License version 2 only, as
17810 + * published by the Free Software Foundation. Oracle designates this
17811 + * particular file as subject to the "Classpath" exception as provided
17812 + * by Oracle in the LICENSE file that accompanied this code.
17814 + * This code is distributed in the hope that it will be useful, but WITHOUT
17815 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17816 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17817 + * version 2 for more details (a copy is included in the LICENSE file that
17818 + * accompanied this code).
17820 + * You should have received a copy of the GNU General Public License version
17821 + * 2 along with this work; if not, write to the Free Software Foundation,
17822 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17824 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17825 + * or visit www.oracle.com if you need additional information or have any
17826 + * questions.
17827 + */
17829 +package sun.font;
17831 +import java.nio.CharBuffer;
17832 +import java.nio.ByteBuffer;
17833 +import java.nio.charset.*;
17834 +import sun.nio.cs.*;
17836 +public abstract class X11CNS11643 extends Charset {
17837 + private final int plane;
17838 + public X11CNS11643 (int plane, String name) {
17839 + super(name, null);
17840 + switch (plane) {
17841 + case 1:
17842 + this.plane = 0; // CS1
17843 + break;
17844 + case 2:
17845 + case 3:
17846 + this.plane = plane;
17847 + break;
17848 + default:
17849 + throw new IllegalArgumentException
17850 + ("Only planes 1, 2, and 3 supported");
17854 + public CharsetEncoder newEncoder() {
17855 + return new Encoder(this, plane);
17858 + public CharsetDecoder newDecoder() {
17859 + return new Decoder(this, plane);
17862 + public boolean contains(Charset cs) {
17863 + return cs instanceof X11CNS11643;
17866 + private class Encoder extends EUC_TW.Encoder {
17867 + private int plane;
17868 + public Encoder(Charset cs, int plane) {
17869 + super(cs);
17870 + this.plane = plane;
17873 + private byte[] bb = new byte[4];
17874 + public boolean canEncode(char c) {
17875 + if (c <= 0x7F) {
17876 + return false;
17878 + int nb = toEUC(c, bb);
17879 + if (nb == -1)
17880 + return false;
17881 + int p = 0;
17882 + if (nb == 4)
17883 + p = (bb[1] & 0xff) - 0xa0;
17884 + return (p == plane);
17887 + public boolean isLegalReplacement(byte[] repl) {
17888 + return true;
17891 + protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
17892 + char[] sa = src.array();
17893 + int sp = src.arrayOffset() + src.position();
17894 + int sl = src.arrayOffset() + src.limit();
17895 + byte[] da = dst.array();
17896 + int dp = dst.arrayOffset() + dst.position();
17897 + int dl = dst.arrayOffset() + dst.limit();
17899 + try {
17900 + while (sp < sl) {
17901 + char c = sa[sp];
17902 + if ( c > '\u007f'&& c < '\uFFFE') {
17903 + int nb = toEUC(c, bb);
17904 + if (nb != -1) {
17905 + int p = 0;
17906 + if (nb == 4)
17907 + p = (bb[1] & 0xff) - 0xa0;
17908 + if (p == plane) {
17909 + if (dl - dp < 2)
17910 + return CoderResult.OVERFLOW;
17911 + if (nb == 2) {
17912 + da[dp++] = (byte)(bb[0] & 0x7f);
17913 + da[dp++] = (byte)(bb[1] & 0x7f);
17914 + } else {
17915 + da[dp++] = (byte)(bb[2] & 0x7f);
17916 + da[dp++] = (byte)(bb[3] & 0x7f);
17918 + sp++;
17919 + continue;
17923 + return CoderResult.unmappableForLength(1);
17925 + return CoderResult.UNDERFLOW;
17926 + } finally {
17927 + src.position(sp - src.arrayOffset());
17928 + dst.position(dp - dst.arrayOffset());
17933 + private class Decoder extends EUC_TW.Decoder {
17934 + int plane;
17935 + private String table;
17936 + protected Decoder(Charset cs, int plane) {
17937 + super(cs);
17938 + if (plane == 0)
17939 + this.plane = plane;
17940 + else if (plane == 2 || plane == 3)
17941 + this.plane = plane - 1;
17942 + else
17943 + throw new IllegalArgumentException
17944 + ("Only planes 1, 2, and 3 supported");
17947 + //we only work on array backed buffer.
17948 + protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
17949 + byte[] sa = src.array();
17950 + int sp = src.arrayOffset() + src.position();
17951 + int sl = src.arrayOffset() + src.limit();
17953 + char[] da = dst.array();
17954 + int dp = dst.arrayOffset() + dst.position();
17955 + int dl = dst.arrayOffset() + dst.limit();
17957 + try {
17958 + while (sp < sl) {
17959 + if ( sl - sp < 2) {
17960 + return CoderResult.UNDERFLOW;
17962 + int b1 = (sa[sp] & 0xff) | 0x80;
17963 + int b2 = (sa[sp + 1] & 0xff) | 0x80;
17964 + char[] cc = toUnicode(b1, b2, plane);
17965 + // plane3 has non-bmp characters(added), x11cnsp3
17966 + // however does not support them
17967 + if (cc == null || cc.length == 2)
17968 + return CoderResult.unmappableForLength(2);
17969 + if (dl - dp < 1)
17970 + return CoderResult.OVERFLOW;
17971 + da[dp++] = cc[0];
17972 + sp +=2;
17974 + return CoderResult.UNDERFLOW;
17975 + } finally {
17976 + src.position(sp - src.arrayOffset());
17977 + dst.position(dp - dst.arrayOffset());
17982 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P1.java jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P1.java
17983 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P1.java 1970-01-01 01:00:00.000000000 +0100
17984 +++ jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P1.java 2024-08-17 20:36:14.303225731 +0200
17985 @@ -0,0 +1,33 @@
17987 + * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
17988 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17990 + * This code is free software; you can redistribute it and/or modify it
17991 + * under the terms of the GNU General Public License version 2 only, as
17992 + * published by the Free Software Foundation. Oracle designates this
17993 + * particular file as subject to the "Classpath" exception as provided
17994 + * by Oracle in the LICENSE file that accompanied this code.
17996 + * This code is distributed in the hope that it will be useful, but WITHOUT
17997 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17998 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17999 + * version 2 for more details (a copy is included in the LICENSE file that
18000 + * accompanied this code).
18002 + * You should have received a copy of the GNU General Public License version
18003 + * 2 along with this work; if not, write to the Free Software Foundation,
18004 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18006 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18007 + * or visit www.oracle.com if you need additional information or have any
18008 + * questions.
18009 + */
18012 +package sun.font;
18014 +public class X11CNS11643P1 extends X11CNS11643 {
18015 + public X11CNS11643P1() {
18016 + super(1, "X11CNS11643P1");
18019 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P2.java jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P2.java
18020 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P2.java 1970-01-01 01:00:00.000000000 +0100
18021 +++ jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P2.java 2024-08-17 20:36:14.303460468 +0200
18022 @@ -0,0 +1,32 @@
18024 + * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
18025 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18027 + * This code is free software; you can redistribute it and/or modify it
18028 + * under the terms of the GNU General Public License version 2 only, as
18029 + * published by the Free Software Foundation. Oracle designates this
18030 + * particular file as subject to the "Classpath" exception as provided
18031 + * by Oracle in the LICENSE file that accompanied this code.
18033 + * This code is distributed in the hope that it will be useful, but WITHOUT
18034 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18035 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18036 + * version 2 for more details (a copy is included in the LICENSE file that
18037 + * accompanied this code).
18039 + * You should have received a copy of the GNU General Public License version
18040 + * 2 along with this work; if not, write to the Free Software Foundation,
18041 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18043 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18044 + * or visit www.oracle.com if you need additional information or have any
18045 + * questions.
18046 + */
18048 +package sun.font;
18050 +public class X11CNS11643P2 extends X11CNS11643 {
18051 + public X11CNS11643P2() {
18052 + super(2, "X11CNS11643P2");
18055 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P3.java jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P3.java
18056 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/classes/sun/font/X11CNS11643P3.java 1970-01-01 01:00:00.000000000 +0100
18057 +++ jdk-jdk-24-11/src/java.desktop/solaris/classes/sun/font/X11CNS11643P3.java 2024-08-17 20:36:14.303704088 +0200
18058 @@ -0,0 +1,32 @@
18060 + * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
18061 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18063 + * This code is free software; you can redistribute it and/or modify it
18064 + * under the terms of the GNU General Public License version 2 only, as
18065 + * published by the Free Software Foundation. Oracle designates this
18066 + * particular file as subject to the "Classpath" exception as provided
18067 + * by Oracle in the LICENSE file that accompanied this code.
18069 + * This code is distributed in the hope that it will be useful, but WITHOUT
18070 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18071 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18072 + * version 2 for more details (a copy is included in the LICENSE file that
18073 + * accompanied this code).
18075 + * You should have received a copy of the GNU General Public License version
18076 + * 2 along with this work; if not, write to the Free Software Foundation,
18077 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18079 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18080 + * or visit www.oracle.com if you need additional information or have any
18081 + * questions.
18082 + */
18084 +package sun.font;
18086 +public class X11CNS11643P3 extends X11CNS11643 {
18087 + public X11CNS11643P3() {
18088 + super(3, "X11CNS11643P3");
18091 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/data/fontconfig/fontconfig.properties jdk-jdk-24-11/src/java.desktop/solaris/data/fontconfig/fontconfig.properties
18092 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/data/fontconfig/fontconfig.properties 1970-01-01 01:00:00.000000000 +0100
18093 +++ jdk-jdk-24-11/src/java.desktop/solaris/data/fontconfig/fontconfig.properties 2024-08-17 20:36:14.278001854 +0200
18094 @@ -0,0 +1,516 @@
18097 +# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
18098 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18100 +# This code is free software; you can redistribute it and/or modify it
18101 +# under the terms of the GNU General Public License version 2 only, as
18102 +# published by the Free Software Foundation. Oracle designates this
18103 +# particular file as subject to the "Classpath" exception as provided
18104 +# by Oracle in the LICENSE file that accompanied this code.
18106 +# This code is distributed in the hope that it will be useful, but WITHOUT
18107 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18108 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18109 +# version 2 for more details (a copy is included in the LICENSE file that
18110 +# accompanied this code).
18112 +# You should have received a copy of the GNU General Public License version
18113 +# 2 along with this work; if not, write to the Free Software Foundation,
18114 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18116 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18117 +# or visit www.oracle.com if you need additional information or have any
18118 +# questions.
18121 +# Version
18123 +version=1
18125 +# Component Font Mappings
18127 +allfonts.chinese-gb2312=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18128 +allfonts.chinese-gbk=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18129 +allfonts.chinese-gb18030-0=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18130 +allfonts.chinese-gb18030-1=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18131 +allfonts.chinese-cns11643-1=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18132 +allfonts.chinese-cns11643-2=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18133 +allfonts.chinese-cns11643-3=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18134 +allfonts.chinese-big5=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18135 +allfonts.chinese-hkscs=-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18136 +allfonts.dingbats=-microsoft-wingdings-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific
18137 +allfonts.japanese-x0212=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18138 +allfonts.korean=-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18139 +allfonts.korean-johab=-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18140 +allfonts.symbol=-monotype-symbol-medium-r-normal--*-%d-*-*-p-*-adobe-symbol
18141 +allfonts.bengali=-misc-lohit bengali-medium-r-normal--0-0-0-0-p-0-iso10646-1
18142 +allfonts.gujarati=-misc-lohit gujarati-medium-r-normal--0-0-0-0-p-0-iso10646-1
18143 +allfonts.hindi=-misc-lohit hindi-medium-r-normal--0-0-0-0-p-0-iso10646-1
18144 +allfonts.kannada=-misc-lohit kannada-medium-r-normal--0-0-0-0-p-0-iso10646-1
18145 +allfonts.malayalam=-misc-lohit malayalam-medium-r-normal--0-0-0-0-p-0-iso10646-1
18146 +allfonts.marathi=-misc-lohit marathi-medium-r-normal--0-0-0-0-p-0-iso10646-1
18147 +allfonts.tamil=-misc-lohit tamil-medium-r-normal--0-0-0-0-p-0-iso10646-1
18148 +allfonts.telugu=-misc-lohit telugu-medium-r-normal--0-0-0-0-p-0-iso10646-1
18149 +allfonts.dejavusans=-misc-dejavu sans-medium-r-normal--0-0-0-0-p-0-iso10646-1
18151 +serif.plain.arabic=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18152 +serif.plain.cyrillic-iso8859-5=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18153 +serif.plain.cyrillic-cp1251=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18154 +serif.plain.cyrillic-koi8-r=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18155 +serif.plain.greek=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18156 +serif.plain.hebrew=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18157 +serif.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18158 +serif.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18159 +serif.plain.latin-1=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18160 +serif.plain.latin-2=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18161 +serif.plain.latin-5=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18162 +serif.plain.latin-7=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18163 +serif.plain.latin-9=-monotype-times new roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18164 +serif.plain.thai=-monotype-angsana new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18166 +serif.bold.arabic=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18167 +serif.bold.cyrillic-iso8859-5=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18168 +serif.bold.cyrillic-cp1251=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18169 +serif.bold.cyrillic-koi8-r=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18170 +serif.bold.greek=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18171 +serif.bold.hebrew=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18172 +serif.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18173 +serif.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18174 +serif.bold.latin-1=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18175 +serif.bold.latin-2=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18176 +serif.bold.latin-5=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18177 +serif.bold.latin-7=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18178 +serif.bold.latin-9=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18179 +serif.bold.thai=-monotype-angsana new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18181 +serif.italic.arabic=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18182 +serif.italic.cyrillic-iso8859-5=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18183 +serif.italic.cyrillic-cp1251=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18184 +serif.italic.cyrillic-koi8-r=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18185 +serif.italic.greek=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18186 +serif.italic.hebrew=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18187 +serif.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18188 +serif.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18189 +serif.italic.latin-1=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18190 +serif.italic.latin-2=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18191 +serif.italic.latin-5=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18192 +serif.italic.latin-7=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18193 +serif.italic.latin-9=-monotype-times new roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18194 +serif.italic.thai=-monotype-angsana new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18196 +serif.bolditalic.arabic=-monotype-times new roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18197 +serif.bolditalic.cyrillic-iso8859-5=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18198 +serif.bolditalic.cyrillic-cp1251=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18199 +serif.bolditalic.cyrillic-koi8-r=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18200 +serif.bolditalic.greek=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18201 +serif.bolditalic.hebrew=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18202 +serif.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18203 +serif.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18204 +serif.bolditalic.latin-1=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18205 +serif.bolditalic.latin-2=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18206 +serif.bolditalic.latin-5=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18207 +serif.bolditalic.latin-7=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18208 +serif.bolditalic.latin-9=-monotype-times new roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18209 +serif.bolditalic.thai=-monotype-angsana new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18211 +sansserif.plain.arabic=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18212 +sansserif.plain.cyrillic-iso8859-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18213 +sansserif.plain.cyrillic-cp1251=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18214 +sansserif.plain.cyrillic-koi8-r=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18215 +sansserif.plain.greek=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18216 +sansserif.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18217 +sansserif.plain.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18218 +sansserif.plain.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18219 +sansserif.plain.latin-1=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18220 +sansserif.plain.latin-2=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18221 +sansserif.plain.latin-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18222 +sansserif.plain.latin-7=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18223 +sansserif.plain.latin-9=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18224 +sansserif.plain.thai=-monotype-browallia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18226 +sansserif.bold.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18227 +sansserif.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18228 +sansserif.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18229 +sansserif.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18230 +sansserif.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18231 +sansserif.bold.hebrew=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18232 +sansserif.bold.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18233 +sansserif.bold.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18234 +sansserif.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18235 +sansserif.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18236 +sansserif.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18237 +sansserif.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18238 +sansserif.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18239 +sansserif.bold.thai=-monotype-browallia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18241 +sansserif.italic.arabic=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18242 +sansserif.italic.cyrillic-iso8859-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18243 +sansserif.italic.cyrillic-cp1251=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18244 +sansserif.italic.cyrillic-koi8-r=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18245 +sansserif.italic.greek=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18246 +sansserif.italic.hebrew=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18247 +sansserif.italic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18248 +sansserif.italic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18249 +sansserif.italic.latin-1=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18250 +sansserif.italic.latin-2=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18251 +sansserif.italic.latin-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18252 +sansserif.italic.latin-7=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18253 +sansserif.italic.latin-9=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18254 +sansserif.italic.thai=-monotype-browallia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18256 +sansserif.bolditalic.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18257 +sansserif.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18258 +sansserif.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18259 +sansserif.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18260 +sansserif.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18261 +sansserif.bolditalic.hebrew=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18262 +sansserif.bolditalic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18263 +sansserif.bolditalic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18264 +sansserif.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18265 +sansserif.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18266 +sansserif.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18267 +sansserif.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18268 +sansserif.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18269 +sansserif.bolditalic.thai=-monotype-browallia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18271 +monospaced.plain.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18272 +monospaced.plain.cyrillic-iso8859-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18273 +monospaced.plain.cyrillic-cp1251=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18274 +monospaced.plain.cyrillic-koi8-r=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18275 +monospaced.plain.greek=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18276 +monospaced.plain.hebrew=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18277 +monospaced.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18278 +monospaced.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18279 +monospaced.plain.latin-1=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18280 +monospaced.plain.latin-2=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18281 +monospaced.plain.latin-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18282 +monospaced.plain.latin-7=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18283 +monospaced.plain.latin-9=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18284 +monospaced.plain.thai=-monotype-cordia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18286 +monospaced.bold.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18287 +monospaced.bold.cyrillic-iso8859-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18288 +monospaced.bold.cyrillic-cp1251=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18289 +monospaced.bold.cyrillic-koi8-r=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18290 +monospaced.bold.greek=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18291 +monospaced.bold.hebrew=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18292 +monospaced.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18293 +monospaced.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18294 +monospaced.bold.latin-1=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18295 +monospaced.bold.latin-2=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18296 +monospaced.bold.latin-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18297 +monospaced.bold.latin-7=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18298 +monospaced.bold.latin-9=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18299 +monospaced.bold.thai=-monotype-cordia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18301 +monospaced.italic.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18302 +monospaced.italic.cyrillic-iso8859-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18303 +monospaced.italic.cyrillic-cp1251=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18304 +monospaced.italic.cyrillic-koi8-r=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18305 +monospaced.italic.greek=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18306 +monospaced.italic.hebrew=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18307 +monospaced.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18308 +monospaced.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18309 +monospaced.italic.latin-1=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18310 +monospaced.italic.latin-2=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18311 +monospaced.italic.latin-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18312 +monospaced.italic.latin-7=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18313 +monospaced.italic.latin-9=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18314 +monospaced.italic.thai=-monotype-cordia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18316 +monospaced.bolditalic.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18317 +monospaced.bolditalic.cyrillic-iso8859-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18318 +monospaced.bolditalic.cyrillic-cp1251=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18319 +monospaced.bolditalic.cyrillic-koi8-r=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18320 +monospaced.bolditalic.greek=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18321 +monospaced.bolditalic.hebrew=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18322 +monospaced.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18323 +monospaced.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18324 +monospaced.bolditalic.latin-1=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18325 +monospaced.bolditalic.latin-2=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18326 +monospaced.bolditalic.latin-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18327 +monospaced.bolditalic.latin-7=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18328 +monospaced.bolditalic.latin-9=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18329 +monospaced.bolditalic.thai=-monotype-cordia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18331 +dialog.plain.arabic=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18332 +dialog.plain.cyrillic-iso8859-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18333 +dialog.plain.cyrillic-cp1251=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18334 +dialog.plain.cyrillic-koi8-r=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18335 +dialog.plain.greek=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18336 +dialog.plain.hebrew=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18337 +dialog.plain.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18338 +dialog.plain.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18339 +dialog.plain.latin-1=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18340 +dialog.plain.latin-2=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18341 +dialog.plain.latin-5=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18342 +dialog.plain.latin-7=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18343 +dialog.plain.latin-9=-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18344 +dialog.plain.thai=-monotype-browallia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18346 +dialog.bold.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18347 +dialog.bold.cyrillic-iso8859-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18348 +dialog.bold.cyrillic-cp1251=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18349 +dialog.bold.cyrillic-koi8-r=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18350 +dialog.bold.greek=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18351 +dialog.bold.hebrew=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18352 +dialog.bold.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18353 +dialog.bold.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18354 +dialog.bold.latin-1=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18355 +dialog.bold.latin-2=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18356 +dialog.bold.latin-5=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18357 +dialog.bold.latin-7=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18358 +dialog.bold.latin-9=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18359 +dialog.bold.thai=-monotype-browallia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18361 +dialog.italic.arabic=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18362 +dialog.italic.cyrillic-iso8859-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18363 +dialog.italic.cyrillic-cp1251=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18364 +dialog.italic.cyrillic-koi8-r=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18365 +dialog.italic.greek=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18366 +dialog.italic.hebrew=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18367 +dialog.italic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18368 +dialog.italic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18369 +dialog.italic.latin-1=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18370 +dialog.italic.latin-2=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18371 +dialog.italic.latin-5=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18372 +dialog.italic.latin-7=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18373 +dialog.italic.latin-9=-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18374 +dialog.italic.thai=-monotype-browallia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18376 +dialog.bolditalic.arabic=-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18377 +dialog.bolditalic.cyrillic-iso8859-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18378 +dialog.bolditalic.cyrillic-cp1251=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18379 +dialog.bolditalic.cyrillic-koi8-r=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18380 +dialog.bolditalic.greek=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18381 +dialog.bolditalic.hebrew=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18382 +dialog.bolditalic.japanese-x0201=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18383 +dialog.bolditalic.japanese-x0208=-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18384 +dialog.bolditalic.latin-1=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18385 +dialog.bolditalic.latin-2=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18386 +dialog.bolditalic.latin-5=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18387 +dialog.bolditalic.latin-7=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18388 +dialog.bolditalic.latin-9=-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18389 +dialog.bolditalic.thai=-monotype-browallia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18391 +dialoginput.plain.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18392 +dialoginput.plain.cyrillic-iso8859-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18393 +dialoginput.plain.cyrillic-cp1251=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18394 +dialoginput.plain.cyrillic-koi8-r=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18395 +dialoginput.plain.greek=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18396 +dialoginput.plain.hebrew=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18397 +dialoginput.plain.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18398 +dialoginput.plain.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18399 +dialoginput.plain.latin-1=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18400 +dialoginput.plain.latin-2=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18401 +dialoginput.plain.latin-5=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18402 +dialoginput.plain.latin-7=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18403 +dialoginput.plain.latin-9=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18404 +dialoginput.plain.thai=-monotype-cordia new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18406 +dialoginput.bold.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18407 +dialoginput.bold.cyrillic-iso8859-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18408 +dialoginput.bold.cyrillic-cp1251=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18409 +dialoginput.bold.cyrillic-koi8-r=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18410 +dialoginput.bold.greek=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18411 +dialoginput.bold.hebrew=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18412 +dialoginput.bold.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18413 +dialoginput.bold.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18414 +dialoginput.bold.latin-1=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18415 +dialoginput.bold.latin-2=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18416 +dialoginput.bold.latin-5=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18417 +dialoginput.bold.latin-7=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18418 +dialoginput.bold.latin-9=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18419 +dialoginput.bold.thai=-monotype-cordia new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18421 +dialoginput.italic.arabic=-monotype-courier new-medium-r-normal--*-%d-*-*-p-*-iso10646-1
18422 +dialoginput.italic.cyrillic-iso8859-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18423 +dialoginput.italic.cyrillic-cp1251=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18424 +dialoginput.italic.cyrillic-koi8-r=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18425 +dialoginput.italic.greek=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18426 +dialoginput.italic.hebrew=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18427 +dialoginput.italic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18428 +dialoginput.italic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18429 +dialoginput.italic.latin-1=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18430 +dialoginput.italic.latin-2=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18431 +dialoginput.italic.latin-5=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18432 +dialoginput.italic.latin-7=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18433 +dialoginput.italic.latin-9=-monotype-courier new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18434 +dialoginput.italic.thai=-monotype-cordia new-medium-i-normal--*-%d-*-*-p-*-iso10646-1
18436 +dialoginput.bolditalic.arabic=-monotype-courier new-bold-r-normal--*-%d-*-*-p-*-iso10646-1
18437 +dialoginput.bolditalic.cyrillic-iso8859-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18438 +dialoginput.bolditalic.cyrillic-cp1251=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18439 +dialoginput.bolditalic.cyrillic-koi8-r=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18440 +dialoginput.bolditalic.greek=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18441 +dialoginput.bolditalic.hebrew=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18442 +dialoginput.bolditalic.japanese-x0201=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18443 +dialoginput.bolditalic.japanese-x0208=-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1
18444 +dialoginput.bolditalic.latin-1=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18445 +dialoginput.bolditalic.latin-2=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18446 +dialoginput.bolditalic.latin-5=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18447 +dialoginput.bolditalic.latin-7=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18448 +dialoginput.bolditalic.latin-9=-monotype-courier new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18449 +dialoginput.bolditalic.thai=-monotype-cordia new-bold-i-normal--*-%d-*-*-p-*-iso10646-1
18451 +# Search Sequences
18453 +sequence.allfonts=latin-1
18455 +sequence.allfonts.Big5=latin-1,chinese-big5
18457 +sequence.allfonts.Big5-HKSCS-2001=latin-1,chinese-big5,chinese-hkscs
18459 +sequence.allfonts.windows-1251=cyrillic-cp1251,latin-1
18461 +sequence.allfonts.GB2312=latin-1,chinese-gb2312
18463 +sequence.allfonts.x-eucJP-Open=latin-1,japanese-x0201,japanese-x0208,japanese-x0212
18465 +sequence.allfonts.EUC-KR=latin-1,korean
18467 +sequence.allfonts.x-EUC-TW=latin-1,chinese-cns11643-1,chinese-cns11643-2,chinese-cns11643-3
18469 +sequence.allfonts.GBK=latin-1,chinese-gbk
18471 +sequence.allfonts.GB18030=latin-1,chinese-gb18030-0,chinese-gb18030-1
18473 +sequence.allfonts.ISO-8859-2=latin-2,latin-1
18475 +sequence.allfonts.ISO-8859-5=cyrillic-iso8859-5,latin-1
18477 +sequence.allfonts.ISO-8859-6=arabic,latin-1
18479 +sequence.allfonts.ISO-8859-7=latin-1,greek
18481 +sequence.allfonts.ISO-8859-8=latin-1,hebrew
18483 +sequence.allfonts.ISO-8859-9=latin-5,latin-1
18485 +sequence.allfonts.ISO-8859-13=latin-7,latin-1
18487 +sequence.allfonts.ISO-8859-15=latin-9
18489 +sequence.allfonts.KOI8-R=cyrillic-koi8-r,latin-1
18491 +sequence.allfonts.x-PCK=latin-1,japanese-x0201,japanese-x0208,japanese-x0212
18493 +sequence.allfonts.TIS-620=latin-1,thai
18495 +sequence.allfonts.UTF-8=latin-1
18496 +sequence.allfonts.UTF-8.en=latin-1
18497 +sequence.allfonts.UTF-8.hi=latin-1,hindi
18498 +sequence.allfonts.UTF-8.be=latin-1,bengali
18499 +sequence.allfonts.UTF-8.te=latin-1,telugu
18500 +sequence.allfonts.UTF-8.mr=latin-1,marathi
18501 +sequence.allfonts.UTF-8.ta=latin-1,tamil
18502 +sequence.allfonts.UTF-8.gu=latin-1,gujarati
18503 +sequence.allfonts.UTF-8.kn=latin-1,kannada
18504 +sequence.allfonts.UTF-8.ma=latin-1,malayalam
18506 +sequence.allfonts.UTF-8.ko=latin-1,korean-johab,japanese-x0201,japanese-x0208,japanese-x0212
18508 +sequence.allfonts.UTF-8.th=latin-1,thai
18510 +sequence.allfonts.UTF-8.zh.CN=latin-1,chinese-gb18030-0,chinese-gb18030-1,chinese-big5,chinese-hkscs
18512 +sequence.allfonts.UTF-8.zh.HK=latin-1,chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1
18514 +sequence.allfonts.UTF-8.zh.TW=latin-1,chinese-big5,chinese-hkscs,chinese-gb18030-0,chinese-gb18030-1
18516 +# the fallback sequence omits the following character subsets:
18517 +# - chinese: all same file : just use chinese-gb18030-0
18518 +# - japanese-x0208: same files as japanese-x0201
18519 +# - japanese-x0212: same files as japanese-x0201
18520 +# - korean: same file as korean-johab
18521 +sequence.fallback=latin-1,latin-2,latin-7,cyrillic-iso8859-5,greek,latin-5,latin-9,\
18522 + arabic,hebrew,thai,\
18523 + chinese-gb18030-0,\
18524 + japanese-x0201,korean-johab,\
18525 + hindi,bengali,telugu,marathi,tamil,gujarati,kannada,malayalam,\
18526 + dejavusans,dingbats,symbol
18528 +# Font File Names
18530 +filename.-monotype-arial-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arial.ttf
18531 +filename.-monotype-arial-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/ariali.ttf
18532 +filename.-monotype-arial-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbd.ttf
18533 +filename.-monotype-arial-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/arialbi.ttf
18534 +filename.-monotype-courier_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cour.ttf
18535 +filename.-monotype-courier_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/couri.ttf
18536 +filename.-monotype-courier_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbd.ttf
18537 +filename.-monotype-courier_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/courbi.ttf
18538 +filename.-monotype-times_new_roman-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/times.ttf
18539 +filename.-monotype-times_new_roman-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesi.ttf
18540 +filename.-monotype-times_new_roman-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbd.ttf
18541 +filename.-monotype-times_new_roman-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/timesbi.ttf
18543 +filename.-monotype-angsana_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsa.ttf
18544 +filename.-monotype-angsana_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsai.ttf
18545 +filename.-monotype-angsana_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsab.ttf
18546 +filename.-monotype-angsana_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/angsaz.ttf
18547 +filename.-monotype-browallia_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browa.ttf
18548 +filename.-monotype-browallia_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browai.ttf
18549 +filename.-monotype-browallia_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browab.ttf
18550 +filename.-monotype-browallia_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/browaz.ttf
18551 +filename.-monotype-cordia_new-medium-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordia.ttf
18552 +filename.-monotype-cordia_new-medium-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiai.ttf
18553 +filename.-monotype-cordia_new-bold-r-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiab.ttf
18554 +filename.-monotype-cordia_new-bold-i-normal--*-%d-*-*-p-*-iso10646-1=/usr/share/fonts/TrueType/core/cordiaz.ttf
18556 +filename.-misc-ipagothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/ipafont/ipag.otf
18557 +filename.-misc-ipamincho-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/ipafont/ipam.otf
18558 +filename.-hanyang-gothic-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/hanyang/h2gtrm.ttf
18559 +filename.-arphic-uming-medium-r-normal--*-%d-*-*-m-*-iso10646-1=/usr/share/fonts/TrueType/arphic/uming.ttf
18560 +filename.-monotype-symbol-medium-r-normal--*-%d-*-*-p-*-adobe-symbol=/usr/share/fonts/TrueType/core/symbol.ttf
18561 +filename.-microsoft-wingdings-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific=/usr/share/fonts/TrueType/core/wingdings.ttf
18562 +filename.-misc-lohit_bengali-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Bengali.ttf
18563 +filename.-misc-lohit_gujarati-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Gujarati.ttf
18564 +filename.-misc-lohit_hindi-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Hindi.ttf
18565 +filename.-misc-lohit_kannada-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Kannada.ttf
18566 +filename.-misc-lohit_malayalam-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Malayalam.ttf
18567 +filename.-misc-lohit_marathi-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Marathi.ttf
18568 +filename.-misc-lohit_tamil-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Tamil.ttf
18569 +filename.-misc-lohit_telugu-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/lohit/Lohit-Telugu.ttf
18570 +filename.-misc-dejavu_sans-medium-r-normal--0-0-0-0-p-0-iso10646-1=/usr/share/fonts/TrueType/dejavu/DejaVuSans.ttf
18572 +# AWT X11 font paths
18573 +awtfontpath.latin-1=/usr/share/fonts/TrueType/core
18574 +awtfontpath.latin-2=/usr/share/fonts/TrueType/core
18575 +awtfontpath.latin-5=/usr/share/fonts/TrueType/core
18576 +awtfontpath.latin-7=/usr/share/fonts/TrueType/core
18577 +awtfontpath.latin-9=/usr/share/fonts/TrueType/core
18578 +awtfontpath.hebrew=/usr/share/fonts/TrueType/core
18579 +awtfontpath.arabic=/usr/share/fonts/TrueType/core
18580 +awtfontpath.thai=/usr/share/fonts/TrueType/core
18581 +awtfontpath.greek=/usr/share/fonts/TrueType/core
18582 +awtfontpath.cyrillic-iso8859-5=/usr/share/fonts/TrueType/core
18583 +awtfontpath.cyrillic-cp1251=/usr/share/fonts/TrueType/core
18584 +awtfontpath.cyrillic-koi8-r=/usr/share/fonts/TrueType/core
18585 +awtfontpath.korean=/usr/share/fonts/TrueType/hanyang
18586 +awtfontpath.korean-johab=/usr/share/fonts/TrueType/hanyang
18587 +awtfontpath.japanese-x0201=/usr/share/fonts/TrueType/ipafont
18588 +awtfontpath.japanese-x0208=/usr/share/fonts/TrueType/ipafont
18589 +awtfontpath.japanese-x0212=/usr/share/fonts/TrueType/ipafont
18590 +awtfontpath.chinese-gbk=/usr/share/fonts/TrueType/arphic
18591 +awtfontpath.chinese-cns11643-1=/usr/share/fonts/TrueType/arphic
18592 +awtfontpath.chinese-cns11643-2=/usr/share/fonts/TrueType/arphic
18593 +awtfontpath.chinese-cns11643-3=/usr/share/fonts/TrueType/arphic
18594 +awtfontpath.chinese-big5=/usr/share/fonts/TrueType/arphic
18595 +awtfontpath.chinese-gb2312=/usr/share/fonts/TrueType/arphic
18596 +awtfontpath.chinese-gb18030-0=/usr/share/fonts/TrueType/arphic
18597 +awtfontpath.chinese-gb18030-1=/usr/share/fonts/TrueType/arphic
18598 +awtfontpath.chinese-hkscs=/usr/share/fonts/TrueType/arphic
18599 +awtfontpath.bengali=/usr/share/fonts/TrueType/lohit
18600 +awtfontpath.gujarati=/usr/share/fonts/TrueType/lohit
18601 +awtfontpath.hindi=/usr/share/fonts/TrueType/lohit
18602 +awtfontpath.kannada=/usr/share/fonts/TrueType/lohit
18603 +awtfontpath.malayalam=/usr/share/fonts/TrueType/lohit
18604 +awtfontpath.marathi=/usr/share/fonts/TrueType/lohit
18605 +awtfontpath.tamil=/usr/share/fonts/TrueType/lohit
18606 +awtfontpath.telugu=/usr/share/fonts/TrueType/lohit
18607 +awtfontpath.dejavusans=/usr/share/fonts/TrueType/dejavu
18609 +# Appended Font Path
18611 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_PCM.c jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_PCM.c
18612 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_PCM.c 1970-01-01 01:00:00.000000000 +0100
18613 +++ jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_PCM.c 2024-08-17 20:36:14.304279446 +0200
18614 @@ -0,0 +1,627 @@
18616 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
18617 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18619 + * This code is free software; you can redistribute it and/or modify it
18620 + * under the terms of the GNU General Public License version 2 only, as
18621 + * published by the Free Software Foundation. Oracle designates this
18622 + * particular file as subject to the "Classpath" exception as provided
18623 + * by Oracle in the LICENSE file that accompanied this code.
18625 + * This code is distributed in the hope that it will be useful, but WITHOUT
18626 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18627 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18628 + * version 2 for more details (a copy is included in the LICENSE file that
18629 + * accompanied this code).
18631 + * You should have received a copy of the GNU General Public License version
18632 + * 2 along with this work; if not, write to the Free Software Foundation,
18633 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18635 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18636 + * or visit www.oracle.com if you need additional information or have any
18637 + * questions.
18638 + */
18640 +#define USE_ERROR
18641 +#define USE_TRACE
18643 +#include "PLATFORM_API_SolarisOS_Utils.h"
18644 +#include "DirectAudio.h"
18646 +#if USE_DAUDIO == TRUE
18649 +// The default buffer time
18650 +#define DEFAULT_PERIOD_TIME_MILLIS 50
18652 +///// implemented functions of DirectAudio.h
18654 +INT32 DAUDIO_GetDirectAudioDeviceCount() {
18655 + return (INT32) getAudioDeviceCount();
18659 +INT32 DAUDIO_GetDirectAudioDeviceDescription(INT32 mixerIndex,
18660 + DirectAudioDeviceDescription* description) {
18661 + AudioDeviceDescription desc;
18663 + if (getAudioDeviceDescriptionByIndex(mixerIndex, &desc, TRUE)) {
18664 + description->maxSimulLines = desc.maxSimulLines;
18665 + strncpy(description->name, desc.name, DAUDIO_STRING_LENGTH-1);
18666 + description->name[DAUDIO_STRING_LENGTH-1] = 0;
18667 + strncpy(description->vendor, desc.vendor, DAUDIO_STRING_LENGTH-1);
18668 + description->vendor[DAUDIO_STRING_LENGTH-1] = 0;
18669 + strncpy(description->version, desc.version, DAUDIO_STRING_LENGTH-1);
18670 + description->version[DAUDIO_STRING_LENGTH-1] = 0;
18671 + /*strncpy(description->description, desc.description, DAUDIO_STRING_LENGTH-1);*/
18672 + strncpy(description->description, "Solaris Mixer", DAUDIO_STRING_LENGTH-1);
18673 + description->description[DAUDIO_STRING_LENGTH-1] = 0;
18674 + return TRUE;
18676 + return FALSE;
18680 +#define MAX_SAMPLE_RATES 20
18682 +void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* creator) {
18683 + int fd = -1;
18684 + AudioDeviceDescription desc;
18685 + am_sample_rates_t *sr;
18686 + /* hardcoded bits and channels */
18687 + int bits[] = {8, 16};
18688 + int bitsCount = 2;
18689 + int channels[] = {1, 2};
18690 + int channelsCount = 2;
18691 + /* for querying sample rates */
18692 + int err;
18693 + int ch, b;
18694 + uint_t s;
18696 + TRACE2("DAUDIO_GetFormats, mixer %d, isSource=%d\n", mixerIndex, isSource);
18697 + if (getAudioDeviceDescriptionByIndex(mixerIndex, &desc, FALSE)) {
18698 + fd = open(desc.pathctl, O_RDONLY);
18700 + if (fd < 0) {
18701 + ERROR1("Couldn't open audio device ctl for device %d!\n", mixerIndex);
18702 + return;
18705 + /* get sample rates */
18706 + sr = (am_sample_rates_t*) malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(MAX_SAMPLE_RATES));
18707 + if (sr == NULL) {
18708 + ERROR1("DAUDIO_GetFormats: out of memory for mixer %d\n", (int) mixerIndex);
18709 + close(fd);
18710 + return;
18713 + sr->num_samp_rates = MAX_SAMPLE_RATES;
18714 + sr->type = isSource?AUDIO_PLAY:AUDIO_RECORD;
18715 + sr->samp_rates[0] = -2;
18716 + err = ioctl(fd, AUDIO_MIXER_GET_SAMPLE_RATES, sr);
18717 + if (err < 0) {
18718 + ERROR1(" DAUDIO_GetFormats: AUDIO_MIXER_GET_SAMPLE_RATES failed for mixer %d!\n",
18719 + (int)mixerIndex);
18720 + ERROR2(" -> num_sample_rates=%d sample_rates[0] = %d\n",
18721 + (int) sr->num_samp_rates,
18722 + (int) sr->samp_rates[0]);
18723 + /* Some Solaris 8 drivers fail for get sample rates!
18724 + * Do as if we support all sample rates
18725 + */
18726 + sr->flags = MIXER_SR_LIMITS;
18728 + if ((sr->flags & MIXER_SR_LIMITS)
18729 + || (sr->num_samp_rates > MAX_SAMPLE_RATES)) {
18730 +#ifdef USE_TRACE
18731 + if ((sr->flags & MIXER_SR_LIMITS)) {
18732 + TRACE1(" DAUDIO_GetFormats: floating sample rate allowed by mixer %d\n",
18733 + (int)mixerIndex);
18735 + if (sr->num_samp_rates > MAX_SAMPLE_RATES) {
18736 + TRACE2(" DAUDIO_GetFormats: more than %d formats. Use -1 for sample rates mixer %d\n",
18737 + MAX_SAMPLE_RATES, (int)mixerIndex);
18739 +#endif
18740 + /*
18741 + * Fake it to have only one sample rate: -1
18742 + */
18743 + sr->num_samp_rates = 1;
18744 + sr->samp_rates[0] = -1;
18746 + close(fd);
18748 + for (ch = 0; ch < channelsCount; ch++) {
18749 + for (b = 0; b < bitsCount; b++) {
18750 + for (s = 0; s < sr->num_samp_rates; s++) {
18751 + DAUDIO_AddAudioFormat(creator,
18752 + bits[b], /* significant bits */
18753 + 0, /* frameSize: let it be calculated */
18754 + channels[ch],
18755 + (float) ((int) sr->samp_rates[s]),
18756 + DAUDIO_PCM, /* encoding - let's only do PCM */
18757 + (bits[b] > 8)?TRUE:TRUE, /* isSigned */
18758 +#ifdef _LITTLE_ENDIAN
18759 + FALSE /* little endian */
18760 +#else
18761 + (bits[b] > 8)?TRUE:FALSE /* big endian */
18762 +#endif
18763 + );
18767 + free(sr);
18771 +typedef struct {
18772 + int fd;
18773 + audio_info_t info;
18774 + int bufferSizeInBytes;
18775 + int frameSize; /* storage size in Bytes */
18776 + /* how many bytes were written or read */
18777 + INT32 transferedBytes;
18778 + /* if transferedBytes exceed 32-bit boundary,
18779 + * it will be reset and positionOffset will receive
18780 + * the offset
18781 + */
18782 + INT64 positionOffset;
18783 +} SolPcmInfo;
18786 +void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource,
18787 + int encoding, float sampleRate, int sampleSizeInBits,
18788 + int frameSize, int channels,
18789 + int isSigned, int isBigEndian, int bufferSizeInBytes) {
18790 + int err = 0;
18791 + int openMode;
18792 + AudioDeviceDescription desc;
18793 + SolPcmInfo* info;
18795 + TRACE0("> DAUDIO_Open\n");
18796 + if (encoding != DAUDIO_PCM) {
18797 + ERROR1(" DAUDIO_Open: invalid encoding %d\n", (int) encoding);
18798 + return NULL;
18800 + if (channels <= 0) {
18801 + ERROR1(" DAUDIO_Open: Invalid number of channels=%d!\n", channels);
18802 + return NULL;
18805 + info = (SolPcmInfo*) malloc(sizeof(SolPcmInfo));
18806 + if (!info) {
18807 + ERROR0("Out of memory\n");
18808 + return NULL;
18810 + memset(info, 0, sizeof(SolPcmInfo));
18811 + info->frameSize = frameSize;
18812 + info->fd = -1;
18814 + if (isSource) {
18815 + openMode = O_WRONLY;
18816 + } else {
18817 + openMode = O_RDONLY;
18820 +#ifndef __linux__
18821 + /* blackdown does not use NONBLOCK */
18822 + openMode |= O_NONBLOCK;
18823 +#endif
18825 + if (getAudioDeviceDescriptionByIndex(mixerIndex, &desc, FALSE)) {
18826 + info->fd = open(desc.path, openMode);
18828 + if (info->fd < 0) {
18829 + ERROR1("Couldn't open audio device for mixer %d!\n", mixerIndex);
18830 + free(info);
18831 + return NULL;
18833 + /* set to multiple open */
18834 + if (ioctl(info->fd, AUDIO_MIXER_MULTIPLE_OPEN, NULL) >= 0) {
18835 + TRACE1("DAUDIO_Open: %s set to multiple open\n", desc.path);
18836 + } else {
18837 + ERROR1("DAUDIO_Open: ioctl AUDIO_MIXER_MULTIPLE_OPEN failed on %s!\n", desc.path);
18840 + AUDIO_INITINFO(&(info->info));
18841 + /* need AUDIO_GETINFO ioctl to get this to work on solaris x86 */
18842 + err = ioctl(info->fd, AUDIO_GETINFO, &(info->info));
18844 + /* not valid to call AUDIO_SETINFO ioctl with all the fields from AUDIO_GETINFO. */
18845 + AUDIO_INITINFO(&(info->info));
18847 + if (isSource) {
18848 + info->info.play.sample_rate = sampleRate;
18849 + info->info.play.precision = sampleSizeInBits;
18850 + info->info.play.channels = channels;
18851 + info->info.play.encoding = AUDIO_ENCODING_LINEAR;
18852 + info->info.play.buffer_size = bufferSizeInBytes;
18853 + info->info.play.pause = 1;
18854 + } else {
18855 + info->info.record.sample_rate = sampleRate;
18856 + info->info.record.precision = sampleSizeInBits;
18857 + info->info.record.channels = channels;
18858 + info->info.record.encoding = AUDIO_ENCODING_LINEAR;
18859 + info->info.record.buffer_size = bufferSizeInBytes;
18860 + info->info.record.pause = 1;
18862 + err = ioctl(info->fd, AUDIO_SETINFO, &(info->info));
18863 + if (err < 0) {
18864 + ERROR0("DAUDIO_Open: could not set info!\n");
18865 + DAUDIO_Close((void*) info, isSource);
18866 + return NULL;
18868 + DAUDIO_Flush((void*) info, isSource);
18870 + err = ioctl(info->fd, AUDIO_GETINFO, &(info->info));
18871 + if (err >= 0) {
18872 + if (isSource) {
18873 + info->bufferSizeInBytes = info->info.play.buffer_size;
18874 + } else {
18875 + info->bufferSizeInBytes = info->info.record.buffer_size;
18877 + TRACE2("DAUDIO: buffersize in bytes: requested=%d, got %d\n",
18878 + (int) bufferSizeInBytes,
18879 + (int) info->bufferSizeInBytes);
18880 + } else {
18881 + ERROR0("DAUDIO_Open: cannot get info!\n");
18882 + DAUDIO_Close((void*) info, isSource);
18883 + return NULL;
18885 + TRACE0("< DAUDIO_Open: Opened device successfully.\n");
18886 + return (void*) info;
18890 +int DAUDIO_Start(void* id, int isSource) {
18891 + SolPcmInfo* info = (SolPcmInfo*) id;
18892 + int err, modified;
18893 + audio_info_t audioInfo;
18895 + TRACE0("> DAUDIO_Start\n");
18897 + AUDIO_INITINFO(&audioInfo);
18898 + err = ioctl(info->fd, AUDIO_GETINFO, &audioInfo);
18899 + if (err >= 0) {
18900 + // unpause
18901 + modified = FALSE;
18902 + if (isSource && audioInfo.play.pause) {
18903 + audioInfo.play.pause = 0;
18904 + modified = TRUE;
18906 + if (!isSource && audioInfo.record.pause) {
18907 + audioInfo.record.pause = 0;
18908 + modified = TRUE;
18910 + if (modified) {
18911 + err = ioctl(info->fd, AUDIO_SETINFO, &audioInfo);
18915 + TRACE1("< DAUDIO_Start %s\n", (err>=0)?"success":"error");
18916 + return (err >= 0)?TRUE:FALSE;
18919 +int DAUDIO_Stop(void* id, int isSource) {
18920 + SolPcmInfo* info = (SolPcmInfo*) id;
18921 + int err, modified;
18922 + audio_info_t audioInfo;
18924 + TRACE0("> DAUDIO_Stop\n");
18926 + AUDIO_INITINFO(&audioInfo);
18927 + err = ioctl(info->fd, AUDIO_GETINFO, &audioInfo);
18928 + if (err >= 0) {
18929 + // pause
18930 + modified = FALSE;
18931 + if (isSource && !audioInfo.play.pause) {
18932 + audioInfo.play.pause = 1;
18933 + modified = TRUE;
18935 + if (!isSource && !audioInfo.record.pause) {
18936 + audioInfo.record.pause = 1;
18937 + modified = TRUE;
18939 + if (modified) {
18940 + err = ioctl(info->fd, AUDIO_SETINFO, &audioInfo);
18944 + TRACE1("< DAUDIO_Stop %s\n", (err>=0)?"success":"error");
18945 + return (err >= 0)?TRUE:FALSE;
18948 +void DAUDIO_Close(void* id, int isSource) {
18949 + SolPcmInfo* info = (SolPcmInfo*) id;
18951 + TRACE0("DAUDIO_Close\n");
18952 + if (info != NULL) {
18953 + if (info->fd >= 0) {
18954 + DAUDIO_Flush(id, isSource);
18955 + close(info->fd);
18957 + free(info);
18961 +#ifndef USE_TRACE
18962 +/* close to 2^31 */
18963 +#define POSITION_MAX 2000000000
18964 +#else
18965 +/* for testing */
18966 +#define POSITION_MAX 1000000
18967 +#endif
18969 +void resetErrorFlagAndAdjustPosition(SolPcmInfo* info, int isSource, int count) {
18970 + audio_info_t audioInfo;
18971 + audio_prinfo_t* prinfo;
18972 + int err;
18973 + int offset = -1;
18974 + int underrun = FALSE;
18975 + int devBytes = 0;
18977 + if (count > 0) {
18978 + info->transferedBytes += count;
18980 + if (isSource) {
18981 + prinfo = &(audioInfo.play);
18982 + } else {
18983 + prinfo = &(audioInfo.record);
18985 + AUDIO_INITINFO(&audioInfo);
18986 + err = ioctl(info->fd, AUDIO_GETINFO, &audioInfo);
18987 + if (err >= 0) {
18988 + underrun = prinfo->error;
18989 + devBytes = prinfo->samples * info->frameSize;
18991 + AUDIO_INITINFO(&audioInfo);
18992 + if (underrun) {
18993 + /* if an underrun occurred, reset */
18994 + ERROR1("DAUDIO_Write/Read: Underrun/overflow: adjusting positionOffset by %d:\n",
18995 + (devBytes - info->transferedBytes));
18996 + ERROR1(" devBytes from %d to 0, ", devBytes);
18997 + ERROR2(" positionOffset from %d to %d ",
18998 + (int) info->positionOffset,
18999 + (int) (info->positionOffset + info->transferedBytes));
19000 + ERROR1(" transferedBytes from %d to 0\n",
19001 + (int) info->transferedBytes);
19002 + prinfo->samples = 0;
19003 + info->positionOffset += info->transferedBytes;
19004 + info->transferedBytes = 0;
19006 + else if (info->transferedBytes > POSITION_MAX) {
19007 + /* we will reset transferedBytes and
19008 + * the samples field in prinfo
19009 + */
19010 + offset = devBytes;
19011 + prinfo->samples = 0;
19013 + /* reset error flag */
19014 + prinfo->error = 0;
19016 + err = ioctl(info->fd, AUDIO_SETINFO, &audioInfo);
19017 + if (err >= 0) {
19018 + if (offset > 0) {
19019 + /* upon exit of AUDIO_SETINFO, the samples parameter
19020 + * was set to the previous value. This is our
19021 + * offset.
19022 + */
19023 + TRACE1("Adjust samplePos: offset=%d, ", (int) offset);
19024 + TRACE2("transferedBytes=%d -> %d, ",
19025 + (int) info->transferedBytes,
19026 + (int) (info->transferedBytes - offset));
19027 + TRACE2("positionOffset=%d -> %d\n",
19028 + (int) (info->positionOffset),
19029 + (int) (((int) info->positionOffset) + offset));
19030 + info->transferedBytes -= offset;
19031 + info->positionOffset += offset;
19033 + } else {
19034 + ERROR0("DAUDIO: resetErrorFlagAndAdjustPosition ioctl failed!\n");
19039 +// returns -1 on error
19040 +int DAUDIO_Write(void* id, char* data, int byteSize) {
19041 + SolPcmInfo* info = (SolPcmInfo*) id;
19042 + int ret = -1;
19044 + TRACE1("> DAUDIO_Write %d bytes\n", byteSize);
19045 + if (info!=NULL) {
19046 + ret = write(info->fd, data, byteSize);
19047 + resetErrorFlagAndAdjustPosition(info, TRUE, ret);
19048 + /* sets ret to -1 if buffer full, no error! */
19049 + if (ret < 0) {
19050 + ret = 0;
19053 + TRACE1("< DAUDIO_Write: returning %d bytes.\n", ret);
19054 + return ret;
19057 +// returns -1 on error
19058 +int DAUDIO_Read(void* id, char* data, int byteSize) {
19059 + SolPcmInfo* info = (SolPcmInfo*) id;
19060 + int ret = -1;
19062 + TRACE1("> DAUDIO_Read %d bytes\n", byteSize);
19063 + if (info != NULL) {
19064 + ret = read(info->fd, data, byteSize);
19065 + resetErrorFlagAndAdjustPosition(info, TRUE, ret);
19066 + /* sets ret to -1 if buffer full, no error! */
19067 + if (ret < 0) {
19068 + ret = 0;
19071 + TRACE1("< DAUDIO_Read: returning %d bytes.\n", ret);
19072 + return ret;
19076 +int DAUDIO_GetBufferSize(void* id, int isSource) {
19077 + SolPcmInfo* info = (SolPcmInfo*) id;
19078 + if (info) {
19079 + return info->bufferSizeInBytes;
19081 + return 0;
19084 +int DAUDIO_StillDraining(void* id, int isSource) {
19085 + SolPcmInfo* info = (SolPcmInfo*) id;
19086 + audio_info_t audioInfo;
19087 + audio_prinfo_t* prinfo;
19088 + int ret = FALSE;
19090 + if (info!=NULL) {
19091 + if (isSource) {
19092 + prinfo = &(audioInfo.play);
19093 + } else {
19094 + prinfo = &(audioInfo.record);
19096 + /* check error flag */
19097 + AUDIO_INITINFO(&audioInfo);
19098 + ioctl(info->fd, AUDIO_GETINFO, &audioInfo);
19099 + ret = (prinfo->error != 0)?FALSE:TRUE;
19101 + return ret;
19105 +int getDevicePosition(SolPcmInfo* info, int isSource) {
19106 + audio_info_t audioInfo;
19107 + audio_prinfo_t* prinfo;
19108 + int err;
19110 + if (isSource) {
19111 + prinfo = &(audioInfo.play);
19112 + } else {
19113 + prinfo = &(audioInfo.record);
19115 + AUDIO_INITINFO(&audioInfo);
19116 + err = ioctl(info->fd, AUDIO_GETINFO, &audioInfo);
19117 + if (err >= 0) {
19118 + /*TRACE2("---> device paused: %d eof=%d\n",
19119 + prinfo->pause, prinfo->eof);
19120 + */
19121 + return (int) (prinfo->samples * info->frameSize);
19123 + ERROR0("DAUDIO: getDevicePosition: ioctl failed!\n");
19124 + return -1;
19127 +int DAUDIO_Flush(void* id, int isSource) {
19128 + SolPcmInfo* info = (SolPcmInfo*) id;
19129 + int err = -1;
19130 + int pos;
19132 + TRACE0("DAUDIO_Flush\n");
19133 + if (info) {
19134 + if (isSource) {
19135 + err = ioctl(info->fd, I_FLUSH, FLUSHW);
19136 + } else {
19137 + err = ioctl(info->fd, I_FLUSH, FLUSHR);
19139 + if (err >= 0) {
19140 + /* resets the transferedBytes parameter to
19141 + * the current samples count of the device
19142 + */
19143 + pos = getDevicePosition(info, isSource);
19144 + if (pos >= 0) {
19145 + info->transferedBytes = pos;
19149 + if (err < 0) {
19150 + ERROR0("ERROR in DAUDIO_Flush\n");
19152 + return (err < 0)?FALSE:TRUE;
19155 +int DAUDIO_GetAvailable(void* id, int isSource) {
19156 + SolPcmInfo* info = (SolPcmInfo*) id;
19157 + int ret = 0;
19158 + int pos;
19160 + if (info) {
19161 + /* unfortunately, the STREAMS architecture
19162 + * seems to not have a method for querying
19163 + * the available bytes to read/write!
19164 + * estimate it...
19165 + */
19166 + pos = getDevicePosition(info, isSource);
19167 + if (pos >= 0) {
19168 + if (isSource) {
19169 + /* we usually have written more bytes
19170 + * to the queue than the device position should be
19171 + */
19172 + ret = (info->bufferSizeInBytes) - (info->transferedBytes - pos);
19173 + } else {
19174 + /* for record, the device stream should
19175 + * be usually ahead of our read actions
19176 + */
19177 + ret = pos - info->transferedBytes;
19179 + if (ret > info->bufferSizeInBytes) {
19180 + ERROR2("DAUDIO_GetAvailable: available=%d, too big at bufferSize=%d!\n",
19181 + (int) ret, (int) info->bufferSizeInBytes);
19182 + ERROR2(" devicePos=%d, transferedBytes=%d\n",
19183 + (int) pos, (int) info->transferedBytes);
19184 + ret = info->bufferSizeInBytes;
19186 + else if (ret < 0) {
19187 + ERROR1("DAUDIO_GetAvailable: available=%d, in theory not possible!\n",
19188 + (int) ret);
19189 + ERROR2(" devicePos=%d, transferedBytes=%d\n",
19190 + (int) pos, (int) info->transferedBytes);
19191 + ret = 0;
19196 + TRACE1("DAUDIO_GetAvailable returns %d bytes\n", ret);
19197 + return ret;
19200 +INT64 DAUDIO_GetBytePosition(void* id, int isSource, INT64 javaBytePos) {
19201 + SolPcmInfo* info = (SolPcmInfo*) id;
19202 + int ret;
19203 + int pos;
19204 + INT64 result = javaBytePos;
19206 + if (info) {
19207 + pos = getDevicePosition(info, isSource);
19208 + if (pos >= 0) {
19209 + result = info->positionOffset + pos;
19213 + //printf("getbyteposition: javaBytePos=%d , return=%d\n", (int) javaBytePos, (int) result);
19214 + return result;
19218 +void DAUDIO_SetBytePosition(void* id, int isSource, INT64 javaBytePos) {
19219 + SolPcmInfo* info = (SolPcmInfo*) id;
19220 + int ret;
19221 + int pos;
19223 + if (info) {
19224 + pos = getDevicePosition(info, isSource);
19225 + if (pos >= 0) {
19226 + info->positionOffset = javaBytePos - pos;
19231 +int DAUDIO_RequiresServicing(void* id, int isSource) {
19232 + // never need servicing on Solaris
19233 + return FALSE;
19236 +void DAUDIO_Service(void* id, int isSource) {
19237 + // never need servicing on Solaris
19241 +#endif // USE_DAUDIO
19242 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Ports.c jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Ports.c
19243 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Ports.c 1970-01-01 01:00:00.000000000 +0100
19244 +++ jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Ports.c 2024-08-17 20:36:14.304779420 +0200
19245 @@ -0,0 +1,600 @@
19247 + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
19248 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19250 + * This code is free software; you can redistribute it and/or modify it
19251 + * under the terms of the GNU General Public License version 2 only, as
19252 + * published by the Free Software Foundation. Oracle designates this
19253 + * particular file as subject to the "Classpath" exception as provided
19254 + * by Oracle in the LICENSE file that accompanied this code.
19256 + * This code is distributed in the hope that it will be useful, but WITHOUT
19257 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19258 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19259 + * version 2 for more details (a copy is included in the LICENSE file that
19260 + * accompanied this code).
19262 + * You should have received a copy of the GNU General Public License version
19263 + * 2 along with this work; if not, write to the Free Software Foundation,
19264 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19266 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19267 + * or visit www.oracle.com if you need additional information or have any
19268 + * questions.
19269 + */
19271 +#define USE_ERROR
19272 +//#define USE_TRACE
19274 +#include "Ports.h"
19275 +#include "PLATFORM_API_SolarisOS_Utils.h"
19277 +#if USE_PORTS == TRUE
19279 +#define MONITOR_GAIN_STRING "Monitor Gain"
19281 +#define ALL_TARGET_PORT_COUNT 6
19283 +// define the following to not use audio_prinfo_t.mod_ports
19284 +#define SOLARIS7_COMPATIBLE
19286 +// Solaris audio defines
19287 +static int targetPorts[ALL_TARGET_PORT_COUNT] = {
19288 + AUDIO_SPEAKER,
19289 + AUDIO_HEADPHONE,
19290 + AUDIO_LINE_OUT,
19291 + AUDIO_AUX1_OUT,
19292 + AUDIO_AUX2_OUT,
19293 + AUDIO_SPDIF_OUT
19296 +static char* targetPortNames[ALL_TARGET_PORT_COUNT] = {
19297 + "Speaker",
19298 + "Headphone",
19299 + "Line Out",
19300 + "AUX1 Out",
19301 + "AUX2 Out",
19302 + "SPDIF Out"
19305 +// defined in Ports.h
19306 +static int targetPortJavaSoundMapping[ALL_TARGET_PORT_COUNT] = {
19307 + PORT_DST_SPEAKER,
19308 + PORT_DST_HEADPHONE,
19309 + PORT_DST_LINE_OUT,
19310 + PORT_DST_UNKNOWN,
19311 + PORT_DST_UNKNOWN,
19312 + PORT_DST_UNKNOWN,
19315 +#define ALL_SOURCE_PORT_COUNT 7
19317 +// Solaris audio defines
19318 +static int sourcePorts[ALL_SOURCE_PORT_COUNT] = {
19319 + AUDIO_MICROPHONE,
19320 + AUDIO_LINE_IN,
19321 + AUDIO_CD,
19322 + AUDIO_AUX1_IN,
19323 + AUDIO_AUX2_IN,
19324 + AUDIO_SPDIF_IN,
19325 + AUDIO_CODEC_LOOPB_IN
19328 +static char* sourcePortNames[ALL_SOURCE_PORT_COUNT] = {
19329 + "Microphone In",
19330 + "Line In",
19331 + "Compact Disc In",
19332 + "AUX1 In",
19333 + "AUX2 In",
19334 + "SPDIF In",
19335 + "Internal Loopback"
19338 +// Ports.h defines
19339 +static int sourcePortJavaSoundMapping[ALL_SOURCE_PORT_COUNT] = {
19340 + PORT_SRC_MICROPHONE,
19341 + PORT_SRC_LINE_IN,
19342 + PORT_SRC_COMPACT_DISC,
19343 + PORT_SRC_UNKNOWN,
19344 + PORT_SRC_UNKNOWN,
19345 + PORT_SRC_UNKNOWN,
19346 + PORT_SRC_UNKNOWN
19349 +struct tag_PortControlID;
19351 +typedef struct tag_PortInfo {
19352 + int fd; // file descriptor of the pseudo device
19353 + audio_info_t audioInfo;
19354 + // ports
19355 + int targetPortCount;
19356 + int sourcePortCount;
19357 + // indexes to sourcePorts/targetPorts
19358 + // contains first target ports, then source ports
19359 + int ports[ALL_TARGET_PORT_COUNT + ALL_SOURCE_PORT_COUNT];
19360 + // controls
19361 + int maxControlCount; // upper bound of number of controls
19362 + int usedControlIDs; // number of items already filled in controlIDs
19363 + struct tag_PortControlID* controlIDs; // the control IDs themselves
19364 +} PortInfo;
19366 +#define PORT_CONTROL_TYPE_PLAY 0x4000000
19367 +#define PORT_CONTROL_TYPE_RECORD 0x8000000
19368 +#define PORT_CONTROL_TYPE_SELECT_PORT 1
19369 +#define PORT_CONTROL_TYPE_GAIN 2
19370 +#define PORT_CONTROL_TYPE_BALANCE 3
19371 +#define PORT_CONTROL_TYPE_MONITOR_GAIN 10
19372 +#define PORT_CONTROL_TYPE_OUTPUT_MUTED 11
19373 +#define PORT_CONTROL_TYPE_PLAYRECORD_MASK PORT_CONTROL_TYPE_PLAY | PORT_CONTROL_TYPE_RECORD
19374 +#define PORT_CONTROL_TYPE_MASK 0xFFFFFF
19377 +typedef struct tag_PortControlID {
19378 + PortInfo* portInfo;
19379 + INT32 controlType; // PORT_CONTROL_TYPE_XX
19380 + uint_t port;
19381 +} PortControlID;
19384 +///// implemented functions of Ports.h
19386 +INT32 PORT_GetPortMixerCount() {
19387 + return (INT32) getAudioDeviceCount();
19391 +INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* description) {
19392 + AudioDeviceDescription desc;
19394 + if (getAudioDeviceDescriptionByIndex(mixerIndex, &desc, TRUE)) {
19395 + strncpy(description->name, desc.name, PORT_STRING_LENGTH-1);
19396 + description->name[PORT_STRING_LENGTH-1] = 0;
19397 + strncpy(description->vendor, desc.vendor, PORT_STRING_LENGTH-1);
19398 + description->vendor[PORT_STRING_LENGTH-1] = 0;
19399 + strncpy(description->version, desc.version, PORT_STRING_LENGTH-1);
19400 + description->version[PORT_STRING_LENGTH-1] = 0;
19401 + /*strncpy(description->description, desc.description, PORT_STRING_LENGTH-1);*/
19402 + strncpy(description->description, "Solaris Ports", PORT_STRING_LENGTH-1);
19403 + description->description[PORT_STRING_LENGTH-1] = 0;
19404 + return TRUE;
19406 + return FALSE;
19410 +void* PORT_Open(INT32 mixerIndex) {
19411 + PortInfo* info = NULL;
19412 + int fd = -1;
19413 + AudioDeviceDescription desc;
19414 + int success = FALSE;
19416 + TRACE0("PORT_Open\n");
19417 + if (getAudioDeviceDescriptionByIndex(mixerIndex, &desc, FALSE)) {
19418 + fd = open(desc.pathctl, O_RDWR);
19420 + if (fd < 0) {
19421 + ERROR1("Couldn't open audio device ctl for device %d!\n", mixerIndex);
19422 + return NULL;
19425 + info = (PortInfo*) malloc(sizeof(PortInfo));
19426 + if (info != NULL) {
19427 + memset(info, 0, sizeof(PortInfo));
19428 + info->fd = fd;
19429 + success = TRUE;
19431 + if (!success) {
19432 + if (fd >= 0) {
19433 + close(fd);
19435 + PORT_Close((void*) info);
19436 + info = NULL;
19438 + return info;
19441 +void PORT_Close(void* id) {
19442 + TRACE0("PORT_Close\n");
19443 + if (id != NULL) {
19444 + PortInfo* info = (PortInfo*) id;
19445 + if (info->fd >= 0) {
19446 + close(info->fd);
19447 + info->fd = -1;
19449 + if (info->controlIDs) {
19450 + free(info->controlIDs);
19451 + info->controlIDs = NULL;
19453 + free(info);
19459 +INT32 PORT_GetPortCount(void* id) {
19460 + int ret = 0;
19461 + PortInfo* info = (PortInfo*) id;
19462 + if (info != NULL) {
19463 + if (!info->targetPortCount && !info->sourcePortCount) {
19464 + int i;
19465 + AUDIO_INITINFO(&info->audioInfo);
19466 + if (ioctl(info->fd, AUDIO_GETINFO, &info->audioInfo) >= 0) {
19467 + for (i = 0; i < ALL_TARGET_PORT_COUNT; i++) {
19468 + if (info->audioInfo.play.avail_ports & targetPorts[i]) {
19469 + info->ports[info->targetPortCount] = i;
19470 + info->targetPortCount++;
19472 +#ifdef SOLARIS7_COMPATIBLE
19473 + TRACE3("Target %d %s: avail=%d\n", i, targetPortNames[i],
19474 + info->audioInfo.play.avail_ports & targetPorts[i]);
19475 +#else
19476 + TRACE4("Target %d %s: avail=%d mod=%d\n", i, targetPortNames[i],
19477 + info->audioInfo.play.avail_ports & targetPorts[i],
19478 + info->audioInfo.play.mod_ports & targetPorts[i]);
19479 +#endif
19481 + for (i = 0; i < ALL_SOURCE_PORT_COUNT; i++) {
19482 + if (info->audioInfo.record.avail_ports & sourcePorts[i]) {
19483 + info->ports[info->targetPortCount + info->sourcePortCount] = i;
19484 + info->sourcePortCount++;
19486 +#ifdef SOLARIS7_COMPATIBLE
19487 + TRACE3("Source %d %s: avail=%d\n", i, sourcePortNames[i],
19488 + info->audioInfo.record.avail_ports & sourcePorts[i]);
19489 +#else
19490 + TRACE4("Source %d %s: avail=%d mod=%d\n", i, sourcePortNames[i],
19491 + info->audioInfo.record.avail_ports & sourcePorts[i],
19492 + info->audioInfo.record.mod_ports & sourcePorts[i]);
19493 +#endif
19497 + ret = info->targetPortCount + info->sourcePortCount;
19499 + return ret;
19502 +int isSourcePort(PortInfo* info, INT32 portIndex) {
19503 + return (portIndex >= info->targetPortCount);
19506 +INT32 PORT_GetPortType(void* id, INT32 portIndex) {
19507 + PortInfo* info = (PortInfo*) id;
19508 + if ((portIndex >= 0) && (portIndex < PORT_GetPortCount(id))) {
19509 + if (isSourcePort(info, portIndex)) {
19510 + return sourcePortJavaSoundMapping[info->ports[portIndex]];
19511 + } else {
19512 + return targetPortJavaSoundMapping[info->ports[portIndex]];
19515 + return 0;
19518 +// pre-condition: portIndex must have been verified!
19519 +char* getPortName(PortInfo* info, INT32 portIndex) {
19520 + char* ret = NULL;
19522 + if (isSourcePort(info, portIndex)) {
19523 + ret = sourcePortNames[info->ports[portIndex]];
19524 + } else {
19525 + ret = targetPortNames[info->ports[portIndex]];
19527 + return ret;
19530 +INT32 PORT_GetPortName(void* id, INT32 portIndex, char* name, INT32 len) {
19531 + PortInfo* info = (PortInfo*) id;
19532 + char* n;
19534 + if ((portIndex >= 0) && (portIndex < PORT_GetPortCount(id))) {
19535 + n = getPortName(info, portIndex);
19536 + if (n) {
19537 + strncpy(name, n, len-1);
19538 + name[len-1] = 0;
19539 + return TRUE;
19542 + return FALSE;
19545 +void createPortControl(PortInfo* info, PortControlCreator* creator, INT32 portIndex,
19546 + INT32 type, void** controlObjects, int* controlCount) {
19547 + PortControlID* controlID;
19548 + void* newControl = NULL;
19549 + int controlIndex;
19550 + char* jsType = NULL;
19551 + int isBoolean = FALSE;
19553 + TRACE0(">createPortControl\n");
19555 + // fill the ControlID structure and add this control
19556 + if (info->usedControlIDs >= info->maxControlCount) {
19557 + ERROR1("not enough free controlIDs !! maxControlIDs = %d\n", info->maxControlCount);
19558 + return;
19560 + controlID = &(info->controlIDs[info->usedControlIDs]);
19561 + controlID->portInfo = info;
19562 + controlID->controlType = type;
19563 + controlIndex = info->ports[portIndex];
19564 + if (isSourcePort(info, portIndex)) {
19565 + controlID->port = sourcePorts[controlIndex];
19566 + } else {
19567 + controlID->port = targetPorts[controlIndex];
19569 + switch (type & PORT_CONTROL_TYPE_MASK) {
19570 + case PORT_CONTROL_TYPE_SELECT_PORT:
19571 + jsType = CONTROL_TYPE_SELECT; isBoolean = TRUE; break;
19572 + case PORT_CONTROL_TYPE_GAIN:
19573 + jsType = CONTROL_TYPE_VOLUME; break;
19574 + case PORT_CONTROL_TYPE_BALANCE:
19575 + jsType = CONTROL_TYPE_BALANCE; break;
19576 + case PORT_CONTROL_TYPE_MONITOR_GAIN:
19577 + jsType = CONTROL_TYPE_VOLUME; break;
19578 + case PORT_CONTROL_TYPE_OUTPUT_MUTED:
19579 + jsType = CONTROL_TYPE_MUTE; isBoolean = TRUE; break;
19581 + if (isBoolean) {
19582 + TRACE0(" PORT_CONTROL_TYPE_BOOLEAN\n");
19583 + newControl = (creator->newBooleanControl)(creator, controlID, jsType);
19585 + else if (jsType == CONTROL_TYPE_BALANCE) {
19586 + TRACE0(" PORT_CONTROL_TYPE_BALANCE\n");
19587 + newControl = (creator->newFloatControl)(creator, controlID, jsType,
19588 + -1.0f, 1.0f, 2.0f / 65.0f, "");
19589 + } else {
19590 + TRACE0(" PORT_CONTROL_TYPE_FLOAT\n");
19591 + newControl = (creator->newFloatControl)(creator, controlID, jsType,
19592 + 0.0f, 1.0f, 1.0f / 256.0f, "");
19594 + if (newControl) {
19595 + controlObjects[*controlCount] = newControl;
19596 + (*controlCount)++;
19597 + info->usedControlIDs++;
19599 + TRACE0("<createPortControl\n");
19603 +void addCompoundControl(PortInfo* info, PortControlCreator* creator, char* name, void** controlObjects, int* controlCount) {
19604 + void* compControl;
19606 + TRACE1(">addCompoundControl %d controls\n", *controlCount);
19607 + if (*controlCount) {
19608 + // create compound control and add it to the vector
19609 + compControl = (creator->newCompoundControl)(creator, name, controlObjects, *controlCount);
19610 + if (compControl) {
19611 + TRACE1(" addCompoundControl: calling addControl %p\n", compControl);
19612 + (creator->addControl)(creator, compControl);
19614 + *controlCount = 0;
19616 + TRACE0("<addCompoundControl\n");
19619 +void addAllControls(PortInfo* info, PortControlCreator* creator, void** controlObjects, int* controlCount) {
19620 + int i = 0;
19622 + TRACE0(">addAllControl\n");
19623 + // go through all controls and add them to the vector
19624 + for (i = 0; i < *controlCount; i++) {
19625 + (creator->addControl)(creator, controlObjects[i]);
19627 + *controlCount = 0;
19628 + TRACE0("<addAllControl\n");
19631 +void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) {
19632 + PortInfo* info = (PortInfo*) id;
19633 + int portCount = PORT_GetPortCount(id);
19634 + void* controls[4];
19635 + int controlCount = 0;
19636 + INT32 type;
19637 + int selectable = 1;
19638 + memset(controls, 0, sizeof(controls));
19640 + TRACE4(">PORT_GetControls(id=%p, portIndex=%d). controlIDs=%p, maxControlCount=%d\n",
19641 + id, portIndex, info->controlIDs, info->maxControlCount);
19642 + if ((portIndex >= 0) && (portIndex < portCount)) {
19643 + // if the memory isn't reserved for the control structures, allocate it
19644 + if (!info->controlIDs) {
19645 + int maxCount = 0;
19646 + TRACE0("getControl: allocate mem\n");
19647 + // get a maximum number of controls:
19648 + // each port has a select, balance, and volume control.
19649 + maxCount = 3 * portCount;
19650 + // then there is monitorGain and outputMuted
19651 + maxCount += (2 * info->targetPortCount);
19652 + info->maxControlCount = maxCount;
19653 + info->controlIDs = (PortControlID*) malloc(sizeof(PortControlID) * maxCount);
19655 + if (!isSourcePort(info, portIndex)) {
19656 + type = PORT_CONTROL_TYPE_PLAY;
19657 + // add master mute control
19658 + createPortControl(info, creator, portIndex,
19659 + type | PORT_CONTROL_TYPE_OUTPUT_MUTED,
19660 + controls, &controlCount);
19661 + addAllControls(info, creator, controls, &controlCount);
19662 +#ifdef SOLARIS7_COMPATIBLE
19663 + selectable = info->audioInfo.play.avail_ports & targetPorts[info->ports[portIndex]];
19664 +#else
19665 + selectable = info->audioInfo.play.mod_ports & targetPorts[info->ports[portIndex]];
19666 +#endif
19667 + } else {
19668 + type = PORT_CONTROL_TYPE_RECORD;
19669 +#ifdef SOLARIS7_COMPATIBLE
19670 + selectable = info->audioInfo.record.avail_ports & sourcePorts[info->ports[portIndex]];
19671 +#else
19672 + selectable = info->audioInfo.record.mod_ports & sourcePorts[info->ports[portIndex]];
19673 +#endif
19675 + // add a mixer strip with volume, ...
19676 + createPortControl(info, creator, portIndex,
19677 + type | PORT_CONTROL_TYPE_GAIN,
19678 + controls, &controlCount);
19679 + // ... balance, ...
19680 + createPortControl(info, creator, portIndex,
19681 + type | PORT_CONTROL_TYPE_BALANCE,
19682 + controls, &controlCount);
19683 + // ... and select control (if not always on)...
19684 + if (selectable) {
19685 + createPortControl(info, creator, portIndex,
19686 + type | PORT_CONTROL_TYPE_SELECT_PORT,
19687 + controls, &controlCount);
19689 + // ... packaged in a compound control.
19690 + addCompoundControl(info, creator, getPortName(info, portIndex), controls, &controlCount);
19692 + if (type == PORT_CONTROL_TYPE_PLAY) {
19693 + // add a single strip for source ports with monitor gain
19694 + createPortControl(info, creator, portIndex,
19695 + type | PORT_CONTROL_TYPE_MONITOR_GAIN,
19696 + controls, &controlCount);
19697 + // also in a compound control
19698 + addCompoundControl(info, creator, MONITOR_GAIN_STRING, controls, &controlCount);
19701 + TRACE0("< PORT_getControls\n");
19704 +INT32 PORT_GetIntValue(void* controlIDV) {
19705 + PortControlID* controlID = (PortControlID*) controlIDV;
19706 + audio_info_t audioInfo;
19707 + audio_prinfo_t* prinfo;
19709 + AUDIO_INITINFO(&audioInfo);
19710 + if (ioctl(controlID->portInfo->fd, AUDIO_GETINFO, &audioInfo) >= 0) {
19711 + if (controlID->controlType & PORT_CONTROL_TYPE_PLAY) {
19712 + prinfo = &(audioInfo.play);
19713 + } else {
19714 + prinfo = &(audioInfo.record);
19716 + switch (controlID->controlType & PORT_CONTROL_TYPE_MASK) {
19717 + case PORT_CONTROL_TYPE_SELECT_PORT:
19718 + return (prinfo->port & controlID->port)?TRUE:FALSE;
19719 + case PORT_CONTROL_TYPE_OUTPUT_MUTED:
19720 + return (audioInfo.output_muted)?TRUE:FALSE;
19721 + default:
19722 + ERROR1("PORT_GetIntValue: Wrong type %d !\n", controlID->controlType & PORT_CONTROL_TYPE_MASK);
19725 + ERROR0("PORT_GetIntValue: Could not ioctl!\n");
19726 + return 0;
19729 +void PORT_SetIntValue(void* controlIDV, INT32 value) {
19730 + PortControlID* controlID = (PortControlID*) controlIDV;
19731 + audio_info_t audioInfo;
19732 + audio_prinfo_t* prinfo;
19733 + int setPort;
19735 + if (controlID->controlType & PORT_CONTROL_TYPE_PLAY) {
19736 + prinfo = &(audioInfo.play);
19737 + } else {
19738 + prinfo = &(audioInfo.record);
19740 + switch (controlID->controlType & PORT_CONTROL_TYPE_MASK) {
19741 + case PORT_CONTROL_TYPE_SELECT_PORT:
19742 + // first try to just add this port. if that fails, set ONLY to this port.
19743 + AUDIO_INITINFO(&audioInfo);
19744 + if (ioctl(controlID->portInfo->fd, AUDIO_GETINFO, &audioInfo) >= 0) {
19745 + if (value) {
19746 + setPort = (prinfo->port | controlID->port);
19747 + } else {
19748 + setPort = (prinfo->port - controlID->port);
19750 + AUDIO_INITINFO(&audioInfo);
19751 + prinfo->port = setPort;
19752 + if (ioctl(controlID->portInfo->fd, AUDIO_SETINFO, &audioInfo) < 0) {
19753 + // didn't work. Either this line doesn't support to select several
19754 + // ports at once (e.g. record), or a real error
19755 + if (value) {
19756 + // set to ONLY this port (and disable any other currently selected ports)
19757 + AUDIO_INITINFO(&audioInfo);
19758 + prinfo->port = controlID->port;
19759 + if (ioctl(controlID->portInfo->fd, AUDIO_SETINFO, &audioInfo) < 0) {
19760 + ERROR2("Error setting output select port %d to port %d!\n", controlID->port, controlID->port);
19762 + } else {
19763 + // assume it's an error
19764 + ERROR2("Error setting output select port %d to port %d!\n", controlID->port, setPort);
19767 + break;
19768 + case PORT_CONTROL_TYPE_OUTPUT_MUTED:
19769 + AUDIO_INITINFO(&audioInfo);
19770 + audioInfo.output_muted = (value?TRUE:FALSE);
19771 + if (ioctl(controlID->portInfo->fd, AUDIO_SETINFO, &audioInfo) < 0) {
19772 + ERROR2("Error setting output muted on port %d to %d!\n", controlID->port, value);
19774 + break;
19775 + default:
19776 + ERROR1("PORT_SetIntValue: Wrong type %d !\n", controlID->controlType & PORT_CONTROL_TYPE_MASK);
19781 +float PORT_GetFloatValue(void* controlIDV) {
19782 + PortControlID* controlID = (PortControlID*) controlIDV;
19783 + audio_info_t audioInfo;
19784 + audio_prinfo_t* prinfo;
19786 + AUDIO_INITINFO(&audioInfo);
19787 + if (ioctl(controlID->portInfo->fd, AUDIO_GETINFO, &audioInfo) >= 0) {
19788 + if (controlID->controlType & PORT_CONTROL_TYPE_PLAY) {
19789 + prinfo = &(audioInfo.play);
19790 + } else {
19791 + prinfo = &(audioInfo.record);
19793 + switch (controlID->controlType & PORT_CONTROL_TYPE_MASK) {
19794 + case PORT_CONTROL_TYPE_GAIN:
19795 + return ((float) (prinfo->gain - AUDIO_MIN_GAIN))
19796 + / ((float) (AUDIO_MAX_GAIN - AUDIO_MIN_GAIN));
19797 + case PORT_CONTROL_TYPE_BALANCE:
19798 + return ((float) ((prinfo->balance - AUDIO_LEFT_BALANCE - AUDIO_MID_BALANCE) << 1))
19799 + / ((float) (AUDIO_RIGHT_BALANCE - AUDIO_LEFT_BALANCE));
19800 + case PORT_CONTROL_TYPE_MONITOR_GAIN:
19801 + return ((float) (audioInfo.monitor_gain - AUDIO_MIN_GAIN))
19802 + / ((float) (AUDIO_MAX_GAIN - AUDIO_MIN_GAIN));
19803 + default:
19804 + ERROR1("PORT_GetFloatValue: Wrong type %d !\n", controlID->controlType & PORT_CONTROL_TYPE_MASK);
19807 + ERROR0("PORT_GetFloatValue: Could not ioctl!\n");
19808 + return 0.0f;
19811 +void PORT_SetFloatValue(void* controlIDV, float value) {
19812 + PortControlID* controlID = (PortControlID*) controlIDV;
19813 + audio_info_t audioInfo;
19814 + audio_prinfo_t* prinfo;
19816 + AUDIO_INITINFO(&audioInfo);
19818 + if (controlID->controlType & PORT_CONTROL_TYPE_PLAY) {
19819 + prinfo = &(audioInfo.play);
19820 + } else {
19821 + prinfo = &(audioInfo.record);
19823 + switch (controlID->controlType & PORT_CONTROL_TYPE_MASK) {
19824 + case PORT_CONTROL_TYPE_GAIN:
19825 + prinfo->gain = AUDIO_MIN_GAIN
19826 + + (int) ((value * ((float) (AUDIO_MAX_GAIN - AUDIO_MIN_GAIN))) + 0.5f);
19827 + break;
19828 + case PORT_CONTROL_TYPE_BALANCE:
19829 + prinfo->balance = AUDIO_LEFT_BALANCE + AUDIO_MID_BALANCE
19830 + + ((int) (value * ((float) ((AUDIO_RIGHT_BALANCE - AUDIO_LEFT_BALANCE) >> 1))) + 0.5f);
19831 + break;
19832 + case PORT_CONTROL_TYPE_MONITOR_GAIN:
19833 + audioInfo.monitor_gain = AUDIO_MIN_GAIN
19834 + + (int) ((value * ((float) (AUDIO_MAX_GAIN - AUDIO_MIN_GAIN))) + 0.5f);
19835 + break;
19836 + default:
19837 + ERROR1("PORT_SetFloatValue: Wrong type %d !\n", controlID->controlType & PORT_CONTROL_TYPE_MASK);
19838 + return;
19840 + if (ioctl(controlID->portInfo->fd, AUDIO_SETINFO, &audioInfo) < 0) {
19841 + ERROR0("PORT_SetFloatValue: Could not ioctl!\n");
19845 +#endif // USE_PORTS
19846 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.c jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.c
19847 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.c 1970-01-01 01:00:00.000000000 +0100
19848 +++ jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.c 2024-08-17 20:36:14.305073019 +0200
19849 @@ -0,0 +1,193 @@
19851 + * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
19852 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19854 + * This code is free software; you can redistribute it and/or modify it
19855 + * under the terms of the GNU General Public License version 2 only, as
19856 + * published by the Free Software Foundation. Oracle designates this
19857 + * particular file as subject to the "Classpath" exception as provided
19858 + * by Oracle in the LICENSE file that accompanied this code.
19860 + * This code is distributed in the hope that it will be useful, but WITHOUT
19861 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19862 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19863 + * version 2 for more details (a copy is included in the LICENSE file that
19864 + * accompanied this code).
19866 + * You should have received a copy of the GNU General Public License version
19867 + * 2 along with this work; if not, write to the Free Software Foundation,
19868 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19870 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19871 + * or visit www.oracle.com if you need additional information or have any
19872 + * questions.
19873 + */
19875 +#define USE_ERROR
19876 +#define USE_TRACE
19878 +#include "PLATFORM_API_SolarisOS_Utils.h"
19880 +#define MAX_AUDIO_DEVICES 20
19882 +// not thread safe...
19883 +static AudioDevicePath globalADPaths[MAX_AUDIO_DEVICES];
19884 +static int globalADCount = -1;
19885 +static int globalADCacheTime = -1;
19886 +/* how many seconds do we cache devices */
19887 +#define AD_CACHE_TIME 30
19889 +// return seconds
19890 +long getTimeInSeconds() {
19891 + struct timeval tv;
19892 + gettimeofday(&tv, NULL);
19893 + return tv.tv_sec;
19897 +int getAudioDeviceCount() {
19898 + int count = MAX_AUDIO_DEVICES;
19900 + getAudioDevices(globalADPaths, &count);
19901 + return count;
19904 +/* returns TRUE if the path exists at all */
19905 +int addAudioDevice(char* path, AudioDevicePath* adPath, int* count) {
19906 + int i;
19907 + int found = 0;
19908 + int fileExists = 0;
19909 + // not thread safe...
19910 + static struct stat statBuf;
19912 + // get stats on the file
19913 + if (stat(path, &statBuf) == 0) {
19914 + // file exists.
19915 + fileExists = 1;
19916 + // If it is not yet in the adPath array, add it to the array
19917 + for (i = 0; i < *count; i++) {
19918 + if (adPath[i].st_ino == statBuf.st_ino
19919 + && adPath[i].st_dev == statBuf.st_dev) {
19920 + found = 1;
19921 + break;
19924 + if (!found) {
19925 + adPath[*count].st_ino = statBuf.st_ino;
19926 + adPath[*count].st_dev = statBuf.st_dev;
19927 + strncpy(adPath[*count].path, path, MAX_NAME_LENGTH);
19928 + adPath[*count].path[MAX_NAME_LENGTH - 1] = 0;
19929 + (*count)++;
19930 + TRACE1("Added audio device %s\n", path);
19933 + return fileExists;
19937 +void getAudioDevices(AudioDevicePath* adPath, int* count) {
19938 + int maxCount = *count;
19939 + char* audiodev;
19940 + char devsound[15];
19941 + int i;
19942 + long timeInSeconds = getTimeInSeconds();
19944 + if (globalADCount < 0
19945 + || (getTimeInSeconds() - globalADCacheTime) > AD_CACHE_TIME
19946 + || (adPath != globalADPaths)) {
19947 + *count = 0;
19948 + // first device, if set, is AUDIODEV variable
19949 + audiodev = getenv("AUDIODEV");
19950 + if (audiodev != NULL && audiodev[0] != 0) {
19951 + addAudioDevice(audiodev, adPath, count);
19953 + // then try /dev/audio
19954 + addAudioDevice("/dev/audio", adPath, count);
19955 + // then go through all of the /dev/sound/? devices
19956 + for (i = 0; i < 100; i++) {
19957 + sprintf(devsound, "/dev/sound/%d", i);
19958 + if (!addAudioDevice(devsound, adPath, count)) {
19959 + break;
19962 + if (adPath == globalADPaths) {
19963 + /* commit cache */
19964 + globalADCount = *count;
19965 + /* set cache time */
19966 + globalADCacheTime = timeInSeconds;
19968 + } else {
19969 + /* return cache */
19970 + *count = globalADCount;
19972 + // that's it
19975 +int getAudioDeviceDescriptionByIndex(int index, AudioDeviceDescription* adDesc, int getNames) {
19976 + int count = MAX_AUDIO_DEVICES;
19977 + int ret = 0;
19979 + getAudioDevices(globalADPaths, &count);
19980 + if (index>=0 && index < count) {
19981 + ret = getAudioDeviceDescription(globalADPaths[index].path, adDesc, getNames);
19983 + return ret;
19986 +int getAudioDeviceDescription(char* path, AudioDeviceDescription* adDesc, int getNames) {
19987 + int fd;
19988 + int mixerMode;
19989 + int len;
19990 + audio_info_t info;
19991 + audio_device_t deviceInfo;
19993 + strncpy(adDesc->path, path, MAX_NAME_LENGTH);
19994 + adDesc->path[MAX_NAME_LENGTH] = 0;
19995 + strcpy(adDesc->pathctl, adDesc->path);
19996 + strcat(adDesc->pathctl, "ctl");
19997 + strcpy(adDesc->name, adDesc->path);
19998 + adDesc->vendor[0] = 0;
19999 + adDesc->version[0] = 0;
20000 + adDesc->description[0] = 0;
20001 + adDesc->maxSimulLines = 1;
20003 + // try to open the pseudo device and get more information
20004 + fd = open(adDesc->pathctl, O_WRONLY | O_NONBLOCK);
20005 + if (fd >= 0) {
20006 + close(fd);
20007 + if (getNames) {
20008 + fd = open(adDesc->pathctl, O_RDONLY);
20009 + if (fd >= 0) {
20010 + if (ioctl(fd, AUDIO_GETDEV, &deviceInfo) >= 0) {
20011 + strncpy(adDesc->vendor, deviceInfo.name, MAX_AUDIO_DEV_LEN);
20012 + adDesc->vendor[MAX_AUDIO_DEV_LEN] = 0;
20013 + strncpy(adDesc->version, deviceInfo.version, MAX_AUDIO_DEV_LEN);
20014 + adDesc->version[MAX_AUDIO_DEV_LEN] = 0;
20015 + /* add config string to the dev name
20016 + * creates a string like "/dev/audio (onboard1)"
20017 + */
20018 + len = strlen(adDesc->name) + 1;
20019 + if (MAX_NAME_LENGTH - len > 3) {
20020 + strcat(adDesc->name, " (");
20021 + strncat(adDesc->name, deviceInfo.config, MAX_NAME_LENGTH - len);
20022 + strcat(adDesc->name, ")");
20024 + adDesc->name[MAX_NAME_LENGTH-1] = 0;
20026 + if (ioctl(fd, AUDIO_MIXERCTL_GET_MODE, &mixerMode) >= 0) {
20027 + if (mixerMode == AM_MIXER_MODE) {
20028 + TRACE1(" getAudioDeviceDescription: %s is in mixer mode\n", adDesc->path);
20029 + adDesc->maxSimulLines = -1;
20031 + } else {
20032 + ERROR1("ioctl AUDIO_MIXERCTL_GET_MODE failed on %s!\n", adDesc->path);
20034 + close(fd);
20035 + } else {
20036 + ERROR1("could not open %s!\n", adDesc->pathctl);
20039 + return 1;
20041 + return 0;
20043 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.h jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.h
20044 --- jdk-jdk-24-11.orig/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.h 1970-01-01 01:00:00.000000000 +0100
20045 +++ jdk-jdk-24-11/src/java.desktop/solaris/native/libjsound/PLATFORM_API_SolarisOS_Utils.h 2024-08-17 20:36:14.305338585 +0200
20046 @@ -0,0 +1,97 @@
20048 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
20049 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20051 + * This code is free software; you can redistribute it and/or modify it
20052 + * under the terms of the GNU General Public License version 2 only, as
20053 + * published by the Free Software Foundation. Oracle designates this
20054 + * particular file as subject to the "Classpath" exception as provided
20055 + * by Oracle in the LICENSE file that accompanied this code.
20057 + * This code is distributed in the hope that it will be useful, but WITHOUT
20058 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20059 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20060 + * version 2 for more details (a copy is included in the LICENSE file that
20061 + * accompanied this code).
20063 + * You should have received a copy of the GNU General Public License version
20064 + * 2 along with this work; if not, write to the Free Software Foundation,
20065 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20067 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20068 + * or visit www.oracle.com if you need additional information or have any
20069 + * questions.
20070 + */
20072 +#include <Utilities.h>
20073 +#include <string.h>
20074 +#include <stdlib.h>
20075 +#include <fcntl.h>
20076 +/* does not work on Solaris 2.7 */
20077 +#include <sys/audio.h>
20078 +#include <sys/mixer.h>
20079 +#include <sys/types.h>
20080 +#ifndef __linux__
20081 +#include <stropts.h>
20082 +#endif
20083 +#include <sys/conf.h>
20084 +#include <sys/stat.h>
20085 +#include <unistd.h>
20087 +#ifndef PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED
20088 +#define PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED
20090 +/* defines for Solaris 2.7
20091 + #ifndef AUDIO_AUX1_OUT
20092 + #define AUDIO_AUX1_OUT (0x08) // output to aux1 out
20093 + #define AUDIO_AUX2_OUT (0x10) // output to aux2 out
20094 + #define AUDIO_SPDIF_OUT (0x20) // output to SPDIF port
20095 + #define AUDIO_AUX1_IN (0x08) // input from aux1 in
20096 + #define AUDIO_AUX2_IN (0x10) // input from aux2 in
20097 + #define AUDIO_SPDIF_IN (0x20) // input from SPDIF port
20098 + #endif
20101 +/* input from Codec inter. loopback */
20102 +#ifndef AUDIO_CODEC_LOOPB_IN
20103 +#define AUDIO_CODEC_LOOPB_IN (0x40)
20104 +#endif
20107 +#define MAX_NAME_LENGTH 300
20109 +typedef struct tag_AudioDevicePath {
20110 + char path[MAX_NAME_LENGTH];
20111 + ino_t st_ino; // inode number to detect duplicate devices
20112 + dev_t st_dev; // device ID to detect duplicate audio devices
20113 +} AudioDevicePath;
20115 +typedef struct tag_AudioDeviceDescription {
20116 + INT32 maxSimulLines;
20117 + char path[MAX_NAME_LENGTH+1];
20118 + char pathctl[MAX_NAME_LENGTH+4];
20119 + char name[MAX_NAME_LENGTH+1];
20120 + char vendor[MAX_NAME_LENGTH+1];
20121 + char version[MAX_NAME_LENGTH+1];
20122 + char description[MAX_NAME_LENGTH+1];
20123 +} AudioDeviceDescription;
20125 +int getAudioDeviceCount();
20128 + * adPath is an array of AudioDevicePath structures
20129 + * count contains initially the number of elements in adPath
20130 + * and will be set to the returned number of paths.
20131 + */
20132 +void getAudioDevices(AudioDevicePath* adPath, int* count);
20135 + * fills adDesc from the audio device given in path
20136 + * returns 0 if an error occurred
20137 + * if getNames is 0, only path and pathctl are filled
20138 + */
20139 +int getAudioDeviceDescription(char* path, AudioDeviceDescription* adDesc, int getNames);
20140 +int getAudioDeviceDescriptionByIndex(int index, AudioDeviceDescription* adDesc, int getNames);
20143 +#endif // PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED
20144 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/awt/X11FontManager.java jdk-jdk-24-11/src/java.desktop/unix/classes/sun/awt/X11FontManager.java
20145 --- jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/awt/X11FontManager.java 2024-08-15 09:39:31.000000000 +0200
20146 +++ jdk-jdk-24-11/src/java.desktop/unix/classes/sun/awt/X11FontManager.java 2024-08-17 20:36:14.261566915 +0200
20147 @@ -686,7 +686,8 @@
20148 * and do the best we can.
20150 FontConfiguration mFontConfig = new MFontConfiguration(this);
20151 - if ((FontUtilities.isLinux && !mFontConfig.foundOsSpecificFile())) {
20152 + if ((FontUtilities.isLinux && !mFontConfig.foundOsSpecificFile()) ||
20153 + (FontUtilities.isSolaris && !mFontConfig.fontFilesArePresent())) {
20154 FcFontConfiguration fcFontConfig =
20155 new FcFontConfiguration(this);
20156 if (fcFontConfig.init()) {
20157 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/font/MFontConfiguration.java jdk-jdk-24-11/src/java.desktop/unix/classes/sun/font/MFontConfiguration.java
20158 --- jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/font/MFontConfiguration.java 2024-08-15 09:39:31.000000000 +0200
20159 +++ jdk-jdk-24-11/src/java.desktop/unix/classes/sun/font/MFontConfiguration.java 2024-08-17 20:36:14.262143848 +0200
20160 @@ -68,7 +68,59 @@
20162 protected void initReorderMap() {
20163 reorderMap = new HashMap<>();
20164 + if (osName == null) { /* null means SunOS */
20165 + initReorderMapForSolaris();
20166 + } else {
20167 + initReorderMapForLinux();
20171 + private void initReorderMapForSolaris() {
20172 + /* Don't create a no-op entry, so we can optimize this case
20173 + * i.e. we don't need to do anything so can avoid slower paths in
20174 + * the code.
20175 + */
20176 +// reorderMap.put("UTF-8", "latin-1");
20177 + reorderMap.put("UTF-8.hi", "devanagari"); // NB is in Lucida.
20178 + reorderMap.put("UTF-8.ja",
20179 + new String[] {"japanese-x0201", "japanese-x0208", "japanese-x0212"});
20180 + reorderMap.put("UTF-8.ko", "korean-johab");
20181 + reorderMap.put("UTF-8.th", "thai");
20182 + reorderMap.put("UTF-8.zh.TW", "chinese-big5");
20183 + reorderMap.put("UTF-8.zh.HK", new String[] {"chinese-big5", "chinese-hkscs"});
20184 + reorderMap.put("UTF-8.zh.CN",
20185 + new String[] {"chinese-gb18030-0", "chinese-gb18030-1"});
20186 + reorderMap.put("UTF-8.zh",
20187 + new String[] {"chinese-big5", "chinese-hkscs", "chinese-gb18030-0,chinese-gb18030-1"});
20188 + reorderMap.put("Big5", "chinese-big5");
20189 + reorderMap.put("Big5-HKSCS", new String[] {"chinese-big5", "chinese-hkscs"});
20190 + reorderMap.put("GB2312", new String[] {"chinese-gbk", "chinese-gb2312"});
20191 + reorderMap.put("x-EUC-TW",
20192 + new String[] {"chinese-cns11643-1", "chinese-cns11643-2", "chinese-cns11643-3"});
20193 + reorderMap.put("GBK", "chinese-gbk");
20194 + reorderMap.put("GB18030",new String[] {"chinese-gb18030-0", "chinese-gb18030-1"});
20196 + reorderMap.put("TIS-620", "thai");
20197 + reorderMap.put("x-PCK",
20198 + new String[] {"japanese-x0201", "japanese-x0208", "japanese-x0212"});
20199 + reorderMap.put("x-eucJP-Open",
20200 + new String[] {"japanese-x0201", "japanese-x0208", "japanese-x0212"});
20201 + reorderMap.put("EUC-KR", "korean");
20202 + /* Don't create a no-op entry, so we can optimize this case */
20203 +// reorderMap.put("ISO-8859-1", "latin-1");
20204 + reorderMap.put("ISO-8859-2", "latin-2");
20205 + reorderMap.put("ISO-8859-5", "cyrillic-iso8859-5");
20206 + reorderMap.put("windows-1251", "cyrillic-cp1251");
20207 + reorderMap.put("KOI8-R", "cyrillic-koi8-r");
20208 + reorderMap.put("ISO-8859-6", "arabic");
20209 + reorderMap.put("ISO-8859-7", "greek");
20210 + reorderMap.put("ISO-8859-8", "hebrew");
20211 + reorderMap.put("ISO-8859-9", "latin-5");
20212 + reorderMap.put("ISO-8859-13", "latin-7");
20213 + reorderMap.put("ISO-8859-15", "latin-9");
20216 + private void initReorderMapForLinux() {
20217 reorderMap.put("UTF-8.ja.JP", "japanese-iso10646");
20218 reorderMap.put("UTF-8.ko.KR", "korean-iso10646");
20219 reorderMap.put("UTF-8.zh.TW", "chinese-tw-iso10646");
20220 @@ -78,7 +130,12 @@
20221 reorderMap.put("GB2312", "chinese-gb18030");
20222 reorderMap.put("Big5", "chinese-big5");
20223 reorderMap.put("EUC-KR", "korean");
20224 - reorderMap.put("GB18030", "chinese-gb18030");
20225 + if (osName.equals("Sun")){
20226 + reorderMap.put("GB18030", "chinese-cn-iso10646");
20228 + else {
20229 + reorderMap.put("GB18030", "chinese-gb18030");
20234 @@ -87,7 +144,10 @@
20235 protected void setOsNameAndVersion(){
20236 super.setOsNameAndVersion();
20238 - if (osName.equals("Linux")) {
20239 + if (osName.equals("SunOS")) {
20240 + //don't care os name on Solaris
20241 + osName = null;
20242 + } else if (osName.equals("Linux")) {
20243 try {
20244 File f;
20245 if ((f = new File("/etc/fedora-release")).canRead()) {
20246 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
20247 --- jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java 2024-08-15 09:39:31.000000000 +0200
20248 +++ jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java 2024-08-17 20:36:14.262895147 +0200
20249 @@ -150,6 +150,10 @@
20250 return OSInfo.getOSType() == OSInfo.OSType.MACOSX;
20253 + static boolean isSysV() {
20254 + return OSInfo.getOSType() == OSInfo.OSType.SOLARIS;
20257 static boolean isLinux() {
20258 return OSInfo.getOSType() == OSInfo.OSType.LINUX;
20260 @@ -301,7 +305,7 @@
20263 } else {
20264 - if (isMac()) {
20265 + if (isMac() || isSysV()) {
20266 printers = getAllPrinterNamesSysV();
20267 } else if (isAIX()) {
20268 printers = getAllPrinterNamesAIX();
20269 @@ -485,7 +489,7 @@
20271 /* fallback if nothing not having a printer at this point */
20272 PrintService printer = null;
20273 - if (isMac()) {
20274 + if (isMac() || isSysV()) {
20275 printer = getNamedPrinterNameSysV(name);
20276 } else if (isAIX()) {
20277 printer = getNamedPrinterNameAIX(name);
20278 @@ -656,7 +660,7 @@
20279 psuri = printerInfo[1];
20281 } else {
20282 - if (isMac()) {
20283 + if (isMac() || isSysV()) {
20284 defaultPrinter = getDefaultPrinterNameSysV();
20285 } else if (isAIX()) {
20286 defaultPrinter = getDefaultPrinterNameAIX();
20287 @@ -876,7 +880,7 @@
20288 ArrayList<String> results = null;
20289 try {
20290 final String[] cmd = new String[3];
20291 - if (isAIX()) {
20292 + if (isSysV() || isAIX()) {
20293 cmd[0] = "/usr/bin/sh";
20294 cmd[1] = "-c";
20295 cmd[2] = "env LC_ALL=C " + command;
20296 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java
20297 --- jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java 2024-08-15 09:39:31.000000000 +0200
20298 +++ jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java 2024-08-17 20:36:14.263477253 +0200
20299 @@ -872,25 +872,51 @@
20300 isAttributeCategorySupported(JobSheets.class)) {
20301 ncomps+=1;
20303 - execCmd = new String[ncomps];
20304 - execCmd[n++] = "/usr/bin/lpr";
20305 - if ((pFlags & PRINTER) != 0) {
20306 - execCmd[n++] = "-P" + printer;
20308 - if ((pFlags & JOBTITLE) != 0) {
20309 - execCmd[n++] = "-J " + jobTitle;
20311 - if ((pFlags & COPIES) != 0) {
20312 - execCmd[n++] = "-#" + copies;
20314 - if ((pFlags & NOSHEET) != 0) {
20315 - execCmd[n++] = "-h";
20316 - } else if (getPrintService().
20317 - isAttributeCategorySupported(JobSheets.class)) {
20318 - execCmd[n++] = "-o job-sheets=standard";
20320 - if ((pFlags & OPTIONS) != 0) {
20321 - execCmd[n++] = "-o" + options;
20322 + if (PrintServiceLookupProvider.isSysV()) {
20323 + ncomps+=1; // lp uses 1 more arg than lpr (make a copy)
20324 + execCmd = new String[ncomps];
20325 + execCmd[n++] = "/usr/bin/lp";
20326 + execCmd[n++] = "-c"; // make a copy of the spool file
20327 + if ((pFlags & PRINTER) != 0) {
20328 + execCmd[n++] = "-d" + printer;
20330 + if ((pFlags & JOBTITLE) != 0) {
20331 + String quoteChar = "\"";
20332 + execCmd[n++] = "-t " + quoteChar+jobTitle+quoteChar;
20334 + if ((pFlags & COPIES) != 0) {
20335 + execCmd[n++] = "-n " + copies;
20337 + if ((pFlags & NOSHEET) != 0) {
20338 + execCmd[n++] = "-o nobanner";
20339 + } else if (getPrintService().
20340 + isAttributeCategorySupported(JobSheets.class)) {
20341 + execCmd[n++] = "-o job-sheets=standard";
20343 + if ((pFlags & OPTIONS) != 0) {
20344 + execCmd[n++] = "-o " + options;
20346 + } else {
20347 + execCmd = new String[ncomps];
20348 + execCmd[n++] = "/usr/bin/lpr";
20349 + if ((pFlags & PRINTER) != 0) {
20350 + execCmd[n++] = "-P" + printer;
20352 + if ((pFlags & JOBTITLE) != 0) {
20353 + execCmd[n++] = "-J " + jobTitle;
20355 + if ((pFlags & COPIES) != 0) {
20356 + execCmd[n++] = "-#" + copies;
20358 + if ((pFlags & NOSHEET) != 0) {
20359 + execCmd[n++] = "-h";
20360 + } else if (getPrintService().
20361 + isAttributeCategorySupported(JobSheets.class)) {
20362 + execCmd[n++] = "-o job-sheets=standard";
20364 + if ((pFlags & OPTIONS) != 0) {
20365 + execCmd[n++] = "-o" + options;
20368 execCmd[n++] = spoolFile;
20369 if (IPPPrintService.debugPrint) {
20370 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/UnixPrintService.java jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/UnixPrintService.java
20371 --- jdk-jdk-24-11.orig/src/java.desktop/unix/classes/sun/print/UnixPrintService.java 2024-08-15 09:39:31.000000000 +0200
20372 +++ jdk-jdk-24-11/src/java.desktop/unix/classes/sun/print/UnixPrintService.java 2024-08-17 20:36:14.264800536 +0200
20373 @@ -220,6 +220,31 @@
20374 return name;
20377 + private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsSysV() {
20378 + String command = "/usr/bin/lpstat -a " + printer;
20379 + String[] results= PrintServiceLookupProvider.execCmd(command);
20381 + if (results != null && results.length > 0) {
20382 + if (results[0].startsWith(printer + " accepting requests")) {
20383 + return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
20385 + else if (results[0].startsWith(printer)) {
20386 + /* As well as "myprinter accepting requests", look for
20387 + * "myprinter@somehost accepting requests".
20388 + */
20389 + int index = printer.length();
20390 + String str = results[0];
20391 + if (str.length() > index &&
20392 + str.charAt(index) == '@' &&
20393 + str.indexOf(" accepting requests", index) > 0 &&
20394 + str.indexOf(" not accepting requests", index) == -1) {
20395 + return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
20399 + return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS ;
20402 private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsBSD() {
20403 if (PrintServiceLookupProvider.cmdIndex ==
20404 PrintServiceLookupProvider.UNINITIALIZED) {
20405 @@ -297,7 +322,9 @@
20408 private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
20409 - if (PrintServiceLookupProvider.isBSD()) {
20410 + if (PrintServiceLookupProvider.isSysV()) {
20411 + return getPrinterIsAcceptingJobsSysV();
20412 + } else if (PrintServiceLookupProvider.isBSD()) {
20413 return getPrinterIsAcceptingJobsBSD();
20414 } else if (PrintServiceLookupProvider.isAIX()) {
20415 return getPrinterIsAcceptingJobsAIX();
20416 @@ -324,6 +351,14 @@
20420 + private QueuedJobCount getQueuedJobCountSysV() {
20421 + String command = "/usr/bin/lpstat -R " + printer;
20422 + String[] results= PrintServiceLookupProvider.execCmd(command);
20423 + int qlen = (results == null) ? 0 : results.length;
20425 + return new QueuedJobCount(qlen);
20428 private QueuedJobCount getQueuedJobCountBSD() {
20429 if (PrintServiceLookupProvider.cmdIndex ==
20430 PrintServiceLookupProvider.UNINITIALIZED) {
20431 @@ -380,7 +415,9 @@
20434 private QueuedJobCount getQueuedJobCount() {
20435 - if (PrintServiceLookupProvider.isBSD()) {
20436 + if (PrintServiceLookupProvider.isSysV()) {
20437 + return getQueuedJobCountSysV();
20438 + } else if (PrintServiceLookupProvider.isBSD()) {
20439 return getQueuedJobCountBSD();
20440 } else if (PrintServiceLookupProvider.isAIX()) {
20441 return getQueuedJobCountAIX();
20442 @@ -389,6 +426,13 @@
20446 + private PrintServiceAttributeSet getSysVServiceAttributes() {
20447 + PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
20448 + attrs.add(getQueuedJobCountSysV());
20449 + attrs.add(getPrinterIsAcceptingJobsSysV());
20450 + return attrs;
20453 private PrintServiceAttributeSet getBSDServiceAttributes() {
20454 PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
20455 attrs.add(getQueuedJobCountBSD());
20456 @@ -427,7 +471,9 @@
20459 private PrintServiceAttributeSet getDynamicAttributes() {
20460 - if (PrintServiceLookupProvider.isAIX()) {
20461 + if (PrintServiceLookupProvider.isSysV()) {
20462 + return getSysVServiceAttributes();
20463 + } else if (PrintServiceLookupProvider.isAIX()) {
20464 return getAIXServiceAttributes();
20465 } else {
20466 return getBSDServiceAttributes();
20467 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/native/common/awt/fontpath.c jdk-jdk-24-11/src/java.desktop/unix/native/common/awt/fontpath.c
20468 --- jdk-jdk-24-11.orig/src/java.desktop/unix/native/common/awt/fontpath.c 2024-08-15 09:39:31.000000000 +0200
20469 +++ jdk-jdk-24-11/src/java.desktop/unix/native/common/awt/fontpath.c 2024-08-17 20:36:14.265635933 +0200
20470 @@ -57,7 +57,57 @@
20472 #define MAXFDIRS 512 /* Max number of directories that contain fonts */
20474 -#if defined( __linux__)
20475 +#if defined(__solaris__)
20477 + * This can be set in the makefile to "/usr/X11" if so desired.
20478 + */
20479 +#ifndef OPENWINHOMELIB
20480 +#define OPENWINHOMELIB "/usr/openwin/lib/"
20481 +#endif
20483 +/* This is all known Solaris X11 directories on Solaris 8, 9 and 10.
20484 + * It is ordered to give precedence to TrueType directories.
20485 + * It is needed if fontconfig is not installed or configured properly.
20486 + */
20487 +static char *fullSolarisFontPath[] = {
20488 + OPENWINHOMELIB "X11/fonts/TrueType",
20489 + OPENWINHOMELIB "locale/euro_fonts/X11/fonts/TrueType",
20490 + OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/TrueType",
20491 + OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/TrueType",
20492 + OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/TrueType",
20493 + OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/TrueType",
20494 + OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/TrueType",
20495 + OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/TrueType",
20496 + OPENWINHOMELIB "locale/iso_8859_15/X11/fonts/TrueType",
20497 + OPENWINHOMELIB "locale/ar/X11/fonts/TrueType",
20498 + OPENWINHOMELIB "locale/hi_IN.UTF-8/X11/fonts/TrueType",
20499 + OPENWINHOMELIB "locale/ja/X11/fonts/TT",
20500 + OPENWINHOMELIB "locale/ko/X11/fonts/TrueType",
20501 + OPENWINHOMELIB "locale/ko.UTF-8/X11/fonts/TrueType",
20502 + OPENWINHOMELIB "locale/KOI8-R/X11/fonts/TrueType",
20503 + OPENWINHOMELIB "locale/ru.ansi-1251/X11/fonts/TrueType",
20504 + OPENWINHOMELIB "locale/th_TH/X11/fonts/TrueType",
20505 + OPENWINHOMELIB "locale/zh_TW/X11/fonts/TrueType",
20506 + OPENWINHOMELIB "locale/zh_TW.BIG5/X11/fonts/TT",
20507 + OPENWINHOMELIB "locale/zh_HK.BIG5HK/X11/fonts/TT",
20508 + OPENWINHOMELIB "locale/zh_CN.GB18030/X11/fonts/TrueType",
20509 + OPENWINHOMELIB "locale/zh/X11/fonts/TrueType",
20510 + OPENWINHOMELIB "locale/zh.GBK/X11/fonts/TrueType",
20511 + OPENWINHOMELIB "X11/fonts/Type1",
20512 + OPENWINHOMELIB "X11/fonts/Type1/sun",
20513 + OPENWINHOMELIB "X11/fonts/Type1/sun/outline",
20514 + OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/Type1",
20515 + OPENWINHOMELIB "locale/iso_8859_4/X11/fonts/Type1",
20516 + OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/Type1",
20517 + OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/Type1",
20518 + OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/Type1",
20519 + OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/Type1",
20520 + OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
20521 + OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
20522 + NULL, /* terminates the list */
20525 +#elif defined( __linux__)
20526 /* All the known interesting locations we have discovered on
20527 * various flavors of Linux
20529 @@ -173,6 +223,14 @@
20530 if (strstr(x11Path[i], ".gnome") != NULL) {
20531 continue;
20533 +#ifdef __solaris__
20534 + if (strstr(x11Path[i], "/F3/") != NULL) {
20535 + continue;
20537 + if (strstr(x11Path[i], "bitmap") != NULL) {
20538 + continue;
20540 +#endif
20541 fontdirs[pos] = strdup(x11Path[i]);
20542 slen = strlen(fontdirs[pos]);
20543 if (slen > 0 && fontdirs[pos][slen-1] == '/') {
20544 @@ -322,6 +380,8 @@
20546 #if defined(__linux__)
20547 knowndirs = fullLinuxFontPath;
20548 +#elif defined(__solaris__)
20549 + knowndirs = fullSolarisFontPath;
20550 #elif defined(_AIX)
20551 knowndirs = fullAixFontPath;
20552 #endif
20553 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c jdk-jdk-24-11/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c
20554 --- jdk-jdk-24-11.orig/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c 2024-08-15 09:39:31.000000000 +0200
20555 +++ jdk-jdk-24-11/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c 2024-08-17 20:36:14.266453082 +0200
20556 @@ -402,7 +402,12 @@
20557 xrenderLibHandle = dlopen("libXrender.so", RTLD_LAZY | RTLD_GLOBAL);
20560 -#if defined(_AIX)
20561 +#if defined(__solaris__)
20562 + if (xrenderLibHandle == NULL) {
20563 + xrenderLibHandle = dlopen("libXrender.so.1",
20564 + RTLD_LAZY | RTLD_GLOBAL);
20566 +#elif defined(_AIX)
20567 if (xrenderLibHandle == NULL) {
20568 xrenderLibHandle = dlopen("libXrender.a(libXrender.so.0)",
20569 RTLD_MEMBER | RTLD_LAZY | RTLD_GLOBAL);
20570 diff -Nru jdk-jdk-24-11.orig/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c jdk-jdk-24-11/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c
20571 --- jdk-jdk-24-11.orig/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c 2024-08-15 09:39:31.000000000 +0200
20572 +++ jdk-jdk-24-11/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c 2024-08-17 20:36:14.267252334 +0200
20573 @@ -61,6 +61,29 @@
20575 #include <dlfcn.h>
20577 +#if defined(__solaris__)
20578 +/* Solaris 10 will not have these symbols at compile time */
20580 +typedef Picture (*XRenderCreateLinearGradientFuncType)
20581 + (Display *dpy,
20582 + const XLinearGradient *gradient,
20583 + const XFixed *stops,
20584 + const XRenderColor *colors,
20585 + int nstops);
20587 +typedef Picture (*XRenderCreateRadialGradientFuncType)
20588 + (Display *dpy,
20589 + const XRadialGradient *gradient,
20590 + const XFixed *stops,
20591 + const XRenderColor *colors,
20592 + int nstops);
20594 +static
20595 +XRenderCreateLinearGradientFuncType XRenderCreateLinearGradientFunc = NULL;
20596 +static
20597 + XRenderCreateRadialGradientFuncType XRenderCreateRadialGradientFunc = NULL;
20598 +#endif
20600 #define BUILD_TRANSFORM_MATRIX(TRANSFORM, M00, M01, M02, M10, M11, M12) \
20602 TRANSFORM.matrix[0][0] = M00; \
20603 @@ -128,6 +151,27 @@
20604 } else {
20605 available = JNI_FALSE;
20607 +#elif defined(__solaris__)
20608 + xrenderlib = dlopen("libXrender.so",RTLD_GLOBAL|RTLD_LAZY);
20609 + if (xrenderlib != NULL) {
20611 + XRenderCreateLinearGradientFunc =
20612 + (XRenderCreateLinearGradientFuncType)
20613 + dlsym(xrenderlib, "XRenderCreateLinearGradient");
20615 + XRenderCreateRadialGradientFunc =
20616 + (XRenderCreateRadialGradientFuncType)
20617 + dlsym(xrenderlib, "XRenderCreateRadialGradient");
20619 + if (XRenderCreateLinearGradientFunc == NULL ||
20620 + XRenderCreateRadialGradientFunc == NULL)
20622 + available = JNI_FALSE;
20624 + dlclose(xrenderlib);
20625 + } else {
20626 + available = JNI_FALSE;
20628 #else
20629 Dl_info info;
20630 jboolean versionInfoIsFound = JNI_FALSE;
20631 @@ -534,7 +578,13 @@
20632 colors[i].green = pixels[i*4 + 2];
20633 colors[i].blue = pixels[i*4 + 3];
20635 +#ifdef __solaris__
20636 + if (XRenderCreateLinearGradientFunc!=NULL) {
20637 + gradient = (*XRenderCreateLinearGradientFunc)(awt_display, &grad, stops, colors, numStops);
20639 +#else
20640 gradient = XRenderCreateLinearGradient(awt_display, &grad, stops, colors, numStops);
20641 +#endif
20642 free(colors);
20643 free(stops);
20645 @@ -612,7 +662,13 @@
20646 colors[i].green = pixels[i*4 + 2];
20647 colors[i].blue = pixels[i*4 + 3];
20649 +#ifdef __solaris__
20650 + if (XRenderCreateRadialGradientFunc != NULL) {
20651 + gradient = (jint) (*XRenderCreateRadialGradientFunc)(awt_display, &grad, stops, colors, numStops);
20653 +#else
20654 gradient = (jint) XRenderCreateRadialGradient(awt_display, &grad, stops, colors, numStops);
20655 +#endif
20656 free(colors);
20657 free(stops);
20659 diff -Nru jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java
20660 --- jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java 2024-08-15 09:39:31.000000000 +0200
20661 +++ jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java 2024-08-17 20:36:14.267849062 +0200
20662 @@ -91,6 +91,9 @@
20663 = System.getProperty("sun.security.jgss.lib");
20664 if (defaultLib == null || defaultLib.trim().equals("")) {
20665 gssLibs = switch (OperatingSystem.current()) {
20666 + case SOLARIS -> new String[]{
20667 + "libgss.so",
20668 + };
20669 case LINUX -> new String[]{
20670 "libgssapi.so",
20671 "libgssapi_krb5.so",
20672 diff -Nru jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/krb5/Config.java jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/krb5/Config.java
20673 --- jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/krb5/Config.java 2024-08-15 09:39:31.000000000 +0200
20674 +++ jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/krb5/Config.java 2024-08-17 20:36:14.268528302 +0200
20675 @@ -930,6 +930,8 @@
20676 if (name == null) {
20677 name = "c:\\winnt\\krb5.ini";
20679 + } else if (OperatingSystem.isSolaris()) {
20680 + name = "/etc/krb5/krb5.conf";
20681 } else if (OperatingSystem.isMacOS()) {
20682 name = findMacosConfigFile();
20683 } else {
20684 diff -Nru jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java
20685 --- jdk-jdk-24-11.orig/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java 2024-08-15 09:39:31.000000000 +0200
20686 +++ jdk-jdk-24-11/src/java.security.jgss/share/classes/sun/security/krb5/internal/rcache/DflCache.java 2024-08-17 20:36:14.269052538 +0200
20687 @@ -107,7 +107,7 @@
20689 private static long uid;
20690 static {
20691 - // Available on Linux and Mac. Otherwise, -1 and no _euid suffix
20692 + // Available on Solaris, Linux and Mac. Otherwise, -1 and no _euid suffix
20693 uid = jdk.internal.misc.VM.geteuid();
20696 diff -Nru jdk-jdk-24-11.orig/src/java.smartcardio/unix/classes/sun/security/smartcardio/PlatformPCSC.java jdk-jdk-24-11/src/java.smartcardio/unix/classes/sun/security/smartcardio/PlatformPCSC.java
20697 --- jdk-jdk-24-11.orig/src/java.smartcardio/unix/classes/sun/security/smartcardio/PlatformPCSC.java 2024-08-15 09:39:31.000000000 +0200
20698 +++ jdk-jdk-24-11/src/java.smartcardio/unix/classes/sun/security/smartcardio/PlatformPCSC.java 2024-08-17 20:36:14.269549505 +0200
20699 @@ -86,8 +86,12 @@
20700 if (k != -1) {
20701 String libDir;
20702 if ("64".equals(System.getProperty("sun.arch.data.model"))) {
20703 - // assume Linux convention
20704 - libDir = "lib64";
20705 + if ("SunOS".equals(System.getProperty("os.name"))) {
20706 + libDir = "lib/64";
20707 + } else {
20708 + // assume Linux convention
20709 + libDir = "lib64";
20711 } else {
20712 // must be 32-bit
20713 libDir = "lib";
20714 diff -Nru jdk-jdk-24-11.orig/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java jdk-jdk-24-11/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java
20715 --- jdk-jdk-24-11.orig/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java 2024-08-15 09:39:31.000000000 +0200
20716 +++ jdk-jdk-24-11/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/output/WriterOutputBuffer.java 2024-08-17 20:36:14.270154343 +0200
20717 @@ -33,12 +33,21 @@
20718 private static final int KB = 1024;
20719 private static int BUFFER_SIZE = 4 * KB;
20721 + static {
20722 + // Set a larger buffer size for Solaris
20723 + final String osName = SecuritySupport.getSystemProperty("os.name");
20724 + if (osName.equalsIgnoreCase("solaris")) {
20725 + BUFFER_SIZE = 32 * KB;
20729 private Writer _writer;
20732 * Initializes a WriterOutputBuffer by creating an instance of a
20733 * BufferedWriter. The size of the buffer in this writer may have
20734 - * a significant impact on throughput.
20735 + * a significant impact on throughput. Solaris prefers a larger
20736 + * buffer, while Linux works better with a smaller one.
20738 public WriterOutputBuffer(Writer writer) {
20739 _writer = new BufferedWriter(writer, BUFFER_SIZE);
20740 diff -Nru jdk-jdk-24-11.orig/src/jdk.attach/solaris/classes/sun/tools/attach/AttachProviderImpl.java jdk-jdk-24-11/src/jdk.attach/solaris/classes/sun/tools/attach/AttachProviderImpl.java
20741 --- jdk-jdk-24-11.orig/src/jdk.attach/solaris/classes/sun/tools/attach/AttachProviderImpl.java 1970-01-01 01:00:00.000000000 +0100
20742 +++ jdk-jdk-24-11/src/jdk.attach/solaris/classes/sun/tools/attach/AttachProviderImpl.java 2024-08-17 20:36:14.305902647 +0200
20743 @@ -0,0 +1,79 @@
20745 + * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
20746 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20748 + * This code is free software; you can redistribute it and/or modify it
20749 + * under the terms of the GNU General Public License version 2 only, as
20750 + * published by the Free Software Foundation. Oracle designates this
20751 + * particular file as subject to the "Classpath" exception as provided
20752 + * by Oracle in the LICENSE file that accompanied this code.
20754 + * This code is distributed in the hope that it will be useful, but WITHOUT
20755 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20756 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20757 + * version 2 for more details (a copy is included in the LICENSE file that
20758 + * accompanied this code).
20760 + * You should have received a copy of the GNU General Public License version
20761 + * 2 along with this work; if not, write to the Free Software Foundation,
20762 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20764 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20765 + * or visit www.oracle.com if you need additional information or have any
20766 + * questions.
20767 + */
20768 +package sun.tools.attach;
20770 +import com.sun.tools.attach.VirtualMachine;
20771 +import com.sun.tools.attach.VirtualMachineDescriptor;
20772 +import com.sun.tools.attach.AttachNotSupportedException;
20773 +import java.io.IOException;
20776 + * An AttachProvider implementation for Solaris that use the doors
20777 + * interface to the VM.
20778 + */
20779 +public class AttachProviderImpl extends HotSpotAttachProvider {
20781 + public AttachProviderImpl() {
20784 + public String name() {
20785 + return "sun";
20788 + public String type() {
20789 + return "doors";
20792 + public VirtualMachine attachVirtualMachine(String vmid)
20793 + throws AttachNotSupportedException, IOException
20795 + checkAttachPermission();
20797 + // AttachNotSupportedException will be thrown if the target VM can be determined
20798 + // to be not attachable.
20799 + testAttachable(vmid);
20801 + return new VirtualMachineImpl(this, vmid);
20804 + public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd)
20805 + throws AttachNotSupportedException, IOException
20807 + if (vmd.provider() != this) {
20808 + throw new AttachNotSupportedException("provider mismatch");
20810 + // To avoid re-checking if the VM if attachable, we check if the descriptor
20811 + // is for a hotspot VM - these descriptors are created by the listVirtualMachines
20812 + // implementation which only returns a list of attachable VMs.
20813 + if (vmd instanceof HotSpotVirtualMachineDescriptor) {
20814 + assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable();
20815 + checkAttachPermission();
20816 + return new VirtualMachineImpl(this, vmd.id());
20817 + } else {
20818 + return attachVirtualMachine(vmd.id());
20823 diff -Nru jdk-jdk-24-11.orig/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java jdk-jdk-24-11/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java
20824 --- jdk-jdk-24-11.orig/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java 1970-01-01 01:00:00.000000000 +0100
20825 +++ jdk-jdk-24-11/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java 2024-08-17 20:36:14.306253283 +0200
20826 @@ -0,0 +1,272 @@
20828 + * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
20829 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20831 + * This code is free software; you can redistribute it and/or modify it
20832 + * under the terms of the GNU General Public License version 2 only, as
20833 + * published by the Free Software Foundation. Oracle designates this
20834 + * particular file as subject to the "Classpath" exception as provided
20835 + * by Oracle in the LICENSE file that accompanied this code.
20837 + * This code is distributed in the hope that it will be useful, but WITHOUT
20838 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20839 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20840 + * version 2 for more details (a copy is included in the LICENSE file that
20841 + * accompanied this code).
20843 + * You should have received a copy of the GNU General Public License version
20844 + * 2 along with this work; if not, write to the Free Software Foundation,
20845 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20847 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20848 + * or visit www.oracle.com if you need additional information or have any
20849 + * questions.
20850 + */
20851 +package sun.tools.attach;
20853 +import com.sun.tools.attach.AttachOperationFailedException;
20854 +import com.sun.tools.attach.AgentLoadException;
20855 +import com.sun.tools.attach.AttachNotSupportedException;
20856 +import com.sun.tools.attach.spi.AttachProvider;
20858 +import java.io.InputStream;
20859 +import java.io.IOException;
20860 +import java.io.File;
20861 +import java.io.FileNotFoundException;
20864 + * Solaris implementation of HotSpotVirtualMachine.
20865 + */
20866 +public class VirtualMachineImpl extends HotSpotVirtualMachine {
20867 + // "/tmp" is used as a global well-known location for the files
20868 + // .java_pid<pid>. and .attach_pid<pid>. It is important that this
20869 + // location is the same for all processes, otherwise the tools
20870 + // will not be able to find all Hotspot processes.
20871 + // Any changes to this needs to be synchronized with HotSpot.
20872 + private static final String tmpdir = "/tmp";
20874 + // door descriptor;
20875 + private int fd = -1;
20876 + String socket_path;
20878 + /**
20879 + * Attaches to the target VM
20880 + */
20881 + VirtualMachineImpl(AttachProvider provider, String vmid)
20882 + throws AttachNotSupportedException, IOException
20884 + super(provider, vmid);
20885 + // This provider only understands process-ids (pids).
20886 + int pid;
20887 + try {
20888 + pid = Integer.parseInt(vmid);
20889 + if (pid < 1) {
20890 + throw new NumberFormatException();
20892 + } catch (NumberFormatException x) {
20893 + throw new AttachNotSupportedException("Invalid process identifier: " + vmid);
20896 + // Opens the door file to the target VM. If the file is not
20897 + // found it might mean that the attach mechanism isn't started in the
20898 + // target VM so we attempt to start it and retry.
20899 + try {
20900 + fd = openDoor(pid);
20901 + } catch (FileNotFoundException fnf1) {
20902 + File f = createAttachFile(pid);
20903 + try {
20904 + sigquit(pid);
20906 + // give the target VM time to start the attach mechanism
20907 + final int delay_step = 100;
20908 + final long timeout = attachTimeout();
20909 + long time_spend = 0;
20910 + long delay = 0;
20911 + do {
20912 + // Increase timeout on each attempt to reduce polling
20913 + delay += delay_step;
20914 + try {
20915 + Thread.sleep(delay);
20916 + } catch (InterruptedException x) { }
20917 + try {
20918 + fd = openDoor(pid);
20919 + } catch (FileNotFoundException fnf2) {
20920 + // pass
20923 + time_spend += delay;
20924 + if (time_spend > timeout/2 && fd == -1) {
20925 + // Send QUIT again to give target VM the last chance to react
20926 + sigquit(pid);
20928 + } while (time_spend <= timeout && fd == -1);
20929 + if (fd == -1) {
20930 + throw new AttachNotSupportedException(
20931 + String.format("Unable to open door %s: " +
20932 + "target process %d doesn't respond within %dms " +
20933 + "or HotSpot VM not loaded", socket_path, pid, time_spend));
20935 + } finally {
20936 + f.delete();
20939 + assert fd >= 0;
20942 + /**
20943 + * Detach from the target VM
20944 + */
20945 + public void detach() throws IOException {
20946 + synchronized (this) {
20947 + if (fd != -1) {
20948 + close(fd);
20949 + fd = -1;
20954 + /**
20955 + * Execute the given command in the target VM.
20956 + */
20957 + InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {
20958 + assert args.length <= 3; // includes null
20960 + // first check that we are still attached
20961 + int door;
20962 + synchronized (this) {
20963 + if (fd == -1) {
20964 + throw new IOException("Detached from target VM");
20966 + door = fd;
20969 + // enqueue the command via a door call
20970 + int s = enqueue(door, cmd, args);
20971 + assert s >= 0; // valid file descriptor
20973 + // The door call returns a file descriptor (one end of a socket pair).
20974 + // Create an input stream around it.
20975 + SocketInputStream sis = new SocketInputStream(s);
20977 + // Read the command completion status
20978 + int completionStatus;
20979 + try {
20980 + completionStatus = readInt(sis);
20981 + } catch (IOException ioe) {
20982 + sis.close();
20983 + throw ioe;
20986 + // If non-0 it means an error but we need to special-case the
20987 + // "load" command to ensure that the right exception is thrown.
20988 + if (completionStatus != 0) {
20989 + // read from the stream and use that as the error message
20990 + String message = readErrorMessage(sis);
20991 + sis.close();
20992 + if (cmd.equals("load")) {
20993 + String msg = "Failed to load agent library";
20994 + if (!message.isEmpty())
20995 + msg += ": " + message;
20996 + throw new AgentLoadException(msg);
20997 + } else {
20998 + if (message.isEmpty())
20999 + message = "Command failed in target VM";
21000 + throw new AttachOperationFailedException(message);
21004 + // Return the input stream so that the command output can be read
21005 + return sis;
21008 + // InputStream over a socket
21009 + private class SocketInputStream extends InputStream {
21010 + int s;
21012 + public SocketInputStream(int s) {
21013 + this.s = s;
21016 + public synchronized int read() throws IOException {
21017 + byte b[] = new byte[1];
21018 + int n = this.read(b, 0, 1);
21019 + if (n == 1) {
21020 + return b[0] & 0xff;
21021 + } else {
21022 + return -1;
21026 + public synchronized int read(byte[] bs, int off, int len) throws IOException {
21027 + if ((off < 0) || (off > bs.length) || (len < 0) ||
21028 + ((off + len) > bs.length) || ((off + len) < 0)) {
21029 + throw new IndexOutOfBoundsException();
21030 + } else if (len == 0)
21031 + return 0;
21033 + return VirtualMachineImpl.read(s, bs, off, len);
21036 + public synchronized void close() throws IOException {
21037 + if (s != -1) {
21038 + int toClose = s;
21039 + s = -1;
21040 + VirtualMachineImpl.close(toClose);
21045 + // The door is attached to .java_pid<pid> in the temporary directory.
21046 + private int openDoor(int pid) throws IOException {
21047 + socket_path = tmpdir + "/.java_pid" + pid;
21048 + fd = open(socket_path);
21050 + // Check that the file owner/permission to avoid attaching to
21051 + // bogus process
21052 + try {
21053 + checkPermissions(socket_path);
21054 + } catch (IOException ioe) {
21055 + close(fd);
21056 + throw ioe;
21058 + return fd;
21061 + // On Solaris a simple handshake is used to start the attach mechanism
21062 + // if not already started. The client creates a .attach_pid<pid> file in the
21063 + // target VM's working directory (or temporary directory), and the SIGQUIT
21064 + // handler checks for the file.
21065 + private File createAttachFile(int pid) throws IOException {
21066 + String fn = ".attach_pid" + pid;
21067 + String path = "/proc/" + pid + "/cwd/" + fn;
21068 + File f = new File(path);
21069 + try {
21070 + f = f.getCanonicalFile();
21071 + f.createNewFile();
21072 + } catch (IOException x) {
21073 + f = new File(tmpdir, fn);
21074 + f.createNewFile();
21076 + return f;
21079 + //-- native methods
21081 + static native int open(String path) throws IOException;
21083 + static native void close(int fd) throws IOException;
21085 + static native int read(int fd, byte buf[], int off, int buflen) throws IOException;
21087 + static native void checkPermissions(String path) throws IOException;
21089 + static native void sigquit(int pid) throws IOException;
21091 + // enqueue a command (and arguments) to the given door
21092 + static native int enqueue(int fd, String cmd, Object ... args)
21093 + throws IOException;
21095 + static {
21096 + System.loadLibrary("attach");
21099 diff -Nru jdk-jdk-24-11.orig/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c jdk-jdk-24-11/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c
21100 --- jdk-jdk-24-11.orig/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c 1970-01-01 01:00:00.000000000 +0100
21101 +++ jdk-jdk-24-11/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c 2024-08-17 20:36:14.306775010 +0200
21102 @@ -0,0 +1,389 @@
21104 + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
21105 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21107 + * This code is free software; you can redistribute it and/or modify it
21108 + * under the terms of the GNU General Public License version 2 only, as
21109 + * published by the Free Software Foundation. Oracle designates this
21110 + * particular file as subject to the "Classpath" exception as provided
21111 + * by Oracle in the LICENSE file that accompanied this code.
21113 + * This code is distributed in the hope that it will be useful, but WITHOUT
21114 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21115 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21116 + * version 2 for more details (a copy is included in the LICENSE file that
21117 + * accompanied this code).
21119 + * You should have received a copy of the GNU General Public License version
21120 + * 2 along with this work; if not, write to the Free Software Foundation,
21121 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21123 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21124 + * or visit www.oracle.com if you need additional information or have any
21125 + * questions.
21126 + */
21128 +#include "jni_util.h"
21130 +#include <sys/stat.h>
21131 +#include <sys/types.h>
21132 +#include <door.h>
21133 +#include <errno.h>
21134 +#include <fcntl.h>
21135 +#include <limits.h>
21136 +#include <signal.h>
21137 +#include <stdlib.h>
21138 +#include <string.h>
21139 +#include <unistd.h>
21141 +#include "sun_tools_attach_VirtualMachineImpl.h"
21143 +#define ROOT_UID 0
21145 +#define RESTARTABLE(_cmd, _result) do { \
21146 + do { \
21147 + _result = _cmd; \
21148 + } while((_result == -1) && (errno == EINTR)); \
21149 +} while(0)
21152 + * Declare library specific JNI_Onload entry if static build
21153 + */
21154 +DEF_STATIC_JNI_OnLoad
21157 + * Class: sun_tools_attach_VirtualMachineImpl
21158 + * Method: open
21159 + * Signature: (Ljava/lang/String;)I
21160 + */
21161 +JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_open
21162 + (JNIEnv *env, jclass cls, jstring path)
21164 + jboolean isCopy;
21165 + const char* p = GetStringPlatformChars(env, path, &isCopy);
21166 + if (p == NULL) {
21167 + return 0;
21168 + } else {
21169 + int fd;
21170 + int err = 0;
21172 + fd = open(p, O_RDWR);
21173 + if (fd == -1) {
21174 + err = errno;
21177 + if (isCopy) {
21178 + JNU_ReleaseStringPlatformChars(env, path, p);
21181 + if (fd == -1) {
21182 + if (err == ENOENT) {
21183 + JNU_ThrowByName(env, "java/io/FileNotFoundException", NULL);
21184 + } else {
21185 + char* msg = strdup(strerror(err));
21186 + JNU_ThrowIOException(env, msg);
21187 + if (msg != NULL) {
21188 + free(msg);
21192 + return fd;
21197 + * Class: sun_tools_attach_VirtualMachineImpl
21198 + * Method: checkPermissions
21199 + * Signature: (Ljava/lang/String;)V
21200 + */
21201 +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
21202 + (JNIEnv *env, jclass cls, jstring path)
21204 + jboolean isCopy;
21205 + const char* p = GetStringPlatformChars(env, path, &isCopy);
21206 + if (p != NULL) {
21207 + struct stat64 sb;
21208 + uid_t uid, gid;
21209 + int res;
21211 + memset(&sb, 0, sizeof(struct stat64));
21213 + /*
21214 + * Check that the path is owned by the effective uid/gid of this
21215 + * process. Also check that group/other access is not allowed.
21216 + */
21217 + uid = geteuid();
21218 + gid = getegid();
21220 + res = stat64(p, &sb);
21221 + if (res != 0) {
21222 + /* save errno */
21223 + res = errno;
21226 + if (res == 0) {
21227 + char msg[100];
21228 + jboolean isError = JNI_FALSE;
21229 + if (sb.st_uid != uid && uid != ROOT_UID) {
21230 + snprintf(msg, sizeof(msg),
21231 + "file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
21232 + isError = JNI_TRUE;
21233 + } else if (sb.st_gid != gid && uid != ROOT_UID) {
21234 + snprintf(msg, sizeof(msg),
21235 + "file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
21236 + isError = JNI_TRUE;
21237 + } else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
21238 + snprintf(msg, sizeof(msg),
21239 + "file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
21240 + isError = JNI_TRUE;
21242 + if (isError) {
21243 + char buf[256];
21244 + snprintf(buf, sizeof(buf), "well-known file %s is not secure: %s", p, msg);
21245 + JNU_ThrowIOException(env, buf);
21247 + } else {
21248 + char* msg = strdup(strerror(res));
21249 + JNU_ThrowIOException(env, msg);
21250 + if (msg != NULL) {
21251 + free(msg);
21255 + if (isCopy) {
21256 + JNU_ReleaseStringPlatformChars(env, path, p);
21262 + * Class: sun_tools_attach_VirtualMachineImpl
21263 + * Method: close
21264 + * Signature: (I)V
21265 + */
21266 +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_close
21267 + (JNIEnv *env, jclass cls, jint fd)
21269 + int ret;
21270 + RESTARTABLE(close(fd), ret);
21274 + * Class: sun_tools_attach_VirtualMachineImpl
21275 + * Method: read
21276 + * Signature: (I[BI)I
21277 + */
21278 +JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_read
21279 + (JNIEnv *env, jclass cls, jint fd, jbyteArray ba, jint off, jint baLen)
21281 + unsigned char buf[128];
21282 + size_t len = sizeof(buf);
21283 + ssize_t n;
21285 + size_t remaining = (size_t)(baLen - off);
21286 + if (len > remaining) {
21287 + len = remaining;
21290 + RESTARTABLE(read(fd, buf, len), n);
21291 + if (n == -1) {
21292 + JNU_ThrowIOExceptionWithLastError(env, "read");
21293 + } else {
21294 + if (n == 0) {
21295 + n = -1; // EOF
21296 + } else {
21297 + (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf));
21300 + return n;
21304 + * Class: sun_tools_attach_VirtualMachineImpl
21305 + * Method: sigquit
21306 + * Signature: (I)V
21307 + */
21308 +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_sigquit
21309 + (JNIEnv *env, jclass cls, jint pid)
21311 + if (kill((pid_t)pid, SIGQUIT) == -1) {
21312 + JNU_ThrowIOExceptionWithLastError(env, "kill");
21317 + * A simple table to translate some known errors into reasonable
21318 + * error messages
21319 + */
21320 +static struct {
21321 + jint err;
21322 + const char* msg;
21323 +} const error_messages[] = {
21324 + { 100, "Bad request" },
21325 + { 101, "Protocol mismatch" },
21326 + { 102, "Resource failure" },
21327 + { 103, "Internal error" },
21328 + { 104, "Permission denied" },
21332 + * Lookup the given error code and return the appropriate
21333 + * message. If not found return NULL.
21334 + */
21335 +static const char* translate_error(jint err) {
21336 + int table_size = sizeof(error_messages) / sizeof(error_messages[0]);
21337 + int i;
21339 + for (i = 0; i < table_size; i++) {
21340 + if (err == error_messages[i].err) {
21341 + return error_messages[i].msg;
21344 + return NULL;
21348 + * Current protocol version
21349 + */
21350 +static const char* PROTOCOL_VERSION = "1";
21353 + * Class: sun_tools_attach_VirtualMachineImpl
21354 + * Method: enqueue
21355 + * Signature: (JILjava/lang/String;[Ljava/lang/Object;)V
21356 + */
21357 +JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue
21358 + (JNIEnv *env, jclass cls, jint fd, jstring cmd, jobjectArray args)
21360 + jint arg_count, i;
21361 + size_t size;
21362 + jboolean isCopy;
21363 + door_arg_t door_args;
21364 + char res_buffer[128];
21365 + jint result = -1;
21366 + int rc;
21367 + const char* cstr;
21368 + char* buf;
21370 + /*
21371 + * First we get the command string and create the start of the
21372 + * argument string to send to the target VM:
21373 + * <ver>\0<cmd>\0
21374 + */
21375 + cstr = JNU_GetStringPlatformChars(env, cmd, &isCopy);
21376 + if (cstr == NULL) {
21377 + return -1; /* pending exception */
21379 + size = strlen(PROTOCOL_VERSION) + strlen(cstr) + 2;
21380 + buf = (char*)malloc(size);
21381 + if (buf != NULL) {
21382 + char* pos = buf;
21383 + strcpy(buf, PROTOCOL_VERSION);
21384 + pos += strlen(PROTOCOL_VERSION)+1;
21385 + strcpy(pos, cstr);
21387 + if (isCopy) {
21388 + JNU_ReleaseStringPlatformChars(env, cmd, cstr);
21390 + if (buf == NULL) {
21391 + JNU_ThrowOutOfMemoryError(env, "malloc failed");
21392 + return -1;
21395 + /*
21396 + * Next we iterate over the arguments and extend the buffer
21397 + * to include them.
21398 + */
21399 + arg_count = (*env)->GetArrayLength(env, args);
21401 + for (i = 0; i < arg_count; i++) {
21402 + jobject obj = (*env)->GetObjectArrayElement(env, args, i);
21403 + if (obj != NULL) {
21404 + cstr = JNU_GetStringPlatformChars(env, obj, &isCopy);
21405 + if (cstr != NULL) {
21406 + size_t len = strlen(cstr);
21407 + char* newbuf = (char*)realloc(buf, size+len+1);
21408 + if (newbuf != NULL) {
21409 + buf = newbuf;
21410 + strcpy(buf+size, cstr);
21411 + size += len+1;
21413 + if (isCopy) {
21414 + JNU_ReleaseStringPlatformChars(env, obj, cstr);
21416 + if (newbuf == NULL) {
21417 + free(buf);
21418 + JNU_ThrowOutOfMemoryError(env, "realloc failed");
21419 + return -1;
21422 + } else {
21423 + char* newbuf = (char*)realloc(buf, size + 1);
21424 + if (newbuf == NULL) {
21425 + free(buf);
21426 + JNU_ThrowOutOfMemoryError(env, "realloc failed");
21427 + return -1;
21429 + buf = newbuf;
21430 + buf[size++] = 0;
21432 + if ((*env)->ExceptionOccurred(env)) {
21433 + free(buf);
21434 + return -1;
21438 + /*
21439 + * The arguments to the door function are in 'buf' so we now
21440 + * do the door call
21441 + */
21442 + door_args.data_ptr = buf;
21443 + door_args.data_size = size;
21444 + door_args.desc_ptr = NULL;
21445 + door_args.desc_num = 0;
21446 + door_args.rbuf = (char*)&res_buffer;
21447 + door_args.rsize = sizeof(res_buffer);
21449 + RESTARTABLE(door_call(fd, &door_args), rc);
21451 + /*
21452 + * door_call failed
21453 + */
21454 + if (rc == -1) {
21455 + JNU_ThrowIOExceptionWithLastError(env, "door_call");
21456 + } else {
21457 + /*
21458 + * door_call succeeded but the call didn't return the expected jint.
21459 + */
21460 + if (door_args.data_size < sizeof(jint)) {
21461 + JNU_ThrowIOException(env, "Enqueue error - reason unknown as result is truncated!");
21462 + } else {
21463 + jint* res = (jint*)(door_args.data_ptr);
21464 + if (*res != JNI_OK) {
21465 + const char* msg = translate_error(*res);
21466 + char buf[255];
21467 + if (msg == NULL) {
21468 + sprintf(buf, "Unable to enqueue command to target VM: %d", *res);
21469 + } else {
21470 + sprintf(buf, "Unable to enqueue command to target VM: %s", msg);
21472 + JNU_ThrowIOException(env, buf);
21473 + } else {
21474 + /*
21475 + * The door call should return a file descriptor to one end of
21476 + * a socket pair
21477 + */
21478 + if ((door_args.desc_ptr != NULL) &&
21479 + (door_args.desc_num == 1) &&
21480 + (door_args.desc_ptr->d_attributes & DOOR_DESCRIPTOR)) {
21481 + result = door_args.desc_ptr->d_data.d_desc.d_descriptor;
21482 + } else {
21483 + JNU_ThrowIOException(env, "Reply from enqueue missing descriptor!");
21489 + free(buf);
21490 + return result;
21492 diff -Nru jdk-jdk-24-11.orig/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java jdk-jdk-24-11/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java
21493 --- jdk-jdk-24-11.orig/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java 2024-08-15 09:39:31.000000000 +0200
21494 +++ jdk-jdk-24-11/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java 2024-08-17 20:36:14.270714506 +0200
21495 @@ -95,7 +95,7 @@
21496 private static class Decoder extends CharsetDecoder {
21498 private static final String SJISName = getSJISName();
21499 - private static final String EUCJPName = "EUC_JP";
21500 + private static final String EUCJPName = getEUCJPName();
21501 private DelegatableDecoder detectedDecoder = null;
21503 public Decoder(Charset cs) {
21504 @@ -223,11 +223,24 @@
21505 * Returned Shift_JIS Charset name is OS dependent
21507 private static String getSJISName() {
21508 - if (OperatingSystem.isWindows())
21509 + if (OperatingSystem.isSolaris())
21510 + return("PCK");
21511 + else if (OperatingSystem.isWindows())
21512 return("windows-31J");
21513 else
21514 return("Shift_JIS");
21517 + /**
21518 + * Returned EUC-JP Charset name is OS dependent
21519 + */
21521 + private static String getEUCJPName() {
21522 + if (OperatingSystem.isSolaris())
21523 + return("x-eucjp-open");
21524 + else
21525 + return("EUC_JP");
21530 diff -Nru jdk-jdk-24-11.orig/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java jdk-jdk-24-11/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java
21531 --- jdk-jdk-24-11.orig/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java 2024-08-15 09:39:31.000000000 +0200
21532 +++ jdk-jdk-24-11/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java 2024-08-17 20:36:14.271379727 +0200
21533 @@ -742,10 +742,15 @@
21534 lib = expand(lib);
21535 int i = lib.indexOf("/$ISA/");
21536 if (i != -1) {
21537 - // replace "/$ISA/" with "/"
21538 + // replace "/$ISA/" with "/amd64/" on Solaris AMD64.
21539 + // On all other platforms, just turn it into a "/"
21540 String prefix = lib.substring(0, i);
21541 String suffix = lib.substring(i + 5);
21542 - lib = prefix + suffix;
21543 + if (osName.equals("SunOS") && osArch.equals("amd64")) {
21544 + lib = prefix + "/amd64" + suffix;
21545 + } else {
21546 + lib = prefix + suffix;
21549 if (DEBUG) {
21550 System.out.println(keyword + ": " + lib);
21551 diff -Nru jdk-jdk-24-11.orig/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg jdk-jdk-24-11/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg
21552 --- jdk-jdk-24-11.orig/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg 1970-01-01 01:00:00.000000000 +0100
21553 +++ jdk-jdk-24-11/src/jdk.crypto.cryptoki/solaris/conf/security/sunpkcs11-solaris.cfg 2024-08-17 20:36:14.307146537 +0200
21554 @@ -0,0 +1,23 @@
21556 +# Configuration file to allow the SunPKCS11 provider to utilize
21557 +# the Solaris Cryptographic Framework, if it is available
21560 +name = Solaris
21562 +description = SunPKCS11 accessing Solaris Cryptographic Framework
21564 +library = /usr/lib/$ISA/libpkcs11.so
21566 +handleStartupErrors = ignoreAll
21568 +# Use the X9.63 encoding for EC points (do not wrap in an ASN.1 OctetString).
21569 +useEcX963Encoding = true
21571 +attributes = compatibility
21573 +disabledMechanisms = {
21574 + CKM_DSA_KEY_PAIR_GEN
21575 + SecureRandom
21578 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java
21579 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java 1970-01-01 01:00:00.000000000 +0100
21580 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java 2024-08-17 20:36:14.307443469 +0200
21581 @@ -0,0 +1,65 @@
21583 + * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
21584 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21586 + * This code is free software; you can redistribute it and/or modify it
21587 + * under the terms of the GNU General Public License version 2 only, as
21588 + * published by the Free Software Foundation.
21590 + * This code is distributed in the hope that it will be useful, but WITHOUT
21591 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21592 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21593 + * version 2 for more details (a copy is included in the LICENSE file that
21594 + * accompanied this code).
21596 + * You should have received a copy of the GNU General Public License version
21597 + * 2 along with this work; if not, write to the Free Software Foundation,
21598 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21600 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21601 + * or visit www.oracle.com if you need additional information or have any
21602 + * questions.
21604 + */
21606 +package sun.jvm.hotspot;
21608 +import java.util.*;
21609 +import sun.jvm.hotspot.debugger.*;
21610 +import sun.jvm.hotspot.types.*;
21611 +import sun.jvm.hotspot.types.basic.*;
21613 +/** This class implements the compiler-specific access to the vtbl for
21614 + a given C++ type. */
21615 +public class HotSpotSolarisVtblAccess extends BasicVtblAccess {
21617 + public HotSpotSolarisVtblAccess(SymbolLookup symbolLookup,
21618 + String[] jvmLibNames) {
21619 + super(symbolLookup, jvmLibNames);
21622 + protected String vtblSymbolForType(Type type) {
21623 + String demangledSymbol = type.getName() + "::__vtbl";
21624 + return mangle(demangledSymbol);
21627 + //--------------------------------------------------------------------------------
21628 + // Internals only below this point
21629 + //
21631 + private String mangle(String symbol) {
21632 + String[] parts = symbol.split("::");
21633 + StringBuffer mangled = new StringBuffer("__1c");
21634 + for (int i = 0; i < parts.length; i++) {
21635 + int len = parts[i].length();
21636 + if (len >= 26) {
21637 + mangled.append((char)('a' + (len / 26)));
21638 + len = len % 26;
21640 + mangled.append((char)('A' + len));
21641 + mangled.append(parts[i]);
21643 + mangled.append("_");
21644 + return mangled.toString();
21647 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java
21648 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java 1970-01-01 01:00:00.000000000 +0100
21649 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java 2024-08-17 20:36:14.307831177 +0200
21650 @@ -0,0 +1,140 @@
21652 + * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
21653 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21655 + * This code is free software; you can redistribute it and/or modify it
21656 + * under the terms of the GNU General Public License version 2 only, as
21657 + * published by the Free Software Foundation.
21659 + * This code is distributed in the hope that it will be useful, but WITHOUT
21660 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21661 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21662 + * version 2 for more details (a copy is included in the LICENSE file that
21663 + * accompanied this code).
21665 + * You should have received a copy of the GNU General Public License version
21666 + * 2 along with this work; if not, write to the Free Software Foundation,
21667 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21669 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21670 + * or visit www.oracle.com if you need additional information or have any
21671 + * questions.
21673 + */
21675 +package sun.jvm.hotspot.runtime.solaris_amd64;
21677 +import java.io.*;
21678 +import java.util.*;
21679 +import sun.jvm.hotspot.debugger.*;
21680 +import sun.jvm.hotspot.debugger.amd64.*;
21681 +import sun.jvm.hotspot.runtime.*;
21682 +import sun.jvm.hotspot.runtime.amd64.*;
21683 +import sun.jvm.hotspot.runtime.x86.*;
21684 +import sun.jvm.hotspot.types.*;
21685 +import sun.jvm.hotspot.utilities.*;
21686 +import sun.jvm.hotspot.utilities.Observable;
21687 +import sun.jvm.hotspot.utilities.Observer;
21689 +public class SolarisAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
21690 + private static AddressField lastJavaFPField;
21691 + private static AddressField osThreadField;
21692 + private static AddressField baseOfStackPointerField;
21694 + // Field from OSThread
21695 + private static CIntegerField osThreadThreadIDField;
21697 + // This is currently unneeded but is being kept in case we change
21698 + // the currentFrameGuess algorithm
21699 + private static final long GUESS_SCAN_RANGE = 128 * 1024;
21702 + static {
21703 + VM.registerVMInitializedObserver(new Observer() {
21704 + public void update(Observable o, Object data) {
21705 + initialize(VM.getVM().getTypeDataBase());
21707 + });
21710 + private static synchronized void initialize(TypeDataBase db) {
21711 + Type type = db.lookupType("JavaThread");
21712 + Type anchorType = db.lookupType("JavaFrameAnchor");
21714 + lastJavaFPField = anchorType.getAddressField("_last_Java_fp");
21715 + osThreadField = type.getAddressField("_osthread");
21717 + type = db.lookupType("OSThread");
21718 + osThreadThreadIDField = type.getCIntegerField("_thread_id");
21721 + public Address getLastJavaFP(Address addr) {
21722 + return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
21725 + public Address getLastJavaPC(Address addr) {
21726 + return null;
21729 + public Address getBaseOfStackPointer(Address addr) {
21730 + return null;
21733 + public Frame getLastFramePD(JavaThread thread, Address addr) {
21734 + Address fp = thread.getLastJavaFP();
21735 + if (fp == null) {
21736 + return null; // no information
21738 + Address pc = thread.getLastJavaPC();
21739 + if ( pc != null ) {
21740 + return new X86Frame(thread.getLastJavaSP(), fp, pc);
21741 + } else {
21742 + return new X86Frame(thread.getLastJavaSP(), fp);
21746 + public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
21747 + return new X86RegisterMap(thread, updateMap);
21750 + public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
21751 + ThreadProxy t = getThreadProxy(addr);
21752 + AMD64ThreadContext context = (AMD64ThreadContext) t.getContext();
21753 + AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread);
21754 + if (!guesser.run(GUESS_SCAN_RANGE)) {
21755 + return null;
21757 + if (guesser.getPC() == null) {
21758 + return new X86Frame(guesser.getSP(), guesser.getFP());
21759 + } else {
21760 + return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
21765 + public void printThreadIDOn(Address addr, PrintStream tty) {
21766 + tty.print(getThreadProxy(addr));
21770 + public void printInfoOn(Address threadAddr, PrintStream tty) {
21773 + public Address getLastSP(Address addr) {
21774 + ThreadProxy t = getThreadProxy(addr);
21775 + AMD64ThreadContext context = (AMD64ThreadContext) t.getContext();
21776 + return context.getRegisterAsAddress(AMD64ThreadContext.RSP);
21779 + public ThreadProxy getThreadProxy(Address addr) {
21780 + // Fetch the OSThread (for now and for simplicity, not making a
21781 + // separate "OSThread" class in this package)
21782 + Address osThreadAddr = osThreadField.getValue(addr);
21783 + // Get the address of the thread ID from the OSThread
21784 + Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
21786 + JVMDebugger debugger = VM.getVM().getDebugger();
21787 + return debugger.getThreadForIdentifierAddress(tidAddr);
21791 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java
21792 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java 1970-01-01 01:00:00.000000000 +0100
21793 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java 2024-08-17 20:36:14.308225568 +0200
21794 @@ -0,0 +1,142 @@
21796 + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
21797 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21799 + * This code is free software; you can redistribute it and/or modify it
21800 + * under the terms of the GNU General Public License version 2 only, as
21801 + * published by the Free Software Foundation.
21803 + * This code is distributed in the hope that it will be useful, but WITHOUT
21804 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21805 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21806 + * version 2 for more details (a copy is included in the LICENSE file that
21807 + * accompanied this code).
21809 + * You should have received a copy of the GNU General Public License version
21810 + * 2 along with this work; if not, write to the Free Software Foundation,
21811 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21813 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21814 + * or visit www.oracle.com if you need additional information or have any
21815 + * questions.
21817 + */
21819 +package sun.jvm.hotspot.runtime.solaris_x86;
21821 +import java.io.*;
21822 +import java.util.*;
21823 +import sun.jvm.hotspot.debugger.*;
21824 +import sun.jvm.hotspot.debugger.x86.*;
21825 +import sun.jvm.hotspot.runtime.*;
21826 +import sun.jvm.hotspot.runtime.x86.*;
21827 +import sun.jvm.hotspot.types.*;
21828 +import sun.jvm.hotspot.utilities.*;
21829 +import sun.jvm.hotspot.utilities.Observable;
21830 +import sun.jvm.hotspot.utilities.Observer;
21832 +/** Placeholder for now to allow us to start the SA without support
21833 + for stack traces */
21835 +public class SolarisX86JavaThreadPDAccess implements JavaThreadPDAccess {
21836 + private static AddressField lastJavaFPField;
21837 + private static AddressField osThreadField;
21838 + private static AddressField baseOfStackPointerField;
21840 + // Field from OSThread
21841 + private static CIntegerField osThreadThreadIDField;
21843 + // This is currently unneeded but is being kept in case we change
21844 + // the currentFrameGuess algorithm
21845 + private static final long GUESS_SCAN_RANGE = 128 * 1024;
21848 + static {
21849 + VM.registerVMInitializedObserver(new Observer() {
21850 + public void update(Observable o, Object data) {
21851 + initialize(VM.getVM().getTypeDataBase());
21853 + });
21856 + private static synchronized void initialize(TypeDataBase db) {
21857 + Type type = db.lookupType("JavaThread");
21858 + Type anchorType = db.lookupType("JavaFrameAnchor");
21860 + lastJavaFPField = anchorType.getAddressField("_last_Java_fp");
21861 + osThreadField = type.getAddressField("_osthread");
21863 + type = db.lookupType("OSThread");
21864 + osThreadThreadIDField = type.getCIntegerField("_thread_id");
21867 + public Address getLastJavaFP(Address addr) {
21868 + return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
21871 + public Address getLastJavaPC(Address addr) {
21872 + return null;
21875 + public Address getBaseOfStackPointer(Address addr) {
21876 + return null;
21879 + public Frame getLastFramePD(JavaThread thread, Address addr) {
21880 + Address fp = thread.getLastJavaFP();
21881 + if (fp == null) {
21882 + return null; // no information
21884 + Address pc = thread.getLastJavaPC();
21885 + if ( pc != null ) {
21886 + return new X86Frame(thread.getLastJavaSP(), fp, pc);
21887 + } else {
21888 + return new X86Frame(thread.getLastJavaSP(), fp);
21892 + public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
21893 + return new X86RegisterMap(thread, updateMap);
21896 + public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
21897 + ThreadProxy t = getThreadProxy(addr);
21898 + X86ThreadContext context = (X86ThreadContext) t.getContext();
21899 + X86CurrentFrameGuess guesser = new X86CurrentFrameGuess(context, thread);
21900 + if (!guesser.run(GUESS_SCAN_RANGE)) {
21901 + return null;
21903 + if (guesser.getPC() == null) {
21904 + return new X86Frame(guesser.getSP(), guesser.getFP());
21905 + } else {
21906 + return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
21911 + public void printThreadIDOn(Address addr, PrintStream tty) {
21912 + tty.print(getThreadProxy(addr));
21916 + public void printInfoOn(Address threadAddr, PrintStream tty) {
21919 + public Address getLastSP(Address addr) {
21920 + ThreadProxy t = getThreadProxy(addr);
21921 + X86ThreadContext context = (X86ThreadContext) t.getContext();
21922 + return context.getRegisterAsAddress(X86ThreadContext.ESP);
21925 + public ThreadProxy getThreadProxy(Address addr) {
21926 + // Fetch the OSThread (for now and for simplicity, not making a
21927 + // separate "OSThread" class in this package)
21928 + Address osThreadAddr = osThreadField.getValue(addr);
21929 + // Get the address of the thread ID from the OSThread
21930 + Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
21932 + JVMDebugger debugger = VM.getVM().getDebugger();
21933 + return debugger.getThreadForIdentifierAddress(tidAddr);
21937 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java
21938 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java 2024-08-15 09:39:31.000000000 +0200
21939 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java 2024-08-17 20:36:14.272029877 +0200
21940 @@ -28,6 +28,8 @@
21942 import sun.jvm.hotspot.debugger.*;
21943 import sun.jvm.hotspot.types.*;
21944 +import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess;
21945 +import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess;
21946 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
21947 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
21948 import sun.jvm.hotspot.runtime.win32_aarch64.Win32AARCH64JavaThreadPDAccess;
21949 @@ -97,7 +99,13 @@
21951 access = null;
21952 // FIXME: find the platform specific PD class by reflection?
21953 - if (os.equals("win32")) {
21954 + if (os.equals("solaris")) {
21955 + if (cpu.equals("x86")) {
21956 + access = new SolarisX86JavaThreadPDAccess();
21957 + } else if (cpu.equals("amd64")) {
21958 + access = new SolarisAMD64JavaThreadPDAccess();
21960 + } else if (os.equals("win32")) {
21961 if (cpu.equals("x86")) {
21962 access = new Win32X86JavaThreadPDAccess();
21963 } else if (cpu.equals("amd64")) {
21964 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java
21965 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java 2024-08-15 09:39:31.000000000 +0200
21966 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java 2024-08-17 20:36:14.272475992 +0200
21967 @@ -28,10 +28,14 @@
21968 system. */
21970 public class PlatformInfo {
21971 - /* Returns "win32" if Windows; "linux" if Linux. */
21972 + /* Returns "solaris" if on Solaris; "win32" if Windows; "linux" if
21973 + Linux. Used to determine location of dbx and import module, or
21974 + possible debugger agent on win32. */
21975 public static String getOS() throws UnsupportedPlatformException {
21976 String os = System.getProperty("os.name");
21977 - if (os.equals("Linux")) {
21978 + if (os.equals("SunOS")) {
21979 + return "solaris";
21980 + } else if (os.equals("Linux")) {
21981 return "linux";
21982 } else if (os.equals("FreeBSD")) {
21983 return "bsd";
21984 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c jdk-jdk-24-11/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c
21985 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2024-08-15 09:39:31.000000000 +0200
21986 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2024-08-17 20:36:14.272960823 +0200
21987 @@ -22,6 +22,8 @@
21991 +#include <jni.h> // just include something, or else solaris compiler will complain that this file is empty
21993 #if defined(LINUX) || defined(__APPLE__)
21994 #include <unistd.h>
21995 #include <fcntl.h>
21996 diff -Nru jdk-jdk-24-11.orig/src/jdk.hotspot.agent/test/libproc/libproctest.sh jdk-jdk-24-11/src/jdk.hotspot.agent/test/libproc/libproctest.sh
21997 --- jdk-jdk-24-11.orig/src/jdk.hotspot.agent/test/libproc/libproctest.sh 2024-08-15 09:39:31.000000000 +0200
21998 +++ jdk-jdk-24-11/src/jdk.hotspot.agent/test/libproc/libproctest.sh 2024-08-17 20:36:14.273352682 +0200
21999 @@ -59,8 +59,10 @@
22000 kill -9 $pid
22003 +OPTIONS="-Djava.library.path=$STARTDIR/../src/os/solaris/proc/`uname -p`:$STARTDIR/../solaris/`uname -p`"
22005 # run libproc client
22006 -$SA_JAVA -showversion -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid
22007 +$SA_JAVA -showversion ${OPTIONS} -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid
22009 # delete core
22010 rm -f core.$pid
22011 diff -Nru jdk-jdk-24-11.orig/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c jdk-jdk-24-11/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c
22012 --- jdk-jdk-24-11.orig/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c 2024-08-15 09:39:31.000000000 +0200
22013 +++ jdk-jdk-24-11/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c 2024-08-17 20:36:14.273946224 +0200
22014 @@ -33,8 +33,12 @@
22015 #include <errno.h>
22016 #include <string.h>
22017 #include <sys/time.h>
22018 +#ifdef __solaris__
22019 +#include <thread.h>
22020 +#else
22021 #include <pthread.h>
22022 #include <poll.h>
22023 +#endif
22025 #include "socket_md.h"
22026 #include "sysSocket.h"
22027 @@ -271,6 +275,35 @@
22028 return 0;
22031 +#ifdef __solaris__
22032 +int
22033 +dbgsysTlsAlloc() {
22034 + thread_key_t tk;
22035 + if (thr_keycreate(&tk, NULL)) {
22036 + perror("thr_keycreate");
22037 + exit(-1);
22039 + return (int)tk;
22042 +void
22043 +dbgsysTlsFree(int index) {
22044 + /* no-op */
22047 +void
22048 +dbgsysTlsPut(int index, void *value) {
22049 + thr_setspecific((thread_key_t)index, value) ;
22052 +void *
22053 +dbgsysTlsGet(int index) {
22054 + void* r = NULL;
22055 + thr_getspecific((thread_key_t)index, &r);
22056 + return r;
22059 +#else
22061 dbgsysTlsAlloc() {
22062 pthread_key_t key;
22063 @@ -296,6 +329,8 @@
22064 return pthread_getspecific((pthread_key_t)index);
22067 +#endif
22069 long
22070 dbgsysCurrentTimeMillis() {
22071 struct timeval t;
22072 diff -Nru jdk-jdk-24-11.orig/src/jdk.management/solaris/native/libmanagement_ext/UnixOperatingSystem.c jdk-jdk-24-11/src/jdk.management/solaris/native/libmanagement_ext/UnixOperatingSystem.c
22073 --- jdk-jdk-24-11.orig/src/jdk.management/solaris/native/libmanagement_ext/UnixOperatingSystem.c 1970-01-01 01:00:00.000000000 +0100
22074 +++ jdk-jdk-24-11/src/jdk.management/solaris/native/libmanagement_ext/UnixOperatingSystem.c 2024-08-17 20:36:14.308703262 +0200
22075 @@ -0,0 +1,254 @@
22077 + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
22078 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
22080 + * This code is free software; you can redistribute it and/or modify it
22081 + * under the terms of the GNU General Public License version 2 only, as
22082 + * published by the Free Software Foundation. Oracle designates this
22083 + * particular file as subject to the "Classpath" exception as provided
22084 + * by Oracle in the LICENSE file that accompanied this code.
22086 + * This code is distributed in the hope that it will be useful, but WITHOUT
22087 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22088 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22089 + * version 2 for more details (a copy is included in the LICENSE file that
22090 + * accompanied this code).
22092 + * You should have received a copy of the GNU General Public License version
22093 + * 2 along with this work; if not, write to the Free Software Foundation,
22094 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22096 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22097 + * or visit www.oracle.com if you need additional information or have any
22098 + * questions.
22099 + */
22101 +#include <fcntl.h>
22102 +#include <kstat.h>
22103 +#include <procfs.h>
22104 +#include <unistd.h>
22105 +#include <stdlib.h>
22106 +#include <stdio.h>
22107 +#include <string.h>
22108 +#include <sys/sysinfo.h>
22109 +#include <sys/lwp.h>
22110 +#include <pthread.h>
22111 +#include <utmpx.h>
22112 +#include <dlfcn.h>
22113 +#include <sys/loadavg.h>
22114 +#include <jni.h>
22115 +#include "jvm.h"
22116 +#include "com_sun_management_internal_OperatingSystemImpl.h"
22118 +typedef struct {
22119 + kstat_t *kstat;
22120 + uint64_t last_idle;
22121 + uint64_t last_total;
22122 + double last_ratio;
22123 +} cpuload_t;
22125 +static cpuload_t *cpu_loads = NULL;
22126 +static unsigned int num_cpus;
22127 +static kstat_ctl_t *kstat_ctrl = NULL;
22129 +static void map_cpu_kstat_counters() {
22130 + kstat_t *kstat;
22131 + int i;
22133 + // Get number of CPU(s)
22134 + if ((num_cpus = sysconf(_SC_NPROCESSORS_ONLN)) == -1) {
22135 + num_cpus = 1;
22138 + // Data structure for saving CPU load
22139 + if ((cpu_loads = calloc(num_cpus,sizeof(cpuload_t))) == NULL) {
22140 + return;
22143 + // Get kstat cpu_stat counters for every CPU
22144 + // (loop over kstat to find our cpu_stat(s)
22145 + i = 0;
22146 + for (kstat = kstat_ctrl->kc_chain; kstat != NULL; kstat = kstat->ks_next) {
22147 + if (strncmp(kstat->ks_module, "cpu_stat", 8) == 0) {
22149 + if (kstat_read(kstat_ctrl, kstat, NULL) == -1) {
22150 + // Failed to initialize kstat for this CPU so ignore it
22151 + continue;
22154 + if (i == num_cpus) {
22155 + // Found more cpu_stats than reported CPUs
22156 + break;
22159 + cpu_loads[i++].kstat = kstat;
22164 +static int init_cpu_kstat_counters() {
22165 + static int initialized = 0;
22167 + // Concurrence in this method is prevented by the lock in
22168 + // the calling method get_cpu_load();
22169 + if(!initialized) {
22170 + if ((kstat_ctrl = kstat_open()) != NULL) {
22171 + map_cpu_kstat_counters();
22172 + initialized = 1;
22175 + return initialized ? 0 : -1;
22178 +static void update_cpu_kstat_counters() {
22179 + if(kstat_chain_update(kstat_ctrl) != 0) {
22180 + free(cpu_loads);
22181 + map_cpu_kstat_counters();
22185 +int read_cpustat(cpuload_t *load, cpu_stat_t *cpu_stat) {
22186 + if (load->kstat == NULL) {
22187 + // no handle.
22188 + return -1;
22190 + if (kstat_read(kstat_ctrl, load->kstat, cpu_stat) == -1) {
22191 + // disabling for now, a kstat chain update is likely to happen next time
22192 + load->kstat = NULL;
22193 + return -1;
22195 + return 0;
22198 +double get_single_cpu_load(unsigned int n) {
22199 + cpuload_t *load;
22200 + cpu_stat_t cpu_stat;
22201 + uint_t *usage;
22202 + uint64_t c_idle;
22203 + uint64_t c_total;
22204 + uint64_t d_idle;
22205 + uint64_t d_total;
22206 + int i;
22208 + if (n >= num_cpus) {
22209 + return -1.0;
22212 + load = &cpu_loads[n];
22213 + if (read_cpustat(load, &cpu_stat) < 0) {
22214 + return -1.0;
22217 + usage = cpu_stat.cpu_sysinfo.cpu;
22218 + c_idle = usage[CPU_IDLE];
22220 + for (c_total = 0, i = 0; i < CPU_STATES; i++) {
22221 + c_total += usage[i];
22224 + // Calculate diff against previous snapshot
22225 + d_idle = c_idle - load->last_idle;
22226 + d_total = c_total - load->last_total;
22228 + /** update if weve moved */
22229 + if (d_total > 0) {
22230 + // Save current values for next time around
22231 + load->last_idle = c_idle;
22232 + load->last_total = c_total;
22233 + load->last_ratio = (double) (d_total - d_idle) / d_total;
22236 + return load->last_ratio;
22239 +int get_info(const char *path, void *info, size_t s, off_t o) {
22240 + int fd;
22241 + int ret = 0;
22242 + if ((fd = open(path, O_RDONLY)) < 0) {
22243 + return -1;
22245 + if (pread(fd, info, s, o) != s) {
22246 + ret = -1;
22248 + close(fd);
22249 + return ret;
22252 +#define MIN(a, b) ((a < b) ? a : b)
22254 +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
22256 +/**
22257 + * Return the cpu load (0-1) for proc number 'which' (or average all if which == -1)
22258 + */
22259 +double get_cpu_load(int which) {
22260 + double load =.0;
22262 + pthread_mutex_lock(&lock);
22263 + if(init_cpu_kstat_counters()==0) {
22265 + update_cpu_kstat_counters();
22267 + if (which == -1) {
22268 + unsigned int i;
22269 + double t;
22271 + for (t = .0, i = 0; i < num_cpus; i++) {
22272 + t += get_single_cpu_load(i);
22275 + // Cap total systemload to 1.0
22276 + load = MIN((t / num_cpus), 1.0);
22277 + } else {
22278 + load = MIN(get_single_cpu_load(which), 1.0);
22280 + } else {
22281 + load = -1.0;
22283 + pthread_mutex_unlock(&lock);
22285 + return load;
22288 +/**
22289 + * Return the cpu load (0-1) for the current process (i.e the JVM)
22290 + * or -1.0 if the get_info() call failed
22291 + */
22292 +double get_process_load(void) {
22293 + psinfo_t info;
22295 + // Get the percentage of "recent cpu usage" from all the lwp:s in the JVM:s
22296 + // process. This is returned as a value between 0.0 and 1.0 multiplied by 0x8000.
22297 + if (get_info("/proc/self/psinfo",&info.pr_pctcpu, sizeof(info.pr_pctcpu), offsetof(psinfo_t, pr_pctcpu)) == 0) {
22298 + return (double) info.pr_pctcpu / 0x8000;
22300 + return -1.0;
22303 +JNIEXPORT jdouble JNICALL
22304 +Java_com_sun_management_internal_OperatingSystemImpl_getCpuLoad0
22305 +(JNIEnv *env, jobject dummy)
22307 + return get_cpu_load(-1);
22310 +JNIEXPORT jdouble JNICALL
22311 +Java_com_sun_management_internal_OperatingSystemImpl_getProcessCpuLoad0
22312 +(JNIEnv *env, jobject dummy)
22314 + return get_process_load();
22317 +JNIEXPORT jdouble JNICALL
22318 +Java_com_sun_management_internal_OperatingSystemImpl_getSingleCpuLoad0
22319 +(JNIEnv *env, jobject mbean, jint cpu_number)
22321 + return -1.0;
22324 +JNIEXPORT jint JNICALL
22325 +Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0
22326 +(JNIEnv *env, jobject mbean)
22328 + return -1;
22330 diff -Nru jdk-jdk-24-11.orig/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c jdk-jdk-24-11/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
22331 --- jdk-jdk-24-11.orig/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c 2024-08-15 09:39:31.000000000 +0200
22332 +++ jdk-jdk-24-11/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c 2024-08-17 20:36:14.274609615 +0200
22333 @@ -77,7 +77,63 @@
22334 // true = get available swap in bytes
22335 // false = get total swap in bytes
22336 static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean available) {
22337 -#if defined(__linux__)
22338 +#ifdef __solaris__
22339 + long total, avail;
22340 + int nswap, i, count;
22341 + swaptbl_t *stbl;
22342 + char *strtab;
22344 + // First get the number of swap resource entries
22345 + if ((nswap = swapctl(SC_GETNSWP, NULL)) == -1) {
22346 + throw_internal_error(env, "swapctl failed to get nswap");
22347 + return -1;
22349 + if (nswap == 0) {
22350 + return 0;
22353 + // Allocate storage for resource entries
22354 + stbl = (swaptbl_t*) malloc(nswap * sizeof(swapent_t) +
22355 + sizeof(struct swaptable));
22356 + if (stbl == NULL) {
22357 + JNU_ThrowOutOfMemoryError(env, 0);
22358 + return -1;
22361 + // Allocate storage for the table
22362 + strtab = (char*) malloc((nswap + 1) * MAXPATHLEN);
22363 + if (strtab == NULL) {
22364 + free(stbl);
22365 + JNU_ThrowOutOfMemoryError(env, 0);
22366 + return -1;
22369 + for (i = 0; i < (nswap + 1); i++) {
22370 + stbl->swt_ent[i].ste_path = strtab + (i * MAXPATHLEN);
22372 + stbl->swt_n = nswap + 1;
22374 + // Get the entries
22375 + if ((count = swapctl(SC_LIST, stbl)) < 0) {
22376 + free(stbl);
22377 + free(strtab);
22378 + throw_internal_error(env, "swapctl failed to get swap list");
22379 + return -1;
22382 + // Sum the entries to get total and free swap
22383 + total = 0;
22384 + avail = 0;
22385 + for (i = 0; i < count; i++) {
22386 + total += stbl->swt_ent[i].ste_pages;
22387 + avail += stbl->swt_ent[i].ste_free;
22390 + free(stbl);
22391 + free(strtab);
22392 + return available ? ((jlong)avail * page_size) :
22393 + ((jlong)total * page_size);
22394 +#elif defined(__linux__)
22395 int ret;
22396 jlong total = 0, avail = 0;
22398 @@ -126,7 +182,37 @@
22399 Java_com_sun_management_internal_OperatingSystemImpl_getCommittedVirtualMemorySize0
22400 (JNIEnv *env, jobject mbean)
22402 -#if defined(__APPLE__)
22403 +#ifdef __solaris__
22404 + psinfo_t psinfo;
22405 + ssize_t result;
22406 + size_t remaining;
22407 + char* addr;
22408 + int fd;
22410 + fd = open64("/proc/self/psinfo", O_RDONLY, 0);
22411 + if (fd < 0) {
22412 + throw_internal_error(env, "Unable to open /proc/self/psinfo");
22413 + return -1;
22416 + addr = (char *)&psinfo;
22417 + for (remaining = sizeof(psinfo_t); remaining > 0;) {
22418 + result = read(fd, addr, remaining);
22419 + if (result < 0) {
22420 + if (errno != EINTR) {
22421 + close(fd);
22422 + throw_internal_error(env, "Unable to read /proc/self/psinfo");
22423 + return -1;
22425 + } else {
22426 + remaining -= result;
22427 + addr += result;
22431 + close(fd);
22432 + return (jlong) psinfo.pr_size * 1024;
22433 +#elif defined(__APPLE__)
22434 struct task_basic_info t_info;
22435 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
22437 @@ -182,7 +268,7 @@
22438 * BSDNOTE: FreeBSD implements _SC_CLK_TCK since FreeBSD 5, so
22439 * add a magic to handle it
22441 -#if defined(_SC_CLK_TCK)
22442 +#if defined(__solaris__) || defined(_SC_CLK_TCK)
22443 clk_tck = (jlong) sysconf(_SC_CLK_TCK);
22444 #elif defined(__linux__) || defined(_ALLBSD_SOURCE)
22445 clk_tck = 100;
22446 diff -Nru jdk-jdk-24-11.orig/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java jdk-jdk-24-11/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java
22447 --- jdk-jdk-24-11.orig/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java 2024-08-15 09:39:31.000000000 +0200
22448 +++ jdk-jdk-24-11/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java 2024-08-17 20:36:14.275207400 +0200
22449 @@ -44,6 +44,12 @@
22450 /* -- Miscellaneous SCTP utilities -- */
22452 private static boolean IPv4MappedAddresses() {
22453 + if (true) {
22454 + /* FIXME - nonportable hack */
22455 + /* Solaris supports IPv4Mapped Addresses with bindx */
22456 + return true;
22457 + } /* else { //other OS/implementations */
22459 /* lksctp/linux requires Ipv4 addresses */
22460 return false;
22462 diff -Nru jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/Sctp.h jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/Sctp.h
22463 --- jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/Sctp.h 2024-08-15 09:39:31.000000000 +0200
22464 +++ jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/Sctp.h 2024-08-17 20:36:14.275722096 +0200
22465 @@ -26,6 +26,48 @@
22466 #ifndef SUN_NIO_CH_SCTP_H
22467 #define SUN_NIO_CH_SCTP_H
22469 +#ifdef __solaris__
22471 +#define _XPG4_2
22472 +#define __EXTENSIONS__
22473 +#include <sys/socket.h>
22474 +#include <netinet/sctp.h>
22475 +#include "jni.h"
22477 +/* Current Solaris headers don't comply with draft rfc */
22478 +#ifndef SCTP_EOF
22479 +#define SCTP_EOF MSG_EOF
22480 +#endif
22482 +#ifndef SCTP_UNORDERED
22483 +#define SCTP_UNORDERED MSG_UNORDERED
22484 +#endif
22486 +/* The current version of the socket API extension shipped with Solaris does
22487 + * not define the following options that the Java API (optionally) supports */
22488 +#ifndef SCTP_EXPLICIT_EOR
22489 +#define SCTP_EXPLICIT_EOR -1
22490 +#endif
22491 +#ifndef SCTP_FRAGMENT_INTERLEAVE
22492 +#define SCTP_FRAGMENT_INTERLEAVE -1
22493 +#endif
22494 +#ifndef SCTP_SET_PEER_PRIMARY_ADDR
22495 +#define SCTP_SET_PEER_PRIMARY_ADDR -1
22496 +#endif
22498 +/* Function types to support dynamic linking of socket API extension functions
22499 + * for SCTP. This is so that there is no linkage depandancy during build or
22500 + * runtime for libsctp.*/
22501 +typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
22502 +typedef int sctp_freeladdrs_func(void* addrs);
22503 +typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
22504 +typedef int sctp_freepaddrs_func(void *addrs);
22505 +typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
22506 +typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
22510 +#else /* __linux__ */
22511 #include <stdint.h>
22512 #include <linux/types.h>
22513 #include <sys/socket.h>
22514 @@ -278,6 +320,8 @@
22515 typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
22518 +#endif /* __linux__ */
22520 extern sctp_getladdrs_func* nio_sctp_getladdrs;
22521 extern sctp_freeladdrs_func* nio_sctp_freeladdrs;
22522 extern sctp_getpaddrs_func* nio_sctp_getpaddrs;
22523 diff -Nru jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c
22524 --- jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c 2024-08-15 09:39:31.000000000 +0200
22525 +++ jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c 2024-08-17 20:36:14.276160664 +0200
22526 @@ -331,11 +331,10 @@
22527 break;
22528 case SCTP_ADDR_MADE_PRIM :
22529 event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_MADE_PRIM;
22530 +#ifdef __linux__ /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
22531 break;
22532 -#ifdef __linux__
22533 case SCTP_ADDR_CONFIRMED :
22534 event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_CONFIRMED;
22535 - break;
22536 #endif /* __linux__ */
22539 diff -Nru jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/SctpNet.c jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/SctpNet.c
22540 --- jdk-jdk-24-11.orig/src/jdk.sctp/unix/native/libsctp/SctpNet.c 2024-08-15 09:39:31.000000000 +0200
22541 +++ jdk-jdk-24-11/src/jdk.sctp/unix/native/libsctp/SctpNet.c 2024-08-17 20:36:14.276659536 +0200
22542 @@ -371,7 +371,11 @@
22543 int i, addrCount;
22544 jobjectArray isaa;
22546 +#ifdef __solaris__
22547 + if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
22548 +#else /* __linux__ */
22549 if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
22550 +#endif
22551 sctpHandleSocketError(env, errno);
22552 return NULL;
22554 @@ -416,7 +420,11 @@
22555 int i, addrCount;
22556 jobjectArray isaa;
22558 +#if defined(__solaris__)
22559 + if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
22560 +#else /* __linux__ */
22561 if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr **)&addr_buf)) == -1) {
22562 +#endif
22563 sctpHandleSocketError(env, errno);
22564 return NULL;
22566 diff -Nru jdk-jdk-24-11.orig/src/jdk.security.auth/unix/native/libjaas/Unix.c jdk-jdk-24-11/src/jdk.security.auth/unix/native/libjaas/Unix.c
22567 --- jdk-jdk-24-11.orig/src/jdk.security.auth/unix/native/libjaas/Unix.c 2024-08-15 09:39:31.000000000 +0200
22568 +++ jdk-jdk-24-11/src/jdk.security.auth/unix/native/libjaas/Unix.c 2024-08-17 20:36:14.277135860 +0200
22569 @@ -32,6 +32,10 @@
22570 #include <stdlib.h>
22571 #include <string.h>
22573 +/* For POSIX-compliant getpwuid_r on Solaris */
22574 +#if defined(__solaris__)
22575 +#define _POSIX_PTHREAD_SEMANTICS
22576 +#endif
22577 #include <pwd.h>