forked from KolibriOS/kolibrios
newlib-2.1.0
git-svn-id: svn://kolibrios.org@4921 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -26,12 +26,12 @@ INDEX
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
size_t fwrite(const void *<[buf]>, size_t <[size]>,
|
||||
size_t <[count]>, FILE *<[fp]>);
|
||||
size_t fwrite(const void *restrict <[buf]>, size_t <[size]>,
|
||||
size_t <[count]>, FILE *restrict <[fp]>);
|
||||
|
||||
#include <stdio.h>
|
||||
size_t _fwrite_r(struct _reent *<[ptr]>, const void *<[buf]>, size_t <[size]>,
|
||||
size_t <[count]>, FILE *<[fp]>);
|
||||
size_t _fwrite_r(struct _reent *<[ptr]>, const void *restrict <[buf]>, size_t <[size]>,
|
||||
size_t <[count]>, FILE *restrict <[fp]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <stdio.h>
|
||||
@@ -97,12 +97,13 @@ static char sccsid[] = "%W% (Berkeley) %G%";
|
||||
size_t
|
||||
_DEFUN(_fwrite_r, (ptr, buf, size, count, fp),
|
||||
struct _reent * ptr _AND
|
||||
_CONST _PTR buf _AND
|
||||
_CONST _PTR __restrict buf _AND
|
||||
size_t size _AND
|
||||
size_t count _AND
|
||||
FILE * fp)
|
||||
FILE * __restrict fp)
|
||||
{
|
||||
size_t n;
|
||||
#ifdef _FVWRITE_IN_STREAMIO
|
||||
struct __suio uio;
|
||||
struct __siov iov;
|
||||
|
||||
@@ -119,21 +120,45 @@ _DEFUN(_fwrite_r, (ptr, buf, size, count, fp),
|
||||
|
||||
CHECK_INIT(ptr, fp);
|
||||
|
||||
_flockfile (fp);
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT (fp, -1);
|
||||
if (__sfvwrite_r (ptr, fp, &uio) == 0)
|
||||
{
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_exit (fp);
|
||||
return count;
|
||||
}
|
||||
_funlockfile (fp);
|
||||
_newlib_flockfile_end (fp);
|
||||
return (n - uio.uio_resid) / size;
|
||||
#else
|
||||
size_t i = 0;
|
||||
_CONST char *p = buf;
|
||||
n = count * size;
|
||||
CHECK_INIT (ptr, fp);
|
||||
|
||||
_newlib_flockfile_start (fp);
|
||||
ORIENT (fp, -1);
|
||||
/* Make sure we can write. */
|
||||
if (cantwrite (ptr, fp))
|
||||
goto ret;
|
||||
|
||||
while (i < n)
|
||||
{
|
||||
if (__sputc_r (ptr, p[i], fp) == EOF)
|
||||
break;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
ret:
|
||||
_newlib_flockfile_end (fp);
|
||||
return i / size;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
size_t
|
||||
_DEFUN(fwrite, (buf, size, count, fp),
|
||||
_CONST _PTR buf _AND
|
||||
_CONST _PTR __restrict buf _AND
|
||||
size_t size _AND
|
||||
size_t count _AND
|
||||
FILE * fp)
|
||||
|
Reference in New Issue
Block a user