Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.goliath.bindings.nvml.functions;
- import java.lang.invoke.MethodHandle;
- import java.lang.invoke.MethodType;
- import jdk.incubator.foreign.FunctionDescriptor;
- import jdk.incubator.foreign.MemoryAddress;
- import jdk.incubator.foreign.MemoryLayouts;
- import jdk.incubator.foreign.SystemABI;
- import org.goliath.bindings.nvml.main.nvml_h;
- import org.goliath.crosspoint.interfaces.NativeFunction;
- public record nvmlInit(MemoryAddress address, FunctionDescriptor descriptor, MethodType type, MethodHandle handle) implements NativeFunction
- {
- public static nvmlInit create() throws NoSuchMethodException
- {
- MemoryAddress address = nvml_h.LIBRARY_LOOKUP.lookup("nvmlInit");
- FunctionDescriptor descriptor = FunctionDescriptor.of(MemoryLayouts.C_INT);
- MethodType type = MethodType.methodType(int.class);
- MethodHandle handle = SystemABI.getInstance().downcallHandle(address, type, descriptor);
- return new nvmlInit(address, descriptor, type, handle);
- }
- public nvmlInit(MemoryAddress address, FunctionDescriptor descriptor, MethodType type, MethodHandle handle)
- {
- this.address = address;
- this.descriptor = descriptor;
- this.type = type;
- this.handle = handle;
- }
- @Override
- public Object call(Object... args) throws Throwable
- {
- return this.handle.invoke();
- }
- @Override
- public MemoryAddress getAddress()
- {
- return this.address;
- }
- @Override
- public FunctionDescriptor getDescriptor()
- {
- return this.descriptor;
- }
- @Override
- public MethodType getMethodType()
- {
- return this.type;
- }
- @Override
- public MethodHandle getMethodHandle()
- {
- return this.handle;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement