fgetpos.c 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifdef __DO_LARGEFILE
  9. # ifndef __UCLIBC_HAS_LFS__
  10. # error large file support is not enabled!
  11. # endif
  12. # define fgetpos fgetpos64
  13. # define fpos_t fpos64_t
  14. # define ftell ftello64
  15. #endif
  16. int fgetpos(FILE * __restrict stream, register fpos_t * __restrict pos)
  17. {
  18. #ifdef __STDIO_MBSTATE
  19. int retval = -1;
  20. __STDIO_AUTO_THREADLOCK_VAR;
  21. __STDIO_AUTO_THREADLOCK(stream);
  22. if ((pos->__pos = ftell(stream)) >= 0) {
  23. __COPY_MBSTATE(&(pos->__mbstate), &(stream->__state));
  24. pos->__mblen_pending = stream->__ungot_width[0];
  25. retval = 0;
  26. }
  27. __STDIO_AUTO_THREADUNLOCK(stream);
  28. return retval;
  29. #else
  30. return ((pos->__pos = ftell(stream)) >= 0) ? 0 : -1;
  31. #endif
  32. }