summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/fclose.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2004-04-08 22:26:50 +0000
committerJeff Johnston <jjohnstn@redhat.com>2004-04-08 22:26:50 +0000
commit47dcaf565d2d1001f7644e4f619ffc06fe753f1d (patch)
tree990ab07dbe60414e36d2bce99e2e5de94544c0c2 /newlib/libc/stdio/fclose.c
parent4121d8cf68e69c4569be2be0fb31c68ab0e6f847 (diff)
downloadcygnal-47dcaf565d2d1001f7644e4f619ffc06fe753f1d.tar.gz
cygnal-47dcaf565d2d1001f7644e4f619ffc06fe753f1d.tar.bz2
cygnal-47dcaf565d2d1001f7644e4f619ffc06fe753f1d.zip
2004-04-08 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* libc/stdio/fclose.c (_fclose_r): New function. * libc/stdio/freopen.c (_freopen_r): Call _fclose_r. * libc/stdio/fcloseall.c (_fcloseall_r): Call _fwalk_reent. * libc/stdio64/freopen64.c (_freopen64_r): Use _fclose_r. * libc/include/stdio.h (_fclose_r): New prototype. * libc/stdio/fopen.c: Fix typo in comment. 2004-04-08 Jeff Johnston <jjohnstn@redhat.com> * libc/stdio/fwalk.c (_fwalk_reent): New version of _fwalk to handle _r reentrant functions.
Diffstat (limited to 'newlib/libc/stdio/fclose.c')
-rw-r--r--newlib/libc/stdio/fclose.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index a125f16ef..0f92e0777 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -4,21 +4,31 @@ FUNCTION
INDEX
fclose
+INDEX
+ _fclose_r
ANSI_SYNOPSIS
#include <stdio.h>
int fclose(FILE *<[fp]>);
+ int _fclose_r(void *<[reent]>, FILE *<[fp]>);
TRAD_SYNOPSIS
#include <stdio.h>
int fclose(<[fp]>)
FILE *<[fp]>;
+
+ int fclose(<[fp]>)
+ void *<[reent]>
+ FILE *<[fp]>;
DESCRIPTION
If the file or stream identified by <[fp]> is open, <<fclose>> closes
it, after first ensuring that any pending data is written (by calling
<<fflush(<[fp]>)>>).
+The alternate function <<_fclose_r>> is a reentrant version.
+The extra argument <[reent]> is a pointer to a reentrancy structure.
+
RETURNS
<<fclose>> returns <<0>> if successful (including when <[fp]> is
<<NULL>> or not an open file); otherwise, it returns <<EOF>>.
@@ -47,6 +57,7 @@ Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>,
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include <reent.h>
#include <stdio.h>
#include <stdlib.h>
#include "local.h"
@@ -57,8 +68,9 @@ Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>,
*/
int
-_DEFUN (fclose, (fp),
- register FILE * fp)
+_DEFUN (_fclose_r, (rptr, fp),
+ struct _reent *rptr _AND
+ register FILE * fp)
{
int r;
@@ -81,7 +93,7 @@ _DEFUN (fclose, (fp),
if (fp->_close != NULL && (*fp->_close) (fp->_cookie) < 0)
r = EOF;
if (fp->_flags & __SMBF)
- _free_r (_REENT, (char *) fp->_bf._base);
+ _free_r (rptr, (char *) fp->_bf._base);
if (HASUB (fp))
FREEUB (fp);
if (HASLB (fp))
@@ -96,3 +108,15 @@ _DEFUN (fclose, (fp),
return (r);
}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (fclose, (fp),
+ register FILE * fp)
+{
+ return _fclose_r(_REENT, fp);
+}
+
+#endif
+