Re: [AD] mingw, static, tls |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] mingw, static, tls
- From: "Trent Gamblin" <trent@xxxxxxxxxx>
- Date: Sat, 18 Jul 2009 16:05:50 -0600 (MDT)
On Sat, July 18, 2009 10:32 am, Elias Pschernig said:
> I guess it should be possible to create TLS "manually", by using the
> current thread id to return the right value in all the tls functions.
Yeah I guess. Something like this should sort of work (pseudo code):
DWORD cookie;
thread_local_state *tls_get(void)
{
static bool initialized = false;
if (!initialized) {
cookie = TlsAlloc();
initialized = true;
}
thread_local_state *tls = TlsGetValue(cookie);
if (tls == NULL && GetLastError() == NO_ERROR) {
tls = _AL_MALLOC(sizeof(tls));
/* initialize tls */
TlsSetValue(cookie, tls);
}
return tls;
}
But how do you free the memory?
Trent :{)>
- References:
- [AD] mingw, static, tls
- Re: [AD] mingw, static, tls
- Re: [AD] mingw, static, tls
- Re: [AD] mingw, static, tls
- Re: [AD] mingw, static, tls