[Libreoffice-commits] .: sal/rtl

Caolán McNamara caolan at kemper.freedesktop.org
Tue Apr 5 07:31:31 PDT 2011


 sal/rtl/source/alloc_fini.cxx |   32 +++++++++++++++++++++++++++++---
 sal/rtl/source/locale.c       |   23 +++++------------------
 2 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit 0e4e9c3bcd6bfa5fb3ee3b60f85fa380a30de668
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 5 15:31:23 2011 +0100

    put the deprecated rtl_Locale stuff in here too

diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx
index f079676..dfd3599 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 964be09..79f2fb8 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);


More information about the Libreoffice-commits mailing list