PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/arm-gp2x-linux-glibc-2.3.6/glibc-2.3.6/libio/iofwrite.c

#
C | 62 lines | 32 code | 3 blank | 27 comment | 8 complexity | 2f2fb57dbb4cdcdbb230132cf501c0e8 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause, LGPL-2.0
  1. /* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2002, 2003
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. As a special exception, if you link the code in this file with
  17. files compiled with a GNU compiler to produce an executable,
  18. that does not cause the resulting executable to be covered by
  19. the GNU Lesser General Public License. This exception does not
  20. however invalidate any other reasons why the executable file
  21. might be covered by the GNU Lesser General Public License.
  22. This exception applies to code released by its copyright holders
  23. in files containing the exception. */
  24. #include "libioP.h"
  25. _IO_size_t
  26. _IO_fwrite (buf, size, count, fp)
  27. const void *buf;
  28. _IO_size_t size;
  29. _IO_size_t count;
  30. _IO_FILE *fp;
  31. {
  32. _IO_size_t request = size * count;
  33. _IO_size_t written = 0;
  34. CHECK_FILE (fp, 0);
  35. if (request == 0)
  36. return 0;
  37. _IO_acquire_lock (fp);
  38. if (_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
  39. written = _IO_sputn (fp, (const char *) buf, request);
  40. _IO_release_lock (fp);
  41. if (written == request)
  42. return count;
  43. else
  44. return written / size;
  45. }
  46. INTDEF(_IO_fwrite)
  47. #ifdef weak_alias
  48. # include <stdio.h>
  49. weak_alias (_IO_fwrite, fwrite)
  50. libc_hidden_weak (fwrite)
  51. # ifndef _IO_MTSAFE_IO
  52. weak_alias (_IO_fwrite, fwrite_unlocked)
  53. libc_hidden_weak (fwrite_unlocked)
  54. # endif
  55. #endif