This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: emulating tls for systems without



On 06/10/2006, at 3:53 PM, Paolo Carlini wrote:


Geoffrey Keating wrote:

About this, I would be curious to know whether this enhancement
benefits libstdc++/24025, which, if I remember correctly, only affects
systems not defining _GLIBCXX_HAVE_TLS...


It might make it worse.  The thread emulation code abort()s when it
runs out of memory.

Humm, unfortunately I'm missing too many details about the emulation, sorry about that. Do you mean, it essentially allocates on the heap behind the scenes, similarly to the current ! _GLIBCXX_HAVE_TLS case? Thanks in advance for any clarification,

I only looked at it very briefly, but it does:


+static void
+emutls_init (void)
+{
+#ifndef __GTHREAD_MUTEX_INIT
+  __GTHREAD_MUTEX_INIT_FUNCTION (&emutls_mutex);
+#endif
+  if (__gthread_key_create (&emutls_key, emutls_destroy) != 0)
+    abort ();
+}
+#endif

and

+      ptr = malloc (obj->size + sizeof (void *));
+      if (ptr == NULL)
+       abort ();

and so on.

(The big benefit of the non-emulated TLS is that memory is allocated on pthread_create(), so you know that either memory gets allocated or the thread doesn't get created, and either way you don't get random crashes...)

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]