fgetpos.c 703 B

12345678910111213141516171819202122232425262728293031323334
  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. int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos)
  9. {
  10. #ifdef __STDIO_MBSTATE
  11. int retval = -1;
  12. __STDIO_AUTO_THREADLOCK_VAR;
  13. __STDIO_AUTO_THREADLOCK(stream);
  14. if ((pos->__pos = ftell(stream)) >= 0) {
  15. __COPY_MBSTATE(&(pos->__mbstate), &(stream->__state));
  16. pos->__mblen_pending = stream->__ungot_width[0];
  17. retval = 0;
  18. }
  19. __STDIO_AUTO_THREADUNLOCK(stream);
  20. return retval;
  21. #else
  22. return ((pos->__pos = ftell(stream)) >= 0) ? 0 : -1;
  23. #endif
  24. }