fgetpos.c 756 B

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