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

me.bechberger.ebpf.bpf.raw.bpf_btf_info 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_btf_info {
 *     __u64 btf;
 *     __u32 btf_size;
 *     __u32 id;
 *     __u64 name;
 *     __u32 name_len;
 *     __u32 kernel_btf;
 * }
 * }
 */
public class bpf_btf_info {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_LONG_LONG.withName("btf"),
        Lib.C_INT.withName("btf_size"),
        Lib.C_INT.withName("id"),
        Lib.C_LONG_LONG.withName("name"),
        Lib.C_INT.withName("name_len"),
        Lib.C_INT.withName("kernel_btf")
    ).withName("bpf_btf_info");

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

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

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

    private static final long btf$OFFSET = 0;

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

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

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

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

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

    private static final long btf_size$OFFSET = 8;

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

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

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

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

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

    private static final long id$OFFSET = 12;

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

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

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

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

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

    private static final long name$OFFSET = 16;

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

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

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

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

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

    private static final long name_len$OFFSET = 24;

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

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

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

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

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

    private static final long kernel_btf$OFFSET = 28;

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

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

    /**
     * Setter for field:
     * {@snippet lang=c :
     * __u32 kernel_btf
     * }
     */
    public static void kernel_btf(MemorySegment struct, int fieldValue) {
        struct.set(kernel_btf$LAYOUT, kernel_btf$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