X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsymbian%2Fsilcsymbianthread.cpp;h=05a2e893b294a22ed8b72e20ad838e0dc35dda49;hp=10d7142ac06ae2eeeb669bf1cba78ea117f486c3;hb=c6bb9e5e82ae3a2d667e826b9bd979cbe72e1493;hpb=0f330f9f731f0659b210c29109a4272c7c7f5380 diff --git a/lib/silcutil/symbian/silcsymbianthread.cpp b/lib/silcutil/symbian/silcsymbianthread.cpp index 10d7142a..05a2e893 100644 --- a/lib/silcutil/symbian/silcsymbianthread.cpp +++ b/lib/silcutil/symbian/silcsymbianthread.cpp @@ -46,9 +46,12 @@ static TInt silc_thread_start(TAny *context) void *user_context = tc->context; SilcBool waitable = tc->waitable; void *ret = NULL; + SilcTls tls; silc_free(tc); + tls = silc_thread_tls_init(); + CTrapCleanup *cs = CTrapCleanup::New(); if (cs) { CActiveScheduler *s = new CActiveScheduler; @@ -63,6 +66,7 @@ static TInt silc_thread_start(TAny *context) delete cs; } + silc_free(tls); silc_thread_exit(ret); #endif @@ -409,4 +413,28 @@ SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex, #endif /* SILC_THREADS*/ } +/************************** Thread-local Storage ****************************/ + +SilcTls silc_thread_tls_init(void) +{ + SilcTls tls; + + if (silc_thread_get_tls()) + return silc_thread_get_tls(); + + /* Allocate Tls for the thread */ + tls = (SilcTls)silc_calloc(1, sizeof(*tls)); + if (!tls) + return NULL; + + Dll::SetTls(tls); + + return tls; +} + +SilcTls silc_thread_get_tls(void) +{ + return STATIC_CAST(SilcTls, Dll::Tls()); +} + } /* extern "C" */