]> Nishi Git Mirror - dataworks.git/commitdiff
make lock work on linux too
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 17:09:52 +0000 (17:09 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 17:09:52 +0000 (17:09 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@36 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Library/util.c
common-decl.mk

index cb47e651326f0f0dabb834e86d96be9084bda743..9273a17b7974bf0c64385f638a16ed2e4fbf5306 100644 (file)
@@ -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;
 }
index 03d5677095f940e11cc862dd6101a0096588060c..ea523c70e3b4766ecd95d5668f2d5fd61fad4a9f 100644 (file)
@@ -1,7 +1,7 @@
 # $Id$
 
 CC = cc
-CFLAGS = -std=c99
+CFLAGS = -std=c99 -D_DEFAULT_SOURCE
 LDFLAGS = -L`pwd`/Library
 LIBS =
 LIB_PREFIX = lib