lib/util/lockfile.h
raw| 1 | /// @file |
| 2 | /// @brief platform abstraction over `flockfile` |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | static inline void lockfile(FILE *file) { |
| 9 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 10 | _lock_file(file); |
| 11 | #else |
| 12 | flockfile(file); |
| 13 | #endif |
| 14 | } |
| 15 | |
| 16 | static inline void unlockfile(FILE *file) { |
| 17 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 18 | _unlock_file(file); |
| 19 | #else |
| 20 | funlockfile(file); |
| 21 | #endif |
| 22 | } |