fsetpos.c 756 B

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