Advertisement
Guest User

Untitled

a guest
Sep 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.06 KB | None | 0 0
  1. diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c
  2.     index 67775ff..7e2bfd6 100644
  3.     --- a/libc/stdio/puts.c
  4.     +++ b/libc/stdio/puts.c
  5.     @@ -6,8 +6,17 @@
  6.       */
  7.      
  8.      #include "_stdio.h"
  9.     +#ifdef __UCLIBC_HAS_THREADS__
  10.     +#include "pthreadP.h"
  11.      
  12.      
  13.     +static void my_unlock(void *u)
  14.     +{
  15.     +       __lll_unlock(u, LLL_PRIVATE);
  16.     +}
  17.     +
  18.     +#endif
  19.     +
  20.      int puts(register const char * __restrict s)
  21.      {
  22.             register FILE *stream = stdout; /* This helps bcc optimize. */
  23.     @@ -21,12 +30,16 @@ int puts(register const char * __restrict s)
  24.              * then we could have a newline in the buffer of an LBF stream. */
  25.      
  26.             /* Note: Nonportable as fputs need only return nonnegative on success. */
  27.     +
  28.     +
  29.     +       pthread_cleanup_push(my_unlock, (&(stream->__lock.lock)));
  30.             if ((n = fputs_unlocked(s, stream)) != EOF) {
  31.                     ++n;
  32.                     if (__fputc_unlocked('\n', stream) == EOF) {
  33.                             n = EOF;
  34.                     }
  35.             }
  36.     +       pthread_cleanup_pop(0);
  37.      
  38.             __STDIO_AUTO_THREADUNLOCK(stream);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement