< prev index next >

test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java

Print this page
*** 20,50 ***
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  package org.openjdk.bench.jdk.incubator.foreign.points.support;
  
  import jdk.incubator.foreign.FunctionDescriptor;
- import jdk.incubator.foreign.SymbolLookup;
  import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.MemoryLayout;
  import jdk.incubator.foreign.MemorySegment;
- import jdk.incubator.foreign.CLinker;
  import jdk.incubator.foreign.ResourceScope;
  
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.VarHandle;
  
  import static java.lang.invoke.MethodType.methodType;
  import static jdk.incubator.foreign.MemoryLayout.PathElement.groupElement;
- import static jdk.incubator.foreign.CLinker.*;
  
! public class PanamaPoint implements AutoCloseable {
  
      public static final MemoryLayout LAYOUT = MemoryLayout.structLayout(
          C_INT.withName("x"),
          C_INT.withName("y")
      );
  
!     private static final VarHandle VH_x = LAYOUT.varHandle(int.class, groupElement("x"));
!     private static final VarHandle VH_y = LAYOUT.varHandle(int.class, groupElement("y"));
      private static final MethodHandle MH_distance;
      private static final MethodHandle MH_distance_ptrs;
  
      static {
!         CLinker abi = CLinker.getInstance();
          System.loadLibrary("Point");
          SymbolLookup lookup = SymbolLookup.loaderLookup();
          MH_distance = abi.downcallHandle(
              lookup.lookup("distance").get(),
!             methodType(double.class, MemorySegment.class, MemorySegment.class),
-             FunctionDescriptor.of(C_DOUBLE, LAYOUT, LAYOUT)
          );
          MH_distance_ptrs = abi.downcallHandle(
!             lookup.lookup("distance_ptrs").get(),
!             methodType(double.class, MemoryAddress.class, MemoryAddress.class),
-             FunctionDescriptor.of(C_DOUBLE, C_POINTER, C_POINTER)
          );
      }
  
      private final MemorySegment segment;
  
--- 20,48 ---
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  package org.openjdk.bench.jdk.incubator.foreign.points.support;
  
+ import jdk.incubator.foreign.CLinker;
  import jdk.incubator.foreign.FunctionDescriptor;
  import jdk.incubator.foreign.MemoryAddress;
+ import jdk.incubator.foreign.SymbolLookup;
  import jdk.incubator.foreign.MemoryLayout;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
+ import org.openjdk.bench.jdk.incubator.foreign.CLayouts;
  
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.VarHandle;
  
  import static java.lang.invoke.MethodType.methodType;
  import static jdk.incubator.foreign.MemoryLayout.PathElement.groupElement;
  
! public class PanamaPoint extends CLayouts implements AutoCloseable {
  
      public static final MemoryLayout LAYOUT = MemoryLayout.structLayout(
          C_INT.withName("x"),
          C_INT.withName("y")
      );
  
!     private static final VarHandle VH_x = LAYOUT.varHandle(groupElement("x"));
!     private static final VarHandle VH_y = LAYOUT.varHandle(groupElement("y"));
      private static final MethodHandle MH_distance;
      private static final MethodHandle MH_distance_ptrs;
  
      static {
!         CLinker abi = CLinker.systemCLinker();
          System.loadLibrary("Point");
          SymbolLookup lookup = SymbolLookup.loaderLookup();
          MH_distance = abi.downcallHandle(
              lookup.lookup("distance").get(),
!                 FunctionDescriptor.of(C_DOUBLE, LAYOUT, LAYOUT)
          );
          MH_distance_ptrs = abi.downcallHandle(
!                 lookup.lookup("distance_ptrs").get(),
!                 FunctionDescriptor.of(C_DOUBLE, C_POINTER, C_POINTER)
          );
      }
  
      private final MemorySegment segment;
  
< prev index next >