aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/flock.h
blob: 210e834825d0bca47d9c1223ca7dd27c354cbc97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include "error.h"
#include "defaults.h"
#include "file.h" 

#if defined(_unix_)

    #include <sys/file.h>
    #include <fcntl.h>

static inline int Flock(int fd, int op) {
    return flock(fd, op);
}

#else // not _unix_ 

    #ifdef __cplusplus
extern "C" {
    #endif

    #define LOCK_SH 1 /* shared lock */
    #define LOCK_EX 2 /* exclusive lock */
    #define LOCK_NB 4 /* don't block when locking */
    #define LOCK_UN 8 /* unlock */

    int Flock(void* hndl, int operation);
    int flock(int fd, int operation);
    int fsync(int fd);

    #ifdef __cplusplus
}
    #endif

#endif // not _unix_