summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ferror.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/ferror.c')
-rw-r--r--lib/libc/stdio/ferror.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c
index 2311926..c4424c6 100644
--- a/lib/libc/stdio/ferror.c
+++ b/lib/libc/stdio/ferror.c
@@ -42,16 +42,24 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include <stdio.h>
+#include "un-namespace.h"
+#include "libc_private.h"
/*
- * A subroutine version of the macro ferror.
+ * ferror has traditionally been a macro in <stdio.h>. That is no
+ * longer true because it needs to be thread-safe.
+ *
+ * #undef ferror
*/
-#undef ferror
-
int
-ferror(fp)
- FILE *fp;
+ferror(FILE *fp)
{
- return (__sferror(fp));
+ int ret;
+
+ FLOCKFILE(fp);
+ ret = __sferror(fp);
+ FUNLOCKFILE(fp);
+ return (ret);
}
OpenPOWER on IntegriCloud