[project @ 1998-04-10 10:54:14 by simonm]
[ghc-hetmet.git] / ghc / lib / std / cbits / filePosn.c
1 /* 
2  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
3  *
4  * $Id: filePosn.c,v 1.1 1998/04/10 10:54:25 simonm Exp $
5  *
6  * hGetPosn and hSetPosn Runtime Support
7  */
8
9 #include "Rts.h"
10 #include "stgio.h"
11
12 StgInt
13 getFilePosn(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(StgAddr fp, I_ posn)
32 {
33     while (fseek((FILE *) fp, posn, SEEK_SET) != 0) {
34         if (errno != EINTR) {
35             cvtErrno();
36             stdErrno();
37             return -1;
38         }
39     }
40     return 0;
41 }
42
43