add flag/hint to PlatformGetSpecific. If true, then the caller requires that
the tls slot be allocated even if this is the first, to ensure that it can
later call PlatformSetSpecific. When this is false (which is most of the time)
the implementation may optimize by not even creating the slot, and just
returning null.



git-svn-id: http://skia.googlecode.com/svn/trunk@3871 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkTLS.cpp b/src/core/SkTLS.cpp
index 0cd79de..b31a666 100755
--- a/src/core/SkTLS.cpp
+++ b/src/core/SkTLS.cpp
@@ -28,7 +28,7 @@
         return NULL;
     }
 
-    void* ptr = SkTLS::PlatformGetSpecific();
+    void* ptr = SkTLS::PlatformGetSpecific(true);
 
     if (ptr) {
         const SkTLSRec* rec = (const SkTLSRec*)ptr;
@@ -58,7 +58,7 @@
         return NULL;
     }
     
-    void* ptr = SkTLS::PlatformGetSpecific();
+    void* ptr = SkTLS::PlatformGetSpecific(false);
 
     if (ptr) {
         const SkTLSRec* rec = (const SkTLSRec*)ptr;
@@ -76,7 +76,7 @@
         return;
     }
     
-    void* ptr = SkTLS::PlatformGetSpecific();
+    void* ptr = SkTLS::PlatformGetSpecific(false);
     
     SkTLSRec* curr = (SkTLSRec*)ptr;
     SkTLSRec* prev = NULL;
diff --git a/src/core/SkTLS.h b/src/core/SkTLS.h
index 0ce3924..5d0e1a6 100644
--- a/src/core/SkTLS.h
+++ b/src/core/SkTLS.h
@@ -50,12 +50,24 @@
     // ourselves in a list, with the platform specific value as our head.
 
     /**
-     *  implemented by the platform, to return the value of our (one) slot per-thread
+     *  Implemented by the platform, to return the value of our (one) slot per-thread
+     *
+     *  If forceCreateTheSlot is true, then we must have created the "slot" for
+     *  our TLS, even though we know that the return value will be NULL in that
+     *  case (i.e. no-slot and first-time-slot both return NULL). This ensures
+     *  that after calling GetSpecific, we know that we can legally call
+     *  SetSpecific.
+     *
+     *  If forceCreateTheSlot is false, then the impl can either create the
+     *  slot or not.
      */
-    static void* PlatformGetSpecific();
+    static void* PlatformGetSpecific(bool forceCreateTheSlot);
 
     /**
-     *  implemented by the platform, to set the value for our (one) slot per-thread
+     *  Implemented by the platform, to set the value for our (one) slot per-thread
+     *
+     *  The implementation can rely on GetSpecific(true) having been previously
+     *  called before SetSpecific is called.
      */
     static void  PlatformSetSpecific(void*);