summaryrefslogtreecommitdiffstats
path: root/sal/rtl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-04-05 15:31:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-04-05 15:31:23 +0100
commitd49ffe4e5aceee5abf084b6941963e4f8ad69388 (patch)
tree228aacfd2474202b0c755527f34eec92b4f56bfc /sal/rtl
parentremove ADAPT_EXT_STL (diff)
downloadcore-d49ffe4e5aceee5abf084b6941963e4f8ad69388.tar.gz
core-d49ffe4e5aceee5abf084b6941963e4f8ad69388.zip
put the deprecated rtl_Locale stuff in here too
Diffstat (limited to 'sal/rtl')
-rw-r--r--sal/rtl/source/alloc_fini.cxx32
-rw-r--r--sal/rtl/source/locale.c23
2 files changed, 34 insertions, 21 deletions
diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx
index 89b2930250a4..1c1d30af43d1 100644
--- a/sal/rtl/source/alloc_fini.cxx
+++ b/sal/rtl/source/alloc_fini.cxx
@@ -43,7 +43,8 @@ namespace
rtl_memory_fini();
}
};
- class theMemorySingleton : public rtl::Static<rtlMemorySingleton, theMemorySingleton>{};
+ class theMemorySingleton
+ : public rtl::Static<rtlMemorySingleton, theMemorySingleton>{};
}
extern "C" void ensureMemorySingleton()
{
@@ -65,7 +66,8 @@ namespace
rtl_cache_fini();
}
};
- class theCacheSingleton : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{};
+ class theCacheSingleton
+ : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{};
}
extern "C" void ensureCacheSingleton()
{
@@ -87,11 +89,35 @@ namespace
rtl_arena_fini();
}
};
- class theArenaSingleton : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{};
+ class theArenaSingleton
+ : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{};
}
extern "C" void ensureArenaSingleton()
{
theArenaSingleton::get();
}
+extern "C" void rtl_locale_fini (void);
+extern "C" void rtl_locale_init (void);
+namespace
+{
+ struct rtlLocaleSingleton
+ {
+ rtlLocaleSingleton()
+ {
+ rtl_locale_init();
+ }
+ ~rtlLocaleSingleton()
+ {
+ rtl_locale_fini();
+ }
+ };
+ class theLocaleSingleton
+ : public rtl::Static<rtlLocaleSingleton, theLocaleSingleton>{};
+}
+extern "C" void ensureLocaleSingleton()
+{
+ theLocaleSingleton::get();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/source/locale.c b/sal/rtl/source/locale.c
index 3c3c98c80157..2885b4cc4b68 100644
--- a/sal/rtl/source/locale.c
+++ b/sal/rtl/source/locale.c
@@ -58,8 +58,6 @@ static RTL_HASHTABLE* g_pLocaleTable = NULL;
static rtl_Locale* g_pDefaultLocale = NULL;
-static int rtl_locale_init (void);
-
/*************************************************************************
*/
void rtl_hashentry_destroy(RTL_HASHENTRY* entry)
@@ -228,29 +226,15 @@ sal_Bool rtl_hashtable_find(RTL_HASHTABLE * table, sal_Int32 key, sal_Int32 hash
/*************************************************************************
* rtl_locale_init
*/
-static void rtl_locale_once_init (void)
+void rtl_locale_init (void)
{
OSL_ASSERT(g_pLocaleTable == 0);
rtl_hashtable_init(&g_pLocaleTable, 1);
}
-static int rtl_locale_init (void)
-{
- static sal_once_type g_once = SAL_ONCE_INIT;
- SAL_ONCE(&g_once, rtl_locale_once_init);
- return (g_pLocaleTable != 0);
-}
-
/*************************************************************************
* rtl_locale_fini
*/
-#if defined(__GNUC__)
-static void rtl_locale_fini (void) __attribute__((destructor));
-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma fini(rtl_locale_fini)
-static void rtl_locale_fini (void);
-#endif /* __GNUC__ || __SUNPRO_C */
-
void rtl_locale_fini (void)
{
if (g_pLocaleTable != 0)
@@ -260,6 +244,8 @@ void rtl_locale_fini (void)
}
}
+extern void ensureLocaleSingleton();
+
/*************************************************************************
* rtl_locale_register
*/
@@ -278,7 +264,8 @@ rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const s
if ( !variant )
variant = &c;
- if (!rtl_locale_init())
+ ensureLocaleSingleton();
+ if (!g_pLocaleTable)
return NULL;
hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant);