import java.lang.invoke.*; import java.lang.foreign.*; import java.nio.ByteOrder; import java.util.*; import java.util.function.*; import java.util.stream.*; import static java.lang.foreign.ValueLayout.*; import static java.lang.foreign.MemoryLayout.PathElement.*; /** * {@snippet lang=c : * struct in6_addr { * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } __u6_addr; * } * } */ public class in6_addr { in6_addr() { // Should not be called directly } private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( in6_addr.union (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/netinet6/in6.h:153:2).layout().withName("__u6_addr") ).withName("in6_addr"); /** * The layout of this struct */ public static final GroupLayout layout() { return $LAYOUT; } /** * {@snippet lang=c : * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } * } */ public static class union (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/netinet6/in6.h:153:2) { union (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/netinet6/in6.h:153:2)() { // Should not be called directly } private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout( MemoryLayout.sequenceLayout(16, plc.C_CHAR).withName("__u6_addr8"), MemoryLayout.sequenceLayout(8, plc.C_SHORT).withName("__u6_addr16"), MemoryLayout.sequenceLayout(4, plc.C_INT).withName("__u6_addr32") ).withName("union (unnamed at /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/netinet6/in6.h:153:2)"); /** * The layout of this union */ public static final GroupLayout layout() { return $LAYOUT; } private static final SequenceLayout __u6_addr8$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("__u6_addr8")); /** * Layout for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static final SequenceLayout __u6_addr8$layout() { return __u6_addr8$LAYOUT; } private static final long __u6_addr8$OFFSET = 0; /** * Offset for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static final long __u6_addr8$offset() { return __u6_addr8$OFFSET; } /** * Getter for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static MemorySegment __u6_addr8(MemorySegment union) { return union.asSlice(__u6_addr8$OFFSET, __u6_addr8$LAYOUT.byteSize()); } /** * Setter for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static void __u6_addr8(MemorySegment union, MemorySegment fieldValue) { MemorySegment.copy(fieldValue, 0L, union, __u6_addr8$OFFSET, __u6_addr8$LAYOUT.byteSize()); } private static long[] __u6_addr8$DIMS = { 16 }; /** * Dimensions for array field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static long[] __u6_addr8$dimensions() { return __u6_addr8$DIMS; } private static final VarHandle __u6_addr8$ELEM_HANDLE = __u6_addr8$LAYOUT.varHandle(sequenceElement()); /** * Indexed getter for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static byte __u6_addr8(MemorySegment union, long index0) { return (byte)__u6_addr8$ELEM_HANDLE.get(union, 0L, index0); } /** * Indexed setter for field: * {@snippet lang=c : * __uint8_t __u6_addr8[16] * } */ public static void __u6_addr8(MemorySegment union, long index0, byte fieldValue) { __u6_addr8$ELEM_HANDLE.set(union, 0L, index0, fieldValue); } private static final SequenceLayout __u6_addr16$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("__u6_addr16")); /** * Layout for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static final SequenceLayout __u6_addr16$layout() { return __u6_addr16$LAYOUT; } private static final long __u6_addr16$OFFSET = 0; /** * Offset for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static final long __u6_addr16$offset() { return __u6_addr16$OFFSET; } /** * Getter for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static MemorySegment __u6_addr16(MemorySegment union) { return union.asSlice(__u6_addr16$OFFSET, __u6_addr16$LAYOUT.byteSize()); } /** * Setter for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static void __u6_addr16(MemorySegment union, MemorySegment fieldValue) { MemorySegment.copy(fieldValue, 0L, union, __u6_addr16$OFFSET, __u6_addr16$LAYOUT.byteSize()); } private static long[] __u6_addr16$DIMS = { 8 }; /** * Dimensions for array field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static long[] __u6_addr16$dimensions() { return __u6_addr16$DIMS; } private static final VarHandle __u6_addr16$ELEM_HANDLE = __u6_addr16$LAYOUT.varHandle(sequenceElement()); /** * Indexed getter for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static short __u6_addr16(MemorySegment union, long index0) { return (short)__u6_addr16$ELEM_HANDLE.get(union, 0L, index0); } /** * Indexed setter for field: * {@snippet lang=c : * __uint16_t __u6_addr16[8] * } */ public static void __u6_addr16(MemorySegment union, long index0, short fieldValue) { __u6_addr16$ELEM_HANDLE.set(union, 0L, index0, fieldValue); } private static final SequenceLayout __u6_addr32$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("__u6_addr32")); /** * Layout for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static final SequenceLayout __u6_addr32$layout() { return __u6_addr32$LAYOUT; } private static final long __u6_addr32$OFFSET = 0; /** * Offset for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static final long __u6_addr32$offset() { return __u6_addr32$OFFSET; } /** * Getter for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static MemorySegment __u6_addr32(MemorySegment union) { return union.asSlice(__u6_addr32$OFFSET, __u6_addr32$LAYOUT.byteSize()); } /** * Setter for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static void __u6_addr32(MemorySegment union, MemorySegment fieldValue) { MemorySegment.copy(fieldValue, 0L, union, __u6_addr32$OFFSET, __u6_addr32$LAYOUT.byteSize()); } private static long[] __u6_addr32$DIMS = { 4 }; /** * Dimensions for array field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static long[] __u6_addr32$dimensions() { return __u6_addr32$DIMS; } private static final VarHandle __u6_addr32$ELEM_HANDLE = __u6_addr32$LAYOUT.varHandle(sequenceElement()); /** * Indexed getter for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static int __u6_addr32(MemorySegment union, long index0) { return (int)__u6_addr32$ELEM_HANDLE.get(union, 0L, index0); } /** * Indexed setter for field: * {@snippet lang=c : * __uint32_t __u6_addr32[4] * } */ public static void __u6_addr32(MemorySegment union, long index0, int fieldValue) { __u6_addr32$ELEM_HANDLE.set(union, 0L, index0, 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 union */ 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<MemorySegment> 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<MemorySegment> cleanup) { return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); } } private static final GroupLayout __u6_addr$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("__u6_addr")); /** * Layout for field: * {@snippet lang=c : * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } __u6_addr * } */ public static final GroupLayout __u6_addr$layout() { return __u6_addr$LAYOUT; } private static final long __u6_addr$OFFSET = 0; /** * Offset for field: * {@snippet lang=c : * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } __u6_addr * } */ public static final long __u6_addr$offset() { return __u6_addr$OFFSET; } /** * Getter for field: * {@snippet lang=c : * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } __u6_addr * } */ public static MemorySegment __u6_addr(MemorySegment struct) { return struct.asSlice(__u6_addr$OFFSET, __u6_addr$LAYOUT.byteSize()); } /** * Setter for field: * {@snippet lang=c : * union { * __uint8_t __u6_addr8[16]; * __uint16_t __u6_addr16[8]; * __uint32_t __u6_addr32[4]; * } __u6_addr * } */ public static void __u6_addr(MemorySegment struct, MemorySegment fieldValue) { MemorySegment.copy(fieldValue, 0L, struct, __u6_addr$OFFSET, __u6_addr$LAYOUT.byteSize()); } /** * 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<MemorySegment> 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<MemorySegment> cleanup) { return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); } }