]> pd.if.org Git - pdclib/blobdiff - functions/stdio/fputc.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[pdclib] / functions / stdio / fputc.c
index 818d45f645057fe4c93954964eb6b9d4c526e098..ae998eaacb0562c01070589c56f4400ae9451c8c 100644 (file)
@@ -16,7 +16,7 @@
    Returns c if successful, EOF otherwise.
    If a write error occurs, the error indicator of the stream is set.
 */
-int fputc( int c, struct _PDCLIB_file_t * stream )
+int fputc_unlocked( int c, struct _PDCLIB_file_t * stream )
 {
     if ( _PDCLIB_prepwrite( stream ) == EOF )
     {
@@ -34,6 +34,14 @@ int fputc( int c, struct _PDCLIB_file_t * stream )
     return c;
 }
 
+int fputc( int c, struct _PDCLIB_file_t * stream )
+{
+    flockfile( stream );
+    int r = fputc_unlocked( c, stream );
+    funlockfile( stream );
+    return r;
+}
+
 #endif
 
 #ifdef TEST