4 #ifdef BENCHMARK_STL_ANDROID_GNUSTL
19 const char kBigSIUnits[] =
"kMGTPEZY";
21 const char kBigIECUnits[] =
"KMGTPEZY";
23 const char kSmallSIUnits[] =
"munpfazy";
27 "SI and IEC unit arrays must be the same size");
29 "Small SI and Big SI unit arrays must be the same size");
36 std::stringstream mantissa_stream;
39 mantissa_stream <<
"-";
45 const double adjusted_threshold =
47 const double big_threshold = adjusted_threshold * one_k;
48 const double small_threshold = adjusted_threshold;
50 const double simple_threshold = 0.01;
52 if (val > big_threshold) {
55 for (
size_t i = 0;
i <
arraysize(kBigSIUnits); ++
i) {
57 if (scaled <= big_threshold) {
58 mantissa_stream << scaled;
64 mantissa_stream << val;
66 }
else if (val < small_threshold) {
68 if (val < simple_threshold) {
70 for (
size_t i = 0;
i <
arraysize(kSmallSIUnits); ++
i) {
72 if (scaled >= small_threshold) {
73 mantissa_stream << scaled;
80 mantissa_stream << val;
83 mantissa_stream << val;
93 if (
index >= kUnitsSize)
return "";
96 (
exponent > 0 ? (iec ? kBigIECUnits : kBigSIUnits) : kSmallSIUnits);
115 std::stringstream ss;
131 va_copy(args_cp,
args);
135 std::array<char, 256> local_buff;
136 std::size_t
size = local_buff.size();
145 if (
static_cast<std::size_t
>(
ret) <
size)
150 size =
static_cast<std::size_t
>(
ret) + 1;
151 auto buff_ptr = std::unique_ptr<char[]>(
new char[
size]);
167 if (
str.empty())
return {};
168 std::vector<std::string>
ret;
171 for (;
next != std::string::npos;
179 #ifdef BENCHMARK_STL_ANDROID_GNUSTL
188 const int oldErrno = errno;
191 const char* strStart =
str.c_str();
192 char* strEnd =
const_cast<char*
>(strStart);
193 const unsigned long result = strtoul(strStart, &strEnd,
base);
195 const int strtoulErrno = errno;
200 if (strtoulErrno == ERANGE) {
201 throw std::out_of_range(
202 "stoul failed: " +
str +
" is outside of range of unsigned long");
203 }
else if (strEnd == strStart || strtoulErrno != 0) {
204 throw std::invalid_argument(
205 "stoul failed: " +
str +
" is not an integer");
207 if (
pos !=
nullptr) {
208 *
pos =
static_cast<size_t>(strEnd - strStart);
215 const int oldErrno = errno;
218 const char* strStart =
str.c_str();
219 char* strEnd =
const_cast<char*
>(strStart);
220 const long result = strtol(strStart, &strEnd,
base);
222 const int strtolErrno = errno;
227 if (strtolErrno == ERANGE ||
long(
int(
result)) !=
result) {
228 throw std::out_of_range(
229 "stoul failed: " +
str +
" is outside of range of int");
230 }
else if (strEnd == strStart || strtolErrno != 0) {
231 throw std::invalid_argument(
232 "stoul failed: " +
str +
" is not an integer");
234 if (
pos !=
nullptr) {
235 *
pos =
static_cast<size_t>(strEnd - strStart);
242 const int oldErrno = errno;
245 const char* strStart =
str.c_str();
246 char* strEnd =
const_cast<char*
>(strStart);
247 const double result = strtod(strStart, &strEnd);
250 const int strtodErrno = errno;
254 if (strtodErrno == ERANGE) {
255 throw std::out_of_range(
256 "stoul failed: " +
str +
" is outside of range of int");
257 }
else if (strEnd == strStart || strtodErrno != 0) {
258 throw std::invalid_argument(
259 "stoul failed: " +
str +
" is not an integer");
261 if (
pos !=
nullptr) {
262 *
pos =
static_cast<size_t>(strEnd - strStart);