1 | // Copyright (c) 2012, 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_ANDROID) |
7 | |
8 | #include <dlfcn.h> // NOLINT |
9 | #include "bin/extensions.h" |
10 | |
11 | #include "platform/assert.h" |
12 | |
13 | namespace dart { |
14 | namespace bin { |
15 | |
16 | void* Extensions::LoadExtensionLibrary(const char* library_file) { |
17 | return dlopen(library_file, RTLD_LAZY); |
18 | } |
19 | |
20 | void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
21 | dlerror(); |
22 | return dlsym(lib_handle, symbol); |
23 | } |
24 | |
25 | void Extensions::UnloadLibrary(void* lib_handle) { |
26 | dlerror(); |
27 | int result = dlclose(lib_handle); |
28 | ASSERT(result == 0); |
29 | } |
30 | |
31 | Dart_Handle Extensions::GetError() { |
32 | const char* err_str = dlerror(); |
33 | if (err_str != NULL) { |
34 | return Dart_NewApiError(err_str); |
35 | } |
36 | return Dart_Null(); |
37 | } |
38 | |
39 | } // namespace bin |
40 | } // namespace dart |
41 | |
42 | #endif // defined(HOST_OS_ANDROID) |
43 | |