summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-08 03:27:33 +0000
committerDavid Robillard <d@drobilla.net>2012-01-08 03:27:33 +0000
commit47bdfa160502acc78cb90f350258fe975e4f956f (patch)
treed86ba2004cc536dcdac3ca685a3eb5d5ba7284a6
parenta79fe5a88d0ef9f440fd6b8330a82fb67839fabd (diff)
downloadlilv-47bdfa160502acc78cb90f350258fe975e4f956f.tar.gz
lilv-47bdfa160502acc78cb90f350258fe975e4f956f.tar.bz2
lilv-47bdfa160502acc78cb90f350258fe975e4f956f.zip
Use flock instead of lockf (seems to be more portable).
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3919 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/util.c9
-rw-r--r--wscript7
2 files changed, 9 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c
index b421660..cda7468 100644
--- a/src/util.c
+++ b/src/util.c
@@ -15,7 +15,6 @@
*/
#define _POSIX_SOURCE 1 /* for wordexp, fileno */
-#define _BSD_SOURCE 1 /* for lockf */
#include <assert.h>
#include <errno.h>
@@ -28,6 +27,10 @@
#include <sys/types.h>
#include <unistd.h>
+#if defined(HAVE_FLOCK) && defined(HAVE_FILENO)
+# include <sys/file.h>
+#endif
+
#include "lilv_internal.h"
#ifdef HAVE_WORDEXP
@@ -354,8 +357,8 @@ lilv_path_is_child(const char* path, const char* dir)
int
lilv_flock(FILE* file, bool lock)
{
-#if defined(HAVE_LOCKF) && defined(HAVE_FILENO)
- return lockf(fileno(file), lock ? F_LOCK : F_ULOCK, 0);
+#if defined(HAVE_FLOCK) && defined(HAVE_FILENO)
+ return flock(fileno(file), lock ? LOCK_EX : LOCK_UN);
#else
return 0;
#endif
diff --git a/wscript b/wscript
index 4d9de86..730c814 100644
--- a/wscript
+++ b/wscript
@@ -86,10 +86,9 @@ def configure(conf):
define_name='HAVE_WORDEXP',
mandatory=False)
- conf.check_cc(function_name='lockf',
- header_name='unistd.h',
- defines='_BSD_SOURCE',
- define_name='HAVE_LOCKF',
+ conf.check_cc(function_name='flock',
+ header_name='sys/file.h',
+ define_name='HAVE_FLOCK',
mandatory=False)
conf.check_cc(function_name='fileno',