|
| 1 | +// Generated by jextract |
| 2 | + |
| 3 | +package net.codecrete.usb.linux.gen.epoll; |
| 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 | +public class epoll$shared { |
| 16 | + |
| 17 | + epoll$shared() { |
| 18 | + // Should not be called directly |
| 19 | + } |
| 20 | + |
| 21 | + public static final ValueLayout.OfBoolean C_BOOL = (ValueLayout.OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); |
| 22 | + public static final ValueLayout.OfByte C_CHAR =(ValueLayout.OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); |
| 23 | + public static final ValueLayout.OfShort C_SHORT = (ValueLayout.OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); |
| 24 | + public static final ValueLayout.OfInt C_INT = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); |
| 25 | + public static final ValueLayout.OfLong C_LONG_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("long long"); |
| 26 | + public static final ValueLayout.OfFloat C_FLOAT = (ValueLayout.OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); |
| 27 | + public static final ValueLayout.OfDouble C_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); |
| 28 | + public static final AddressLayout C_POINTER = ((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) |
| 29 | + .withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, C_CHAR)); |
| 30 | + public static final ValueLayout.OfLong C_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("long"); |
| 31 | + |
| 32 | + static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); |
| 33 | + |
| 34 | + static void traceDowncall(String name, Object... args) { |
| 35 | + String traceArgs = Arrays.stream(args) |
| 36 | + .map(Object::toString) |
| 37 | + .collect(Collectors.joining(", ")); |
| 38 | + System.out.printf("%s(%s)\n", name, traceArgs); |
| 39 | + } |
| 40 | + |
| 41 | + static MethodHandle upcallHandle(Class<?> fi, String name, FunctionDescriptor fdesc) { |
| 42 | + try { |
| 43 | + return MethodHandles.lookup().findVirtual(fi, name, fdesc.toMethodType()); |
| 44 | + } catch (ReflectiveOperationException ex) { |
| 45 | + throw new AssertionError(ex); |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + static MemoryLayout align(MemoryLayout layout, long align) { |
| 50 | + return switch (layout) { |
| 51 | + case PaddingLayout p -> p; |
| 52 | + case ValueLayout v -> v.withByteAlignment(align); |
| 53 | + case GroupLayout g -> { |
| 54 | + MemoryLayout[] alignedMembers = g.memberLayouts().stream() |
| 55 | + .map(m -> align(m, align)).toArray(MemoryLayout[]::new); |
| 56 | + yield g instanceof StructLayout ? |
| 57 | + MemoryLayout.structLayout(alignedMembers) : MemoryLayout.unionLayout(alignedMembers); |
| 58 | + } |
| 59 | + case SequenceLayout s -> MemoryLayout.sequenceLayout(s.elementCount(), align(s.elementLayout(), align)); |
| 60 | + }; |
| 61 | + } |
| 62 | +} |
| 63 | + |
0 commit comments