summaryrefslogtreecommitdiffstats
path: root/src/util.cc
Commit message (Collapse)AuthorAgeFilesLines
* Take CPU set limitations into account when calculating processor countJan Niklas Hasse2019-02-261-0/+9
| | | | Fixes #1278.
* Merge pull request #1474 from mathstuf/win32-invalid-parameter-helpJan Niklas Hasse2018-11-161-2/+6
|\ | | | | Win32 invalid parameter help
| * Win32Fatal: support a "hint" for the errorBen Boeckel2018-11-091-2/+6
| | | | | | | | | | The callsite might have extra context which is helpful for interpreting the error message.
* | Merge pull request #1196 from danw/ReadFile_optJan Niklas Hasse2018-11-141-1/+11
|\ \ | | | | | | Optimize ReadFile allocations
| * | Optimize ReadFile allocationsDan Willemsen2016-11-071-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of continuously reallocating the output string, call reserve() up front to enlarge the string's buffer. Also use feof() instead of an empty read to detect the end of the file. This saves a syscall on <64kb files, which is about 5% (200ns) of the time to read a file on my machine. For our larger build.ninja files (~550MB), this saves about 500ms, which is more than half the time spent in this function. (Measured by adding METRICS_RECORD to this function during manifest_parser_perftest) For the standard manifest_parser_perftest, this only saves ~20ms out of ~600ms for a full run.
* | | util: don't add ellipses width when deciding if they're necessaryBen Boeckel2018-11-091-1/+1
| |/ |/| | | | | | | If the string fits, just use it. If we need the ellipses, *then* we need to compute the width based on that.
* | Add NINJA_FALLTHROUGH macroStefan Becker2018-04-111-1/+1
| | | | | | | | | | | | | | | | Borrow macro implementation from OpenSSL code. Add the macro after each fallthrough switch case to indicate our intention to the compiler. This silences GCC -Wimplicit-fallthrough warnings, which is implied by GCC 7.x -Wextra.
* | Fix building on Windows in UNICODE modeGergely Nagy2017-10-311-7/+2
| |
* | Remove path component limit from input of CanonicalizePath in windowsTakuto Ikuta2017-08-301-54/+25
| |
* | Fix for reviewTakuto Ikuta2017-05-091-1/+1
| |
* | Merge pull request #1181 from DanielWeber/issue-1161Nico Weber2017-01-241-9/+9
|\ \ | | | | | | Allow more path components
| * | Allow more path componentsDaniel Weber2016-08-221-9/+9
| |/ | | | | | | | | | | | | - 60 instead of 30 path components - 64 instead of 32 backslashes in a path (windows only) Issue: 1161
* | Fix build with uclibcPawel Hajdan, Jr2017-01-021-0/+7
|/ | | | | | | | Resolves #985 This is based on musl implementation, http://git.musl-libc.org/cgit/musl/commit/?id=20cbd607759038dca57f84ef7e7b5d44a3088574 (thanks to jbergstroem@ for reference)
* Canonicalize "." to "."Colin Cross2015-12-161-2/+2
| | | | | "." is a legal path, if the string is empty after canonicalization return ".".
* Implement GetLoadAverage on AIX using libperfstatMike Seplowitz2015-08-191-0/+12
|
* Run more than 34 processes on Win32 if we have 32+ cores.Rui Ueyama2015-04-171-1/+1
| | | | | | | | For compatiblity reason, dwNumberOfProcessors in Win32 is capped at 32. So even if your machine has more than 32 cores, Ninja spawns at most 34 subprocesses. This patch fixes the issue by using GetNativeSystemInfo, which returns the system info from Wow64 point of view, instead of GetSystemInfo.
* Merge pull request #835 from rainlabs-eu/fix-cygwin-compatibilityNico Weber2014-12-041-1/+4
|\ | | | | Fixed cygwin compatibility (issue #806)
| * Fixed cygwin compatibility (issue #806)kwesolowski2014-10-251-1/+4
| | | | | | | | Fixed platform specific issues causing cygwin build to fail.
* | Merge pull request #850 from sgraham/ocdNico Weber2014-11-121-16/+19
|\ \ | | | | | | whitespace/comment/wrap fixes, no intended functionality change
| * | whitespace/comment/wrap fixes, no intended functionality changeScott Graham2014-11-121-16/+19
| | |
* | | set *err when too many components in CanonicalizePathScott Graham2014-11-121-1/+3
|/ /
* | properly guard against slash_bits overflowScott Graham2014-11-121-2/+5
| |
* | fix not respecting lengthScott Graham2014-11-111-14/+18
| |
* | fix CanonicalizePath going past StringPiece length + testScott Graham2014-11-101-0/+2
| |
* | initialize slash_bits on non-winScott Graham2014-11-101-0/+2
| |
* | non-win compilationScott Graham2014-11-091-0/+10
| |
* | fix order of args to CanonicalizePathScott Graham2014-11-091-4/+4
| |
* | remove CanonicalizePath overloads, test for toplevel behaviourScott Graham2014-11-091-10/+0
| |
* | fix multiple sequential slashesScott Graham2014-11-081-1/+1
| |
* | track back->forward conversions in a bitmaskScott Graham2014-11-081-6/+46
| |
* | Use strchr in \ conversion in CanonicalizePath on WindowsScott Graham2014-10-301-3/+2
| |
* | CanonicalizePath handles \ on WindowsScott Graham2014-10-301-1/+39
|/
* Changed implementation to provide load from 0 to ProcessorCountkwesolowski2014-07-261-4/+6
| | | | This makes this implementation more consisten with POSIX load avarage.
* Fixed naming convention in GetLoadAverage support functions.kwesolowski2014-07-261-25/+25
|
* Improved load calculationkwesolowski2014-07-251-9/+20
| | | | | | | Added code to gracefully handle: 1. Call to CalculateProcessorLoad with not incremented ticks (fast calls to GetSystemTimes can result same results), 2. Smooth/filter load estimation for consecutive calls.
* Fixes for windows CalculateProcessorLoadkwesolowski2014-07-251-1/+4
| | | | | - Fixed bad logic condition, - Added comment to clarify
* Prepared load (-l N) support for windows.kwesolowski2014-07-251-3/+44
| | | | | Inspired by: http://stackoverflow.com/questions/23143693/retrieving-cpu-load-percent-total-in-windows-with-c
* Allow + in filenames without escapingNico Weber2014-05-301-0/+1
| | | | | | Due to #690, file.c++ used to be escaped. + seems as safe as -, so allow it to not be escaped, to keep compile command lines with a fairly common extension slightly cleaner.
* Don’t unnecessarily escape backslashes in Win32 pathsNicholas Hutchinson2014-01-081-1/+0
| | | | Under ::CommandLineToArgvW() rules, the backslash character only gets special treatment if it’s immediately followed by a double quote. So, when checking to see if a string needs Win32 escaping, it’s sufficient to check for the presence of a double quote character. This allows paths like "foo\bar" to be recognised as “sensible” paths, which don’t require the full escaping.
* More robust escaping of $in, $out pathsNicholas Hutchinson2014-01-061-0/+104
| | | | | | In summary: don’t escape if the path doesn’t contain problematic characters, otherwise: - Shell: enclose string in single quotes, escape embedded single quotes with the magic quote-backslash-quote sequence - Win32: Escape double quotes by doubling the number of consecutive backslashes that precede them (if any) and adding one more. Finally, double the number of trailing backslashes, and enclose the whole thing in double quotes.
* Simplify implementation of GetProcessorCount().Benedikt Meurer2013-09-011-22/+2
| | | | | | | | | The current implementation is unnecessarily complex, because: - The BSD derived systems implement sysconf(_SC_NPROCESSORS_ONLN) in terms of sysctl({CTL_HW,HW_NCPU}). - get_nprocs() is a GNU extension, and glibc implements sysconf(_SC_NPROCESSORS_ONLN) in terms of get_nprocs().
* Don't use va_start() with reference parameters, it's undefined behavior.Nico Weber2013-05-241-1/+4
| | | | Should fix issue #584.
* minor formatting changeNico Weber2013-05-011-3/+2
|
* added missing windows includePatrick von Reth2013-04-301-0/+1
|
* Fix Windows build more.Nico Weber2013-04-291-1/+1
|
* Introduce a Truncate() function that works on POSIX and Windows.Nico Weber2013-04-291-0/+20
| | | | Hopefully fixes the build on Windows.
* util.cc: Reusing windows workaround for cygwin.Paul Kunysch2013-02-091-1/+1
| | | | | | This fixes: src/util.cc: In function 'double GetLoadAverage()': src/util.cc:337:28: error: 'getloadavg' was not declared in this scope
* fix build on non-Linux glibc systemsPino Toscano2012-12-291-2/+2
| | | | | | | | | | | | ninja-build does not build on non-Linux archs, such as GNU/kFreeBSD and GNU/Hurd. The problem is that the GetProcessorCount() implementation for these architectures is the sysconf() one, but <unistd.h> has not been included, causing sysconf() and _SC_NPROCESSORS_ONLN to not be declared. Another solution (which is the one I chose) is to make use of the "linux" implementation which uses get_nprocs(), which is a GNU extension and thus available for anything using GNU libc.
* Improved error message with more informationRichard Geary2012-11-091-1/+1
| | | | Change-Id: Idb1ce67a320a9819de262d83b498ee10eb362ed2
* add GetProcessorCount() implementation for SolarisAlex Caudill2012-09-071-0/+9
|