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

me.bechberger.ebpf.bpf.raw.bpf_stack_build_id 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_stack_build_id {
 *     __s32 status;
 *     unsigned char build_id[20];
 *     union {
 *         __u64 offset;
 *         __u64 ip;
 *     };
 * }
 * }
 */
public class bpf_stack_build_id {

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

    private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
        Lib.C_INT.withName("status"),
        MemoryLayout.sequenceLayout(20, Lib.C_CHAR).withName("build_id"),
        MemoryLayout.unionLayout(
            Lib.C_LONG_LONG.withName("offset"),
            Lib.C_LONG_LONG.withName("ip")
        ).withName("$anon$1448:2")
    ).withName("bpf_stack_build_id");

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

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

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

    private static final long status$OFFSET = 0;

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

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

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

    private static final SequenceLayout build_id$LAYOUT = (SequenceLayout)$LAYOUT.select(groupElement("build_id"));

    /**
     * Layout for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static final SequenceLayout build_id$layout() {
        return build_id$LAYOUT;
    }

    private static final long build_id$OFFSET = 4;

    /**
     * Offset for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static final long build_id$offset() {
        return build_id$OFFSET;
    }

    /**
     * Getter for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static MemorySegment build_id(MemorySegment struct) {
        return struct.asSlice(build_id$OFFSET, build_id$LAYOUT.byteSize());
    }

    /**
     * Setter for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static void build_id(MemorySegment struct, MemorySegment fieldValue) {
        MemorySegment.copy(fieldValue, 0L, struct, build_id$OFFSET, build_id$LAYOUT.byteSize());
    }

    private static long[] build_id$DIMS = { 20 };

    /**
     * Dimensions for array field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static long[] build_id$dimensions() {
        return build_id$DIMS;
    }
    private static final VarHandle build_id$ELEM_HANDLE = build_id$LAYOUT.varHandle(sequenceElement());

    /**
     * Indexed getter for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static byte build_id(MemorySegment struct, long index0) {
        return (byte)build_id$ELEM_HANDLE.get(struct, 0L, index0);
    }

    /**
     * Indexed setter for field:
     * {@snippet lang=c :
     * unsigned char build_id[20]
     * }
     */
    public static void build_id(MemorySegment struct, long index0, byte fieldValue) {
        build_id$ELEM_HANDLE.set(struct, 0L, index0, fieldValue);
    }

    private static final OfLong offset$LAYOUT = (OfLong)$LAYOUT.select(groupElement("$anon$1448:2"), groupElement("offset"));

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

    private static final long offset$OFFSET = 24;

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

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

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

    private static final OfLong ip$LAYOUT = (OfLong)$LAYOUT.select(groupElement("$anon$1448:2"), groupElement("ip"));

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

    private static final long ip$OFFSET = 24;

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

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

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