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 io_uring_cqe {
 18  *     __u64 user_data;
 19  *     __s32 res;
 20  *     __u32 flags;
 21  *     __u64 big_cqe[];
 22  * }
 23  * }
 24  */
 25 @SuppressWarnings("restricted") public class io_uring_cqe {
 26 
 27     io_uring_cqe() {
 28         // Suppresses public default constructor, ensuring non-instantiability,
 29         // but allows generated subclasses in same package.
 30     }
 31 
 32     private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
 33         iouring_h.C_LONG_LONG.withName("user_data"),
 34         iouring_h.C_INT.withName("res"),
 35         iouring_h.C_INT.withName("flags"),
 36         MemoryLayout.sequenceLayout(0, iouring_h.C_LONG_LONG).withName("big_cqe")
 37     ).withName("io_uring_cqe");
 38 
 39     public static final GroupLayout $LAYOUT() {
 40         return $LAYOUT;
 41     }
 42 
 43     private static final long user_data$OFFSET = 0;
 44     private static final OfLong user_data$LAYOUT = (OfLong)$LAYOUT.select(groupElement("user_data"));
 45 
 46     /**
 47      * Getter for field:
 48      * {@snippet lang=c :
 49      * __u64 user_data
 50      * }
 51      */
 52     public static long user_data(MemorySegment struct) {
 53         return struct.get(user_data$LAYOUT, user_data$OFFSET);
 54     }
 55 
 56     /**
 57      * Setter for field:
 58      * {@snippet lang=c :
 59      * __u64 user_data
 60      * }
 61      */
 62     public static void user_data(MemorySegment struct, long fieldValue) {
 63         struct.set(user_data$LAYOUT, user_data$OFFSET, fieldValue);
 64     }
 65 
 66     private static final long res$OFFSET = 8;
 67     private static final OfInt res$LAYOUT = (OfInt)$LAYOUT.select(groupElement("res"));
 68 
 69     /**
 70      * Getter for field:
 71      * {@snippet lang=c :
 72      * __s32 res
 73      * }
 74      */
 75     public static int res(MemorySegment struct) {
 76         return struct.get(res$LAYOUT, res$OFFSET);
 77     }
 78 
 79     /**
 80      * Setter for field:
 81      * {@snippet lang=c :
 82      * __s32 res
 83      * }
 84      */
 85     public static void res(MemorySegment struct, int fieldValue) {
 86         struct.set(res$LAYOUT, res$OFFSET, fieldValue);
 87     }
 88 
 89     private static final long flags$OFFSET = 12;
 90     private static final OfInt flags$LAYOUT = (OfInt)$LAYOUT.select(groupElement("flags"));
 91 
 92     /**
 93      * Getter for field:
 94      * {@snippet lang=c :
 95      * __u32 flags
 96      * }
 97      */
 98     public static int flags(MemorySegment struct) {
 99         return struct.get(flags$LAYOUT, flags$OFFSET);
100     }
101 
102     /**
103      * Setter for field:
104      * {@snippet lang=c :
105      * __u32 flags
106      * }
107      */
108     public static void flags(MemorySegment struct, int fieldValue) {
109         struct.set(flags$LAYOUT, flags$OFFSET, fieldValue);
110     }
111 
112     private static final long big_cqe$OFFSET = 16;
113     private static final long big_cqe$SIZE = 0;
114 
115     /**
116      * Getter for field:
117      * {@snippet lang=c :
118      * __u64 big_cqe[]
119      * }
120      */
121     public static MemorySegment big_cqe(MemorySegment struct) {
122         return struct.asSlice(big_cqe$OFFSET, big_cqe$SIZE);
123     }
124 
125     /**
126      * Setter for field:
127      * {@snippet lang=c :
128      * __u64 big_cqe[]
129      * }
130      */
131     public static void big_cqe(MemorySegment struct, MemorySegment fieldValue) {
132         MemorySegment.copy(fieldValue, 0L, struct, big_cqe$OFFSET, big_cqe$SIZE);
133     }
134 
135     public static MemorySegment asSlice(MemorySegment array, long index) {
136         return array.asSlice($LAYOUT().byteSize() * index);
137     }
138 
139     public static long sizeof() { return $LAYOUT().byteSize(); }
140 
141     public static MemorySegment allocate(SegmentAllocator allocator) {
142         return allocator.allocate($LAYOUT());
143     }
144 
145     public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
146         return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, $LAYOUT()));
147     }
148 
149     public static MemorySegment reinterpret(MemorySegment addr, Arena scope, Consumer<MemorySegment> cleanup) {
150         return reinterpret(addr, 1, scope, cleanup);
151     }
152 
153     public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena scope, Consumer<MemorySegment> cleanup) {
154         return addr.reinterpret($LAYOUT().byteSize() * elementCount, scope, cleanup);
155     }
156 }
157