flock.h 619 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "error.h"
  3. #include "defaults.h"
  4. #include "file.h"
  5. #if defined(_unix_)
  6. #include <sys/file.h>
  7. #include <fcntl.h>
  8. static inline int Flock(int fd, int op) {
  9. return flock(fd, op);
  10. }
  11. #else // not _unix_
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #define LOCK_SH 1 /* shared lock */
  16. #define LOCK_EX 2 /* exclusive lock */
  17. #define LOCK_NB 4 /* don't block when locking */
  18. #define LOCK_UN 8 /* unlock */
  19. int Flock(void* hndl, int operation);
  20. int flock(int fd, int operation);
  21. int fsync(int fd);
  22. #ifdef __cplusplus
  23. }
  24. #endif
  25. #endif // not _unix_