2018-01-01 00:32:25 +00:00
|
|
|
/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
2001-07-06 04:58:11 +00:00
|
|
|
This file is part of the GNU C Library.
|
1995-11-20 03:48:11 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1995-11-20 03:48:11 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1997-08-20 03:53:21 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1995-11-20 03:48:11 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
|
<http://www.gnu.org/licenses/>.
|
1995-11-20 03:48:11 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
As a special exception, if you link the code in this file with
|
|
|
|
|
files compiled with a GNU compiler to produce an executable,
|
|
|
|
|
that does not cause the resulting executable to be covered by
|
|
|
|
|
the GNU Lesser General Public License. This exception does not
|
|
|
|
|
however invalidate any other reasons why the executable file
|
|
|
|
|
might be covered by the GNU Lesser General Public License.
|
|
|
|
|
This exception applies to code released by its copyright holders
|
|
|
|
|
in files containing the exception. */
|
1995-11-20 03:48:11 +00:00
|
|
|
|
|
|
|
|
#include "libioP.h"
|
|
|
|
|
|
2018-02-07 18:42:04 -05:00
|
|
|
size_t
|
|
|
|
|
_IO_fwrite (const void *buf, size_t size, size_t count, FILE *fp)
|
1995-11-20 03:48:11 +00:00
|
|
|
{
|
2018-02-07 18:42:04 -05:00
|
|
|
size_t request = size * count;
|
|
|
|
|
size_t written = 0;
|
1995-11-20 03:48:11 +00:00
|
|
|
CHECK_FILE (fp, 0);
|
|
|
|
|
if (request == 0)
|
2000-06-08 06:17:50 +00:00
|
|
|
return 0;
|
2003-08-29 19:58:49 +00:00
|
|
|
_IO_acquire_lock (fp);
|
2003-08-12 18:40:03 +00:00
|
|
|
if (_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
|
1999-06-16 22:55:47 +00:00
|
|
|
written = _IO_sputn (fp, (const char *) buf, request);
|
2003-08-29 19:58:49 +00:00
|
|
|
_IO_release_lock (fp);
|
2013-10-11 22:29:38 +05:30
|
|
|
/* We have written all of the input in case the return value indicates
|
|
|
|
|
this or EOF is returned. The latter is a special case where we
|
|
|
|
|
simply did not manage to flush the buffer. But the data is in the
|
|
|
|
|
buffer and therefore written as far as fwrite is concerned. */
|
|
|
|
|
if (written == request || written == EOF)
|
1995-11-20 03:48:11 +00:00
|
|
|
return count;
|
|
|
|
|
else
|
1997-08-20 03:53:21 +00:00
|
|
|
return written / size;
|
1995-11-20 03:48:11 +00:00
|
|
|
}
|
2012-05-23 13:33:15 +02:00
|
|
|
libc_hidden_def (_IO_fwrite)
|
1995-11-20 03:48:11 +00:00
|
|
|
|
2002-08-10 09:24:53 +00:00
|
|
|
# include <stdio.h>
|
1995-11-20 03:48:11 +00:00
|
|
|
weak_alias (_IO_fwrite, fwrite)
|
2002-08-10 09:24:53 +00:00
|
|
|
libc_hidden_weak (fwrite)
|
1999-07-30 06:32:48 +00:00
|
|
|
# ifndef _IO_MTSAFE_IO
|
|
|
|
|
weak_alias (_IO_fwrite, fwrite_unlocked)
|
2002-11-24 23:56:47 +00:00
|
|
|
libc_hidden_weak (fwrite_unlocked)
|
1999-07-30 06:32:48 +00:00
|
|
|
# endif
|