me.bechberger.ebpf.bpf.raw.libbpf_print_fn_t Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rawbpf Show documentation
Show all versions of rawbpf Show documentation
Raw Panama bindings for libbpf generated for jextract on 64-bit Linux
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 :
* typedef int (*libbpf_print_fn_t)(enum libbpf_print_level {
* LIBBPF_WARN,
* LIBBPF_INFO,
* LIBBPF_DEBUG
* }, const char *, struct __va_list_tag {
* unsigned int gp_offset;
* unsigned int fp_offset;
* void *overflow_arg_area;
* void *reg_save_area;
* } *)
* }
*/
public class libbpf_print_fn_t {
libbpf_print_fn_t() {
// Should not be called directly
}
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(int level, MemorySegment _x1, MemorySegment ap);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
Lib.C_INT,
Lib.C_INT,
Lib.C_POINTER,
Lib.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = Lib.upcallHandle(libbpf_print_fn_t.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(libbpf_print_fn_t.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static int invoke(MemorySegment funcPtr,int level, MemorySegment _x1, MemorySegment ap) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, level, _x1, ap);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}