| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "crazy_linker_system.h" | 5 #include "crazy_linker_system.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool PathIsFile(const char* path) { | 80 bool PathIsFile(const char* path) { |
| 81 struct stat st; | 81 struct stat st; |
| 82 if (TEMP_FAILURE_RETRY(stat(path, &st)) < 0) | 82 if (TEMP_FAILURE_RETRY(stat(path, &st)) < 0) |
| 83 return false; | 83 return false; |
| 84 | 84 |
| 85 return S_ISREG(st.st_mode); | 85 return S_ISREG(st.st_mode); |
| 86 } | 86 } |
| 87 | 87 |
| 88 #endif // !UNIT_TESTS | 88 #endif // !UNIT_TESTS |
| 89 | 89 |
| 90 // Returns true iff |lib_name| corresponds to one of the NDK-exposed | |
| 91 // system libraries. | |
| 92 bool IsSystemLibrary(const char* lib_name) { | |
| 93 static const char* const kSystemLibs[] = { | |
| 94 "libandroid.so", "libc.so", "libdl.so", "libjnigraphics.so", | |
| 95 "liblog.so", "libm.so", "libstdc++.so", "libz.so", | |
| 96 "libEGL.so", "libGLESv1_CM.so", "libGLESv2.so", "libGLESv3.so", | |
| 97 "libOpenMAXAL.so", "libOpenSLES.so", "libsigchain.so", }; | |
| 98 const size_t kSize = sizeof(kSystemLibs) / sizeof(kSystemLibs[0]); | |
| 99 const char* base_name = ::strrchr(lib_name, '/'); | |
| 100 if (!base_name) | |
| 101 base_name = lib_name; | |
| 102 else | |
| 103 base_name += 1; | |
| 104 | |
| 105 for (size_t n = 0; n < kSize; ++n) { | |
| 106 if (!strcmp(kSystemLibs[n], base_name)) | |
| 107 return true; | |
| 108 } | |
| 109 return false; | |
| 110 } | |
| 111 | |
| 112 } // namespace crazy | 90 } // namespace crazy |
| OLD | NEW |