OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 // Functions for dynamically loading the trusted plugin when running unit | |
6 // tests. | |
7 | |
8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_DYLIB_UNITTEST_H_ | |
9 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_DYLIB_UNITTEST_H_ | |
10 | |
11 #if NACL_WINDOWS | |
12 #include <windows.h> | |
13 typedef HINSTANCE DylibHandle; | |
14 typedef void (*SymbolHandle)(); | |
15 #else | |
16 #include <dlfcn.h> | |
17 #include <inttypes.h> | |
18 typedef void* DylibHandle; | |
19 // uintptr_t is used here because ISO C++ won't allow casting from a void* | |
20 // (the return type of dlsym()) to a pointer-to-function. Instead, | |
21 // GetSymbolHandle() returns a uintptr_t which can then be cast into a pointer- | |
22 // to-function. This depends on uintptr_t being the same size (or larger than) | |
23 // void*. | |
24 typedef uintptr_t SymbolHandle; | |
25 #endif | |
26 | |
27 // Load the dynamic library at |lib_path|. Returns NULL on error. | |
28 DylibHandle DylibOpen(const char* lib_path); | |
29 | |
30 // Close the dynamic library and free all the system resources associated with | |
31 // it. Returns |true| on success. | |
32 bool DylibClose(DylibHandle dl_handle); | |
33 | |
34 // Return a handle to the symbol named |name| in the library represented by | |
35 // |dl_handle|. Returns NULL ff the symbol does not exist, or some other error | |
36 // occurs. | |
37 SymbolHandle GetSymbolHandle(DylibHandle dl_handle, const char* name); | |
38 | |
39 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_DYLIB_UNITTEST_H_ | |
OLD | NEW |