Add an API for acquiring and releasing file-level locks. This abstracts
away the platform-specific aspects of file locking, and also makes the
locking work when several threads attempt to acquire a lock within the
same process.
This commit just adds the functions and datatypes; nothing actually uses
them. The users will be added in (hopefully nearby) future commits.