| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #if defined(__ANDROID__) | 5 #if defined(__ANDROID__) |
| 6 // Post-L versions of bionic define the GNU-specific strerror_r if _GNU_SOURCE | 6 // Post-L versions of bionic define the GNU-specific strerror_r if _GNU_SOURCE |
| 7 // is defined, but the symbol is renamed to __gnu_strerror_r which only exists | 7 // is defined, but the symbol is renamed to __gnu_strerror_r which only exists |
| 8 // on those later versions. To preserve ABI compatibility with older versions, | 8 // on those later versions. To preserve ABI compatibility with older versions, |
| 9 // undefine _GNU_SOURCE and use the POSIX version. | 9 // undefine _GNU_SOURCE and use the POSIX version. |
| 10 #undef _GNU_SOURCE | 10 #undef _GNU_SOURCE |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/posix/safe_strerror.h" | 13 #include "base/posix/safe_strerror.h" |
| 14 | 14 |
| 15 #include <errno.h> | 15 #include <errno.h> |
| 16 #include <stdio.h> | 16 #include <stdio.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 | 18 |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 | 22 |
| 23 #define USE_HISTORICAL_STRERRO_R (defined(__GLIBC__) || defined(OS_NACL)) | 23 #if defined(__GLIBC__) || defined(OS_NACL) |
| 24 #define USE_HISTORICAL_STRERRO_R 1 |
| 25 #else |
| 26 #define USE_HISTORICAL_STRERRO_R 0 |
| 27 #endif |
| 24 | 28 |
| 25 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) | 29 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) |
| 26 // GCC will complain about the unused second wrap function unless we tell it | 30 // GCC will complain about the unused second wrap function unless we tell it |
| 27 // that we meant for them to be potentially unused, which is exactly what this | 31 // that we meant for them to be potentially unused, which is exactly what this |
| 28 // attribute is for. | 32 // attribute is for. |
| 29 #define POSSIBLY_UNUSED __attribute__((unused)) | 33 #define POSSIBLY_UNUSED __attribute__((unused)) |
| 30 #else | 34 #else |
| 31 #define POSSIBLY_UNUSED | 35 #define POSSIBLY_UNUSED |
| 32 #endif | 36 #endif |
| 33 | 37 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 119 } |
| 116 | 120 |
| 117 std::string safe_strerror(int err) { | 121 std::string safe_strerror(int err) { |
| 118 const int buffer_size = 256; | 122 const int buffer_size = 256; |
| 119 char buf[buffer_size]; | 123 char buf[buffer_size]; |
| 120 safe_strerror_r(err, buf, sizeof(buf)); | 124 safe_strerror_r(err, buf, sizeof(buf)); |
| 121 return std::string(buf); | 125 return std::string(buf); |
| 122 } | 126 } |
| 123 | 127 |
| 124 } // namespace base | 128 } // namespace base |
| OLD | NEW |