michael@0: /* michael@0: * Copyright 2013 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "SkTLS.h" michael@0: michael@0: #include michael@0: michael@0: static pthread_key_t gSkTLSKey; michael@0: static pthread_once_t gSkTLSKey_Once = PTHREAD_ONCE_INIT; michael@0: michael@0: static void sk_tls_make_key() { michael@0: (void)pthread_key_create(&gSkTLSKey, SkTLS::Destructor); michael@0: } michael@0: michael@0: void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) { michael@0: // should we use forceCreateTheSlot to potentially skip calling pthread_once michael@0: // and just return NULL if we've never been called with michael@0: // forceCreateTheSlot==true ? michael@0: michael@0: (void)pthread_once(&gSkTLSKey_Once, sk_tls_make_key); michael@0: return pthread_getspecific(gSkTLSKey); michael@0: } michael@0: michael@0: void SkTLS::PlatformSetSpecific(void* ptr) { michael@0: (void)pthread_setspecific(gSkTLSKey, ptr); michael@0: }