summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fgetwc.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-09-20 13:20:41 +0000
committertjr <tjr@FreeBSD.org>2002-09-20 13:20:41 +0000
commit124e10a79789354088f943545a5e56f4cc7c94bd (patch)
treedba84dabdfa686ba4668a3256bd3ecb1eb4313be /lib/libc/stdio/fgetwc.c
parent1919170e9039df45d87abbe1d7b256cc0db1ed19 (diff)
downloadFreeBSD-src-124e10a79789354088f943545a5e56f4cc7c94bd.zip
FreeBSD-src-124e10a79789354088f943545a5e56f4cc7c94bd.tar.gz
Introduce unlocked versions of fputwc() and fgetwc() called __fputwc()
and __fgetwc() which can be used when we know the file is locked.
Diffstat (limited to 'lib/libc/stdio/fgetwc.c')
-rw-r--r--lib/libc/stdio/fgetwc.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c
index 90b17ea..311391a 100644
--- a/lib/libc/stdio/fgetwc.c
+++ b/lib/libc/stdio/fgetwc.c
@@ -38,13 +38,14 @@ __FBSDID("$FreeBSD$");
static __inline wint_t __fgetwc_nbf(FILE *);
+/*
+ * Non-MT-safe version.
+ */
wint_t
-fgetwc(FILE *fp)
+__fgetwc(FILE *fp)
{
wint_t wc;
- FLOCKFILE(fp);
- ORIENT(fp, 1);
if (MB_CUR_MAX == 1) {
/*
* Assume we're using a single-byte locale. A safer test
@@ -53,11 +54,26 @@ fgetwc(FILE *fp)
wc = (wint_t)__sgetc(fp);
} else
wc = __fgetwc_nbf(fp);
- FUNLOCKFILE(fp);
return (wc);
}
+/*
+ * MT-safe version.
+ */
+wint_t
+fgetwc(FILE *fp)
+{
+ wint_t r;
+
+ FLOCKFILE(fp);
+ ORIENT(fp, 1);
+ r = __fgetwc(fp);
+ FUNLOCKFILE(fp);
+
+ return (r);
+}
+
static __inline wint_t
__fgetwc_nbf(FILE *fp)
{
@@ -85,10 +101,8 @@ __fgetwc_nbf(FILE *fp)
break;
}
- FUNLOCKFILE(fp);
while (n-- != 0)
- ungetc((unsigned char)buf[n], fp);
- FLOCKFILE(fp);
+ __ungetc((unsigned char)buf[n], fp);
errno = EILSEQ;
return (WEOF);
}
OpenPOWER on IntegriCloud