This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [basic-improvements] Remove __gthread_key_dtor
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Eric Christopher <echristo at redhat dot com>
- Cc: Zack Weinberg <zack at codesourcery dot com>,Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Nov 2002 17:08:19 -0800
- Subject: Re: [basic-improvements] Remove __gthread_key_dtor
- References: <20021029223346.GB31573@codesourcery.com> <20021031191828.GU4764@redhat.com> <20021031194229.GB5766@codesourcery.com> <20021031210229.GA5029@redhat.com> <20021031212027.GH5766@codesourcery.com> <1036103481.1438.70.camel@ghostwheel> <20021101001223.GK5766@codesourcery.com> <1036442469.1509.22.camel@ghostwheel>
On Mon, Nov 04, 2002 at 12:41:08PM -0800, Eric Christopher wrote:
> >
> > There needs to be just one version of these variables, but gthr.h is
> > included all over the place - this needs to go out-of-line, into a
> > libgcc.a extra part, probably along with the code that uses it.
>
> Hrm. I was noticing that other ports use this method and that's why I
> did - I also didn't see a way for it to work otherwise since there's no
> general .c mechanism for it.
You create a .c file in config/ARCH, and mention it in the LIB2ADD
variable in your t-TARGET file.
> > I take it there can be only 256 threads?
>
> Heh. Threads? No. I've got semaphores and only semaphores.
Er, what's this GetThreadId() then?
> > There is no requirement that dtor be nonzero, and you threw away its
> > value; this will cause memory leaks. You're going to need to find
> > some way to get a callback run at thread exit time. And that callback
> > can do the clear-out-the-value thing.
>
> hrm. If I could do that I could also free semaphores which would help me
> avoid the 253 limit that I currently have. I was under the impression
> that this was not possible though - at least not without rewriting the
> machinery.
If the underlying API doesn't support this, you're out of luck. But
if there _is_ a way to get a callback run at thread exit time, you can
just set one up in your init-once routine.
Take a look at gthr-vxworks.h, config/vxlib.c, and config/t-vxworks on
the gcc-3_4-basic-improvements-branch (after I commit them, which will
happen in the next twenty minutes or so) -- they should give you some
ideas.
zw