/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: setBuffering.c,v 1.4 1999/03/01 09:26:45 sof Exp $
+ * $Id: setBuffering.c,v 1.8 2000/04/14 16:19:43 rrt Exp $
*
* hSetBuffering Runtime Support
*/
#define SB_BB (-2)
StgInt
-setBuffering(ptr, size)
-StgForeignPtr ptr;
-StgInt size;
+setBuffering(StgForeignPtr ptr, StgInt size)
{
IOFileObject* fo = (IOFileObject*)ptr;
int flags, rc=0;
/* First off, flush old buffer.. */
- if ( (fo->flags & FILEOBJ_FLUSH) ) {
+ if ( (fo->flags & FILEOBJ_WRITE) ) {
rc = flushBuffer(ptr);
}
if (rc<0) return rc;
break;
case SB_BB:
-#if HAVE_ST_BLKSIZE
+#ifdef HAVE_ST_BLKSIZE
while (fstat(fo->fd, &sb) < 0) {
/* not very likely.. */
if ( errno != EINTR ) {
fo->buf = malloc(size*sizeof(char));
if (fo->buf == NULL) {
return -1;
- }
- fo->bufSize = size;
+ }
}
+ fo->bufSize = size;
#ifndef mingw32_TARGET_OS
if (isaterm) {