< prev index next >

src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java

Print this page
@@ -63,10 +63,16 @@
      static MemorySegment floatType() { return NativeConstants.FLOAT_TYPE; }
      static MemorySegment doubleType() { return NativeConstants.DOUBLE_TYPE; }
      static MemorySegment pointerType() { return NativeConstants.POINTER_TYPE; }
      static MemorySegment voidType() { return NativeConstants.VOID_TYPE; }
  
+     // platform-dependent types
+     static int shortSize() { return NativeConstants.SIZEOF_SHORT; }
+     static int intSize() { return NativeConstants.SIZEOF_INT; }
+     static int longSize() {return NativeConstants.SIZEOF_LONG; }
+     static int wcharSize() {return NativeConstants.SIZEOF_WCHAR; }
+ 
      static short structTag() { return NativeConstants.STRUCT_TAG; }
  
      private static final MethodType UPCALL_TARGET_TYPE = MethodType.methodType(void.class, MemorySegment.class, MemorySegment.class);
  
      /**

@@ -220,10 +226,14 @@
      private static native long ffi_type_uint64();
      private static native long ffi_type_sint64();
      private static native long ffi_type_float();
      private static native long ffi_type_double();
      private static native long ffi_type_pointer();
+     private static native int ffi_sizeof_short();
+     private static native int ffi_sizeof_int();
+     private static native int ffi_sizeof_long();
+     private static native int ffi_sizeof_wchar();
  
      // put these in a separate class to avoid an UnsatisfiedLinkError
      // when LibFallback is initialized but the library is not present
      private static final class NativeConstants {
          private NativeConstants() {}

@@ -237,10 +247,15 @@
          static final MemorySegment SINT32_TYPE = MemorySegment.ofAddress(ffi_type_sint32());
          static final MemorySegment SINT64_TYPE = MemorySegment.ofAddress(ffi_type_sint64());
          static final MemorySegment FLOAT_TYPE = MemorySegment.ofAddress(ffi_type_float());
          static final MemorySegment DOUBLE_TYPE = MemorySegment.ofAddress(ffi_type_double());
          static final MemorySegment POINTER_TYPE = MemorySegment.ofAddress(ffi_type_pointer());
+         static final int SIZEOF_SHORT = ffi_sizeof_short();
+         static final int SIZEOF_INT = ffi_sizeof_int();
+         static final int SIZEOF_LONG = ffi_sizeof_long();
+         static final int SIZEOF_WCHAR = ffi_sizeof_wchar();
+ 
  
          static final MemorySegment VOID_TYPE = MemorySegment.ofAddress(ffi_type_void());
          static final short STRUCT_TAG = ffi_type_struct();
          static final long SIZEOF_CIF = sizeofCif();
      }
< prev index next >