summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/setrunelocale.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/locale/setrunelocale.c')
-rw-r--r--lib/libc/locale/setrunelocale.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 61ce5d9..bc04e9e 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -38,6 +38,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#define __RUNETYPE_INTERNAL 1
+
#include <runetype.h>
#include <errno.h>
#include <limits.h>
@@ -50,6 +52,15 @@ __FBSDID("$FreeBSD$");
#include "mblocal.h"
#include "setlocale.h"
+#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;
extern _RuneLocale *_Read_RuneMagi(FILE *);
@@ -72,7 +83,8 @@ static void destruct_ctype(void *v)
free(l->runes);
free(l);
}
-_RuneLocale *__getCurrentRuneLocale(void)
+
+const _RuneLocale *__getCurrentRuneLocale(void)
{
return XLOCALE_CTYPE(__get_locale())->runes;
}
@@ -168,9 +180,24 @@ __wrap_setrunelocale(const char *locale)
}
__mb_cur_max = __xlocale_global_ctype.__mb_cur_max;
__mb_sb_limit = __xlocale_global_ctype.__mb_sb_limit;
+ _CurrentRuneLocale = __xlocale_global_ctype.runes;
return (_LDP_LOADED);
}
-void *__ctype_load(const char *locale, locale_t unused)
+
+#ifndef __NO_TLS
+void
+__set_thread_rune_locale(locale_t loc) {
+
+ if (loc == NULL) {
+ _ThreadRuneLocale = &_DefaultRuneLocale;
+ } else {
+ _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes;
+ }
+}
+#endif
+
+void *
+__ctype_load(const char *locale, locale_t unused)
{
struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1);
l->header.header.destructor = destruct_ctype;
OpenPOWER on IntegriCloud