]> pd.if.org Git - pdclib/blobdiff - functions/stdio/fseek.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[pdclib] / functions / stdio / fseek.c
index 8e10c2ba007f49cd599c7c5fc62275995076e729..c897325509b4421e7277d8eb4f77b1dc9f5738b8 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <_PDCLIB_glue.h>
 
-int fseek( struct _PDCLIB_file_t * stream, long loffset, int whence )
+int fseek_unlocked( struct _PDCLIB_file_t * stream, long loffset, int whence )
 {
     _PDCLIB_int64_t offset = loffset;
     if ( stream->status & _PDCLIB_FWRITE )
@@ -37,6 +37,14 @@ int fseek( struct _PDCLIB_file_t * stream, long loffset, int whence )
     return ( _PDCLIB_seek( stream, offset, whence ) != EOF ) ? 0 : EOF;
 }
 
+int fseek( struct _PDCLIB_file_t * stream, long loffset, int whence )
+{
+    flockfile( stream );
+    int r = fseek_unlocked( stream, loffset, whence );
+    funlockfile( stream );
+    return r;
+}
+
 #endif
 
 #ifdef TEST