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
This commit is contained in:
Konstantin Belousov 2021-02-19 17:20:29 +02:00
parent f695e96067
commit 3ae8d83d04
10 changed files with 4 additions and 53 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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
}
/**

View File

@ -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

View File

@ -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 *

View File

@ -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;

View File

@ -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.

View File

@ -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