Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/locale/xlocale_private.h
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
* Caches the rune table in TLS for fast access. | * Caches the rune table in TLS for fast access. | ||||
*/ | */ | ||||
void __set_thread_rune_locale(locale_t loc); | void __set_thread_rune_locale(locale_t loc); | ||||
/** | /** | ||||
* Flag indicating whether a per-thread locale has been set. If no per-thread | * Flag indicating whether a per-thread locale has been set. If no per-thread | ||||
* locale has ever been set, then we always use the global locale. | * locale has ever been set, then we always use the global locale. | ||||
*/ | */ | ||||
extern int __has_thread_locale; | extern int __has_thread_locale; | ||||
#ifndef __NO_TLS | |||||
/** | /** | ||||
* The per-thread locale. Avoids the need to use pthread lookup functions when | * The per-thread locale. Avoids the need to use pthread lookup functions when | ||||
* getting the per-thread locale. | * getting the per-thread locale. | ||||
*/ | */ | ||||
extern _Thread_local locale_t __thread_locale; | extern _Thread_local locale_t __thread_locale; | ||||
/** | /** | ||||
* Returns the current locale for this thread, or the global locale if none is | * Returns the current locale for this thread, or the global locale if none is | ||||
* set. The caller does not have to free the locale. The return value from | * set. The caller does not have to free the locale. The return value from | ||||
* this call is not guaranteed to remain valid after the locale changes. As | * this call is not guaranteed to remain valid after the locale changes. As | ||||
* such, this should only be called within libc functions. | * such, this should only be called within libc functions. | ||||
*/ | */ | ||||
static inline locale_t __get_locale(void) | static inline locale_t __get_locale(void) | ||||
{ | { | ||||
if (!__has_thread_locale) { | if (!__has_thread_locale) { | ||||
return (&__xlocale_global_locale); | return (&__xlocale_global_locale); | ||||
} | } | ||||
return (__thread_locale ? __thread_locale : &__xlocale_global_locale); | 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 | * Two magic values are allowed for locale_t objects. NULL and -1. This | ||||
* function maps those to the real locales that they represent. | * function maps those to the real locales that they represent. | ||||
*/ | */ | ||||
static inline locale_t get_real_locale(locale_t locale) | static inline locale_t get_real_locale(locale_t locale) | ||||
{ | { | ||||
switch ((intptr_t)locale) { | switch ((intptr_t)locale) { | ||||
Show All 12 Lines |