Added release/acquire memory barriers to the atomic API

* Added a destructor to clean up TLS memory at thread shutdown
* Refactored the TLS code to have platform independent code and a small platform dependent core with a fallback to generic code if platform dependent functions fail.
* Fixed recursion issues with SDL_GetErrBuf()
This commit is contained in:
Sam Lantinga 2013-07-10 18:31:17 -07:00
parent 086ecc9949
commit 557bbf3fe6
10 changed files with 334 additions and 319 deletions

View file

@ -33,7 +33,7 @@ quit(int rc)
int SDLCALL
ThreadFunc(void *data)
{
SDL_TLSSet(tls, "baby thread");
SDL_TLSSet(tls, "baby thread", NULL);
printf("Started thread %s: My thread id is %lu, thread data = %s\n",
(char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
while (alive) {
@ -66,7 +66,7 @@ main(int argc, char *argv[])
tls = SDL_TLSCreate();
SDL_assert(tls);
SDL_TLSSet(tls, "main thread");
SDL_TLSSet(tls, "main thread", NULL);
printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
alive = 1;