X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdio%2F_PDCLIB_ftell64.c;h=488f46196a09e19f7b7a3b201c8d22005168b734;hb=3a988bf47bda2322d7759d3c4518c03e0ef98ba4;hp=650eda548d48051863868df176fffdb1584ecf51;hpb=05556502a427911d4499c22b809ca7d366327d7c;p=pdclib diff --git a/functions/stdio/_PDCLIB_ftell64.c b/functions/stdio/_PDCLIB_ftell64.c index 650eda5..488f461 100644 --- a/functions/stdio/_PDCLIB_ftell64.c +++ b/functions/stdio/_PDCLIB_ftell64.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* _PDCLIB_ftell64( FILE * ) This file is part of the Public Domain C Library (PDCLib). @@ -11,8 +9,9 @@ #include #ifndef REGTEST +#include <_PDCLIB_io.h> -uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream ) +uint_fast64_t _PDCLIB_ftell64_unlocked( FILE * stream ) { /* ftell() must take into account: - the actual *physical* offset of the file, i.e. the offset as recognized @@ -38,6 +37,14 @@ uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream ) return ( stream->pos.offset - ( ( (int)stream->bufend - (int)stream->bufidx ) + (int)stream->ungetidx ) ); } +uint_fast64_t _PDCLIB_ftell64( FILE * stream ) +{ + _PDCLIB_flockfile( stream ); + uint_fast64_t pos = _PDCLIB_ftell64_unlocked( stream ); + _PDCLIB_funlockfile( stream ); + return pos; +} + #endif #ifdef TEST