summaryrefslogtreecommitdiff
path: root/ghc/runtime/io/filePutc.lc
blob: bca57bafbeec439f3533f823177e886010972f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%
% (c) The GRASP/AQUA Project, Glasgow University, 1994
%
\subsection[filePuc.lc]{hPutChar Runtime Support}

\begin{code}

#include "rtsdefs.h"
#include "stgio.h"
#include "error.h"

StgInt
filePutc(fp, c)
StgAddr fp;
StgInt c;
{
    int rc;

    /* Try to read a character */
    while ((rc = putc((int) c, (FILE *) fp)) == EOF && errno == EINTR)
	clearerr((FILE *) fp);

    if (rc == EOF) {
	cvtErrno();
	stdErrno();
	return -1;
    }

    return 0;
}

\end{code}