[Support] Add file lock/unlock functions

Authored by sepavloff on Apr 22 2020, 9:00 AM.


[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