File: pthread-dont-override-errno-location.diff

package info (click to toggle)
dietlibc 0.34~cvs20160606-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,768 kB
  • sloc: ansic: 71,692; asm: 13,008; cpp: 1,860; makefile: 817; sh: 300; perl: 62
file content (36 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (2)
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
34
35
36
Description: Don't override errno_location in libpthread if TLS is enabled
 If TLS is enabled, errno is already thread-safe. Don't override
 errno_location in that case, otherwise the errno external code sees is not
 the same as the errno syscalls see (that call __errno_location directly).
Author: Christian Seiler <christian@iwakd.de>
Bug-Debian: https://bugs.debian.org/850276
Last-Update: 2017-01-05

--- a/libpthread/pthread_internal.c
+++ b/libpthread/pthread_internal.c
@@ -155,11 +155,14 @@ static void kill_all_threads(int sig,int
 }
 
 
+/* If thread local storage is enabled, we don't need this. */
+#ifndef WANT_TLS
 /* thread errno location */
 int *__errno_location() {
   _pthread_descr td=__thread_self();
   return &(td->errno);
 }
+#endif
 
 /* exit a thread */
 static void __pthread_exit(void*retval) {
--- a/libpthread/thread_internal.h
+++ b/libpthread/thread_internal.h
@@ -43,7 +43,7 @@ struct _pthread_descr_struct {
   struct _pthread_fastlock lock;
   struct _pthread_fastlock wlock;
 
-  /* errno handling */
+  /* errno handling - not used if WANT_TLS is defined */
   int errno;
 
   /* thread exit handling */