24 extern "C" int flock(
int fd,
int operation) {
25 HANDLE
h = (HANDLE)_get_osfhandle(fd);
26 if (h == INVALID_HANDLE_VALUE) {
31 if (operation & LOCK_UN) {
32 if (!UnlockFile(h, 0, 0, kMaxDWORD, kMaxDWORD)) {
37 (operation & LOCK_NB ? LOCKFILE_FAIL_IMMEDIATELY : 0) |
38 (operation & LOCK_EX ? LOCKFILE_EXCLUSIVE_LOCK : 0));
40 if (!LockFileEx(h, flags, 0, kMaxDWORD, kMaxDWORD, &ov)) {