]> pd.if.org Git - pdclib/blobdiff - functions/stdio/_PDCLIB_ftell64.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[pdclib] / functions / stdio / _PDCLIB_ftell64.c
index 650eda548d48051863868df176fffdb1584ecf51..e0ea368e757e35b81bcdf0d606f7a283520b8971 100644 (file)
@@ -12,7 +12,7 @@
 \r
 #ifndef REGTEST\r
 \r
-uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream )\r
+uint_fast64_t _PDCLIB_ftell64_unlocked( struct _PDCLIB_file_t * stream )\r
 {\r
     /* ftell() must take into account:\r
        - the actual *physical* offset of the file, i.e. the offset as recognized\r
@@ -38,6 +38,14 @@ uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream )
     return ( stream->pos.offset - ( ( (int)stream->bufend - (int)stream->bufidx ) + (int)stream->ungetidx ) );\r
 }\r
 \r
+uint_fast64_t _PDCLIB_ftell64( struct _PDCLIB_file_t * stream )\r
+{\r
+  flockfile( stream );\r
+  uint_fast64_t pos = _PDCLIB_ftell64_unlocked( stream );\r
+  funlockfile( stream );\r
+  return pos;\r
+}\r
+\r
 #endif\r
 \r
 #ifdef TEST\r