mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Use re-entrant locks on stdio
This commit is contained in:
parent
4e9662cbc7
commit
1f229e4efc
78 changed files with 427 additions and 179 deletions
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/spinlock.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
|
@ -41,7 +40,7 @@ FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
|
|||
FILE *res;
|
||||
unsigned flags;
|
||||
flags = fopenflags(mode);
|
||||
_spinlock(&stream->lock);
|
||||
flockfile(stream);
|
||||
fflush_unlocked(stream);
|
||||
if (pathname) {
|
||||
/* open new stream, overwriting existing alloc */
|
||||
|
@ -60,6 +59,6 @@ FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
|
|||
fcntl(stream->fd, F_SETFL, flags & ~O_CLOEXEC);
|
||||
res = stream;
|
||||
}
|
||||
_spunlock(&stream->lock);
|
||||
funlockfile(stream);
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue