diff options
Diffstat (limited to 'src/lock.c')
-rw-r--r-- | src/lock.c | 39 |
1 files changed, 29 insertions, 10 deletions
@@ -1,9 +1,10 @@ -#include <unistd.h> -#include <sys/types.h> -#include <sys/file.h> -#include <fcntl.h> #include "lock.h" +#include <fcntl.h> +#include <sys/file.h> +#include <sys/types.h> +#include <unistd.h> + /** @file lock.c @author djb @@ -12,11 +13,29 @@ */ #ifdef HASFLOCK -int lock_ex(int fd) { return flock(fd,LOCK_EX); } -int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); } -int lock_un(int fd) { return flock(fd,LOCK_UN); } +int lock_ex(int fd) +{ + return flock(fd, LOCK_EX); +} +int lock_exnb(int fd) +{ + return flock(fd, LOCK_EX | LOCK_NB); +} +int lock_un(int fd) +{ + return flock(fd, LOCK_UN); +} #else -int lock_ex(int fd) { return lockf(fd,1,0); } -int lock_exnb(int fd) { return lockf(fd,2,0); } -int lock_un(int fd) { return lockf(fd,0,0); } +int lock_ex(int fd) +{ + return lockf(fd, 1, 0); +} +int lock_exnb(int fd) +{ + return lockf(fd, 2, 0); +} +int lock_un(int fd) +{ + return lockf(fd, 0, 0); +} #endif |