Add GPR_STDCPP_TLS

pull/24247/head
Esun Kim 4 years ago
parent 5256cdf895
commit 1ee0c88817
  1. 1
      BUILD
  2. 1
      BUILD.gn
  3. 1
      build_autogenerated.yaml
  4. 2
      gRPC-C++.podspec
  5. 2
      gRPC-Core.podspec
  6. 1
      grpc.gemspec
  7. 4
      include/grpc/impl/codegen/port_platform.h
  8. 1
      package.xml
  9. 4
      src/core/lib/gpr/tls.h
  10. 48
      src/core/lib/gpr/tls_stdcpp.h
  11. 1
      tools/doxygen/Doxyfile.c++.internal
  12. 1
      tools/doxygen/Doxyfile.core.internal

@ -529,6 +529,7 @@ grpc_cc_library(
"src/core/lib/gpr/tls_gcc.h",
"src/core/lib/gpr/tls_msvc.h",
"src/core/lib/gpr/tls_pthread.h",
"src/core/lib/gpr/tls_stdcpp.h",
"src/core/lib/gpr/tmpfile.h",
"src/core/lib/gpr/useful.h",
"src/core/lib/gprpp/arena.h",

@ -137,6 +137,7 @@ config("grpc_config") {
"src/core/lib/gpr/tls_msvc.h",
"src/core/lib/gpr/tls_pthread.cc",
"src/core/lib/gpr/tls_pthread.h",
"src/core/lib/gpr/tls_stdcpp.h",
"src/core/lib/gpr/tmpfile.h",
"src/core/lib/gpr/tmpfile_msys.cc",
"src/core/lib/gpr/tmpfile_posix.cc",

@ -290,6 +290,7 @@ libs:
- src/core/lib/gpr/tls_gcc.h
- src/core/lib/gpr/tls_msvc.h
- src/core/lib/gpr/tls_pthread.h
- src/core/lib/gpr/tls_stdcpp.h
- src/core/lib/gpr/tmpfile.h
- src/core/lib/gpr/useful.h
- src/core/lib/gprpp/arena.h

@ -408,6 +408,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/tls_gcc.h',
'src/core/lib/gpr/tls_msvc.h',
'src/core/lib/gpr/tls_pthread.h',
'src/core/lib/gpr/tls_stdcpp.h',
'src/core/lib/gpr/tmpfile.h',
'src/core/lib/gpr/useful.h',
'src/core/lib/gprpp/arena.h',
@ -925,6 +926,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/tls_gcc.h',
'src/core/lib/gpr/tls_msvc.h',
'src/core/lib/gpr/tls_pthread.h',
'src/core/lib/gpr/tls_stdcpp.h',
'src/core/lib/gpr/tmpfile.h',
'src/core/lib/gpr/useful.h',
'src/core/lib/gprpp/arena.h',

@ -648,6 +648,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/tls_msvc.h',
'src/core/lib/gpr/tls_pthread.cc',
'src/core/lib/gpr/tls_pthread.h',
'src/core/lib/gpr/tls_stdcpp.h',
'src/core/lib/gpr/tmpfile.h',
'src/core/lib/gpr/tmpfile_msys.cc',
'src/core/lib/gpr/tmpfile_posix.cc',
@ -1365,6 +1366,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/tls_gcc.h',
'src/core/lib/gpr/tls_msvc.h',
'src/core/lib/gpr/tls_pthread.h',
'src/core/lib/gpr/tls_stdcpp.h',
'src/core/lib/gpr/tmpfile.h',
'src/core/lib/gpr/useful.h',
'src/core/lib/gprpp/arena.h',

@ -566,6 +566,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gpr/tls_msvc.h )
s.files += %w( src/core/lib/gpr/tls_pthread.cc )
s.files += %w( src/core/lib/gpr/tls_pthread.h )
s.files += %w( src/core/lib/gpr/tls_stdcpp.h )
s.files += %w( src/core/lib/gpr/tmpfile.h )
s.files += %w( src/core/lib/gpr/tmpfile_msys.cc )
s.files += %w( src/core/lib/gpr/tmpfile_posix.cc )

@ -483,9 +483,9 @@ typedef unsigned __int64 uint64_t;
#endif
#if defined(GPR_MSVC_TLS) + defined(GPR_GCC_TLS) + defined(GPR_PTHREAD_TLS) + \
defined(GPR_CUSTOM_TLS) != \
defined(GPR_STDCPP_TLS) + defined(GPR_CUSTOM_TLS) != \
1
#error Must define exactly one of GPR_MSVC_TLS, GPR_GCC_TLS, GPR_PTHREAD_TLS, GPR_CUSTOM_TLS
#error Must define exactly one of GPR_MSVC_TLS, GPR_GCC_TLS, GPR_PTHREAD_TLS, GPR_STDCPP_TLS, GPR_CUSTOM_TLS
#endif
/* maximum alignment needed for any type on this platform, rounded up to a

@ -546,6 +546,7 @@
<file baseinstalldir="/" name="src/core/lib/gpr/tls_msvc.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tls_pthread.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tls_pthread.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tls_stdcpp.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tmpfile.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tmpfile_msys.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tmpfile_posix.cc" role="src" />

@ -53,6 +53,10 @@
ALL functions here may be implemented as macros. */
#ifdef GPR_STDCPP_TLS
#include "src/core/lib/gpr/tls_stdcpp.h"
#endif
#ifdef GPR_GCC_TLS
#include "src/core/lib/gpr/tls_gcc.h"
#endif

@ -0,0 +1,48 @@
/*
*
* Copyright 2020 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_GPR_TLS_STDCPP_H
#define GRPC_CORE_LIB_GPR_TLS_STDCPP_H
#include <grpc/support/port_platform.h>
/** Thread local storage based on C++ thread_local.
#include tls.h to use this - and see that file for documentation */
/** Use GPR_TLS_DECL to declare tls static variables outside a class */
#define GPR_TLS_DECL(name) thread_local static intptr_t name = 0
/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class.
* GPR_TLS_CLASS_DEF needs to be called to define this member. */
#define GPR_TLS_CLASS_DECL(name) thread_local static intptr_t name
#define GPR_TLS_CLASS_DEF(name) thread_local intptr_t name = 0
#define gpr_tls_init(tls) \
do { \
} while (0)
#define gpr_tls_destroy(tls) \
do { \
} while (0)
#define gpr_tls_set(tls, new_value) (*(tls) = (new_value))
#define gpr_tls_get(tls) (*(tls))
#endif /* GRPC_CORE_LIB_GPR_TLS_STDCPP_H */

@ -1499,6 +1499,7 @@ src/core/lib/gpr/tls_gcc.h \
src/core/lib/gpr/tls_msvc.h \
src/core/lib/gpr/tls_pthread.cc \
src/core/lib/gpr/tls_pthread.h \
src/core/lib/gpr/tls_stdcpp.h \
src/core/lib/gpr/tmpfile.h \
src/core/lib/gpr/tmpfile_msys.cc \
src/core/lib/gpr/tmpfile_posix.cc \

@ -1340,6 +1340,7 @@ src/core/lib/gpr/tls_gcc.h \
src/core/lib/gpr/tls_msvc.h \
src/core/lib/gpr/tls_pthread.cc \
src/core/lib/gpr/tls_pthread.h \
src/core/lib/gpr/tls_stdcpp.h \
src/core/lib/gpr/tmpfile.h \
src/core/lib/gpr/tmpfile_msys.cc \
src/core/lib/gpr/tmpfile_posix.cc \

Loading…
Cancel
Save