putw.c 651 B

123456789101112131415161718192021222324252627282930
  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. libc_hidden_proto(fwrite_unlocked)
  9. /* SUSv2 Legacy function -- need not be reentrant. */
  10. int putw(int w, FILE *stream)
  11. {
  12. #define PW &w
  13. /* If w is passed in a register, enable the following. */
  14. #if 0
  15. #undef PW
  16. int PW[1];
  17. PW[0] = w;
  18. #endif
  19. #if EOF == -1
  20. return fwrite_unlocked((void *) PW, sizeof(int), 1, stream) - 1;
  21. #else
  22. return (fwrite_unlocked((void *) PW, sizeof(int), 1, stream) != 0)
  23. ? 0 : EOF;
  24. #endif
  25. }