diff options
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 fe88fecaff..f00b7fd5d1 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 |