1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/ports/SkTLS_pthread.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +/* 1.5 + * Copyright 2013 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "SkTLS.h" 1.12 + 1.13 +#include <pthread.h> 1.14 + 1.15 +static pthread_key_t gSkTLSKey; 1.16 +static pthread_once_t gSkTLSKey_Once = PTHREAD_ONCE_INIT; 1.17 + 1.18 +static void sk_tls_make_key() { 1.19 + (void)pthread_key_create(&gSkTLSKey, SkTLS::Destructor); 1.20 +} 1.21 + 1.22 +void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) { 1.23 + // should we use forceCreateTheSlot to potentially skip calling pthread_once 1.24 + // and just return NULL if we've never been called with 1.25 + // forceCreateTheSlot==true ? 1.26 + 1.27 + (void)pthread_once(&gSkTLSKey_Once, sk_tls_make_key); 1.28 + return pthread_getspecific(gSkTLSKey); 1.29 +} 1.30 + 1.31 +void SkTLS::PlatformSetSpecific(void* ptr) { 1.32 + (void)pthread_setspecific(gSkTLSKey, ptr); 1.33 +}