summaryrefslogtreecommitdiff
path: root/libraries/base/include
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-11-20 12:10:53 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-11-20 12:10:53 +0000
commit5f59f657556ccde209b17784d74e0eb38312b989 (patch)
treeb35886b65f03791723d4a91cc5b8eb1aed56e87d /libraries/base/include
parent530c5c77a9fb6f8464c53b766f1bff3907f6b46a (diff)
downloadhaskell-5f59f657556ccde209b17784d74e0eb38312b989.tar.gz
Move file locking into the RTS, fixing #629, #1109
File locking (of the Haskell 98 variety) was previously done using a static table with linear search, which had two problems: the array had a fixed size and was sometimes too small (#1109), and performance of lockFile/unlockFile was suboptimal due to the linear search. Also the algorithm failed to count readers as required by Haskell 98 (#629). Now it's done using a hash table (provided by the RTS). Furthermore I avoided the extra fstat() for every open file by passing the dev_t and ino_t into lockFile. This and the improvements to the locking algorithm result in a healthy 20% or so performance increase for opening/closing files (see openFile008 test).
Diffstat (limited to 'libraries/base/include')
-rw-r--r--libraries/base/include/HsBase.h3
-rw-r--r--libraries/base/include/lockFile.h14
2 files changed, 2 insertions, 15 deletions
diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h
index dfe68402af..e067c259eb 100644
--- a/libraries/base/include/HsBase.h
+++ b/libraries/base/include/HsBase.h
@@ -125,7 +125,6 @@
#if HAVE_VFORK_H
#include <vfork.h>
#endif
-#include "lockFile.h"
#include "dirUtils.h"
#include "WCsubst.h"
@@ -502,6 +501,8 @@ INLINE time_t __hscore_st_mtime ( struct stat* st ) { return st->st_mtime; }
INLINE off_t __hscore_st_size ( struct stat* st ) { return st->st_size; }
#if !defined(_MSC_VER)
INLINE mode_t __hscore_st_mode ( struct stat* st ) { return st->st_mode; }
+INLINE mode_t __hscore_st_dev ( struct stat* st ) { return st->st_dev; }
+INLINE mode_t __hscore_st_ino ( struct stat* st ) { return st->st_ino; }
#endif
#if HAVE_TERMIOS_H
diff --git a/libraries/base/include/lockFile.h b/libraries/base/include/lockFile.h
deleted file mode 100644
index b6deaf41be..0000000000
--- a/libraries/base/include/lockFile.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * (c) The University of Glasgow 2001
- *
- * $Id: lockFile.h,v 1.3 2005/01/28 13:36:34 simonmar Exp $
- *
- * lockFile header
- */
-
-#if !(defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32))
-
-int lockFile(int fd, int for_writing, int exclusive);
-int unlockFile(int fd);
-
-#endif