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