Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: runtime/bin/extensions_android.cc

Issue 186473003: Refactor native extension shared library lookup. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move a platform-independent block to extensions.cc Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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_ANDROID) 29 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698