fsetpos.c 732 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #ifndef __DO_LARGEFILE
  9. #define FSEEK __fseek
  10. #endif
  11. int fsetpos(FILE *stream, register const fpos_t *pos)
  12. {
  13. #ifdef __STDIO_MBSTATE
  14. int retval = -1;
  15. __STDIO_AUTO_THREADLOCK_VAR;
  16. __STDIO_AUTO_THREADLOCK(stream);
  17. if ((retval = FSEEK(stream, pos->__pos, SEEK_SET)) == 0) {
  18. __COPY_MBSTATE(&(stream->__state), &(pos->__mbstate));
  19. stream->__ungot_width[0]= pos->__mblen_pending;
  20. }
  21. __STDIO_AUTO_THREADUNLOCK(stream);
  22. return retval;
  23. #else
  24. return FSEEK(stream, pos->__pos, SEEK_SET);
  25. #endif
  26. }