OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 #include "base/native_library.h" | 5 #include "base/native_library.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 int ret = dlclose(library); | 38 int ret = dlclose(library); |
39 if (ret < 0) { | 39 if (ret < 0) { |
40 LOG(ERROR) << "dlclose failed: " << dlerror(); | 40 LOG(ERROR) << "dlclose failed: " << dlerror(); |
41 NOTREACHED(); | 41 NOTREACHED(); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
46 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, | 46 void* GetFunctionPointerFromNativeLibrary(NativeLibrary library, |
47 const char* name) { | 47 const char* name) { |
48 return dlsym(library, name); | 48 DCHECK(name != NULL) << "NULL name passed in."; |
| 49 void* lib = dlsym(library, name); |
| 50 return lib; |
49 } | 51 } |
50 | 52 |
51 // static | 53 // static |
52 string16 GetNativeLibraryName(const string16& name) { | 54 string16 GetNativeLibraryName(const string16& name) { |
53 return ASCIIToUTF16("lib") + name + ASCIIToUTF16(".so"); | 55 return ASCIIToUTF16("lib") + name + ASCIIToUTF16(".so"); |
54 } | 56 } |
55 | 57 |
| 58 string16 GetLibraryErrorMessage() { |
| 59 const char* last_err_message = dlerror(); |
| 60 string16 err_message; |
| 61 |
| 62 if (last_err_message) { |
| 63 err_message = ASCIIToUTF16(last_err_message); |
| 64 } |
| 65 |
| 66 return err_message; |
| 67 } |
| 68 |
56 } // namespace base | 69 } // namespace base |
OLD | NEW |