mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Daco Harkes](/assets/img/avatar_default.png)
I tested this test manually by reverting 48d92b3176
to confirm that it makes the test segfault.
Closes: https://github.com/dart-lang/sdk/issues/37511
Change-Id: I62cb2b83775780a2fccfd9ee4ebff793de82090a
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try, app-kernel-linux-debug-x64-try, vm-kernel-linux-debug-simdbc64-try,vm-kernel-linux-debug-ia32-try,vm-dartkb-linux-debug-simarm64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-dartkb-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109703
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// All imports must be in all FFI patch files to not depend on the order
|
|
// the patches are applied.
|
|
import "dart:_internal" show patch;
|
|
import 'dart:typed_data' show TypedData;
|
|
|
|
DynamicLibrary _open(String name) native "Ffi_dl_open";
|
|
DynamicLibrary _processLibrary() native "Ffi_dl_processLibrary";
|
|
DynamicLibrary _executableLibrary() native "Ffi_dl_executableLibrary";
|
|
|
|
@patch
|
|
@pragma("vm:entry-point")
|
|
class DynamicLibrary {
|
|
@patch
|
|
factory DynamicLibrary.open(String name) {
|
|
return _open(name);
|
|
}
|
|
|
|
@patch
|
|
factory DynamicLibrary.process() => _processLibrary();
|
|
|
|
@patch
|
|
factory DynamicLibrary.executable() => _executableLibrary();
|
|
|
|
@patch
|
|
Pointer<T> lookup<T extends NativeType>(String symbolName)
|
|
native "Ffi_dl_lookup";
|
|
|
|
// The real implementation of this function lives in FfiUseSiteTransformer
|
|
// for interface calls. Only dynamic calls (which are illegal) reach this
|
|
// implementation.
|
|
@patch
|
|
F lookupFunction<T extends Function, F extends Function>(String symbolName) {
|
|
throw UnsupportedError(
|
|
"Dynamic invocation of lookupFunction is not supported.");
|
|
}
|
|
|
|
// TODO(dacoharkes): Expose this to users, or extend Pointer?
|
|
// https://github.com/dart-lang/sdk/issues/35881
|
|
int getHandle() native "Ffi_dl_getHandle";
|
|
|
|
@patch
|
|
bool operator ==(other) {
|
|
if (other == null) return false;
|
|
return getHandle() == other.getHandle();
|
|
}
|
|
|
|
@patch
|
|
int get hashCode {
|
|
return getHandle().hashCode;
|
|
}
|
|
|
|
@patch
|
|
Pointer<Void> get handle => Pointer.fromAddress(getHandle());
|
|
}
|