Ejemplo n.º 1
0
  public void testLookupGlobalVariable() {
    NativeLibrary lib = NativeLibrary.getInstance("testlib");
    Pointer global = lib.getGlobalVariableAddress("test_global");
    assertNotNull("Test variable not found", global);
    final int MAGIC = 0x12345678;
    assertEquals("Wrong value for library global variable", MAGIC, global.getInt(0));

    global.setInt(0, MAGIC + 1);
    assertEquals("Library global variable not updated", MAGIC + 1, global.getInt(0));
  }
Ejemplo n.º 2
0
  @Override
  public void fromNative(Runtime runtime, Pointer memory, long offset) {
    switch (runtime.findType(typeAlias).getNativeType()) {
      case SCHAR:
      case UCHAR:
        value = memory.getByte(offset);
        break;

      case SSHORT:
      case USHORT:
        value = memory.getShort(offset);
        break;

      case SINT:
      case UINT:
        value = memory.getInt(offset);
        break;

      case SLONG:
      case ULONG:
        value = memory.getLong(offset);
        break;

      case SLONGLONG:
      case ULONGLONG:
        value = memory.getLongLong(offset);
        break;

      case ADDRESS:
        value = memory.getAddress(offset);
        break;

      case FLOAT:
        value = memory.getFloat(offset);
        break;

      case DOUBLE:
        value = memory.getDouble(offset);
        break;

      default:
        throw new UnsupportedOperationException("unsupported type: " + typeAlias);
    }
  }
Ejemplo n.º 3
0
 public int h_errno() {
   return h_errnoPtr.getInt(0);
 }