summaryrefslogtreecommitdiff
path: root/src/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lock.c')
-rw-r--r--src/lock.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/lock.c b/src/lock.c
index 4ac6b40..cec290e 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -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