diff options
author | kib <kib@FreeBSD.org> | 2012-04-24 17:51:36 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-04-24 17:51:36 +0000 |
commit | fa609f4d93f798de2153e04476f9b825aa469491 (patch) | |
tree | 4dea6a5419824f6e6fbe0ef07f6465bd4906fa87 /lib/libc/include | |
parent | f0cabca1b818ea8a0563c3640eddf186f272a402 (diff) | |
download | FreeBSD-src-fa609f4d93f798de2153e04476f9b825aa469491.zip FreeBSD-src-fa609f4d93f798de2153e04476f9b825aa469491.tar.gz |
Take the spinlock around clearing of the fp->_flags in fclose(3), which
indicates the avaliability of FILE, to prevent possible reordering of
the writes as seen by other CPUs.
Reported by: Fengwei yin <yfw.bsd gmail com>
Reviewed by: jhb
MFC after: 1 week
Diffstat (limited to 'lib/libc/include')
-rw-r--r-- | lib/libc/include/libc_private.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index d4b24a7..2182f46 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -81,6 +81,19 @@ void _rtld_error(const char *fmt, ...); #define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) #define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) +struct _spinlock; +extern struct _spinlock __stdio_thread_lock; +#define STDIO_THREAD_LOCK() \ +do { \ + if (__isthreaded) \ + _SPINLOCK(&__stdio_thread_lock); \ +} while (0) +#define STDIO_THREAD_UNLOCK() \ +do { \ + if (__isthreaded) \ + _SPINUNLOCK(&__stdio_thread_lock); \ +} while (0) + /* * Indexes into the pthread jump table. * |