aboutsummaryrefslogblamecommitdiffstats
path: root/util/system/flock.h
blob: 797b1970a1fd46dfd9b45289b8cb1281a1a15d4c (plain) (tree)
1
2
3
4
5
6
7
8
9
10
            
 
                  
                     
                 

                   
                         
 

                                         
 
                   
 
                      
            
          
 


                                                    
 

                                         
 
                      
 
          
 
                    
#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_