Add <stdlib.h> includes for clang++/libc++ on Ubuntu
authorDan Willemsen <dwillemsen@google.com>
Thu, 21 Apr 2016 00:29:00 +0000 (17:29 -0700)
committerDan Willemsen <dwillemsen@google.com>
Thu, 21 Apr 2016 01:24:10 +0000 (18:24 -0700)
commitd4607eb8974a0fcd034ba6d93624544815788ff2
treeef68881c84ebc830cb678c48dba93aceb12b9947
parent73b672ebbf1a28227b070f1f3191c9fd51d8e3ad
Add <stdlib.h> includes for clang++/libc++ on Ubuntu

There are a number of stdlib.h uses in these files without including
stdlib.h:

 hash_collision_bench.cc: rand, RAND_MAX, srand
 manifest_parser_perftest.cc: system, exit
 ninja_test.cc: EXIT_SUCCESS, EXIT_FAILURE
 test.cc: getenv, mkdtemp, system

This works on a Ubuntu g++/libstdc++ build, as the <algorithm> header
pulls in stdlib.h, and on a OSX clang++/libc++ build the <map> and
<string> headers pull in stdlib.h. But a Ubuntu clang++/libc++ build
does not pull in stdlib.h with any of these other headers.

 $ apt-get install clang-3.6 libc++-dev
 $ CXX=clang++-3.6 CFLAGS=-stdlib=libc++ LDFLAGS=-stdlib=libc++ \
   ./configure.py
 $ ninja ninja_test hash_collision_bench manifest_parser_perftest

This was originally discovered using the host toolchain provided with
Android, but the Ubuntu version is much easier to reproduce.
src/hash_collision_bench.cc
src/manifest_parser_perftest.cc
src/ninja_test.cc
src/test.cc