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 iovec {
 18  *     void *iov_base;
 19  *     size_t iov_len;
 20  * }
 21  * }
 22  */
 23 @SuppressWarnings("restricted") public class iovec {
 24 
 25     iovec() {
 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_POINTER.withName("iov_base"),
 32         iouring_h.C_LONG.withName("iov_len")
 33     ).withName("iovec");
 34 
 35     public static final GroupLayout $LAYOUT() {
 36         return $LAYOUT;
 37     }
 38 
 39     private static final long iov_base$OFFSET = 0;
 40     private static final AddressLayout iov_base$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("iov_base"));
 41 
 42     /**
 43      * Getter for field:
 44      * {@snippet lang=c :
 45      * void *iov_base
 46      * }
 47      */
 48     public static MemorySegment iov_base(MemorySegment struct) {
 49         return struct.get(iov_base$LAYOUT, iov_base$OFFSET);
 50     }
 51 
 52     /**
 53      * Setter for field:
 54      * {@snippet lang=c :
 55      * void *iov_base
 56      * }
 57      */
 58     public static void iov_base(MemorySegment struct, MemorySegment fieldValue) {
 59         struct.set(iov_base$LAYOUT, iov_base$OFFSET, fieldValue);
 60     }
 61 
 62     private static final long iov_len$OFFSET = 8;
 63     private static final OfLong iov_len$LAYOUT = (OfLong)$LAYOUT.select(groupElement("iov_len"));
 64 
 65     /**
 66      * Getter for field:
 67      * {@snippet lang=c :
 68      * size_t iov_len
 69      * }
 70      */
 71     public static long iov_len(MemorySegment struct) {
 72         return struct.get(iov_len$LAYOUT, iov_len$OFFSET);
 73     }
 74 
 75     /**
 76      * Setter for field:
 77      * {@snippet lang=c :
 78      * size_t iov_len
 79      * }
 80      */
 81     public static void iov_len(MemorySegment struct, long fieldValue) {
 82         struct.set(iov_len$LAYOUT, iov_len$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