github.com/ccccaoqing/test@v0.0.0-20220510085219-3985d23445c0/misc/cgo/testtls/tls_unix.c (about)

     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 <pthread.h>
     6  
     7  static __thread int tls;
     8  
     9  void
    10  setTLS(int v)
    11  {
    12  	tls = v;
    13  }
    14  
    15  int
    16  getTLS()
    17  {
    18  	return tls;
    19  }