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

Side by Side Diff: native_client_sdk/src/examples/dlopen/dlopen.cc

Issue 9383038: Build cleanups (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « native_client_sdk/src/examples/Makefile ('k') | native_client_sdk/src/examples/pong/view.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 Native Client Authors. All rights reserved. 1 // Copyright (c) 2012 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /// @file 5 /// @file
6 /// This example demonstrates building a dynamic library which is loaded by the 6 /// This example demonstrates building a dynamic library which is loaded by the
7 /// NaCl module. To load the NaCl module, the browser first looks for the 7 /// NaCl module. To load the NaCl module, the browser first looks for the
8 /// CreateModule() factory method (at the end of this file). It calls 8 /// CreateModule() factory method (at the end of this file). It calls
9 /// CreateModule() once to load the module code from your .nexe. After the 9 /// CreateModule() once to load the module code from your .nexe. After the
10 /// .nexe code is loaded, CreateModule() is not called again. 10 /// .nexe code is loaded, CreateModule() is not called again.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 // This function will run on the main thread and use the handle it stored by 76 // This function will run on the main thread and use the handle it stored by
77 // the worker thread, assuming it successfully loaded, to get a pointer to the 77 // the worker thread, assuming it successfully loaded, to get a pointer to the
78 // message function in the shared object. 78 // message function in the shared object.
79 void UseLibrary() { 79 void UseLibrary() {
80 _dlhandle = dlopen("libeightball.so", RTLD_LAZY); 80 _dlhandle = dlopen("libeightball.so", RTLD_LAZY);
81 if(_dlhandle == NULL) { 81 if(_dlhandle == NULL) {
82 logmsg("libeightball.so did not load"); 82 logmsg("libeightball.so did not load");
83 } else { 83 } else {
84 _eightball = (TYPE_eightball) dlsym(this->_dlhandle, "Magic8Ball"); 84 intptr_t offset = (intptr_t) dlsym(this->_dlhandle, "Magic8Ball");
85 _eightball = (TYPE_eightball) offset;
85 if (NULL == _eightball) { 86 if (NULL == _eightball) {
86 std::string ballmessage = "dlsym() returned NULL: "; 87 std::string ballmessage = "dlsym() returned NULL: ";
87 ballmessage += dlerror(); 88 ballmessage += dlerror();
88 ballmessage += "\n"; 89 ballmessage += "\n";
89 logmsg(ballmessage.c_str()); 90 logmsg(ballmessage.c_str());
90 } 91 }
91 else{ 92 else{
92 logmsg("Eightball loaded!"); 93 logmsg("Eightball loaded!");
93 } 94 }
94 } 95 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // The browser keeps a singleton of this module. It calls the 160 // The browser keeps a singleton of this module. It calls the
160 // CreateInstance() method on the object you return to make instances. There 161 // CreateInstance() method on the object you return to make instances. There
161 // is one instance per <embed> tag on the page. This is the main binding 162 // is one instance per <embed> tag on the page. This is the main binding
162 // point for your NaCl module with the browser. 163 // point for your NaCl module with the browser.
163 namespace pp { 164 namespace pp {
164 Module* CreateModule() { 165 Module* CreateModule() {
165 return new dlOpenModule(); 166 return new dlOpenModule();
166 } 167 }
167 } // namespace pp 168 } // namespace pp
168 169
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/Makefile ('k') | native_client_sdk/src/examples/pong/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698