Rewrite the POSIX locking code. It was becomming impossible to track
down bugs in the previous version due to code complexity (in particular
a large number of undocumented short cuts and gotos), and general lack of
documentation.
The new code uses a more straightforward method for managing the lock list
and is far better documented. Basically the conflict space is ranged,
if no conflict occurs the new lock is inserted, overlaps are clipped or
removed, and finally a quick optimization to check for and collapse
compatible adjacent locks.