summaryrefslogtreecommitdiff
path: root/ghc/runtime/io/filePosn.lc
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/runtime/io/filePosn.lc')
-rw-r--r--ghc/runtime/io/filePosn.lc48
1 files changed, 48 insertions, 0 deletions
diff --git a/ghc/runtime/io/filePosn.lc b/ghc/runtime/io/filePosn.lc
new file mode 100644
index 0000000000..826c4f48b3
--- /dev/null
+++ b/ghc/runtime/io/filePosn.lc
@@ -0,0 +1,48 @@
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1994
+%
+\subsection[filePosn.lc]{hGetPosn and hSetPosn Runtime Support}
+
+\begin{code}
+
+#include "rtsdefs.h"
+#include "stgio.h"
+
+StgInt
+getFilePosn(fp)
+StgAddr fp;
+{
+ StgInt posn;
+
+ while ((posn = ftell((FILE *) fp)) == -1) {
+ /* the possibility seems awfully remote */
+ if (errno != EINTR) {
+ cvtErrno();
+ stdErrno();
+ return -1;
+ }
+ }
+ return posn;
+}
+
+/* The following is only called with a position that we've already visited */
+
+StgInt
+setFilePosn(fp, posn)
+StgAddr fp;
+StgInt posn;
+{
+ while (fseek((FILE *) fp, posn, SEEK_SET) != 0) {
+ if (errno != EINTR) {
+ cvtErrno();
+ stdErrno();
+ return -1;
+ }
+ }
+ return 0;
+}
+
+\end{code}
+
+
+