]> pd.if.org Git - pdclib/blobdiff - functions/stdio/ungetc.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[pdclib] / functions / stdio / ungetc.c
index 001735b533c04361648b2c3eb5475cdced99faac..45b8a92a73e9fc004146ad9d46aae51bd0e9d013 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifndef REGTEST
 
-int ungetc( int c, struct _PDCLIB_file_t * stream )
+int ungetc_unlocked( int c, struct _PDCLIB_file_t * stream )
 {
     if ( c == EOF || stream->ungetidx == _PDCLIB_UNGETCBUFSIZE )
     {
@@ -19,6 +19,14 @@ int ungetc( int c, struct _PDCLIB_file_t * stream )
     return stream->ungetbuf[stream->ungetidx++] = (unsigned char) c;
 }
 
+int ungetc( int c, struct _PDCLIB_file_t * stream )
+{
+    flockfile( stream );
+    int r = ungetc_unlocked( c, stream );
+    funlockfile( stream);
+    return r;
+}
+
 #endif
 
 #ifdef TEST