summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/rts/FileLock.h6
-rw-r--r--rts/FileLock.c (renamed from rts/posix/FileLock.c)11
-rw-r--r--rts/FileLock.h (renamed from rts/posix/FileLock.h)0
-rw-r--r--rts/Linker.c4
-rw-r--r--rts/RtsStartup.c6
5 files changed, 10 insertions, 17 deletions
diff --git a/includes/rts/FileLock.h b/includes/rts/FileLock.h
index a7d8d3cfed..e863883c51 100644
--- a/includes/rts/FileLock.h
+++ b/includes/rts/FileLock.h
@@ -14,11 +14,9 @@
#ifndef RTS_FILELOCK_H
#define RTS_FILELOCK_H
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
+#include "Stg.h"
-int lockFile(int fd, dev_t dev, ino_t ino, int for_writing);
+int lockFile(int fd, StgWord64 dev, StgWord64 ino, int for_writing);
int unlockFile(int fd);
#endif /* RTS_FILELOCK_H */
diff --git a/rts/posix/FileLock.c b/rts/FileLock.c
index cb36366070..44ff67140c 100644
--- a/rts/posix/FileLock.c
+++ b/rts/FileLock.c
@@ -14,13 +14,12 @@
#include "RtsUtils.h"
#include <sys/types.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
typedef struct {
- dev_t device;
- ino_t inode;
+ StgWord64 device;
+ StgWord64 inode;
int readers; // >0 : readers, <0 : writers
} Lock;
@@ -45,8 +44,8 @@ static int cmpLocks(StgWord w1, StgWord w2)
static int hashLock(HashTable *table, StgWord w)
{
Lock *l = (Lock *)w;
- // Just xor the dev_t with the ino_t, hope this is good enough.
- return hashWord(table, (StgWord)l->inode ^ (StgWord)l->device);
+ // Just xor all 32-bit words of inode and device, hope this is good enough.
+ return hashWord(table, l->inode ^ (l->inode >> 32) ^ l->device ^ (l->device >> 32));
}
void
@@ -76,7 +75,7 @@ freeFileLocking(void)
}
int
-lockFile(int fd, dev_t dev, ino_t ino, int for_writing)
+lockFile(int fd, StgWord64 dev, StgWord64 ino, int for_writing)
{
Lock key, *lock;
diff --git a/rts/posix/FileLock.h b/rts/FileLock.h
index 72ab170437..72ab170437 100644
--- a/rts/posix/FileLock.h
+++ b/rts/FileLock.h
diff --git a/rts/Linker.c b/rts/Linker.c
index c437eb09a8..7a72789aa2 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -304,8 +304,6 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(__hscore_get_saved_termios) \
SymI_HasProto(__hscore_set_saved_termios) \
SymI_HasProto(shutdownHaskellAndSignal) \
- SymI_HasProto(lockFile) \
- SymI_HasProto(unlockFile) \
SymI_HasProto(signal_handlers) \
SymI_HasProto(stg_sig_install) \
SymI_HasProto(rtsTimerSignal) \
@@ -1284,6 +1282,8 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_traceCcszh) \
SymI_HasProto(stg_traceEventzh) \
SymI_HasProto(getMonotonicNSec) \
+ SymI_HasProto(lockFile) \
+ SymI_HasProto(unlockFile) \
RTS_USER_SIGNALS_SYMBOLS \
RTS_INTCHAR_SYMBOLS
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index ed13915655..f5c29f4a70 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -35,6 +35,7 @@
#include "Profiling.h"
#include "Timer.h"
#include "Globals.h"
+#include "FileLock.h"
void exitLinker( void ); // there is no Linker.h file to include
#if defined(RTS_GTK_FRONTPANEL)
@@ -52,7 +53,6 @@ void exitLinker( void ); // there is no Linker.h file to include
#if !defined(mingw32_HOST_OS)
#include "posix/TTY.h"
-#include "posix/FileLock.h"
#endif
#ifdef HAVE_UNISTD_H
@@ -215,9 +215,7 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
initGlobalStore();
/* initialise file locking, if necessary */
-#if !defined(mingw32_HOST_OS)
initFileLocking();
-#endif
#if defined(DEBUG)
/* initialise thread label table (tso->char*) */
@@ -376,9 +374,7 @@ hs_exit_(rtsBool wait_foreign)
exitLinker();
/* free file locking tables, if necessary */
-#if !defined(mingw32_HOST_OS)
freeFileLocking();
-#endif
/* free the stable pointer table */
exitStablePtrTable();