putw.c 616 B

1234567891011121314151617181920212223242526272829
  1. /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * GNU Library General Public License (LGPL) version 2 or later.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #include "_stdio.h"
  8. /* SUSv2 Legacy function -- need not be reentrant. */
  9. int putw(int w, FILE *stream)
  10. {
  11. #define PW &w
  12. /* If w is passed in a register, enable the following. */
  13. #if 0
  14. #undef PW
  15. int PW[1];
  16. PW[0] = w;
  17. #endif
  18. #if EOF == -1
  19. return fwrite_unlocked((void *) PW, sizeof(int), 1, stream) - 1;
  20. #else
  21. return (fwrite_unlocked((void *) PW, sizeof(int), 1, stream) != 0)
  22. ? 0 : EOF;
  23. #endif
  24. }