aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain/uClibc/patches-0.9.31/000-initialize_stdio_locking.patch
blob: 6a32e5d7c0b5d8f1196fab907aa4da5751af0148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From d4ede2b0a4727c1f5236dd9308f09cbf7a39761a Mon Sep 17 00:00:00 2001
From: Timo Teräs <timo.teras@iki.fi>
Date: Tue, 13 Apr 2010 06:38:59 +0000
Subject: linuxthreads.new: initialize stdio locking

uClibc requires the threading library to enable locking for
stdio, or the locking is not done at all.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
---
diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c
index 6ae9a10..614cad1 100644
--- a/libpthread/linuxthreads/pthread.c
+++ b/libpthread/linuxthreads/pthread.c
@@ -613,6 +613,17 @@ static void pthread_initialize(void)
 #ifdef USE_TLS
   GL(dl_init_static_tls) = &__pthread_init_static_tls;
 #endif
+
+  /* uClibc-specific stdio initialization for threads. */
+  {
+    FILE *fp;
+    _stdio_user_locking = 0;       /* 2 if threading not initialized */
+    for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen) {
+      if (fp->__user_locking != 1) {
+        fp->__user_locking = 0;
+      }
+    }
+  }
 }
 
 void __pthread_initialize(void)