[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / runtime / io / filePosn.lc
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1994
3 %
4 \subsection[filePosn.lc]{hGetPosn and hSetPosn Runtime Support}
5
6 \begin{code}
7
8 #include "rtsdefs.h"
9 #include "stgio.h"
10
11 StgInt
12 getFilePosn(fp)
13 StgAddr fp;
14 {
15     StgInt posn;
16
17     while ((posn = ftell((FILE *) fp)) == -1) {
18         /* the possibility seems awfully remote */
19         if (errno != EINTR) {
20             cvtErrno();
21             stdErrno();
22             return -1;
23         }
24     }
25     return posn;
26 }
27
28 /* The following is only called with a position that we've already visited */
29
30 StgInt
31 setFilePosn(fp, posn)
32 StgAddr fp;
33 StgInt posn;
34 {
35     while (fseek((FILE *) fp, posn, SEEK_SET) != 0) {
36         if (errno != EINTR) {
37             cvtErrno();
38             stdErrno();
39             return -1;
40         }
41     }
42     return 0;
43 }
44
45 \end{code}
46
47
48