aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/flock.h
blob: 797b1970a1fd46dfd9b45289b8cb1281a1a15d4c (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_