From 7ccde89758f23a7eb90549667cffb084e684ed48 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Tue, 13 Oct 2015 13:06:54 +0900 Subject: [PATCH] Fix build issue on MinGW --- src/fccache.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/fccache.c b/src/fccache.c index b27dcfe..b067ada 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -34,6 +34,9 @@ # include # include #endif +#if defined(_WIN32) +#include +#endif #ifndef O_BINARY #define O_BINARY 0 @@ -1202,6 +1205,10 @@ FcDirCacheLock (const FcChar8 *dir, /* No caches in that directory. simply retry with another one */ if (fd != -1) { +#if defined(_WIN32) + if (_locking (fd, _LK_LOCK, 1) == -1) + goto bail; +#else struct flock fl; fl.l_type = F_WRLCK; @@ -1211,6 +1218,7 @@ FcDirCacheLock (const FcChar8 *dir, fl.l_pid = getpid (); if (fcntl (fd, F_SETLKW, &fl) == -1) goto bail; +#endif break; } } @@ -1224,16 +1232,20 @@ bail: void FcDirCacheUnlock (int fd) { - struct flock fl; - if (fd != -1) { +#if defined(_WIN32) + _locking (fd, _LK_UNLCK, 1); +#else + struct flock fl; + fl.l_type = F_UNLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; fl.l_pid = getpid (); fcntl (fd, F_SETLK, &fl); +#endif close (fd); } }