From 77e0f19332a2b4e64d48ecb48557ea7aefa2cc61 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Sun, 1 Sep 2013 23:12:51 +0100 Subject: [PATCH] Enable per-thread locale support to be compiled out --- functions/locale/uselocale.c | 2 ++ includes/locale.h | 3 +++ internals/_PDCLIB_locale.h | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/locale/uselocale.c b/functions/locale/uselocale.c index 718def7..df5abdf 100644 --- a/functions/locale/uselocale.c +++ b/functions/locale/uselocale.c @@ -8,6 +8,7 @@ #ifndef REGTEST #include <_PDCLIB_locale.h> +#ifdef _PDCLIB_LOCALE_METHOD locale_t uselocale( locale_t newloc ) { locale_t oldloc = _PDCLIB_threadlocale(); @@ -20,6 +21,7 @@ locale_t uselocale( locale_t newloc ) return oldloc; } +#endif #endif diff --git a/includes/locale.h b/includes/locale.h index 3ea5e65..a304f5e 100644 --- a/includes/locale.h +++ b/includes/locale.h @@ -109,6 +109,8 @@ typedef _PDCLIB_locale_t locale_t; extern struct _PDCLIB_locale _PDCLIB_global_locale; #define LC_GLOBAL_LOCALE (&_PDCLIB_global_locale) +#ifdef _PDCLIB_LOCALE_METHOD + locale_t newlocale(int category_mask, const char *locale, locale_t base); /* Set the thread locale to newlocale @@ -129,6 +131,7 @@ locale_t duplocale(locale_t loc); /* Frees the passed locale object */ void freelocale(locale_t loc); +#endif #endif diff --git a/internals/_PDCLIB_locale.h b/internals/_PDCLIB_locale.h index 3159dfb..f120748 100644 --- a/internals/_PDCLIB_locale.h +++ b/internals/_PDCLIB_locale.h @@ -10,7 +10,11 @@ #define _PDCLIB_LOCALE_METHOD_THREAD_LOCAL 'T' #if !defined(_PDCLIB_LOCALE_METHOD) - #error _PDCLIB_LOCALE_METHOD undefined: don't know where I'm storing the thread locale + /* If undefined, no POSIX per thread locales */ + static inline locale_t _PDCLIB_threadlocale( void ) + { + return &_PDCLIB_global_locale; + } #elif _PDCLIB_LOCALE_METHOD == _PDCLIB_LOCALE_METHOD_TSS extern tss_t _PDCLIB_locale_tss; static inline locale_t _PDCLIB_threadlocale( void ) -- 2.40.0