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