| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 void* Extensions::LoadExtensionLibrary(const char* library_path, | 15 void* Extensions::LoadExtensionLibrary(const char* library_file) { |
| 16 const char* extension_name) { | 16 return dlopen(library_file, RTLD_LAZY); |
| 17 const char* strings[] = { library_path, "/lib", | |
| 18 extension_name, ".so", NULL }; | |
| 19 char* library_file = Concatenate(strings); | |
| 20 void* lib_handle = dlopen(library_file, RTLD_LAZY); | |
| 21 free(library_file); | |
| 22 return lib_handle; | |
| 23 } | 17 } |
| 24 | 18 |
| 25 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { | 19 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { |
| 26 dlerror(); | 20 dlerror(); |
| 27 void* result = dlsym(lib_handle, symbol); | 21 void* result = dlsym(lib_handle, symbol); |
| 28 if (dlerror() != NULL) return NULL; | 22 if (dlerror() != NULL) return NULL; |
| 29 return result; | 23 return result; |
| 30 } | 24 } |
| 31 | 25 |
| 32 } // namespace bin | 26 } // namespace bin |
| 33 } // namespace dart | 27 } // namespace dart |
| 34 | 28 |
| 35 #endif // defined(TARGET_OS_LINUX) | 29 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |