wxwidgets/include/wx/tls.h
Vadim Zeitlin 4e802e6fc7 Remove wxUSE_COMPILER_TLS and always use C++11 thread_local
Don't use compiler-specific __thread and use the standard keyword
instead.

Keep the existing TLS-related macros for compatibility, but remove our
custom implementation of them, so that they're always trivial now.
2022-10-26 03:31:54 +02:00

42 lines
1.5 KiB
C

///////////////////////////////////////////////////////////////////////////////
// Name: wx/tls.h
// Purpose: Implementation of thread local storage (obsolete)
// Author: Vadim Zeitlin
// Created: 2008-08-08
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TLS_H_
#define _WX_TLS_H_
#include "wx/defs.h"
// ----------------------------------------------------------------------------
// check for compiler support of thread-specific variables
// ----------------------------------------------------------------------------
// when not using threads at all, there is no need for thread-specific
// values to be really thread-specific
#if !wxUSE_THREADS
#define wxTHREAD_SPECIFIC_DECL
#else
#define wxTHREAD_SPECIFIC_DECL thread_local
#endif
// ----------------------------------------------------------------------------
// define wxTLS_TYPE()
// ----------------------------------------------------------------------------
// All these preprocessor symbols are obsolete and defined only for
// compatibility: C++11 compilers always support variables with thread storage,
// so you should just always use thread_local directly in the new code instead.
#define wxHAS_COMPILER_TLS
#define wxTLS_TYPE(T) wxTHREAD_SPECIFIC_DECL T
#define wxTLS_TYPE_REF(T) T&
#define wxTLS_PTR(var) (&(var))
#define wxTLS_VALUE(var) (var)
#endif // _WX_TLS_H_