1 // Generated by jextract 2 3 package jdk.internal.ffi.generated.iouring; 4 5 import java.lang.invoke.*; 6 import java.lang.foreign.*; 7 import java.nio.ByteOrder; 8 import java.util.*; 9 import java.util.function.*; 10 import java.util.stream.*; 11 12 import static java.lang.foreign.ValueLayout.*; 13 import static java.lang.foreign.MemoryLayout.PathElement.*; 14 15 /** 16 * {@snippet lang=c : 17 * struct __kernel_timespec { 18 * __kernel_time64_t tv_sec; 19 * long long tv_nsec; 20 * } 21 * } 22 */ 23 @SuppressWarnings("restricted") public class __kernel_timespec { 24 25 __kernel_timespec() { 26 // Suppresses public default constructor, ensuring non-instantiability, 27 // but allows generated subclasses in same package. 28 } 29 30 private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( 31 iouring_h.C_LONG_LONG.withName("tv_sec"), 32 iouring_h.C_LONG_LONG.withName("tv_nsec") 33 ).withName("__kernel_timespec"); 34 35 public static final GroupLayout $LAYOUT() { 36 return $LAYOUT; 37 } 38 39 private static final long tv_sec$OFFSET = 0; 40 private static final OfLong tv_sec$LAYOUT = (OfLong)$LAYOUT.select(groupElement("tv_sec")); 41 42 /** 43 * Getter for field: 44 * {@snippet lang=c : 45 * __kernel_time64_t tv_sec 46 * } 47 */ 48 public static long tv_sec(MemorySegment struct) { 49 return struct.get(tv_sec$LAYOUT, tv_sec$OFFSET); 50 } 51 52 /** 53 * Setter for field: 54 * {@snippet lang=c : 55 * __kernel_time64_t tv_sec 56 * } 57 */ 58 public static void tv_sec(MemorySegment struct, long fieldValue) { 59 struct.set(tv_sec$LAYOUT, tv_sec$OFFSET, fieldValue); 60 } 61 62 private static final long tv_nsec$OFFSET = 8; 63 private static final OfLong tv_nsec$LAYOUT = (OfLong)$LAYOUT.select(groupElement("tv_nsec")); 64 65 /** 66 * Getter for field: 67 * {@snippet lang=c : 68 * long long tv_nsec 69 * } 70 */ 71 public static long tv_nsec(MemorySegment struct) { 72 return struct.get(tv_nsec$LAYOUT, tv_nsec$OFFSET); 73 } 74 75 /** 76 * Setter for field: 77 * {@snippet lang=c : 78 * long long tv_nsec 79 * } 80 */ 81 public static void tv_nsec(MemorySegment struct, long fieldValue) { 82 struct.set(tv_nsec$LAYOUT, tv_nsec$OFFSET, fieldValue); 83 } 84 85 public static MemorySegment asSlice(MemorySegment array, long index) { 86 return array.asSlice($LAYOUT().byteSize() * index); 87 } 88 89 public static long sizeof() { return $LAYOUT().byteSize(); } 90 91 public static MemorySegment allocate(SegmentAllocator allocator) { 92 return allocator.allocate($LAYOUT()); 93 } 94 95 public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { 96 return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, $LAYOUT())); 97 } 98 99 public static MemorySegment reinterpret(MemorySegment addr, Arena scope, Consumer<MemorySegment> cleanup) { 100 return reinterpret(addr, 1, scope, cleanup); 101 } 102 103 public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena scope, Consumer<MemorySegment> cleanup) { 104 return addr.reinterpret($LAYOUT().byteSize() * elementCount, scope, cleanup); 105 } 106 } 107