From 3ae8d83d04a7a6ec11b64c89ee60c180b0bde30e Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 19 Feb 2021 17:20:29 +0200 Subject: [PATCH] Remove __NO_TLS. All supported platforms support thread-local vars and __thread. Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28796 --- include/runetype.h | 4 ++-- lib/libc/gen/getutxent.c | 5 ----- lib/libc/gen/utxdb.c | 4 ---- lib/libc/locale/setrunelocale.c | 4 ---- lib/libc/locale/xlocale.c | 15 +-------------- lib/libc/locale/xlocale_private.h | 5 +---- lib/libc/string/strerror.c | 5 ----- lib/libgssapi/gss_display_status.c | 10 ---------- sys/sys/cdefs.h | 4 ---- tests/sys/opencrypto/cryptodevh.py | 1 - 10 files changed, 4 insertions(+), 53 deletions(-) diff --git a/include/runetype.h b/include/runetype.h index 4aca128f8c8a..93007809dbf8 100644 --- a/include/runetype.h +++ b/include/runetype.h @@ -88,7 +88,7 @@ typedef struct { __BEGIN_DECLS extern const _RuneLocale _DefaultRuneLocale; extern const _RuneLocale *_CurrentRuneLocale; -#if defined(__NO_TLS) || defined(__RUNETYPE_INTERNAL) +#ifdef __RUNETYPE_INTERNAL extern const _RuneLocale *__getCurrentRuneLocale(void); #else extern _Thread_local const _RuneLocale *_ThreadRuneLocale; @@ -99,7 +99,7 @@ static __inline const _RuneLocale *__getCurrentRuneLocale(void) return _ThreadRuneLocale; return _CurrentRuneLocale; } -#endif /* __NO_TLS || __RUNETYPE_INTERNAL */ +#endif /*__RUNETYPE_INTERNAL */ #define _CurrentRuneLocale (__getCurrentRuneLocale()) __END_DECLS diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c index e0d993221e7e..664498126f13 100644 --- a/lib/libc/gen/getutxent.c +++ b/lib/libc/gen/getutxent.c @@ -40,13 +40,8 @@ __FBSDID("$FreeBSD$"); #include "utxdb.h" #include "un-namespace.h" -#ifdef __NO_TLS -static FILE *uf = NULL; -static int udb; -#else static _Thread_local FILE *uf = NULL; static _Thread_local int udb; -#endif int setutxdb(int db, const char *file) diff --git a/lib/libc/gen/utxdb.c b/lib/libc/gen/utxdb.c index f8dea105702c..3edccdbd2c2f 100644 --- a/lib/libc/gen/utxdb.c +++ b/lib/libc/gen/utxdb.c @@ -128,11 +128,7 @@ utx_to_futx(const struct utmpx *ut, struct futx *fu) struct utmpx * futx_to_utx(const struct futx *fu) { -#ifdef __NO_TLS - static struct utmpx *ut; -#else static _Thread_local struct utmpx *ut; -#endif if (ut == NULL) { ut = calloc(1, sizeof *ut); diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 2e6fed9466e4..551d32b7ab6a 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -56,12 +56,10 @@ __FBSDID("$FreeBSD$"); #undef _CurrentRuneLocale extern _RuneLocale const *_CurrentRuneLocale; -#ifndef __NO_TLS /* * A cached version of the runes for this thread. Used by ctype.h */ _Thread_local const _RuneLocale *_ThreadRuneLocale; -#endif extern int __mb_sb_limit; @@ -199,7 +197,6 @@ __wrap_setrunelocale(const char *locale) return (_LDP_LOADED); } -#ifndef __NO_TLS void __set_thread_rune_locale(locale_t loc) { @@ -212,7 +209,6 @@ __set_thread_rune_locale(locale_t loc) _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes; } } -#endif void * __ctype_load(const char *locale, locale_t unused __unused) diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c index fb674f86bbff..d64262da809e 100644 --- a/lib/libc/locale/xlocale.c +++ b/lib/libc/locale/xlocale.c @@ -55,12 +55,11 @@ extern struct xlocale_component __xlocale_global_messages; extern struct xlocale_component __xlocale_C_collate; extern struct xlocale_component __xlocale_C_ctype; -#ifndef __NO_TLS /* * The locale for this thread. */ _Thread_local locale_t __thread_locale; -#endif + /* * Flag indicating that one or more per-thread locales exist. */ @@ -143,16 +142,6 @@ get_thread_locale(void) pthread_getspecific(locale_info_key)); } -#ifdef __NO_TLS -locale_t -__get_locale(void) -{ - locale_t l = get_thread_locale(); - return (l ? l : &__xlocale_global_locale); - -} -#endif - static void set_thread_locale(locale_t loc) { @@ -172,10 +161,8 @@ set_thread_locale(locale_t loc) } else { pthread_setspecific(locale_info_key, l); } -#ifndef __NO_TLS __thread_locale = l; __set_thread_rune_locale(loc); -#endif } /** diff --git a/lib/libc/locale/xlocale_private.h b/lib/libc/locale/xlocale_private.h index 391e375bc03d..bc40f28fc9eb 100644 --- a/lib/libc/locale/xlocale_private.h +++ b/lib/libc/locale/xlocale_private.h @@ -185,7 +185,7 @@ void __set_thread_rune_locale(locale_t loc); * locale has ever been set, then we always use the global locale. */ extern int __has_thread_locale; -#ifndef __NO_TLS + /** * The per-thread locale. Avoids the need to use pthread lookup functions when * getting the per-thread locale. @@ -206,9 +206,6 @@ static inline locale_t __get_locale(void) } return (__thread_locale ? __thread_locale : &__xlocale_global_locale); } -#else -locale_t __get_locale(void); -#endif /** * Two magic values are allowed for locale_t objects. NULL and -1. This diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index 11b9701d968f..bb685e4f7dc9 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -128,16 +128,11 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) char * strerror_l(int num, locale_t locale) { -#ifndef __NO_TLS static _Thread_local char ebuf[NL_TEXTMAX]; if (strerror_rl(num, ebuf, sizeof(ebuf), locale) != 0) errno = EINVAL; return (ebuf); -#else - errno = ENOTSUP; - return (NULL); -#endif } char * diff --git a/lib/libgssapi/gss_display_status.c b/lib/libgssapi/gss_display_status.c index 55ca83ce9aa8..d0c3453a0d6b 100644 --- a/lib/libgssapi/gss_display_status.c +++ b/lib/libgssapi/gss_display_status.c @@ -174,16 +174,6 @@ supplementary_error(OM_uint32 v) return msgs[v]; } -#if defined(__NO_TLS) - -/* - * These platforms don't support TLS on FreeBSD - threads will just - * have to step on each other's error values for now. - */ -#define __thread - -#endif - struct mg_thread_ctx { gss_OID mech; OM_uint32 maj_stat; diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index ff18911f6acf..1d1fe2965c69 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -768,10 +768,6 @@ #endif #endif /* __STDC_WANT_LIB_EXT1__ */ -#if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1) -#define __NO_TLS 1 -#endif - /* * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h * translates them to __ARM_ARCH and the modern feature symbols defined by ARM. diff --git a/tests/sys/opencrypto/cryptodevh.py b/tests/sys/opencrypto/cryptodevh.py index be853f496930..c5719e47c8c1 100644 --- a/tests/sys/opencrypto/cryptodevh.py +++ b/tests/sys/opencrypto/cryptodevh.py @@ -133,7 +133,6 @@ def __COPYRIGHT(s): return __IDSTRING(__CONCAT(__copyright_,__LINE__),s) __XSI_VISIBLE = 700 __BSD_VISIBLE = 1 __ISO_C_VISIBLE = 2011 -__NO_TLS = 1 CRYPTO_DRIVERS_INITIAL = 4 CRYPTO_SW_SESSIONS = 32 NULL_HASH_LEN = 16