| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(HOST_OS_FUCHSIA) | 6 #if defined(HOST_OS_FUCHSIA) |
| 7 | 7 |
| 8 #include "bin/extensions.h" | 8 #include "bin/extensions.h" |
| 9 | 9 |
| 10 #include <dlfcn.h> | 10 #include <dlfcn.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 "_kDartIsolateSnapshotInstructions"; | 23 "_kDartIsolateSnapshotInstructions"; |
| 24 | 24 |
| 25 void* Extensions::LoadExtensionLibrary(const char* library_file) { | 25 void* Extensions::LoadExtensionLibrary(const char* library_file) { |
| 26 mx_handle_t vmo = launchpad_vmo_from_file(library_file); | 26 mx_handle_t vmo = launchpad_vmo_from_file(library_file); |
| 27 if (vmo <= 0) { | 27 if (vmo <= 0) { |
| 28 return NULL; | 28 return NULL; |
| 29 } | 29 } |
| 30 return dlopen_vmo(vmo, RTLD_LAZY); | 30 return dlopen_vmo(vmo, RTLD_LAZY); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | |
| 34 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 33 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
| 35 dlerror(); | 34 dlerror(); |
| 36 return dlsym(lib_handle, symbol); | 35 return dlsym(lib_handle, symbol); |
| 37 } | 36 } |
| 38 | 37 |
| 39 | |
| 40 void Extensions::UnloadLibrary(void* lib_handle) { | 38 void Extensions::UnloadLibrary(void* lib_handle) { |
| 41 dlerror(); | 39 dlerror(); |
| 42 int result = dlclose(lib_handle); | 40 int result = dlclose(lib_handle); |
| 43 ASSERT(result == 0); | 41 ASSERT(result == 0); |
| 44 } | 42 } |
| 45 | 43 |
| 46 | |
| 47 Dart_Handle Extensions::GetError() { | 44 Dart_Handle Extensions::GetError() { |
| 48 const char* err_str = dlerror(); | 45 const char* err_str = dlerror(); |
| 49 if (err_str != NULL) { | 46 if (err_str != NULL) { |
| 50 return Dart_NewApiError(err_str); | 47 return Dart_NewApiError(err_str); |
| 51 } | 48 } |
| 52 return Dart_Null(); | 49 return Dart_Null(); |
| 53 } | 50 } |
| 54 | 51 |
| 55 } // namespace bin | 52 } // namespace bin |
| 56 } // namespace dart | 53 } // namespace dart |
| 57 | 54 |
| 58 #endif // defined(HOST_OS_FUCHSIA) | 55 #endif // defined(HOST_OS_FUCHSIA) |
| OLD | NEW |