From 130b1e17297f3853c31521e323517eb6dee17c4a Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 18 May 2024 17:09:52 +0000 Subject: [PATCH] make lock work on linux too git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@36 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Library/util.c | 6 ++++-- common-decl.mk | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/util.c b/Library/util.c index cb47e65..9273a17 100644 --- a/Library/util.c +++ b/Library/util.c @@ -51,7 +51,8 @@ bool __dw_lockfile(FILE* fp){ OVERLAPPED overlap = {0}; LockFileEx(fp, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlap); #else - lockf(fp, F_LOCK); + fseek(fp, SEEK_SET, 0); + lockf(fileno(fp), F_LOCK, 0); #endif return false; } @@ -61,7 +62,8 @@ bool __dw_unlockfile(FILE* fp){ OVERLAPPED overlap = {0}; UnlockFileEx(fp, 0, MAXDWORD, MAXDWORD, &overlap); #else - lockf(fp, F_ULOCK); + fseek(fp, SEEK_SET, 0); + lockf(fileno(fp), F_ULOCK, 0); #endif return false; } diff --git a/common-decl.mk b/common-decl.mk index 03d5677..ea523c7 100644 --- a/common-decl.mk +++ b/common-decl.mk @@ -1,7 +1,7 @@ # $Id$ CC = cc -CFLAGS = -std=c99 +CFLAGS = -std=c99 -D_DEFAULT_SOURCE LDFLAGS = -L`pwd`/Library LIBS = LIB_PREFIX = lib -- 2.43.0