svn commit: branches/uClibc-nptl: include libc/misc/internals libc/sysdeps etc...

sjhill at uclibc.org sjhill at uclibc.org
Thu Jan 5 01:31:23 UTC 2006


Author: sjhill
Date: 2006-01-04 17:31:22 -0800 (Wed, 04 Jan 2006)
New Revision: 13096

Log:
And finally, make 'errno' and TLS variable. The TLS conversion of errno, h_errno and __resp was a real challenge. I am glad that is over with.


Modified:
   branches/uClibc-nptl/include/errno.h
   branches/uClibc-nptl/libc/misc/internals/__errno_location.c
   branches/uClibc-nptl/libc/misc/internals/errno.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/bits/errno.h
   branches/uClibc-nptl/libc/sysdeps/linux/mips/bits/syscalls.h


Changeset:
Modified: branches/uClibc-nptl/include/errno.h
===================================================================
--- branches/uClibc-nptl/include/errno.h	2006-01-05 01:28:23 UTC (rev 13095)
+++ branches/uClibc-nptl/include/errno.h	2006-01-05 01:31:22 UTC (rev 13096)
@@ -43,10 +43,8 @@
    variable.  This redeclaration using the macro still works, but it
    will be a function declaration without a prototype and may trigger
    a -Wstrict-prototypes warning.  */
-#ifndef __ASSEMBLER__
-# ifndef	errno
+#ifndef	errno
 extern int errno;
-# endif
 #endif
 
 #if 0 /*def __USE_GNU      uClibc note: not supported */
@@ -60,6 +58,24 @@
 
 __END_DECLS
 
+#if defined _LIBC && defined __UCLIBC_HAS_THREADS_NATIVE__
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+#  undef errno
+#  ifndef NOT_IN_libc
+#   define errno __libc_errno
+#  else
+#   define errno errno             /* For #ifndef errno tests.  */
+#  endif
+extern __thread int errno attribute_tls_model_ie;
+# endif
+#endif
+
+#define __set_errno(val) (errno = (val))
+
+#ifndef __ASSEMBLER__
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+#endif
+
 #endif /* _ERRNO_H */
 
 /* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so

Modified: branches/uClibc-nptl/libc/misc/internals/__errno_location.c
===================================================================
--- branches/uClibc-nptl/libc/misc/internals/__errno_location.c	2006-01-05 01:28:23 UTC (rev 13095)
+++ branches/uClibc-nptl/libc/misc/internals/__errno_location.c	2006-01-05 01:31:22 UTC (rev 13096)
@@ -1,7 +1,15 @@
 #include <errno.h>
+
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
 #undef errno
+extern int errno;
+#endif
 
-int * weak_const_function __errno_location (void)
+int *
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+weak_const_function
+#endif
+__errno_location (void)
 {
     return &errno;
 }

Modified: branches/uClibc-nptl/libc/misc/internals/errno.c
===================================================================
--- branches/uClibc-nptl/libc/misc/internals/errno.c	2006-01-05 01:28:23 UTC (rev 13095)
+++ branches/uClibc-nptl/libc/misc/internals/errno.c	2006-01-05 01:31:22 UTC (rev 13096)
@@ -1,6 +1,24 @@
 #include <features.h>
-#undef errno
 
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+__thread int errno;
+__thread int h_errno;
+
+#ifdef SHARED
+/*
+ * FIXME: Add usage of hidden attribute for both of these when used in
+ *        the shared library. It currently crashes the linker when doing
+ *        section relocations.
+ */
+extern __thread int __libc_errno __attribute__ ((alias ("errno")));
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno")));
+#else
+extern __thread int __libc_errno __attribute__ ((alias ("errno")));
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno")));
+#endif
+#define h_errno __libc_h_errno
+
+#else
 extern int errno;
 extern int h_errno;
 
@@ -15,3 +33,4 @@
 
 weak_alias (_errno, errno)
 weak_alias(_h_errno, h_errno);
+#endif

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/bits/errno.h
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/bits/errno.h	2006-01-05 01:28:23 UTC (rev 13095)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/bits/errno.h	2006-01-05 01:31:22 UTC (rev 13096)
@@ -31,20 +31,10 @@
 
 # ifndef __ASSEMBLER__
 
-/* We now need a declaration of the `errno' variable.  */
-extern int errno;
-
 /* Function to get address of global `errno' variable.  */
 extern int *__errno_location (void) __THROW __attribute__ ((__const__));
 
-#  if defined _LIBC
-/* We wouldn't need a special macro anymore but it is history.  */
-#   ifndef __set_errno
-#    define __set_errno(val) ((errno) = (val))
-#   endif
-#  endif /* _LIBC */
-
-#  if defined __UCLIBC_HAS_THREADS__
+#  if !defined _LIBC || defined __UCLIBC_HAS_THREADS__
 /* When using threads, errno is a per-thread value.  */
 #   define errno (*__errno_location ())
 #  endif

Modified: branches/uClibc-nptl/libc/sysdeps/linux/mips/bits/syscalls.h
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/mips/bits/syscalls.h	2006-01-05 01:28:23 UTC (rev 13095)
+++ branches/uClibc-nptl/libc/sysdeps/linux/mips/bits/syscalls.h	2006-01-05 01:31:22 UTC (rev 13096)
@@ -10,7 +10,11 @@
 #include <bits/sysnum.h>
 
 #ifndef __set_errno
-# define __set_errno(val) (*__errno_location ()) = (val)
+# ifdef __UCLIBC_HAS_THREADS__
+#  define __set_errno(val) (*__errno_location ()) = (val)
+# else
+#  define __set_errno(val) (errno = (val))
+# endif
 #endif
 #ifndef SYS_ify
 # define SYS_ify(syscall_name)  (__NR_##syscall_name)




More information about the uClibc-cvs mailing list