-/* Copyright (C) 1991, 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 92, 93, 94, 96, 97, 98 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
-#include <ansidecl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
/* Write NMEMB chunks of SIZE bytes each from PTR onto STREAM. */
size_t
-DEFUN(fwrite, (ptr, size, nmemb, stream),
- CONST PTR ptr AND size_t size AND
- size_t nmemb AND register FILE *stream)
+fwrite (ptr, size, nmemb, stream)
+ const void *ptr;
+ size_t size;
+ size_t nmemb;
+ register FILE *stream;
{
- register CONST unsigned char *p = (CONST unsigned char *) ptr;
+ register const unsigned char *p = (const unsigned char *) ptr;
register size_t to_write = size * nmemb;
register size_t written = 0;
int newlinep;
if (!__validfp (stream) || !stream->__mode.__write)
{
- errno = EINVAL;
+ __set_errno (EINVAL);
return 0;
}
goto done;
}
- errno = save;
+ __set_errno (save);
}
if (stream->__buffer == NULL && default_func &&
{
int count = (stream->__io_funcs.__write == NULL ? to_write :
(*stream->__io_funcs.__write) (stream->__cookie,
- (CONST char *) p,
+ (const char *) p,
to_write));
if (count > 0)
{
buffer_space = stream->__bufsize - (stream->__bufp - stream->__buffer);
newlinep = (stream->__linebuf &&
- memchr ((CONST PTR) p, '\n', to_write) != NULL);
+ memchr ((const void *) p, '\n', to_write) != NULL);
if (newlinep && stream->__bufp == stream->__buffer &&
stream->__offset == stream->__target)
*stream->__bufp++ = *p++;
else
{
- memcpy ((PTR) stream->__bufp, (PTR) p, n);
+ memcpy ((void *) stream->__bufp, (void *) p, n);
stream->__bufp += n;
p += n;
}
done:;
return (size_t) written / size;
}
+
+weak_alias (fwrite, fwrite_unlocked)