Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
- index 85464fa..4512622 100644
- --- a/libc/stdio/_stdio.h
- +++ b/libc/stdio/_stdio.h
- @@ -22,9 +22,20 @@
- #ifdef __UCLIBC_HAS_WCHAR__
- #include <wchar.h>
- #endif
- +#ifdef __UCLIBC_HAS_THREADS__
- +#include "pthreadP.h"
- +#endif
- #include <bits/uClibc_mutex.h>
- +#ifdef __UCLIBC_HAS_THREADS__
- + #define DISABLE_CANCELLABILITY(oldstate) __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &(oldstate))
- + #define RESTORE_CANCELLABILITY(oldstate) __pthread_setcancelstate(oldstate, NULL)
- +#else
- + #define DISABLE_CANCELLABILITY(oldstate) ((void)0)
- + #define RESTORE_CANCELLABILITY(oldstate) ((void)0)
- +#endif
- +
- #define __STDIO_THREADLOCK_OPENLIST_ADD \
- __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_add_lock)
- @@ -149,9 +160,16 @@ static inline ssize_t __READ(FILE *stream, char *buf, size_t bufsize)
- static inline ssize_t __WRITE(FILE *stream, const char *buf, size_t bufsize)
- {
- + ssize_t ret;
- +#ifdef __UCLIBC_HAS_THREADS__
- + int oldstate;
- +#endif
- + DISABLE_CANCELLABILITY(oldstate);
- __STDIO_STREAM_CUSTOM_WRITE_FUNC(stream, buf, bufsize);
- - return write(stream->__filedes, buf, bufsize);
- + ret = write(stream->__filedes, buf, bufsize);
- + RESTORE_CANCELLABILITY(oldstate);
- + return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment