public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* what does __gthread_active_p() do/mean?
@ 2002-01-14 17:30 Adam Megacz
  2002-01-15  3:41 ` Jeff Sturm
  0 siblings, 1 reply; 4+ messages in thread
From: Adam Megacz @ 2002-01-14 17:30 UTC (permalink / raw)
  To: gcc


What is this function supposed to do? (gthr-*.h)

I'm investigating some breakage involving mingw and sjlj-exceptions's
need for thread-local storage; I believe that it's returning the wrong
value on mingw, but I'd like to know what the meaning of the return
value is.

  - a

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: what does __gthread_active_p() do/mean?
  2002-01-14 17:30 what does __gthread_active_p() do/mean? Adam Megacz
@ 2002-01-15  3:41 ` Jeff Sturm
  2002-01-17 15:49   ` Adam Megacz
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Sturm @ 2002-01-15  3:41 UTC (permalink / raw)
  To: Adam Megacz; +Cc: gcc

On 14 Jan 2002, Adam Megacz wrote:
> What is this function supposed to do? (gthr-*.h)

From gthr.h:

/* If this file is compiled with threads support, it must
       #define __GTHREADS 1
   to indicate that threads support is present.  Also it has define
   function
     int __gthread_active_p ()
   that returns 1 if thread system is active, 0 if not.

Depending on how a program is linked, thread functions may or may not be
available.  Calling __gthread_active_p() will tell.

> I'm investigating some breakage involving mingw and sjlj-exceptions's
> need for thread-local storage; I believe that it's returning the wrong
> value on mingw, but I'd like to know what the meaning of the return
> value is.

Judging by the comments, if you compile/link without -mthreads,
gthr-win32.h assumes your program won't use threads.  Could that be what
is happening?

Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: what does __gthread_active_p() do/mean?
  2002-01-15  3:41 ` Jeff Sturm
@ 2002-01-17 15:49   ` Adam Megacz
  2002-01-18  2:24     ` Jeff Sturm
  0 siblings, 1 reply; 4+ messages in thread
From: Adam Megacz @ 2002-01-17 15:49 UTC (permalink / raw)
  To: gcc


Jeff Sturm <jsturm@one-point.com> writes:
> > I'm investigating some breakage involving mingw and sjlj-exceptions's
> > need for thread-local storage; I believe that it's returning the wrong
> > value on mingw, but I'd like to know what the meaning of the return
> > value is.

> Judging by the comments, if you compile/link without -mthreads,
> gthr-win32.h assumes your program won't use threads.  Could that be what
> is happening?

Yes, that's quite possibly what it is.

However, this isn't always a safe assumption. For various reasons, I
am willing to give up TLS garbage collection in order to not have to
distribute mingwthr.dll (or whatever it's called). This is a pretty
big deal for me.

So the assumption that "no -mthreads == no threads" isn't always true.

Would anybody object to having this always return 1 on mingw
platforms? The TlsGet() and TlsSet() functions which it enables don't
require mingwthr.dll.

  - a

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: what does __gthread_active_p() do/mean?
  2002-01-17 15:49   ` Adam Megacz
@ 2002-01-18  2:24     ` Jeff Sturm
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Sturm @ 2002-01-18  2:24 UTC (permalink / raw)
  To: Adam Megacz; +Cc: gcc

On 17 Jan 2002, Adam Megacz wrote:
> So the assumption that "no -mthreads == no threads" isn't always true.

True.  Most platforms have some way to explicitly request a threaded
runtime, e.g. -lpthread.  For those it's critical that they can disable
the gthr-* functionality.

But for mingw, win32 thread functions are always available with or without
-mthreads.  So you could probably make your proposed modification without
breaking anything (in a single-threaded program, freeing the TLS isn't an
issue).

> Would anybody object to having this always return 1 on mingw
> platforms? The TlsGet() and TlsSet() functions which it enables don't
> require mingwthr.dll.

I'm not exactly objecting, but realize that this will add some overhead to
mingw programs that use EH without threads.  There ought to be a way to
declare to the compiler that you don't intend to use threads, and
ostensibly this is done now by omitting -mthreads.

Alternatively, could you somehow eliminate libmingwthrd from the link
spec?  Perhaps handle threads in the STARTFILE_SPEC instead?

Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-01-18  4:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-14 17:30 what does __gthread_active_p() do/mean? Adam Megacz
2002-01-15  3:41 ` Jeff Sturm
2002-01-17 15:49   ` Adam Megacz
2002-01-18  2:24     ` Jeff Sturm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).