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

Side by Side Diff: base/safe_strerror_posix.cc

Issue 552753002: Handle bionic's strerror_r in an ABI-compatible way. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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) 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__)
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
8 // on those later versions. To preserve ABI compatibility with older versions,
9 // undefine _GNU_SOURCE and use the POSIX version.
10 #undef _GNU_SOURCE
11 #endif
12
5 #include "build/build_config.h" 13 #include "build/build_config.h"
6 #include "base/safe_strerror_posix.h" 14 #include "base/safe_strerror_posix.h"
7 15
8 #include <errno.h> 16 #include <errno.h>
9 #include <stdio.h> 17 #include <stdio.h>
10 #include <string.h> 18 #include <string.h>
11 19
12 #define USE_HISTORICAL_STRERRO_R (defined(__GLIBC__) || defined(__BIONIC__) || \ 20 #define USE_HISTORICAL_STRERRO_R (defined(__GLIBC__) || defined(OS_NACL))
13 defined(OS_NACL))
14 21
15 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) 22 #if USE_HISTORICAL_STRERRO_R && defined(__GNUC__)
16 // GCC will complain about the unused second wrap function unless we tell it 23 // GCC will complain about the unused second wrap function unless we tell it
17 // that we meant for them to be potentially unused, which is exactly what this 24 // that we meant for them to be potentially unused, which is exactly what this
18 // attribute is for. 25 // attribute is for.
19 #define POSSIBLY_UNUSED __attribute__((unused)) 26 #define POSSIBLY_UNUSED __attribute__((unused))
20 #else 27 #else
21 #define POSSIBLY_UNUSED 28 #define POSSIBLY_UNUSED
22 #endif 29 #endif
23 30
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // static. 110 // static.
104 wrap_posix_strerror_r(&strerror_r, err, buf, len); 111 wrap_posix_strerror_r(&strerror_r, err, buf, len);
105 } 112 }
106 113
107 std::string safe_strerror(int err) { 114 std::string safe_strerror(int err) {
108 const int buffer_size = 256; 115 const int buffer_size = 256;
109 char buf[buffer_size]; 116 char buf[buffer_size];
110 safe_strerror_r(err, buf, sizeof(buf)); 117 safe_strerror_r(err, buf, sizeof(buf));
111 return std::string(buf); 118 return std::string(buf);
112 } 119 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698