[PATCH] fix errno location for non-TLS case

Andrew Rybchenko Andrew.Rybchenko at oktetlabs.ru
Tue Nov 29 11:04:31 UTC 2011


__errno_location() function should not be library-wide hidden in
non-TLS (thread local storage) case since it should be overriden
by thread-aware function from linuxthreads.old/linuxthreads.
If the function is hidden, calls from libc itself always use it
regardless libpthread linked or not. As the result errno set
in, for example, recv() function is stored in global errno variable
instead of thread-specific location.

Signed-off-by: Andrew Rybchenko <Andrew.Rybchenko at oktetlabs.ru>
---
  libc/misc/internals/__errno_location.c |    3 +++
  libc/sysdeps/linux/common/bits/errno.h |    2 ++
  2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/libc/misc/internals/__errno_location.c 
b/libc/misc/internals/__errno_location.c
index aec7641..371bd26 100644
--- a/libc/misc/internals/__errno_location.c
+++ b/libc/misc/internals/__errno_location.c
@@ -7,6 +7,9 @@
  #include "internal_errno.h"
   /* psm: moved to bits/errno.h: */
+#ifndef __UCLIBC_HAS_TLS__
+libc_hidden_proto(__errno_location)
+#endif
  int *
  #ifndef __UCLIBC_HAS_THREADS__
  weak_const_function
diff --git a/libc/sysdeps/linux/common/bits/errno.h 
b/libc/sysdeps/linux/common/bits/errno.h
index 0bf6354..5f96c31 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -43,7 +43,9 @@
  # ifndef __ASSEMBLER__
  /* Function to get address of global `errno' variable.  */
  extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+#ifdef __UCLIBC_HAS_TLS__
  libc_hidden_proto(__errno_location)
+#endif
   #  ifdef __UCLIBC_HAS_THREADS__
  /* When using threads, errno is a per-thread value.  */
-- 
1.7.2.5


More information about the uClibc mailing list