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

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

Issue 2986803002: [Fuchsia] Fixes and cleanup for launchpad_vmo_from_file() deprecation (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | runtime/bin/process_fuchsia.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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(HOST_OS_FUCHSIA) 6 #if defined(HOST_OS_FUCHSIA)
7 7
8 #include "bin/extensions.h" 8 #include "bin/extensions.h"
9 9
10 #include <dlfcn.h> 10 #include <dlfcn.h>
11 #include <fcntl.h>
11 #include <launchpad/vmo.h> 12 #include <launchpad/vmo.h>
12 #include <magenta/dlfcn.h> 13 #include <magenta/dlfcn.h>
14 #include <mxio/io.h>
13 15
14 #include "platform/assert.h" 16 #include "platform/assert.h"
15 17
16 namespace dart { 18 namespace dart {
17 namespace bin { 19 namespace bin {
18 20
19 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData"; 21 const char* kVmSnapshotDataSymbolName = "_kDartVmSnapshotData";
20 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions"; 22 const char* kVmSnapshotInstructionsSymbolName = "_kDartVmSnapshotInstructions";
21 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData"; 23 const char* kIsolateSnapshotDataSymbolName = "_kDartIsolateSnapshotData";
22 const char* kIsolateSnapshotInstructionsSymbolName = 24 const char* kIsolateSnapshotInstructionsSymbolName =
23 "_kDartIsolateSnapshotInstructions"; 25 "_kDartIsolateSnapshotInstructions";
24 26
25 void* Extensions::LoadExtensionLibrary(const char* library_file) { 27 void* Extensions::LoadExtensionLibrary(const char* library_file) {
26 mx_handle_t vmo = launchpad_vmo_from_file(library_file); 28 int fd = open(library_file, O_RDONLY);
27 if (vmo <= 0) { 29 if (fd < 0) {
30 return NULL;
31 }
32 mx_handle_t vmo;
33 mx_status_t status = mxio_get_vmo(fd, &vmo);
34 close(fd);
35 if (status != MX_OK) {
28 return NULL; 36 return NULL;
29 } 37 }
30 return dlopen_vmo(vmo, RTLD_LAZY); 38 return dlopen_vmo(vmo, RTLD_LAZY);
31 } 39 }
32 40
33 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) { 41 void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
34 dlerror(); 42 dlerror();
35 return dlsym(lib_handle, symbol); 43 return dlsym(lib_handle, symbol);
36 } 44 }
37 45
38 void Extensions::UnloadLibrary(void* lib_handle) { 46 void Extensions::UnloadLibrary(void* lib_handle) {
39 dlerror(); 47 dlerror();
40 int result = dlclose(lib_handle); 48 int result = dlclose(lib_handle);
41 ASSERT(result == 0); 49 ASSERT(result == 0);
42 } 50 }
43 51
44 Dart_Handle Extensions::GetError() { 52 Dart_Handle Extensions::GetError() {
45 const char* err_str = dlerror(); 53 const char* err_str = dlerror();
46 if (err_str != NULL) { 54 if (err_str != NULL) {
47 return Dart_NewApiError(err_str); 55 return Dart_NewApiError(err_str);
48 } 56 }
49 return Dart_Null(); 57 return Dart_Null();
50 } 58 }
51 59
52 } // namespace bin 60 } // namespace bin
53 } // namespace dart 61 } // namespace dart
54 62
55 #endif // defined(HOST_OS_FUCHSIA) 63 #endif // defined(HOST_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/process_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698