From 0db32c3e539e18db218d5180e7bf5a0bec84efe4 Mon Sep 17 00:00:00 2001 From: Darragh Clarke Date: Tue, 30 Sep 2025 12:25:56 +0100 Subject: [PATCH 1/4] jextract generated code and the package-info.java files that describe how they were genereated --- .../ffi/generated/errno/errno_h$shared.java | 60 +++ .../internal/ffi/generated/errno/errno_h.java | 91 +++++ .../ffi/generated/errno/package-info.java | 43 +++ .../internal/ffi/generated/kqueue/kevent.java | 353 ++++++++++++++++++ .../ffi/generated/kqueue/kqueue_h$shared.java | 60 +++ .../ffi/generated/kqueue/kqueue_h.java | 197 ++++++++++ .../ffi/generated/kqueue/package-info.java | 51 +++ .../ffi/generated/timespec/package-info.java | 41 ++ .../ffi/generated/timespec/timespec.java | 169 +++++++++ .../generated/timespec/timespec_h$shared.java | 60 +++ .../ffi/generated/timespec/timespec_h.java | 19 + 11 files changed, 1144 insertions(+) create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java create mode 100644 src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java new file mode 100644 index 0000000000000..d1fe3ce46384c --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java @@ -0,0 +1,60 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.errno; + +import java.lang.foreign.*; +import java.lang.invoke.*; +import java.util.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; + +public class errno_h$shared { + + errno_h$shared() { + // Should not be called directly + } + + public static final OfBoolean C_BOOL = (OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); + public static final OfByte C_CHAR =(OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); + public static final OfShort C_SHORT = (OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); + public static final OfInt C_INT = (OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); + public static final OfLong C_LONG_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long long"); + public static final OfFloat C_FLOAT = (OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); + public static final OfDouble C_DOUBLE = (OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); + public static final AddressLayout C_POINTER = ((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) + .withTargetLayout(MemoryLayout.sequenceLayout(Long.MAX_VALUE, C_CHAR)); + public static final OfLong C_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long"); + + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java new file mode 100644 index 0000000000000..764ddcc2ab03c --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java @@ -0,0 +1,91 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.errno; + +import java.lang.foreign.*; +import java.lang.invoke.*; + +public class errno_h extends errno_h$shared { + + errno_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + private static final int EINTR = (int)4L; + /** + * {@snippet lang=c : + * #define EINTR 4 + * } + */ + public static int EINTR() { + return EINTR; + } + + private static class strerror_r { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + C_INT, + C_INT, + C_POINTER, + C_LONG + ); + + public static final MemorySegment ADDR = SYMBOL_LOOKUP.findOrThrow("strerror_r"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * int strerror_r(int __errnum, char *__strerrbuf, size_t __buflen) + * } + */ + public static FunctionDescriptor strerror_r$descriptor() { + return strerror_r.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * int strerror_r(int __errnum, char *__strerrbuf, size_t __buflen) + * } + */ + public static MethodHandle strerror_r$handle() { + return strerror_r.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * int strerror_r(int __errnum, char *__strerrbuf, size_t __buflen) + * } + */ + public static MemorySegment strerror_r$address() { + return strerror_r.ADDR; + } + + /** + * {@snippet lang=c : + * int strerror_r(int __errnum, char *__strerrbuf, size_t __buflen) + * } + */ + public static int strerror_r(int __errnum, MemorySegment __strerrbuf, long __buflen) { + var mh$ = strerror_r.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("strerror_r", __errnum, __strerrbuf, __buflen); + } + return (int)mh$.invokeExact(__errnum, __strerrbuf, __buflen); + } catch (Error | RuntimeException ex) { + throw ex; + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java new file mode 100644 index 0000000000000..7b28292c8c064 --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Defines native structures for errno APIs. + * Generated with the following jextract command: + * {@snippet lang = "Shell Script": + * + * HEADER_NAME=errno.h + * echo "#include " > $HEADER_NAME + * echo "#include " >> $HEADER_NAME + * + * jextract --target-package jdk.internal.ffi.generated.errno \ + * --include-constant EINTR \ + * --include-function strerror_r \ + * $HEADER_NAME + * } + * + */ + +package jdk.internal.ffi.generated.errno; \ No newline at end of file diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java new file mode 100644 index 0000000000000..e717dfb6f7d22 --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java @@ -0,0 +1,353 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.kqueue; + +import java.lang.foreign.*; +import java.util.function.*; + +import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.*; + +/** + * {@snippet lang=c : + * struct kevent { + * uintptr_t ident; + * int16_t filter; + * uint16_t flags; + * uint32_t fflags; + * intptr_t data; + * void *udata; + * } + * } + */ +public class kevent { + + kevent() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + kqueue_h.align(kqueue_h.C_LONG, 4).withName("ident"), + kqueue_h.C_SHORT.withName("filter"), + kqueue_h.C_SHORT.withName("flags"), + kqueue_h.C_INT.withName("fflags"), + kqueue_h.align(kqueue_h.C_LONG, 4).withName("data"), + kqueue_h.align(kqueue_h.C_POINTER, 4).withName("udata") + ).withName("kevent"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong ident$LAYOUT = (OfLong)$LAYOUT.select(groupElement("ident")); + + /** + * Layout for field: + * {@snippet lang=c : + * uintptr_t ident + * } + */ + public static final OfLong ident$layout() { + return ident$LAYOUT; + } + + private static final long ident$OFFSET = $LAYOUT.byteOffset(groupElement("ident")); + + /** + * Offset for field: + * {@snippet lang=c : + * uintptr_t ident + * } + */ + public static final long ident$offset() { + return ident$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uintptr_t ident + * } + */ + public static long ident(MemorySegment struct) { + return struct.get(ident$LAYOUT, ident$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uintptr_t ident + * } + */ + public static void ident(MemorySegment struct, long fieldValue) { + struct.set(ident$LAYOUT, ident$OFFSET, fieldValue); + } + + private static final OfShort filter$LAYOUT = (OfShort)$LAYOUT.select(groupElement("filter")); + + /** + * Layout for field: + * {@snippet lang=c : + * int16_t filter + * } + */ + public static final OfShort filter$layout() { + return filter$LAYOUT; + } + + private static final long filter$OFFSET = $LAYOUT.byteOffset(groupElement("filter")); + + /** + * Offset for field: + * {@snippet lang=c : + * int16_t filter + * } + */ + public static final long filter$offset() { + return filter$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * int16_t filter + * } + */ + public static short filter(MemorySegment struct) { + return struct.get(filter$LAYOUT, filter$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * int16_t filter + * } + */ + public static void filter(MemorySegment struct, short fieldValue) { + struct.set(filter$LAYOUT, filter$OFFSET, fieldValue); + } + + private static final OfShort flags$LAYOUT = (OfShort)$LAYOUT.select(groupElement("flags")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint16_t flags + * } + */ + public static final OfShort flags$layout() { + return flags$LAYOUT; + } + + private static final long flags$OFFSET = $LAYOUT.byteOffset(groupElement("flags")); + + /** + * Offset for field: + * {@snippet lang=c : + * uint16_t flags + * } + */ + public static final long flags$offset() { + return flags$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint16_t flags + * } + */ + public static short flags(MemorySegment struct) { + return struct.get(flags$LAYOUT, flags$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint16_t flags + * } + */ + public static void flags(MemorySegment struct, short fieldValue) { + struct.set(flags$LAYOUT, flags$OFFSET, fieldValue); + } + + private static final OfInt fflags$LAYOUT = (OfInt)$LAYOUT.select(groupElement("fflags")); + + /** + * Layout for field: + * {@snippet lang=c : + * uint32_t fflags + * } + */ + public static final OfInt fflags$layout() { + return fflags$LAYOUT; + } + + private static final long fflags$OFFSET = $LAYOUT.byteOffset(groupElement("fflags")); + + /** + * Offset for field: + * {@snippet lang=c : + * uint32_t fflags + * } + */ + public static final long fflags$offset() { + return fflags$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * uint32_t fflags + * } + */ + public static int fflags(MemorySegment struct) { + return struct.get(fflags$LAYOUT, fflags$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * uint32_t fflags + * } + */ + public static void fflags(MemorySegment struct, int fieldValue) { + struct.set(fflags$LAYOUT, fflags$OFFSET, fieldValue); + } + + private static final OfLong data$LAYOUT = (OfLong)$LAYOUT.select(groupElement("data")); + + /** + * Layout for field: + * {@snippet lang=c : + * intptr_t data + * } + */ + public static final OfLong data$layout() { + return data$LAYOUT; + } + + private static final long data$OFFSET = $LAYOUT.byteOffset(groupElement("data")); + + /** + * Offset for field: + * {@snippet lang=c : + * intptr_t data + * } + */ + public static final long data$offset() { + return data$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * intptr_t data + * } + */ + public static long data(MemorySegment struct) { + return struct.get(data$LAYOUT, data$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * intptr_t data + * } + */ + public static void data(MemorySegment struct, long fieldValue) { + struct.set(data$LAYOUT, data$OFFSET, fieldValue); + } + + private static final AddressLayout udata$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("udata")); + + /** + * Layout for field: + * {@snippet lang=c : + * void *udata + * } + */ + public static final AddressLayout udata$layout() { + return udata$LAYOUT; + } + + private static final long udata$OFFSET = $LAYOUT.byteOffset(groupElement("udata")); + + /** + * Offset for field: + * {@snippet lang=c : + * void *udata + * } + */ + public static final long udata$offset() { + return udata$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * void *udata + * } + */ + public static MemorySegment udata(MemorySegment struct) { + return struct.get(udata$LAYOUT, udata$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * void *udata + * } + */ + public static void udata(MemorySegment struct, MemorySegment fieldValue) { + struct.set(udata$LAYOUT, udata$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java new file mode 100644 index 0000000000000..61e074b01b7c2 --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java @@ -0,0 +1,60 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.kqueue; + +import java.lang.foreign.*; +import java.lang.invoke.*; +import java.util.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; + +public class kqueue_h$shared { + + kqueue_h$shared() { + // Should not be called directly + } + + public static final OfBoolean C_BOOL = (OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); + public static final OfByte C_CHAR =(OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); + public static final OfShort C_SHORT = (OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); + public static final OfInt C_INT = (OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); + public static final OfLong C_LONG_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long long"); + public static final OfFloat C_FLOAT = (OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); + public static final OfDouble C_DOUBLE = (OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); + public static final AddressLayout C_POINTER = ((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) + .withTargetLayout(MemoryLayout.sequenceLayout(Long.MAX_VALUE, C_CHAR)); + public static final OfLong C_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long"); + + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java new file mode 100644 index 0000000000000..ed264924d1550 --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java @@ -0,0 +1,197 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.kqueue; + +import java.lang.foreign.*; +import java.lang.invoke.*; + +public class kqueue_h extends kqueue_h$shared { + + kqueue_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + + private static final int EV_ADD = (int)1L; + /** + * {@snippet lang=c : + * #define EV_ADD 1 + * } + */ + public static int EV_ADD() { + return EV_ADD; + } + private static final int EV_DELETE = (int)2L; + /** + * {@snippet lang=c : + * #define EV_DELETE 2 + * } + */ + public static int EV_DELETE() { + return EV_DELETE; + } + private static final int EV_ONESHOT = (int)16L; + /** + * {@snippet lang=c : + * #define EV_ONESHOT 16 + * } + */ + public static int EV_ONESHOT() { + return EV_ONESHOT; + } + private static final int EV_CLEAR = (int)32L; + /** + * {@snippet lang=c : + * #define EV_CLEAR 32 + * } + */ + public static int EV_CLEAR() { + return EV_CLEAR; + } + + private static class kqueue { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + kqueue_h.C_INT ); + + public static final MemorySegment ADDR = SYMBOL_LOOKUP.findOrThrow("kqueue"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * int kqueue() + * } + */ + public static FunctionDescriptor kqueue$descriptor() { + return kqueue.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * int kqueue() + * } + */ + public static MethodHandle kqueue$handle() { + return kqueue.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * int kqueue() + * } + */ + public static MemorySegment kqueue$address() { + return kqueue.ADDR; + } + + /** + * {@snippet lang=c : + * int kqueue() + * } + */ + public static int kqueue() { + var mh$ = kqueue.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("kqueue"); + } + return (int)mh$.invokeExact(); + } catch (Error | RuntimeException ex) { + throw ex; + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static class kevent { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + kqueue_h.C_INT, + kqueue_h.C_INT, + kqueue_h.C_POINTER, + kqueue_h.C_INT, + kqueue_h.C_POINTER, + kqueue_h.C_INT, + kqueue_h.C_POINTER + ); + + public static final MemorySegment ADDR = SYMBOL_LOOKUP.findOrThrow("kevent"); + + public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + /** + * Function descriptor for: + * {@snippet lang=c : + * int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout) + * } + */ + public static FunctionDescriptor kevent$descriptor() { + return kevent.DESC; + } + + /** + * Downcall method handle for: + * {@snippet lang=c : + * int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout) + * } + */ + public static MethodHandle kevent$handle() { + return kevent.HANDLE; + } + + /** + * Address for: + * {@snippet lang=c : + * int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout) + * } + */ + public static MemorySegment kevent$address() { + return kevent.ADDR; + } + + /** + * {@snippet lang=c : + * int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout) + * } + */ + public static int kevent(int kq, MemorySegment changelist, int nchanges, MemorySegment eventlist, int nevents, MemorySegment timeout) { + var mh$ = kevent.HANDLE; + try { + if (TRACE_DOWNCALLS) { + traceDowncall("kevent", kq, changelist, nchanges, eventlist, nevents, timeout); + } + return (int)mh$.invokeExact(kq, changelist, nchanges, eventlist, nevents, timeout); + } catch (Error | RuntimeException ex) { + throw ex; + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + private static final int EVFILT_READ = (int)-1L; + /** + * {@snippet lang=c : + * #define EVFILT_READ -1 + * } + */ + public static int EVFILT_READ() { + return EVFILT_READ; + } + private static final int EVFILT_WRITE = (int)-2L; + /** + * {@snippet lang=c : + * #define EVFILT_WRITE -2 + * } + */ + public static int EVFILT_WRITE() { + return EVFILT_WRITE; + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java new file mode 100644 index 0000000000000..6bf607ec230bd --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Defines native structures for Kqueue socket APIs. + * Generated with the following jextract command: + * {@snippet lang = "Shell Script": + * + * HEADER_NAME=kqueue.h + * echo "#include " > $HEADER_NAME + * echo "#include " >> $HEADER_NAME + * + * + * jextract --target-package jdk.internal.natives.net.kqueue \ + * --include-constant EV_CLEAR \ + * --include-constant EV_ONESHOT \ + * --include-constant EV_DELETE \ + * --include-constant EV_ADD \ + * --include-constant EVFILT_WRITE \ + * --include-constant EVFILT_READ \ + * --include-function kevent \ + * --include-function kqueue \ + * --include-struct kevent \ + * $HEADER_NAME + * } + * + */ + +package jdk.internal.ffi.generated.kqueue; \ No newline at end of file diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java new file mode 100644 index 0000000000000..0941b92d7407b --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * Defines native structures for timespec APIs. + * Generated with the following jextract command: + * {@snippet lang = "Shell Script": + * + * HEADER_NAME=timespec.h + * echo "#include " > $HEADER_NAME + * + * jextract --target-package jdk.internal.ffi.generated.timespec \ + * --include-struct timespec \ + * $HEADER_NAME + * } + * + */ + +package jdk.internal.ffi.generated.timespec; \ No newline at end of file diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java new file mode 100644 index 0000000000000..6b675c2306aa2 --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java @@ -0,0 +1,169 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.timespec; + +import java.lang.foreign.*; +import java.util.function.*; + +import static java.lang.foreign.MemoryLayout.PathElement.*; +import static java.lang.foreign.ValueLayout.*; + +/** + * {@snippet lang=c : + * struct timespec { + * __darwin_time_t tv_sec; + * long tv_nsec; + * } + * } + */ +public class timespec { + + timespec() { + // Should not be called directly + } + + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( + timespec_h.C_LONG.withName("tv_sec"), + timespec_h.C_LONG.withName("tv_nsec") + ).withName("timespec"); + + /** + * The layout of this struct + */ + public static final GroupLayout layout() { + return $LAYOUT; + } + + private static final OfLong tv_sec$LAYOUT = (OfLong)$LAYOUT.select(groupElement("tv_sec")); + + /** + * Layout for field: + * {@snippet lang=c : + * __darwin_time_t tv_sec + * } + */ + public static final OfLong tv_sec$layout() { + return tv_sec$LAYOUT; + } + + private static final long tv_sec$OFFSET = $LAYOUT.byteOffset(groupElement("tv_sec")); + + /** + * Offset for field: + * {@snippet lang=c : + * __darwin_time_t tv_sec + * } + */ + public static final long tv_sec$offset() { + return tv_sec$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * __darwin_time_t tv_sec + * } + */ + public static long tv_sec(MemorySegment struct) { + return struct.get(tv_sec$LAYOUT, tv_sec$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * __darwin_time_t tv_sec + * } + */ + public static void tv_sec(MemorySegment struct, long fieldValue) { + struct.set(tv_sec$LAYOUT, tv_sec$OFFSET, fieldValue); + } + + private static final OfLong tv_nsec$LAYOUT = (OfLong)$LAYOUT.select(groupElement("tv_nsec")); + + /** + * Layout for field: + * {@snippet lang=c : + * long tv_nsec + * } + */ + public static final OfLong tv_nsec$layout() { + return tv_nsec$LAYOUT; + } + + private static final long tv_nsec$OFFSET = $LAYOUT.byteOffset(groupElement("tv_nsec")); + + /** + * Offset for field: + * {@snippet lang=c : + * long tv_nsec + * } + */ + public static final long tv_nsec$offset() { + return tv_nsec$OFFSET; + } + + /** + * Getter for field: + * {@snippet lang=c : + * long tv_nsec + * } + */ + public static long tv_nsec(MemorySegment struct) { + return struct.get(tv_nsec$LAYOUT, tv_nsec$OFFSET); + } + + /** + * Setter for field: + * {@snippet lang=c : + * long tv_nsec + * } + */ + public static void tv_nsec(MemorySegment struct, long fieldValue) { + struct.set(tv_nsec$LAYOUT, tv_nsec$OFFSET, fieldValue); + } + + /** + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} + */ + public static MemorySegment asSlice(MemorySegment array, long index) { + return array.asSlice(layout().byteSize() * index); + } + + /** + * The size (in bytes) of this struct + */ + public static long sizeof() { return layout().byteSize(); } + + /** + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} + */ + public static MemorySegment allocate(SegmentAllocator allocator) { + return allocator.allocate(layout()); + } + + /** + * Allocate an array of size {@code elementCount} using {@code allocator}. + * The returned segment has size {@code elementCount * layout().byteSize()}. + */ + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) { + return reinterpret(addr, 1, arena, cleanup); + } + + /** + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). + * The returned segment has size {@code elementCount * layout().byteSize()} + */ + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) { + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java new file mode 100644 index 0000000000000..058fcb15bca7b --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java @@ -0,0 +1,60 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.timespec; + +import java.lang.foreign.*; +import java.lang.invoke.*; +import java.util.*; +import java.util.stream.*; + +import static java.lang.foreign.ValueLayout.*; + +public class timespec_h$shared { + + timespec_h$shared() { + // Should not be called directly + } + + public static final OfBoolean C_BOOL = (OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); + public static final OfByte C_CHAR =(OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); + public static final OfShort C_SHORT = (OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); + public static final OfInt C_INT = (OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); + public static final OfLong C_LONG_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long long"); + public static final OfFloat C_FLOAT = (OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); + public static final OfDouble C_DOUBLE = (OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); + public static final AddressLayout C_POINTER = ((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) + .withTargetLayout(MemoryLayout.sequenceLayout(Long.MAX_VALUE, C_CHAR)); + public static final OfLong C_LONG = (OfLong) Linker.nativeLinker().canonicalLayouts().get("long"); + + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); + + static void traceDowncall(String name, Object... args) { + String traceArgs = Arrays.stream(args) + .map(Object::toString) + .collect(Collectors.joining(", ")); + System.out.printf("%s(%s)\n", name, traceArgs); + } + + static MethodHandle upcallHandle(Class fi, String name, FunctionDescriptor fdesc) { + try { + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); + } catch (ReflectiveOperationException ex) { + throw new AssertionError(ex); + } + } + + static MemoryLayout align(MemoryLayout layout, long align) { + return switch (layout) { + case PaddingLayout p -> p; + case ValueLayout v -> v.withByteAlignment(align); + case GroupLayout g -> { + MemoryLayout[] alignedMembers = g.memberLayouts().stream() + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); + yield g instanceof StructLayout ? + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); + } + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); + }; + } +} + diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java new file mode 100644 index 0000000000000..761c6dfe3dfce --- /dev/null +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java @@ -0,0 +1,19 @@ +// Generated by jextract + +package jdk.internal.ffi.generated.timespec; + +import java.lang.foreign.*; + +public class timespec_h extends timespec_h$shared { + + timespec_h() { + // Should not be called directly + } + + static final Arena LIBRARY_ARENA = Arena.ofAuto(); + + static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.loaderLookup() + .or(Linker.nativeLinker().defaultLookup()); + +} + From 4e3cec35346d99298fbcfd121e5ab1afe2cc4572 Mon Sep 17 00:00:00 2001 From: Darragh Clarke Date: Tue, 30 Sep 2025 12:27:16 +0100 Subject: [PATCH 2/4] re-added the copyright headers --- .../ffi/generated/errno/errno_h$shared.java | 25 +++++++++++++++++++ .../internal/ffi/generated/errno/errno_h.java | 25 +++++++++++++++++++ .../internal/ffi/generated/kqueue/kevent.java | 25 +++++++++++++++++++ .../ffi/generated/kqueue/kqueue_h$shared.java | 25 +++++++++++++++++++ .../ffi/generated/kqueue/kqueue_h.java | 25 +++++++++++++++++++ .../ffi/generated/timespec/timespec.java | 25 +++++++++++++++++++ .../generated/timespec/timespec_h$shared.java | 25 +++++++++++++++++++ .../ffi/generated/timespec/timespec_h.java | 25 +++++++++++++++++++ 8 files changed, 200 insertions(+) diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java index d1fe3ce46384c..8aedc7ec80e72 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.errno; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java index 764ddcc2ab03c..28c9057e4f8c1 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.errno; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java index e717dfb6f7d22..fbf5398104575 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.kqueue; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java index 61e074b01b7c2..b092c1ffd1527 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.kqueue; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java index ed264924d1550..07d23dd0d6aa5 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.kqueue; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java index 6b675c2306aa2..035817b61abec 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.timespec; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java index 058fcb15bca7b..c813dd19c4a48 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.timespec; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java index 761c6dfe3dfce..cea38579007fe 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2024, 2025 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + // Generated by jextract package jdk.internal.ffi.generated.timespec; From 53c387e4fa5149bc6e7dc8955e8dc8d9385ff0fa Mon Sep 17 00:00:00 2001 From: Darragh Clarke Date: Wed, 1 Oct 2025 11:43:01 +0100 Subject: [PATCH 3/4] added warning supression for restricted methods, fixed missing comma in copyright header --- .../jdk/internal/ffi/generated/errno/errno_h$shared.java | 1 + .../classes/jdk/internal/ffi/generated/errno/errno_h.java | 1 + .../classes/jdk/internal/ffi/generated/kqueue/kevent.java | 1 + .../jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java | 1 + .../classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java | 1 + .../classes/jdk/internal/ffi/generated/timespec/timespec.java | 1 + .../jdk/internal/ffi/generated/timespec/timespec_h$shared.java | 1 + .../classes/jdk/internal/ffi/generated/timespec/timespec_h.java | 2 +- 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java index 8aedc7ec80e72..02a7c1751ffdf 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java @@ -34,6 +34,7 @@ import static java.lang.foreign.ValueLayout.*; +@SuppressWarnings("restricted") public class errno_h$shared { errno_h$shared() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java index 28c9057e4f8c1..eb20ab6df31d6 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java @@ -30,6 +30,7 @@ import java.lang.foreign.*; import java.lang.invoke.*; +@SuppressWarnings("restricted") public class errno_h extends errno_h$shared { errno_h() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java index fbf5398104575..da24464a359d3 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java @@ -45,6 +45,7 @@ * } * } */ +@SuppressWarnings("restricted") public class kevent { kevent() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java index b092c1ffd1527..1aa192dc9b8ed 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java @@ -34,6 +34,7 @@ import static java.lang.foreign.ValueLayout.*; +@SuppressWarnings("restricted") public class kqueue_h$shared { kqueue_h$shared() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java index 07d23dd0d6aa5..bdd34d9aa10e9 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java @@ -30,6 +30,7 @@ import java.lang.foreign.*; import java.lang.invoke.*; +@SuppressWarnings("restricted") public class kqueue_h extends kqueue_h$shared { kqueue_h() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java index 035817b61abec..ab683889368bf 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java @@ -41,6 +41,7 @@ * } * } */ +@SuppressWarnings("restricted") public class timespec { timespec() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java index c813dd19c4a48..c8e7b7e9c45be 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java @@ -34,6 +34,7 @@ import static java.lang.foreign.ValueLayout.*; +@SuppressWarnings("restricted") public class timespec_h$shared { timespec_h$shared() { diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java index cea38579007fe..781f62b5cd809 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From d7b43cbc3bc75bd91b3213a12c0cec7999cc5614 Mon Sep 17 00:00:00 2001 From: Darragh Clarke Date: Mon, 6 Oct 2025 11:11:36 +0100 Subject: [PATCH 4/4] Addressed comment and fixed newlines at end of files --- .../jdk/internal/ffi/generated/errno/errno_h$shared.java | 1 - .../classes/jdk/internal/ffi/generated/errno/errno_h.java | 1 - .../jdk/internal/ffi/generated/errno/package-info.java | 2 +- .../classes/jdk/internal/ffi/generated/kqueue/kevent.java | 1 - .../jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java | 1 - .../classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java | 1 - .../jdk/internal/ffi/generated/kqueue/package-info.java | 4 ++-- .../jdk/internal/ffi/generated/timespec/package-info.java | 2 +- .../classes/jdk/internal/ffi/generated/timespec/timespec.java | 1 - .../internal/ffi/generated/timespec/timespec_h$shared.java | 3 +-- .../jdk/internal/ffi/generated/timespec/timespec_h.java | 1 - 11 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java index 02a7c1751ffdf..dbb8f91ad920a 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h$shared.java @@ -83,4 +83,3 @@ static MemoryLayout align(MemoryLayout layout, long align) { }; } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java index eb20ab6df31d6..7fdc152e91338 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/errno_h.java @@ -114,4 +114,3 @@ public static int strerror_r(int __errnum, MemorySegment __strerrbuf, long __buf } } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java index 7b28292c8c064..2a29f198b2a78 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/errno/package-info.java @@ -40,4 +40,4 @@ * */ -package jdk.internal.ffi.generated.errno; \ No newline at end of file +package jdk.internal.ffi.generated.errno; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java index da24464a359d3..22bbf57bcfa8e 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kevent.java @@ -376,4 +376,3 @@ public static MemorySegment reinterpret(MemorySegment addr, long elementCount, A return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java index 1aa192dc9b8ed..662916d4e8d99 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h$shared.java @@ -83,4 +83,3 @@ static MemoryLayout align(MemoryLayout layout, long align) { }; } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java index bdd34d9aa10e9..2ba04f53ea86d 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/kqueue_h.java @@ -220,4 +220,3 @@ public static int EVFILT_WRITE() { return EVFILT_WRITE; } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java index 6bf607ec230bd..ce372c87b749e 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/kqueue/package-info.java @@ -33,7 +33,7 @@ * echo "#include " >> $HEADER_NAME * * - * jextract --target-package jdk.internal.natives.net.kqueue \ + * jextract --target-package jdk.internal.ffi.generated.kqueue \ * --include-constant EV_CLEAR \ * --include-constant EV_ONESHOT \ * --include-constant EV_DELETE \ @@ -48,4 +48,4 @@ * */ -package jdk.internal.ffi.generated.kqueue; \ No newline at end of file +package jdk.internal.ffi.generated.kqueue; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java index 0941b92d7407b..850991e61fc51 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/package-info.java @@ -38,4 +38,4 @@ * */ -package jdk.internal.ffi.generated.timespec; \ No newline at end of file +package jdk.internal.ffi.generated.timespec; diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java index ab683889368bf..bee0caf26fc5c 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec.java @@ -192,4 +192,3 @@ public static MemorySegment reinterpret(MemorySegment addr, long elementCount, A return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java index c8e7b7e9c45be..6af5bb12e0c3a 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h$shared.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,4 +83,3 @@ static MemoryLayout align(MemoryLayout layout, long align) { }; } } - diff --git a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java index 781f62b5cd809..e1470fcf43f67 100644 --- a/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java +++ b/src/java.base/macosx/classes/jdk/internal/ffi/generated/timespec/timespec_h.java @@ -41,4 +41,3 @@ public class timespec_h extends timespec_h$shared { .or(Linker.nativeLinker().defaultLookup()); } -