1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include <stddef.h> 6 7 #if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) 8 9 // Mingw seems not to have threads.h, so we use the _Thread_local keyword rather 10 // than the thread_local macro. 11 static _Thread_local int tls; 12 13 const char * checkTLS()14checkTLS() { 15 return NULL; 16 } 17 18 void setTLS(int v)19setTLS(int v) 20 { 21 tls = v; 22 } 23 24 int getTLS()25getTLS() 26 { 27 return tls; 28 } 29 30 #else 31 32 const char * checkTLS()33checkTLS() { 34 return "_Thread_local requires C11 and not __STDC_NO_THREADS__"; 35 } 36 37 void setTLS(int v)38setTLS(int v) { 39 } 40 41 int getTLS()42getTLS() 43 { 44 return 0; 45 } 46 47 #endif 48