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 * union epoll_data {
18 * void *ptr;
19 * int fd;
20 * uint32_t u32;
21 * uint64_t u64;
22 * }
23 * }
24 */
25 @SuppressWarnings("restricted") public class epoll_data {
26
27 epoll_data() {
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.unionLayout(
33 iouring_h.C_POINTER.withName("ptr"),
34 iouring_h.C_INT.withName("fd"),
35 iouring_h.C_INT.withName("u32"),
36 iouring_h.C_LONG.withName("u64")
37 ).withName("epoll_data");
38
39 public static final GroupLayout $LAYOUT() {
40 return $LAYOUT;
41 }
42
43 private static final long ptr$OFFSET = 0;
44 private static final AddressLayout ptr$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("ptr"));
45
46 /**
47 * Getter for field:
48 * {@snippet lang=c :
49 * void *ptr
50 * }
51 */
52 public static MemorySegment ptr(MemorySegment union) {
53 return union.get(ptr$LAYOUT, ptr$OFFSET);
54 }
55
56 /**
57 * Setter for field:
58 * {@snippet lang=c :
59 * void *ptr
60 * }
61 */
62 public static void ptr(MemorySegment union, MemorySegment fieldValue) {
63 union.set(ptr$LAYOUT, ptr$OFFSET, fieldValue);
64 }
65
66 private static final long fd$OFFSET = 0;
67 private static final OfInt fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("fd"));
68
69 /**
70 * Getter for field:
71 * {@snippet lang=c :
72 * int fd
73 * }
74 */
75 public static int fd(MemorySegment union) {
76 return union.get(fd$LAYOUT, fd$OFFSET);
77 }
78
79 /**
80 * Setter for field:
81 * {@snippet lang=c :
82 * int fd
83 * }
84 */
85 public static void fd(MemorySegment union, int fieldValue) {
86 union.set(fd$LAYOUT, fd$OFFSET, fieldValue);
87 }
88
89 private static final long u32$OFFSET = 0;
90 private static final OfInt u32$LAYOUT = (OfInt)$LAYOUT.select(groupElement("u32"));
91
92 /**
93 * Getter for field:
94 * {@snippet lang=c :
95 * uint32_t u32
96 * }
97 */
98 public static int u32(MemorySegment union) {
99 return union.get(u32$LAYOUT, u32$OFFSET);
100 }
101
102 /**
103 * Setter for field:
104 * {@snippet lang=c :
105 * uint32_t u32
106 * }
107 */
108 public static void u32(MemorySegment union, int fieldValue) {
109 union.set(u32$LAYOUT, u32$OFFSET, fieldValue);
110 }
111
112 private static final long u64$OFFSET = 0;
113 private static final OfLong u64$LAYOUT = (OfLong)$LAYOUT.select(groupElement("u64"));
114
115 /**
116 * Getter for field:
117 * {@snippet lang=c :
118 * uint64_t u64
119 * }
120 */
121 public static long u64(MemorySegment union) {
122 return union.get(u64$LAYOUT, u64$OFFSET);
123 }
124
125 /**
126 * Setter for field:
127 * {@snippet lang=c :
128 * uint64_t u64
129 * }
130 */
131 public static void u64(MemorySegment union, long fieldValue) {
132 union.set(u64$LAYOUT, u64$OFFSET, fieldValue);
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