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

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

Issue 1401253004: Cleanup the extensions code to avoid the duplication that was introduced in the quick fix to turn t… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « runtime/bin/extensions_linux.cc ('k') | runtime/bin/extensions_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/assert.h"
6 #include "platform/globals.h" 5 #include "platform/globals.h"
7 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
8 7
9 #include "bin/extensions.h" 8 #include "bin/extensions.h"
10 #include <dlfcn.h> // NOLINT 9 #include <dlfcn.h> // NOLINT
11 10
12 11
13 namespace dart { 12 namespace dart {
14 namespace bin { 13 namespace bin {
15 14
16 const char* kPrecompiledLibraryName = "libprecompiled.dylib"; 15 const char* kPrecompiledLibraryName = "libprecompiled.dylib";
17 const char* kPrecompiledSymbolName = "kInstructionsSnapshot"; 16 const char* kPrecompiledSymbolName = "kInstructionsSnapshot";
18 17
19 Dart_Handle Extensions::LoadExtensionLibrary(const char* library_file,
20 void** library_handle) {
21 ASSERT(library_handle != NULL);
22 *library_handle = dlopen(library_file, RTLD_LAZY);
23 if (*library_handle == NULL) {
24 return Dart_NewApiError(dlerror());
25 }
26 return Dart_Null();
27 }
28
29 void* Extensions::LoadExtensionLibrary(const char* library_file) { 18 void* Extensions::LoadExtensionLibrary(const char* library_file) {
30 return dlopen(library_file, RTLD_LAZY); 19 return dlopen(library_file, RTLD_LAZY);
31 } 20 }
32 21
33 Dart_Handle Extensions::ResolveSymbol(void* lib_handle, 22 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
34 const char* symbol,
35 void** init_function) {
36 ASSERT(init_function != NULL);
37 dlerror(); 23 dlerror();
38 *init_function = dlsym(lib_handle, symbol); 24 return dlsym(lib_handle, symbol);
39 char* err_str = dlerror(); 25 }
26
27 Dart_Handle Extensions::GetError() {
28 const char* err_str = dlerror();
40 if (err_str != NULL) { 29 if (err_str != NULL) {
41 return Dart_NewApiError(err_str); 30 return Dart_NewApiError(err_str);
42 } 31 }
43 return Dart_Null(); 32 return Dart_Null();
44 } 33 }
45 34
46 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
47 dlerror();
48 void* result = dlsym(lib_handle, symbol);
49 if (dlerror() != NULL) return NULL;
50 return result;
51 }
52
53 } // namespace bin 35 } // namespace bin
54 } // namespace dart 36 } // namespace dart
55 37
56 #endif // defined(TARGET_OS_MACOS) 38 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/extensions_linux.cc ('k') | runtime/bin/extensions_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698