All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.bechberger.ebpf.bpf.raw.bpf_test_run_opts Maven / Gradle / Ivy

The newest version!
// Generated by jextract

package me.bechberger.ebpf.bpf.raw;

import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;

/**
 * {@snippet lang=c :
 * struct bpf_test_run_opts {
 *     size_t sz;
 *     const void *data_in;
 *     void *data_out;
 *     __u32 data_size_in;
 *     __u32 data_size_out;
 *     const void *ctx_in;
 *     void *ctx_out;
 *     __u32 ctx_size_in;
 *     __u32 ctx_size_out;
 *     __u32 retval;
 *     int repeat;
 *     __u32 duration;
 *     __u32 flags;
 *     __u32 cpu;
 *     __u32 batch_size;
 * }
 * }
 */
public class bpf_test_run_opts {

    bpf_test_run_opts() {
        // Should not be called directly
    }

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_LONG.withName("sz"),
        Lib.C_POINTER.withName("data_in"),
        Lib.C_POINTER.withName("data_out"),
        Lib.C_INT.withName("data_size_in"),
        Lib.C_INT.withName("data_size_out"),
        Lib.C_POINTER.withName("ctx_in"),
        Lib.C_POINTER.withName("ctx_out"),
        Lib.C_INT.withName("ctx_size_in"),
        Lib.C_INT.withName("ctx_size_out"),
        Lib.C_INT.withName("retval"),
        Lib.C_INT.withName("repeat"),
        Lib.C_INT.withName("duration"),
        Lib.C_INT.withName("flags"),
        Lib.C_INT.withName("cpu"),
        Lib.C_INT.withName("batch_size")
    ).withName("bpf_test_run_opts");

    /**
     * The layout of this struct
     */
    public static final GroupLayout layout() {
        return $LAYOUT;
    }

    private static final OfLong sz$LAYOUT = (OfLong)$LAYOUT.select(groupElement("sz"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static final OfLong sz$layout() {
        return sz$LAYOUT;
    }

    private static final long sz$OFFSET = 0;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static final long sz$offset() {
        return sz$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static long sz(MemorySegment struct) {
        return struct.get(sz$LAYOUT, sz$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * size_t sz
     * }
     */
    public static void sz(MemorySegment struct, long fieldValue) {
        struct.set(sz$LAYOUT, sz$OFFSET, fieldValue);
    }

    private static final AddressLayout data_in$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("data_in"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const void *data_in
     * }
     */
    public static final AddressLayout data_in$layout() {
        return data_in$LAYOUT;
    }

    private static final long data_in$OFFSET = 8;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * const void *data_in
     * }
     */
    public static final long data_in$offset() {
        return data_in$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * const void *data_in
     * }
     */
    public static MemorySegment data_in(MemorySegment struct) {
        return struct.get(data_in$LAYOUT, data_in$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * const void *data_in
     * }
     */
    public static void data_in(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(data_in$LAYOUT, data_in$OFFSET, fieldValue);
    }

    private static final AddressLayout data_out$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("data_out"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * void *data_out
     * }
     */
    public static final AddressLayout data_out$layout() {
        return data_out$LAYOUT;
    }

    private static final long data_out$OFFSET = 16;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * void *data_out
     * }
     */
    public static final long data_out$offset() {
        return data_out$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * void *data_out
     * }
     */
    public static MemorySegment data_out(MemorySegment struct) {
        return struct.get(data_out$LAYOUT, data_out$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * void *data_out
     * }
     */
    public static void data_out(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(data_out$LAYOUT, data_out$OFFSET, fieldValue);
    }

    private static final OfInt data_size_in$LAYOUT = (OfInt)$LAYOUT.select(groupElement("data_size_in"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 data_size_in
     * }
     */
    public static final OfInt data_size_in$layout() {
        return data_size_in$LAYOUT;
    }

    private static final long data_size_in$OFFSET = 24;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 data_size_in
     * }
     */
    public static final long data_size_in$offset() {
        return data_size_in$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 data_size_in
     * }
     */
    public static int data_size_in(MemorySegment struct) {
        return struct.get(data_size_in$LAYOUT, data_size_in$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 data_size_in
     * }
     */
    public static void data_size_in(MemorySegment struct, int fieldValue) {
        struct.set(data_size_in$LAYOUT, data_size_in$OFFSET, fieldValue);
    }

    private static final OfInt data_size_out$LAYOUT = (OfInt)$LAYOUT.select(groupElement("data_size_out"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 data_size_out
     * }
     */
    public static final OfInt data_size_out$layout() {
        return data_size_out$LAYOUT;
    }

    private static final long data_size_out$OFFSET = 28;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 data_size_out
     * }
     */
    public static final long data_size_out$offset() {
        return data_size_out$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 data_size_out
     * }
     */
    public static int data_size_out(MemorySegment struct) {
        return struct.get(data_size_out$LAYOUT, data_size_out$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 data_size_out
     * }
     */
    public static void data_size_out(MemorySegment struct, int fieldValue) {
        struct.set(data_size_out$LAYOUT, data_size_out$OFFSET, fieldValue);
    }

    private static final AddressLayout ctx_in$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("ctx_in"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * const void *ctx_in
     * }
     */
    public static final AddressLayout ctx_in$layout() {
        return ctx_in$LAYOUT;
    }

    private static final long ctx_in$OFFSET = 32;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * const void *ctx_in
     * }
     */
    public static final long ctx_in$offset() {
        return ctx_in$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * const void *ctx_in
     * }
     */
    public static MemorySegment ctx_in(MemorySegment struct) {
        return struct.get(ctx_in$LAYOUT, ctx_in$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * const void *ctx_in
     * }
     */
    public static void ctx_in(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(ctx_in$LAYOUT, ctx_in$OFFSET, fieldValue);
    }

    private static final AddressLayout ctx_out$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("ctx_out"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * void *ctx_out
     * }
     */
    public static final AddressLayout ctx_out$layout() {
        return ctx_out$LAYOUT;
    }

    private static final long ctx_out$OFFSET = 40;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * void *ctx_out
     * }
     */
    public static final long ctx_out$offset() {
        return ctx_out$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * void *ctx_out
     * }
     */
    public static MemorySegment ctx_out(MemorySegment struct) {
        return struct.get(ctx_out$LAYOUT, ctx_out$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * void *ctx_out
     * }
     */
    public static void ctx_out(MemorySegment struct, MemorySegment fieldValue) {
        struct.set(ctx_out$LAYOUT, ctx_out$OFFSET, fieldValue);
    }

    private static final OfInt ctx_size_in$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ctx_size_in"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 ctx_size_in
     * }
     */
    public static final OfInt ctx_size_in$layout() {
        return ctx_size_in$LAYOUT;
    }

    private static final long ctx_size_in$OFFSET = 48;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 ctx_size_in
     * }
     */
    public static final long ctx_size_in$offset() {
        return ctx_size_in$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 ctx_size_in
     * }
     */
    public static int ctx_size_in(MemorySegment struct) {
        return struct.get(ctx_size_in$LAYOUT, ctx_size_in$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 ctx_size_in
     * }
     */
    public static void ctx_size_in(MemorySegment struct, int fieldValue) {
        struct.set(ctx_size_in$LAYOUT, ctx_size_in$OFFSET, fieldValue);
    }

    private static final OfInt ctx_size_out$LAYOUT = (OfInt)$LAYOUT.select(groupElement("ctx_size_out"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 ctx_size_out
     * }
     */
    public static final OfInt ctx_size_out$layout() {
        return ctx_size_out$LAYOUT;
    }

    private static final long ctx_size_out$OFFSET = 52;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 ctx_size_out
     * }
     */
    public static final long ctx_size_out$offset() {
        return ctx_size_out$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 ctx_size_out
     * }
     */
    public static int ctx_size_out(MemorySegment struct) {
        return struct.get(ctx_size_out$LAYOUT, ctx_size_out$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 ctx_size_out
     * }
     */
    public static void ctx_size_out(MemorySegment struct, int fieldValue) {
        struct.set(ctx_size_out$LAYOUT, ctx_size_out$OFFSET, fieldValue);
    }

    private static final OfInt retval$LAYOUT = (OfInt)$LAYOUT.select(groupElement("retval"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 retval
     * }
     */
    public static final OfInt retval$layout() {
        return retval$LAYOUT;
    }

    private static final long retval$OFFSET = 56;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 retval
     * }
     */
    public static final long retval$offset() {
        return retval$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 retval
     * }
     */
    public static int retval(MemorySegment struct) {
        return struct.get(retval$LAYOUT, retval$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 retval
     * }
     */
    public static void retval(MemorySegment struct, int fieldValue) {
        struct.set(retval$LAYOUT, retval$OFFSET, fieldValue);
    }

    private static final OfInt repeat$LAYOUT = (OfInt)$LAYOUT.select(groupElement("repeat"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * int repeat
     * }
     */
    public static final OfInt repeat$layout() {
        return repeat$LAYOUT;
    }

    private static final long repeat$OFFSET = 60;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * int repeat
     * }
     */
    public static final long repeat$offset() {
        return repeat$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * int repeat
     * }
     */
    public static int repeat(MemorySegment struct) {
        return struct.get(repeat$LAYOUT, repeat$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * int repeat
     * }
     */
    public static void repeat(MemorySegment struct, int fieldValue) {
        struct.set(repeat$LAYOUT, repeat$OFFSET, fieldValue);
    }

    private static final OfInt duration$LAYOUT = (OfInt)$LAYOUT.select(groupElement("duration"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 duration
     * }
     */
    public static final OfInt duration$layout() {
        return duration$LAYOUT;
    }

    private static final long duration$OFFSET = 64;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 duration
     * }
     */
    public static final long duration$offset() {
        return duration$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 duration
     * }
     */
    public static int duration(MemorySegment struct) {
        return struct.get(duration$LAYOUT, duration$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 duration
     * }
     */
    public static void duration(MemorySegment struct, int fieldValue) {
        struct.set(duration$LAYOUT, duration$OFFSET, fieldValue);
    }

    private static final OfInt flags$LAYOUT = (OfInt)$LAYOUT.select(groupElement("flags"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 flags
     * }
     */
    public static final OfInt flags$layout() {
        return flags$LAYOUT;
    }

    private static final long flags$OFFSET = 68;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 flags
     * }
     */
    public static final long flags$offset() {
        return flags$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 flags
     * }
     */
    public static int flags(MemorySegment struct) {
        return struct.get(flags$LAYOUT, flags$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 flags
     * }
     */
    public static void flags(MemorySegment struct, int fieldValue) {
        struct.set(flags$LAYOUT, flags$OFFSET, fieldValue);
    }

    private static final OfInt cpu$LAYOUT = (OfInt)$LAYOUT.select(groupElement("cpu"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 cpu
     * }
     */
    public static final OfInt cpu$layout() {
        return cpu$LAYOUT;
    }

    private static final long cpu$OFFSET = 72;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 cpu
     * }
     */
    public static final long cpu$offset() {
        return cpu$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 cpu
     * }
     */
    public static int cpu(MemorySegment struct) {
        return struct.get(cpu$LAYOUT, cpu$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 cpu
     * }
     */
    public static void cpu(MemorySegment struct, int fieldValue) {
        struct.set(cpu$LAYOUT, cpu$OFFSET, fieldValue);
    }

    private static final OfInt batch_size$LAYOUT = (OfInt)$LAYOUT.select(groupElement("batch_size"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * __u32 batch_size
     * }
     */
    public static final OfInt batch_size$layout() {
        return batch_size$LAYOUT;
    }

    private static final long batch_size$OFFSET = 76;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * __u32 batch_size
     * }
     */
    public static final long batch_size$offset() {
        return batch_size$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * __u32 batch_size
     * }
     */
    public static int batch_size(MemorySegment struct) {
        return struct.get(batch_size$LAYOUT, batch_size$OFFSET);
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 batch_size
     * }
     */
    public static void batch_size(MemorySegment struct, int fieldValue) {
        struct.set(batch_size$LAYOUT, batch_size$OFFSET, fieldValue);
    }

    /**
     * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
     * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
     */
    public static MemorySegment asSlice(MemorySegment array, long index) {
        return array.asSlice(layout().byteSize() * index);
    }

    /**
     * The size (in bytes) of this struct
     */
    public static long sizeof() { return layout().byteSize(); }

    /**
     * Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
     */
    public static MemorySegment allocate(SegmentAllocator allocator) {
        return allocator.allocate(layout());
    }

    /**
     * Allocate an array of size {@code elementCount} using {@code allocator}.
     * The returned segment has size {@code elementCount * layout().byteSize()}.
     */
    public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
        return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
        return reinterpret(addr, 1, arena, cleanup);
    }

    /**
     * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any).
     * The returned segment has size {@code elementCount * layout().byteSize()}
     */
    public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
        return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy