]> git.saurik.com Git - apple/libc.git/blobdiff - stdio/FreeBSD/rewind.c
Libc-1439.100.3.tar.gz
[apple/libc.git] / stdio / FreeBSD / rewind.c
index b5204ed3a038b6c5640892e491103c46f2dfc4a0..33aea2f5515bbecadc4d5f895a8050058057cea3 100644 (file)
@@ -49,13 +49,12 @@ rewind(FILE *fp)
        int serrno = errno;
 
        /* make sure stdio is set up */
-       if (!__sdidinit)
-               __sinit();
+       pthread_once(&__sdidinit, __sinit);
 
        FLOCKFILE(fp);
        if (_fseeko(fp, (off_t)0, SEEK_SET, 1) == 0) {
-               clearerr_unlocked(fp);
                errno = serrno;
        }
+       clearerr_unlocked(fp);  /* POSIX: clear stdio error regardless */
        FUNLOCKFILE(fp);
 }