1 // Generated by jextract
2
3 package oracle.code.onnx.foreign;
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 OrtSyncNotificationImpl {
18 * uint32_t ort_version_supported;
19 * void (*Release)(OrtSyncNotificationImpl *);
20 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *);
21 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *);
22 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *);
23 * }
24 * }
25 */
26 public class OrtSyncNotificationImpl {
27
28 OrtSyncNotificationImpl() {
29 // Should not be called directly
30 }
31
32 private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
33 onnxruntime_c_api_h.C_INT.withName("ort_version_supported"),
34 MemoryLayout.paddingLayout(4),
35 onnxruntime_c_api_h.C_POINTER.withName("Release"),
36 onnxruntime_c_api_h.C_POINTER.withName("Activate"),
37 onnxruntime_c_api_h.C_POINTER.withName("WaitOnDevice"),
38 onnxruntime_c_api_h.C_POINTER.withName("WaitOnHost")
39 ).withName("OrtSyncNotificationImpl");
40
41 /**
42 * The layout of this struct
43 */
44 public static final GroupLayout layout() {
45 return $LAYOUT;
46 }
47
48 private static final OfInt ort_version_supported$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ort_version_supported"));
49
50 /**
51 * Layout for field:
52 * {@snippet lang=c :
53 * uint32_t ort_version_supported
54 * }
55 */
56 public static final OfInt ort_version_supported$layout() {
57 return ort_version_supported$LAYOUT;
58 }
59
60 private static final long ort_version_supported$OFFSET = $LAYOUT.byteOffset(groupElement("ort_version_supported"));
61
62 /**
63 * Offset for field:
64 * {@snippet lang=c :
65 * uint32_t ort_version_supported
66 * }
67 */
68 public static final long ort_version_supported$offset() {
69 return ort_version_supported$OFFSET;
70 }
71
72 /**
73 * Getter for field:
74 * {@snippet lang=c :
75 * uint32_t ort_version_supported
76 * }
77 */
78 public static int ort_version_supported(MemorySegment struct) {
79 return struct.get(ort_version_supported$LAYOUT, ort_version_supported$OFFSET);
80 }
81
82 /**
83 * Setter for field:
84 * {@snippet lang=c :
85 * uint32_t ort_version_supported
86 * }
87 */
88 public static void ort_version_supported(MemorySegment struct, int fieldValue) {
89 struct.set(ort_version_supported$LAYOUT, ort_version_supported$OFFSET, fieldValue);
90 }
91
92 /**
93 * {@snippet lang=c :
94 * void (*Release)(OrtSyncNotificationImpl *)
95 * }
96 */
97 public final static class Release {
98
99 private Release() {
100 // Should not be called directly
101 }
102
103 /**
104 * The function pointer signature, expressed as a functional interface
105 */
106 public interface Function {
107 void apply(MemorySegment _x0);
108 }
109
110 private static final FunctionDescriptor $DESC = FunctionDescriptor.ofVoid(
111 onnxruntime_c_api_h.C_POINTER
112 );
113
114 /**
115 * The descriptor of this function pointer
116 */
117 public static FunctionDescriptor descriptor() {
118 return $DESC;
119 }
120
121 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(Release.Function.class, "apply", $DESC);
122
123 /**
124 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
125 * The lifetime of the returned segment is managed by {@code arena}
126 */
127 public static MemorySegment allocate(Release.Function fi, Arena arena) {
128 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
129 }
130
131 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
132
133 /**
134 * Invoke the upcall stub {@code funcPtr}, with given parameters
135 */
136 public static void invoke(MemorySegment funcPtr, MemorySegment _x0) {
137 try {
138 DOWN$MH.invokeExact(funcPtr, _x0);
139 } catch (Error | RuntimeException ex) {
140 throw ex;
141 } catch (Throwable ex$) {
142 throw new AssertionError("should not reach here", ex$);
143 }
144 }
145 }
146
147 private static final AddressLayout Release$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("Release"));
148
149 /**
150 * Layout for field:
151 * {@snippet lang=c :
152 * void (*Release)(OrtSyncNotificationImpl *)
153 * }
154 */
155 public static final AddressLayout Release$layout() {
156 return Release$LAYOUT;
157 }
158
159 private static final long Release$OFFSET = $LAYOUT.byteOffset(groupElement("Release"));
160
161 /**
162 * Offset for field:
163 * {@snippet lang=c :
164 * void (*Release)(OrtSyncNotificationImpl *)
165 * }
166 */
167 public static final long Release$offset() {
168 return Release$OFFSET;
169 }
170
171 /**
172 * Getter for field:
173 * {@snippet lang=c :
174 * void (*Release)(OrtSyncNotificationImpl *)
175 * }
176 */
177 public static MemorySegment Release(MemorySegment struct) {
178 return struct.get(Release$LAYOUT, Release$OFFSET);
179 }
180
181 /**
182 * Setter for field:
183 * {@snippet lang=c :
184 * void (*Release)(OrtSyncNotificationImpl *)
185 * }
186 */
187 public static void Release(MemorySegment struct, MemorySegment fieldValue) {
188 struct.set(Release$LAYOUT, Release$OFFSET, fieldValue);
189 }
190
191 /**
192 * {@snippet lang=c :
193 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *)
194 * }
195 */
196 public final static class Activate {
197
198 private Activate() {
199 // Should not be called directly
200 }
201
202 /**
203 * The function pointer signature, expressed as a functional interface
204 */
205 public interface Function {
206 MemorySegment apply(MemorySegment _x0);
207 }
208
209 private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
210 onnxruntime_c_api_h.C_POINTER,
211 onnxruntime_c_api_h.C_POINTER
212 );
213
214 /**
215 * The descriptor of this function pointer
216 */
217 public static FunctionDescriptor descriptor() {
218 return $DESC;
219 }
220
221 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(Activate.Function.class, "apply", $DESC);
222
223 /**
224 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
225 * The lifetime of the returned segment is managed by {@code arena}
226 */
227 public static MemorySegment allocate(Activate.Function fi, Arena arena) {
228 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
229 }
230
231 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
232
233 /**
234 * Invoke the upcall stub {@code funcPtr}, with given parameters
235 */
236 public static MemorySegment invoke(MemorySegment funcPtr, MemorySegment _x0) {
237 try {
238 return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
239 } catch (Error | RuntimeException ex) {
240 throw ex;
241 } catch (Throwable ex$) {
242 throw new AssertionError("should not reach here", ex$);
243 }
244 }
245 }
246
247 private static final AddressLayout Activate$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("Activate"));
248
249 /**
250 * Layout for field:
251 * {@snippet lang=c :
252 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *)
253 * }
254 */
255 public static final AddressLayout Activate$layout() {
256 return Activate$LAYOUT;
257 }
258
259 private static final long Activate$OFFSET = $LAYOUT.byteOffset(groupElement("Activate"));
260
261 /**
262 * Offset for field:
263 * {@snippet lang=c :
264 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *)
265 * }
266 */
267 public static final long Activate$offset() {
268 return Activate$OFFSET;
269 }
270
271 /**
272 * Getter for field:
273 * {@snippet lang=c :
274 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *)
275 * }
276 */
277 public static MemorySegment Activate(MemorySegment struct) {
278 return struct.get(Activate$LAYOUT, Activate$OFFSET);
279 }
280
281 /**
282 * Setter for field:
283 * {@snippet lang=c :
284 * OrtStatusPtr (*Activate)(OrtSyncNotificationImpl *)
285 * }
286 */
287 public static void Activate(MemorySegment struct, MemorySegment fieldValue) {
288 struct.set(Activate$LAYOUT, Activate$OFFSET, fieldValue);
289 }
290
291 /**
292 * {@snippet lang=c :
293 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *)
294 * }
295 */
296 public final static class WaitOnDevice {
297
298 private WaitOnDevice() {
299 // Should not be called directly
300 }
301
302 /**
303 * The function pointer signature, expressed as a functional interface
304 */
305 public interface Function {
306 MemorySegment apply(MemorySegment _x0, MemorySegment _x1);
307 }
308
309 private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
310 onnxruntime_c_api_h.C_POINTER,
311 onnxruntime_c_api_h.C_POINTER,
312 onnxruntime_c_api_h.C_POINTER
313 );
314
315 /**
316 * The descriptor of this function pointer
317 */
318 public static FunctionDescriptor descriptor() {
319 return $DESC;
320 }
321
322 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(WaitOnDevice.Function.class, "apply", $DESC);
323
324 /**
325 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
326 * The lifetime of the returned segment is managed by {@code arena}
327 */
328 public static MemorySegment allocate(WaitOnDevice.Function fi, Arena arena) {
329 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
330 }
331
332 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
333
334 /**
335 * Invoke the upcall stub {@code funcPtr}, with given parameters
336 */
337 public static MemorySegment invoke(MemorySegment funcPtr, MemorySegment _x0, MemorySegment _x1) {
338 try {
339 return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
340 } catch (Error | RuntimeException ex) {
341 throw ex;
342 } catch (Throwable ex$) {
343 throw new AssertionError("should not reach here", ex$);
344 }
345 }
346 }
347
348 private static final AddressLayout WaitOnDevice$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("WaitOnDevice"));
349
350 /**
351 * Layout for field:
352 * {@snippet lang=c :
353 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *)
354 * }
355 */
356 public static final AddressLayout WaitOnDevice$layout() {
357 return WaitOnDevice$LAYOUT;
358 }
359
360 private static final long WaitOnDevice$OFFSET = $LAYOUT.byteOffset(groupElement("WaitOnDevice"));
361
362 /**
363 * Offset for field:
364 * {@snippet lang=c :
365 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *)
366 * }
367 */
368 public static final long WaitOnDevice$offset() {
369 return WaitOnDevice$OFFSET;
370 }
371
372 /**
373 * Getter for field:
374 * {@snippet lang=c :
375 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *)
376 * }
377 */
378 public static MemorySegment WaitOnDevice(MemorySegment struct) {
379 return struct.get(WaitOnDevice$LAYOUT, WaitOnDevice$OFFSET);
380 }
381
382 /**
383 * Setter for field:
384 * {@snippet lang=c :
385 * OrtStatusPtr (*WaitOnDevice)(OrtSyncNotificationImpl *, OrtSyncStream *)
386 * }
387 */
388 public static void WaitOnDevice(MemorySegment struct, MemorySegment fieldValue) {
389 struct.set(WaitOnDevice$LAYOUT, WaitOnDevice$OFFSET, fieldValue);
390 }
391
392 /**
393 * {@snippet lang=c :
394 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *)
395 * }
396 */
397 public final static class WaitOnHost {
398
399 private WaitOnHost() {
400 // Should not be called directly
401 }
402
403 /**
404 * The function pointer signature, expressed as a functional interface
405 */
406 public interface Function {
407 MemorySegment apply(MemorySegment _x0);
408 }
409
410 private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
411 onnxruntime_c_api_h.C_POINTER,
412 onnxruntime_c_api_h.C_POINTER
413 );
414
415 /**
416 * The descriptor of this function pointer
417 */
418 public static FunctionDescriptor descriptor() {
419 return $DESC;
420 }
421
422 private static final MethodHandle UP$MH = onnxruntime_c_api_h.upcallHandle(WaitOnHost.Function.class, "apply", $DESC);
423
424 /**
425 * Allocates a new upcall stub, whose implementation is defined by {@code fi}.
426 * The lifetime of the returned segment is managed by {@code arena}
427 */
428 public static MemorySegment allocate(WaitOnHost.Function fi, Arena arena) {
429 return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
430 }
431
432 private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
433
434 /**
435 * Invoke the upcall stub {@code funcPtr}, with given parameters
436 */
437 public static MemorySegment invoke(MemorySegment funcPtr, MemorySegment _x0) {
438 try {
439 return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
440 } catch (Error | RuntimeException ex) {
441 throw ex;
442 } catch (Throwable ex$) {
443 throw new AssertionError("should not reach here", ex$);
444 }
445 }
446 }
447
448 private static final AddressLayout WaitOnHost$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("WaitOnHost"));
449
450 /**
451 * Layout for field:
452 * {@snippet lang=c :
453 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *)
454 * }
455 */
456 public static final AddressLayout WaitOnHost$layout() {
457 return WaitOnHost$LAYOUT;
458 }
459
460 private static final long WaitOnHost$OFFSET = $LAYOUT.byteOffset(groupElement("WaitOnHost"));
461
462 /**
463 * Offset for field:
464 * {@snippet lang=c :
465 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *)
466 * }
467 */
468 public static final long WaitOnHost$offset() {
469 return WaitOnHost$OFFSET;
470 }
471
472 /**
473 * Getter for field:
474 * {@snippet lang=c :
475 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *)
476 * }
477 */
478 public static MemorySegment WaitOnHost(MemorySegment struct) {
479 return struct.get(WaitOnHost$LAYOUT, WaitOnHost$OFFSET);
480 }
481
482 /**
483 * Setter for field:
484 * {@snippet lang=c :
485 * OrtStatusPtr (*WaitOnHost)(OrtSyncNotificationImpl *)
486 * }
487 */
488 public static void WaitOnHost(MemorySegment struct, MemorySegment fieldValue) {
489 struct.set(WaitOnHost$LAYOUT, WaitOnHost$OFFSET, fieldValue);
490 }
491
492 /**
493 * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
494 * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
495 */
496 public static MemorySegment asSlice(MemorySegment array, long index) {
497 return array.asSlice(layout().byteSize() * index);
498 }
499
500 /**
501 * The size (in bytes) of this struct
502 */
503 public static long sizeof() { return layout().byteSize(); }
504
505 /**
506 * Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
507 */
508 public static MemorySegment allocate(SegmentAllocator allocator) {
509 return allocator.allocate(layout());
510 }
511
512 /**
513 * Allocate an array of size {@code elementCount} using {@code allocator}.
514 * The returned segment has size {@code elementCount * layout().byteSize()}.
515 */
516 public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
517 return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
518 }
519
520 /**
521 * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
522 * The returned segment has size {@code layout().byteSize()}
523 */
524 public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer<MemorySegment> cleanup) {
525 return reinterpret(addr, 1, arena, cleanup);
526 }
527
528 /**
529 * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
530 * The returned segment has size {@code elementCount * layout().byteSize()}
531 */
532 public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer<MemorySegment> cleanup) {
533 return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
534 }
535 }
536