Commit graph

1587 commits

Author SHA1 Message Date
Elliott Hughes
b83bf14a35 Fortify ppoll64.
I've deliberately not bothered with the GCC implementation because we'll
have removed GCC from the NDK before anyone gets to use this.

Bug: http://b/72493232
Test: ran tests
Change-Id: Icfc2a3b214739ab53aa41bacacc11b5c67498fb4
2018-03-22 13:59:02 -07:00
Elliott Hughes
1423bb8498 Merge "timer_create: use SIG_SETMASK restore the signal mask." 2018-03-21 17:01:41 +00:00
Tom Cherry
c6b5bcd182 Add _monotonic_np versions of timed wait functions
As a follow up to Ibba98f5d88be1c306d14e9b9366302ecbef6d534, where we
added a work around to convert the CLOCK_REALTIME timeouts to
CLOCK_MONOTONIC for pthread and semaphore timed wait functions, we're
introducing a set of _monotonic_np versions of each of these functions
that wait on CLOCK_MONOTONIC directly.

The primary motivation here is that while the above work around helps
for 3rd party code, it creates a dilemma when implementing new code
that would use these functions: either one implements code with these
functions knowing there is a race condition possible or one avoids
these functions and reinvent their own waiting/signaling mechanisms.
Neither are satisfactory, so we create a third option to use these
Android specific _monotonic_np functions that completely remove the
race condition while keeping the rest of the interface.

Specifically this adds the below functions:
pthread_mutex_timedlock_monotonic_np()
pthread_cond_timedwait_monotonic_np()
pthread_rwlock_timedrdlock_monotonic_np()
pthread_rwlock_timedwrlock_monotonic_np()
sem_timedwait_monotonic_np()

Note that pthread_cond_timedwait_monotonic_np() previously existed and
was removed since it's possible to initialize a condition variable to
use CLOCK_MONOTONIC.  It is added back for a mix of reasons,
1) Symmetry with the rest of the functions we're adding
2) libc++ cannot easily take advantage of the new initializer, but
   will be able to use this function in order to wait on
   std::steady_clock
3) Frankly, it's a better API to specify the clock in the waiter function
   than to specify the clock when the condition variable is
   initialized.

Bug: 73951740
Test: new unit tests
Change-Id: I23aa5c204e36a194237d41e064c5c8ccaa4204e3
2018-03-20 18:41:22 -07:00
Elliott Hughes
48a69742fe timer_create: use SIG_SETMASK restore the signal mask.
Bug: http://b/73144101
Test: ran tests
Change-Id: I9adf3a512c120ef2280ad469ad11366222d61463
2018-03-20 17:58:11 -07:00
Yabin Cui
9651fdf93a Check using destroyed mutexes.
For apps built for Android < P, return EBUSY.
For apps built for Android >= P, abort.

This is to keep old apps work, and help debugging
apps built for >= P.

Bug: http://b/74632097
Test: run bionic-unit-tests.
Test: run bionic-benchmark.

Change-Id: I5271565a1a6ad12678f85d558a7f862a2b7aab4b
2018-03-15 10:44:30 -07:00
Elliott Hughes
435e669776 Merge "Rewrite system(3) to use posix_spawn(3)." 2018-03-09 18:08:00 +00:00
Jerry Zhang
832f4907f0 Merge "Sign extend offset for pwritev/preadv." 2018-03-07 01:28:26 +00:00
Jerry Zhang
f55dbc0516 Sign extend offset for pwritev/preadv.
Kernel expects a 64 bit offset, so if a
user's offset is 32 bit, the wrapper will
drop the sign. To fix, sign extend the
32 bit value before doing the syscall.

Bug: 31225071
Test: pwritev02 32 bit passes
Change-Id: Ie272601662c2c35b0e8d8fc3823c9063c2f73e64
2018-03-06 15:39:44 -08:00
Elliott Hughes
71ba5899ae Rewrite system(3) to use posix_spawn(3).
We saw crashes from pthread_exit+debuggerd on LP32
(https://issuetracker.google.com/72291624), and it seems like the
equivalent problem should exist with system(3). I fixed posix_spawn(3)
as part of that bug, so the easiest fix is probably to reuse that.

Bug: http://b/72470344
Test: ran tests
Change-Id: I05f838706f2b4a14ac3ee21292833e6c8579b0d4
2018-03-05 17:20:12 -08:00
Josh Gao
6fcba93b17 Filter out reserved signals in functions that take sigset_t.
Prevent processes from blocking libc-reserved signals by filtering them
out.

Bug: http://b/73144101
Test: 32/64-bit bionic-unit-tests-glibc
Test: 32/64-bit bionic-unit-tests on taimen
Change-Id: Ibadcaa7f668ed8be885cc61b67fb4b611fce8b17
2018-02-27 14:12:30 -08:00
Elliott Hughes
7ae39129e1 Move sigprocmask into its own file.
Otherwise clang inlines it into pthread_sigmask(3), which breaks libsigchain.

Bug: http://b/73344857
Test: ran tests, plus the app this broke
Change-Id: Ie4a1dc8f9c6ba58d1a2fa69aeff961c70b74767d
2018-02-26 16:59:37 -08:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed.  This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.

Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2018-02-21 15:10:17 -08:00
Tom Cherry
44c7b6ad0a Merge changes Ibcd45e9b,I1ff5c0fa
* changes:
  Do not munmap in MmapFile::~MmapFile
  Build bionic/tests with cpp_std experimental.
2018-02-21 04:41:21 +00:00
Tom Cherry
5fe73268f3 Do not munmap in MmapFile::~MmapFile
Having any destructor with a global variable in bionic is causing
some issues. Since we don't actually need to munmap in this case, we
remove the destructor to work around that issue.

A small class is used to still munmap during tests.

Bug: 73485611
Test: bionic unit tests
Change-Id: Ibcd45e9b1ab22d187ecfc2738bb87244250d81ea
2018-02-20 16:02:13 -08:00
Tom Cherry
cb4d42173e Fix mmap leak in MmapFile
If the mmap'ed file doesn't end in a new line, previously we'd leak
the mmap'ed region.  This change now munmap's the region.

Test: unit tests
Change-Id: If28d3d9a6b1b9c54123beecb3bbbe8ed984ca81d
2018-02-20 15:50:04 -08:00
Elliott Hughes
665ce210fa Merge "Add remaining _l function stubs." 2018-02-15 01:26:17 +00:00
Elliott Hughes
3376c23dac Add remaining _l function stubs.
Bug: http://b/65595804
Test: ran tests
Change-Id: I3bea3af20b354d1f0d3e05fd35421a9045f29020
2018-02-13 23:14:12 -08:00
Treehugger Robot
2d1e1011cf Merge "Switch the rest of our internal headers to #pragma once." 2018-02-14 02:53:37 +00:00
Elliott Hughes
cbc80ba9d8 Switch the rest of our internal headers to #pragma once.
We've been using #pragma once for new internal files, but let's be more bold.

Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
2018-02-13 14:27:17 -08:00
Christopher Ferris
db478a6274 Implement malloc hooks.
Use the malloc debug framework to implement the malloc debug hooks
since it can introduce a performance issue.

Also, modify the bionic/tests/utils.h slightly to dump an error message
when the exe failed.

Bug: 30561479

Test: Ran malloc hook unit tests.
Test: Ran malloc debug unit tests.
Test: Enabled malloc hooks and ran bionic unit tests and verified no
Test: unexpected failures.
Test: Enabled malloc debug and malloc hooks and verified malloc debug wins.
Test: Enabled malloc debug using env, property, and property with name
Test: still works.

Change-Id: Ib50046a0493c5c2050cf831befb812310bdcc249
(cherry picked from commit d6a1dc2379)
2018-02-13 13:37:30 -08:00
Tom Cherry
ab8c861597 Merge "Add ability to read /etc/passwd and /etc/group" 2018-02-12 16:27:20 +00:00
Treehugger Robot
4362da8076 Merge "Remove __overloadable/__RENAME_CLANG" 2018-02-10 02:30:37 +00:00
Tom Cherry
6034ef85d8 Add ability to read /etc/passwd and /etc/group
Add the capability to read /etc/passwd and /etc/group for getpw* and
getgr* functions.

Bug: 27999086
Test: pwd, grp, grp_pwd_file unit tests
Test: Read in custom users/groups from /etc/{passwd,group}
Change-Id: Idc1f054af8a7ca34743a90493495f0ccc775a0d8
2018-02-08 12:38:57 -08:00
Treehugger Robot
aac0dd9891 Merge "Don't use SA_RESTORER if it is not defined" 2018-02-08 07:47:21 +00:00
Goran Jakovljevic
87c6aac6d2 Don't use SA_RESTORER if it is not defined
This is a follow up to I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8.
This fixes MIPS32 build.

Test: successful build and boot aosp_mips-eng
Change-Id: Ia5b245f5536d8fd037f1798bbdf6215c5f059045
2018-02-07 16:56:33 +01:00
Christopher Ferris
cae21a9b53 Add aligned_alloc to libc.
Bug: 72969374

Test: Bionic unit tests pass.
Test: Malloc debug unit tests pass.
Change-Id: I235985bbc638855d94249c97c98f14ab2924bda0
(cherry picked from commit d69ee59594)
2018-02-07 06:57:14 -08:00
Treehugger Robot
be6fbae74f Merge "Inline __libc_arc4random_has_unlimited_entropy." 2018-02-07 03:19:12 +00:00
Elliott Hughes
fe44c3cde0 Merge "Make sigaction consistent about SA_RESTORER and sa_restorer" 2018-02-06 23:41:46 +00:00
Elliott Hughes
c11fb66739 Inline __libc_arc4random_has_unlimited_entropy.
The name is misleading anyway.

Bug: http://b/67015565
Test: boots
Change-Id: Ic765e376d84e1ca474d3324eab32e14ea1ae9712
2018-02-06 15:35:15 -08:00
George Burgess IV
9024235005 Remove __overloadable/__RENAME_CLANG
Now that we have a clang that supports transparent overloads, we can
kill all of this cruft, and restore our upstream sources to their
untouched glory. Woohoo!

Bug: 12231437
Test: Built aosp_marlin; no obvious patch-related aosp_mips issues.
Change-Id: I520a19d014f12137f80e43f973dccd6711c571cd
2018-02-06 13:35:56 -08:00
Elliott Hughes
a325151da0 Merge "Rewrite getentropy." 2018-02-06 01:12:35 +00:00
Evgeny Eltsin
11f6076410 Make sigaction consistent about SA_RESTORER and sa_restorer
Bug: http://b/72493232
Test: bionic-unit-tests --gtest_filter=*signal.sigaction*
Change-Id: Ia9fceb478498d09c8f2f6222d6a81725e1f6eb23
2018-02-05 22:08:25 +01:00
Elliott Hughes
211c4d35f2 Rewrite getentropy.
The error handling was a mess, resulting in an infinite loop
(and a test timeout) if you actually took the /dev/urandom
fallback. I'm also unconvinced that the getrandom(2) path was correct
because of the various reasons why we might get a short count back
(http://man7.org/linux/man-pages/man2/getrandom.2.html). In this version,
the two paths look very similar except for the getrandom(2) failure case,
where it's now much clearer that we just give up so that we can boot
(http://b/33059407).

Bug: http://b/33059407
Bug: http://b/67015565
Test: ran tests on hikey and a ICS Galaxy Nexus
Change-Id: Ie715d59b46f7a70bae66943c316168838787b40d
2018-02-05 12:57:22 -08:00
Yabin Cui
a026108ec1 Merge "Avoid abort when calling pthread_mutex_destroy more than once." 2018-02-03 02:03:47 +00:00
Yabin Cui
2dec3d7021 Avoid abort when calling pthread_mutex_destroy more than once.
Bug: http://b/72878088
Test: run bionic-unit-tests.
Change-Id: I0c3a6c5a625d187d5f32ec8c821cfdd5e807a671
2018-02-02 15:45:24 -08:00
Yabin Cui
b82dcc6fa7 Merge "Support priority inheritance mutex in 32-bit programs." 2018-02-02 19:44:51 +00:00
Yabin Cui
5a00ba7c1c Support priority inheritance mutex in 32-bit programs.
Add fast path calling PIMutexTryLock() in pthread_mutex_lock.
Add trace for pi mutex waiting.

Bug: http://b/29177606
Test: run bionic-unit-tests.
Test: run bionic-benchmarks.

Change-Id: I30b6436692d5ea6b63ca9905df745edb843b5528
2018-02-01 16:01:46 -08:00
Elliott Hughes
3e235911c9 Add struct sigaction64 and sigaction64.
Bug: http://b/72493232
Test: ran tests
Change-Id: I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8
2018-02-01 14:45:15 -08:00
Elliott Hughes
5905d6f879 Add sigset64_t and accompanying functions.
This doesn't address `struct sigaction` and `sigaction`. That will
come later.

Bug: http://b/72493232
Test: ran tests
Change-Id: I4134346757ce3a4dac6feae413361cec16223386
2018-01-30 18:47:16 -08:00
Treehugger Robot
4cd3550d50 Merge "Move static variable out of should_trace()." 2018-01-30 01:17:47 +00:00
Elliott Hughes
6dafb4ac78 Move all the short <signal.h> functions together.
Bug: N/A
Test: ran tests
Change-Id: Ie5509e4108efcd5d403227ce99bef2b61c79f757
2018-01-26 17:47:56 -08:00
Treehugger Robot
97d1c75ca5 Merge "Better handling of sigset_t on LP32." 2018-01-26 23:07:49 +00:00
Elliott Hughes
4b1c6e7385 Better handling of sigset_t on LP32.
The main motivation here is that the sigprocmask in pthread_exit wasn't
actually blocking the real-time signals, and debuggerd (amongst other
things) is using them. I wasn't able to write a test that actually won
that race but I did write an equivalent one for posix_spawn.

This also fixes all the uses of sigset_t where the sigset_t isn't
exposed to the outside (which we can't easily fix because it would be
an ABI change).

Bug: https://issuetracker.google.com/72291624
Test: ran tests
Change-Id: Ib6eebebc5a7b0150079f1cb79593247917dcf750
2018-01-26 13:04:57 -08:00
Wei Li
2cb5f7f578 Move static variable out of should_trace().
Static variable initialization calls pthread_mutex_lock() and may lead to
deadlock if should_trace() is called in pthread_mutex_lock context.

Here is a stack of blocked init process:
__cxa_guard_acquire ->
should_trace        ->
bionic_trace_begin  ->
__pthread_mutex_lock_with_timeout ->
__cxa_guard_release ->
should_trace        ->
bionic_trace_begin  ->
__pthread_mutex_lock_with_timeout ->
mutex::lock        ->
LogMessage::~LogMessage
......
So we need to move it out

Test: 1 Compiled and booted.
      2 Reboot pressure test for more than 30000 times.

Change-Id: I8d97745161f1aa8942b63338208ea74830768ae1
Signed-off-by: Wei Li <sirius.liwei@huawei.com>
Signed-off-by: Jinguang Dong <dongjinguang@huawei.com>
2018-01-26 17:01:55 +08:00
Yabin Cui
6b9c85b36d Support priority inheritance mutex in 64bit programs.
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
2018-01-24 16:11:07 -08:00
Elliott Hughes
5cec377f49 Address a bunch of clang-tidy complaints.
There were a bunch more unreasonable/incorrect ones, but these ones
seemed legit. Nothing very interesting, though.

Bug: N/A
Test: ran tests, benchmarks
Change-Id: If66971194d4a7b4bf6d0251bedb88e8cdc88a76f
2018-01-19 15:56:12 -08:00
Elliott Hughes
f1515f6408 Clean up the time(2) implementation.
This is also slightly faster for the no VDSO case (56ns vs 66ns).

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I2b0edd06ee6942eb57c32678279278a53ca5ee9b
2018-01-12 15:20:28 -08:00
Mark Salyzyn
4473ccd5b0 bionic: add vdso time()
time() can be a hot call, and it currently uses __vdso_gettimeofday,
which is already pretty fast (~3 times faster than the syscall),
but with a __vdso_time call it is ~3 times even faster, in part
because __vdso_time does not require interlocking with updates,
and the read for just the seconds is atomic.  __vdso_time is
always available, whereas __vdso_gettimeofday is gated on access
to the physical timers.  arm improvement is compelling (x10),
x86 improvement is even more pronounced (x100).

[TL;DR]

w/vdso32 kernel patches, locked cores to MAX, little cores only.

BEFORE:

hikey960 vdso (aarch64):

----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
BM_time_clock_gettime                  48 ns         48 ns   15414753
BM_time_clock_gettime_syscall         175 ns        175 ns    4062031
BM_time_clock_gettime_REALTIME         44 ns         44 ns   15897875
BM_time_clock_gettime_BOOTTIME         47 ns         47 ns   14307903
BM_time_clock_gettime_TAI             210 ns        210 ns    3341372
BM_time_clock_gettime_unsupported     100 ns        100 ns    7030649
BM_time_gettimeofday                   47 ns         47 ns   14969643
BM_time_gettimeofday_syscall          163 ns        163 ns    4283542
BM_time_time                           59 ns         59 ns   11815385

hikey960 vdso32 (aarch32):

----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
BM_time_clock_gettime                  90 ns         90 ns    7572898
BM_time_clock_gettime_syscall         251 ns        251 ns    2763442
BM_time_clock_gettime_REALTIME         81 ns         80 ns    8699536
BM_time_clock_gettime_BOOTTIME         97 ns         97 ns    7256667
BM_time_clock_gettime_TAI             272 ns        272 ns    2570419
BM_time_clock_gettime_unsupported     160 ns        160 ns    4379819
BM_time_gettimeofday                   73 ns         73 ns    9608922
BM_time_gettimeofday_syscall          200 ns        199 ns    3527957
BM_time_time                          123 ns        123 ns    5651095

x86_64 (glibc):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                  21 ns         21 ns   28873070
BM_time_clock_gettime_syscall         224 ns        224 ns    3095370
BM_time_clock_gettime_REALTIME         17 ns         17 ns   42083086
BM_time_clock_gettime_BOOTTIME        239 ns        239 ns    2924015
BM_time_clock_gettime_TAI             236 ns        236 ns    2961423
BM_time_clock_gettime_unsupported     221 ns        221 ns    3357696
BM_time_gettimeofday                 22 ns         22 ns   27975154
BM_time_gettimeofday_syscall        238 ns        238 ns    2882032
BM_time_time                          2 ns          2 ns  340354885
BM_time_time_syscall                207 ns        207 ns    3383073

imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a):
(virtual timers)

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                     20        477    1489362
BM_time_clock_gettime_syscall             20        487    1458333
BM_time_clock_gettime_REALTIME            19        464    1400000
BM_time_clock_gettime_BOOTTIME            29        700    1000000
BM_time_clock_gettime_TAI                 29        690    1000000
BM_time_clock_gettime_unsupported          9        227    3043478
BM_time_gettimeofday                      18        444    1555556
BM_time_gettimeofday_syscall              19        456    1555556
BM_time_time                              21        497    1166667

imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a):
(physical timers)

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                      6        144    4666667
BM_time_clock_gettime_syscall             20        486    1400000
BM_time_clock_gettime_REALTIME             6        136    5000000
BM_time_clock_gettime_BOOTTIME             6        153    4375000
BM_time_clock_gettime_TAI                 31        760    1000000
BM_time_clock_gettime_unsupported         10        233    3043478
BM_time_gettimeofday                       6        140    5000000
BM_time_gettimeofday_syscall              19        450    1555556
BM_time_time                               9        203    3500000

AFTER:

hikey960 vdso (aarch64):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                48 ns         48 ns   15414753
BM_time_clock_gettime_syscall       175 ns        175 ns    4062031
BM_time_clock_gettime_REALTIME       44 ns         44 ns   15897875
BM_time_clock_gettime_BOOTTIME       47 ns         47 ns   14307903
BM_time_clock_gettime_TAI           210 ns        210 ns    3341372
BM_time_clock_gettime_unsupported   100 ns        100 ns    7030649
BM_time_gettimeofday                 47 ns         47 ns   14975314
BM_time_gettimeofday_syscall        164 ns        164 ns    4278797
BM_time_time                         16 ns         16 ns   42932165

hikey960 vdso32 (aarch32):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                90 ns         90 ns    7572898
BM_time_clock_gettime_syscall       251 ns        251 ns    2763442
BM_time_clock_gettime_REALTIME       81 ns         80 ns    8699536
BM_time_clock_gettime_BOOTTIME       97 ns         97 ns    7256667
BM_time_clock_gettime_TAI           272 ns        272 ns    2570419
BM_time_clock_gettime_unsupported   160 ns        160 ns    4379819
BM_time_gettimeofday                 73 ns         73 ns    9596230
BM_time_gettimeofday_syscall        199 ns        199 ns    3575428
BM_time_time                         35 ns         35 ns   19798801

imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a):

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                     20        477    1489362
BM_time_clock_gettime_syscall             20        487    1458333
BM_time_clock_gettime_REALTIME            19        464    1400000
BM_time_clock_gettime_BOOTTIME            29        700    1000000
BM_time_clock_gettime_TAI                 29        690    1000000
BM_time_clock_gettime_unsupported          9        227    3043478
BM_time_gettimeofday                      18        444    1555556
BM_time_gettimeofday_syscall              19        456    1555556
BM_time_time                               2         50   11666667

imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a):

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                      6        144    4666667
BM_time_clock_gettime_syscall             20        486    1400000
BM_time_clock_gettime_REALTIME             6        136    5000000
BM_time_clock_gettime_BOOTTIME             6        153    4375000
BM_time_clock_gettime_TAI                 31        760    1000000
BM_time_clock_gettime_unsupported         10        233    3043478
BM_time_gettimeofday                       6        140    5000000
BM_time_gettimeofday_syscall              19        450    1555556
BM_time_time                               2         50   10000000

Test: bionic-unit-tests --gtest_filter=time.time
      taskset F bionic-benchmarks --bionic_xml=vdso.xml \
          --benchmark_filter='BM_time_(time*|clock_gettime*|gettimeofday*)'
Bug: 63737556
Change-Id: I81b088a12ca41a6c4733d46c5477527777138efa
2018-01-11 15:46:11 +00:00
dimitry
06016f226e Fix dlclose for libraries with thread_local dtors
Introduce new flag to mark soinfo as TLS_NODELETE when
there are thread_local dtors associated with dso_handle
belonging to it.

Test: bionic-unit-tests --gtest_filter=dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Bug: https://github.com/android-ndk/ndk/issues/360
Change-Id: I724ef89fc899788f95c47e6372c38b3313f18fed
2018-01-10 10:24:06 +01:00
Elliott Hughes
cb239bda65 Simplify atoi*/strto* for signed integers.
Make the cost of strto<signed> closer to the cost of strto<unsigned>
by removing an `if` from the inner loop. Previously a signed conversion
cost 10ns more than an unsigned one.

After:

  BM_inttypes_strtoimax         81 ns         81 ns    8603362
  BM_inttypes_strtoumax         78 ns         78 ns    8967174
  BM_stdlib_strtol              81 ns         81 ns    8685537
  BM_stdlib_strtoll             81 ns         81 ns    8685481
  BM_stdlib_strtoul             78 ns         78 ns    8962569
  BM_stdlib_strtoull            78 ns         78 ns    8972023

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I72dd5499427b6a940bd94c4d6f727f7efe134d7e
2017-12-21 17:44:22 -08:00