| 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 | 
|---|
| 3 | // BSD-style license that can be found in the LICENSE file. | 
|---|
| 4 |  | 
|---|
| 5 | #include "platform/globals.h" | 
|---|
| 6 | #if defined(HOST_OS_FUCHSIA) | 
|---|
| 7 |  | 
|---|
| 8 | #include "bin/extensions.h" | 
|---|
| 9 |  | 
|---|
| 10 | #include <dlfcn.h> | 
|---|
| 11 | #include <fcntl.h> | 
|---|
| 12 | #include <lib/fdio/io.h> | 
|---|
| 13 | #include <zircon/dlfcn.h> | 
|---|
| 14 |  | 
|---|
| 15 | #include "platform/assert.h" | 
|---|
| 16 |  | 
|---|
| 17 | namespace dart { | 
|---|
| 18 | namespace bin { | 
|---|
| 19 |  | 
|---|
| 20 | void* Extensions::LoadExtensionLibrary(const char* library_file) { | 
|---|
| 21 | return dlopen(library_file, RTLD_LAZY); | 
|---|
| 22 | } | 
|---|
| 23 |  | 
|---|
| 24 | void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 
|---|
| 25 | dlerror(); | 
|---|
| 26 | return dlsym(lib_handle, symbol); | 
|---|
| 27 | } | 
|---|
| 28 |  | 
|---|
| 29 | void Extensions::UnloadLibrary(void* lib_handle) { | 
|---|
| 30 | dlerror(); | 
|---|
| 31 | int result = dlclose(lib_handle); | 
|---|
| 32 | ASSERT(result == 0); | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | Dart_Handle Extensions::GetError() { | 
|---|
| 36 | const char* err_str = dlerror(); | 
|---|
| 37 | if (err_str != NULL) { | 
|---|
| 38 | return Dart_NewApiError(err_str); | 
|---|
| 39 | } | 
|---|
| 40 | return Dart_Null(); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | }  // namespace bin | 
|---|
| 44 | }  // namespace dart | 
|---|
| 45 |  | 
|---|
| 46 | #endif  // defined(HOST_OS_FUCHSIA) | 
|---|
| 47 |  | 
|---|