[Support] Add file lock/unlock functions
authorSerge Pavlov <sepavloff@gmail.com>
Wed, 22 Apr 2020 16:00:12 +0000 (23:00 +0700)
committerSerge Pavlov <sepavloff@gmail.com>
Tue, 28 Jul 2020 09:44:23 +0000 (16:44 +0700)
commit536736995bf5d073853c7e884968c9847b4ae64d
treeacf7e4d8fbcb587973a9023a016bde193e5c08a1
parenteb10b065f2a870b425dcc2040b9955e0eee464b4
[Support] Add file lock/unlock functions

This is recommit of f51bc4fb60fb, reverted in 8577595e03fa, because
the function `flock` is not available on Solaris. In this variant
`flock` was replaced with `fcntl`, which is a POSIX function.

New functions `lockFile`, `tryLockFile` and `unlockFile` implement
simple file locking. They lock or unlock entire file. This must be
enough to support simulataneous writes to log files in parallel builds.

Differential Revision: https://reviews.llvm.org/D78896
llvm/include/llvm/Support/FileSystem.h
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc
llvm/unittests/Support/ProgramTest.cpp