Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "bin/extensions.h" | 8 #include "bin/extensions.h" |
| 9 #include <dlfcn.h> // NOLINT | 9 #include <dlfcn.h> // NOLINT |
| 10 | 10 |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 namespace bin { | 13 namespace bin { |
| 14 | 14 |
| 15 const char* kPrecompiledLibraryName = "libprecompiled.so"; | 15 const char* kPrecompiledLibraryName = "libprecompiled.so"; |
| 16 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot"; | 16 const char* kPrecompiledSymbolName = "_kInstructionsSnapshot"; |
| 17 | 17 |
| 18 void* Extensions::LoadExtensionLibrary(const char* library_file) { | 18 Dart_Handle Extensions::LoadExtensionLibrary(const char* library_file, |
| 19 return dlopen(library_file, RTLD_LAZY); | 19 void** library_handle) { |
| 20 ASSERT(library_handle != NULL); | |
| 21 *library_handle = dlopen(library_file, RTLD_LAZY); | |
| 22 if (*library_handle == NULL) { | |
| 23 return Dart_NewApiError(dlerror()); | |
| 24 } | |
| 25 return Dart_Null(); | |
| 20 } | 26 } |
| 21 | 27 |
| 22 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 28 Dart_Handle Extensions::ResolveSymbol(void* lib_handle, |
| 29 const char* symbol, | |
| 30 void** init_function) { | |
| 31 ASSERT(init_function != NULL); | |
| 23 dlerror(); | 32 dlerror(); |
| 24 void* result = dlsym(lib_handle, symbol); | 33 *init_function = dlsym(lib_handle, symbol); |
| 25 if (dlerror() != NULL) return NULL; | 34 char* err_str = dlerror(); |
| 26 return result; | 35 if (err_str != NULL) { |
| 36 return Dart_NewApiError(err_str); | |
|
Søren Gjesse
2015/10/14 07:00:25
Drop the temp err_str like above?
siva
2015/10/14 18:13:19
It is not possible to drop the temp err_str, see c
| |
| 37 } | |
| 38 return Dart_Null(); | |
| 27 } | 39 } |
| 28 | 40 |
| 29 } // namespace bin | 41 } // namespace bin |
| 30 } // namespace dart | 42 } // namespace dart |
| 31 | 43 |
| 32 #endif // defined(TARGET_OS_ANDROID) | 44 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |