diff options
author | leo <[email protected]> | 2022-02-10 16:46:40 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:40 +0300 |
commit | 980edcd3304699edf9d4e4d6a656e585028e2a72 (patch) | |
tree | 139f47f3911484ae9af0eb347b1a88bd6c4bb35f /util/system/flock.cpp | |
parent | b036a557f285146e5e35d4213e29a094ab907bcf (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/system/flock.cpp')
-rw-r--r-- | util/system/flock.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/util/system/flock.cpp b/util/system/flock.cpp index fe88fecaff9..f00b7fd5d18 100644 --- a/util/system/flock.cpp +++ b/util/system/flock.cpp @@ -1,36 +1,36 @@ #include "flock.h" - -#ifndef _unix_ - + +#ifndef _unix_ + #include <util/generic/utility.h> #include "winint.h" #include <io.h> #include <errno.h> - + #ifdef __cplusplus -extern "C" { +extern "C" { #endif - + int flock(int fd, int op) { return Flock((HANDLE)_get_osfhandle(fd), op); } - + int Flock(void* hdl, int op) { errno = 0; - + if (hdl == INVALID_HANDLE_VALUE) { errno = EBADF; return -1; } - + DWORD low = 1, high = 0; OVERLAPPED io; - + Zero(io); UnlockFileEx(hdl, 0, low, high, &io); - + switch (op & ~LOCK_NB) { case LOCK_EX: case LOCK_SH: { @@ -47,9 +47,9 @@ extern "C" { if (LockFileEx(hdl, mode, 0, low, high, &io)) { return 0; } - } + } break; - } + } case LOCK_UN: return 0; break; @@ -58,14 +58,14 @@ extern "C" { } errno = EINVAL; return -1; - } - + } + int fsync(int fd) { return _commit(fd); } - + #ifdef __cplusplus -} +} #endif - -#endif + +#endif |