fix to apply

f41
Caolán McNamara 14 years ago
parent 239956c551
commit c7d5d8878d

@ -6,7 +6,7 @@ Subject: [PATCH] helgrind: Related: rhbz#655686 get order of shutdown correct
---
sal/rtl/source/alloc_arena.c | 44 +++-----------
sal/rtl/source/alloc_cache.c | 44 +++-----------
sal/rtl/source/alloc_fini.cxx | 81 +++++++++++++++++++-------
sal/rtl/source/memory_fini.cxx | 81 +++++++++++++++++++-------
sal/rtl/source/alloc_global.c | 131 +++++++++++++++++------------------------
sal/rtl/source/makefile.mk | 15 +----
5 files changed, 135 insertions(+), 180 deletions(-)
@ -15,7 +15,7 @@ diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c
index 27ac970..c2294d8 100644
--- a/sal/rtl/source/alloc_arena.c
+++ b/sal/rtl/source/alloc_arena.c
@@ -102,13 +102,6 @@ rtl_machdep_pagesize (void);
@@ -111,13 +111,6 @@
rtl_arena_type * gp_default_arena = 0;
@ -29,7 +29,7 @@ index 27ac970..c2294d8 100644
/* ================================================================= */
/** rtl_arena_segment_constructor()
@@ -921,6 +914,8 @@ rtl_arena_deactivate (
@@ -930,6 +923,8 @@
*
* ================================================================= */
@ -38,7 +38,7 @@ index 27ac970..c2294d8 100644
/** rtl_arena_create()
*/
rtl_arena_type *
@@ -973,7 +968,8 @@ try_alloc:
@@ -980,7 +975,8 @@
}
else if (gp_arena_arena == 0)
{
@ -48,7 +48,7 @@ index 27ac970..c2294d8 100644
{
/* try again */
goto try_alloc;
@@ -1279,8 +1275,8 @@ rtl_machdep_pagesize (void)
@@ -1276,8 +1272,8 @@
*
* ================================================================= */
@ -59,7 +59,7 @@ index 27ac970..c2294d8 100644
{
{
/* list of arenas */
@@ -1342,36 +1338,11 @@ rtl_arena_once_init (void)
@@ -1336,25 +1332,11 @@
);
OSL_ASSERT(gp_arena_arena != 0);
}
@ -76,18 +76,7 @@ index 27ac970..c2294d8 100644
/* ================================================================= */
-/*
- Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
-
- Mac OS X does not seem to support "__cxa__atexit", thus leading
- to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_{memory|cache|arena}_fini") become called
- _before_ global C++ object d'tors.
-
- Delegated the call to "rtl_arena_fini()" into a dummy C++ object,
- see alloc_fini.cxx .
-*/
-#if defined(__GNUC__) && !defined(MACOSX)
-#if defined(__GNUC__)
-static void rtl_arena_fini (void) __attribute__((destructor));
-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma fini(rtl_arena_fini)
@ -97,7 +86,7 @@ index 27ac970..c2294d8 100644
void
rtl_arena_fini (void)
{
@@ -1394,6 +1365,7 @@ rtl_arena_fini (void)
@@ -1377,6 +1359,7 @@
}
RTL_MEMORY_LOCK_RELEASE(&(g_arena_list.m_lock));
}
@ -109,7 +98,7 @@ diff --git a/sal/rtl/source/alloc_cache.c b/sal/rtl/source/alloc_cache.c
index 06de201..ebf799e 100644
--- a/sal/rtl/source/alloc_cache.c
+++ b/sal/rtl/source/alloc_cache.c
@@ -99,13 +99,6 @@ static rtl_cache_type * gp_cache_slab_cache = 0;
@@ -99,13 +99,6 @@
static rtl_cache_type * gp_cache_bufctl_cache = 0;
@ -123,7 +112,7 @@ index 06de201..ebf799e 100644
/* ================================================================= */
/** RTL_CACHE_HASH_INDEX()
@@ -1119,6 +1112,8 @@ rtl_cache_deactivate (
@@ -1099,6 +1092,8 @@
*
* ================================================================= */
@ -132,7 +121,7 @@ index 06de201..ebf799e 100644
/** rtl_cache_create()
*/
rtl_cache_type *
@@ -1176,7 +1171,8 @@ try_alloc:
@@ -1154,7 +1149,8 @@
}
else if (gp_cache_arena == 0)
{
@ -142,7 +131,7 @@ index 06de201..ebf799e 100644
{
/* try again */
goto try_alloc;
@@ -1583,8 +1579,8 @@ rtl_cache_wsupdate_all (void * arg)
@@ -1552,8 +1548,8 @@
*
* ================================================================= */
@ -153,12 +142,12 @@ index 06de201..ebf799e 100644
{
{
/* list of caches */
@@ -1680,36 +1676,11 @@ rtl_cache_once_init (void)
@@ -1646,25 +1642,10 @@
}
rtl_cache_wsupdate_init();
-}
-
-static int
-rtl_cache_init (void)
-{
@ -168,20 +157,9 @@ index 06de201..ebf799e 100644
+ OSL_TRACE("rtl_cache_init completed");
}
/* ================================================================= */
-/*
- Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
-/* ================================================================= */
-
- Mac OS X does not seem to support "__cxa__atexit", thus leading
- to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_{memory|cache|arena}_fini") become called
- _before_ global C++ object d'tors.
-
- Delegated the call to "rtl_cache_fini()" into a dummy C++ object,
- see alloc_fini.cxx .
-*/
-#if defined(__GNUC__) && !defined(MACOSX)
-#if defined(__GNUC__)
-static void rtl_cache_fini (void) __attribute__((destructor));
-#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-#pragma fini(rtl_cache_fini)
@ -191,7 +169,7 @@ index 06de201..ebf799e 100644
void
rtl_cache_fini (void)
{
@@ -1765,6 +1736,7 @@ rtl_cache_fini (void)
@@ -1717,6 +1698,7 @@
}
RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock));
}
@ -199,31 +177,30 @@ index 06de201..ebf799e 100644
}
/* ================================================================= */
diff --git a/sal/rtl/source/alloc_fini.cxx b/sal/rtl/source/alloc_fini.cxx
diff --git a/sal/rtl/source/memory_fini.cxx b/sal/rtl/source/memory_fini.cxx
index 5bc174e..f079676 100644
--- a/sal/rtl/source/alloc_fini.cxx
+++ b/sal/rtl/source/alloc_fini.cxx
@@ -26,33 +26,72 @@
--- a/sal/rtl/source/memory_fini.cxx
+++ b/sal/rtl/source/memory_fini.cxx
@@ -26,32 +26,98 @@
*
************************************************************************/
-
-/*
- Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
-
- Mac OS X does not seem to support "__cxa__atexit", thus leading
- to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_{memory|cache|arena}_fini") become called
- _before_ global C++ object d'tors.
- (in particular "rtl_memory_fini") become called _before_ global
- C++ object d'tors.
-
- Using a C++ dummy object instead.
-*/
-
-#include <stdio.h>
+#include <rtl/instance.hxx>
extern "C" void rtl_memory_fini (void);
-extern "C" void rtl_cache_fini (void);
-extern "C" void rtl_arena_fini (void);
-
-struct RTL_Alloc_Fini
+extern "C" void rtl_memory_init (void);
+namespace
+{
@ -238,16 +215,21 @@ index 5bc174e..f079676 100644
+ rtl_memory_fini();
+ }
+ };
+ class theMemorySingleton : public rtl::Static<rtlMemorySingleton, theMemorySingleton>{};
+ class theMemorySingleton
+ : public rtl::Static<rtlMemorySingleton, theMemorySingleton>{};
+}
+extern "C" void ensureMemorySingleton()
{
- ~RTL_Alloc_Fini() ;
-};
+{
+ theMemorySingleton::get();
+}
-RTL_Alloc_Fini::~RTL_Alloc_Fini()
-
-struct RTL_Memory_Fini {
- ~RTL_Memory_Fini() ;
-};
-
-RTL_Memory_Fini::~RTL_Memory_Fini() {
- rtl_memory_fini();
+extern "C" void rtl_cache_fini (void);
+extern "C" void rtl_cache_init (void);
+namespace
@ -263,17 +245,14 @@ index 5bc174e..f079676 100644
+ rtl_cache_fini();
+ }
+ };
+ class theCacheSingleton : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{};
+ class theCacheSingleton
+ : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{};
+}
+extern "C" void ensureCacheSingleton()
{
- rtl_memory_fini();
- rtl_cache_fini();
- rtl_arena_fini();
+{
+ theCacheSingleton::get();
}
-static RTL_Alloc_Fini g_RTL_Alloc_Fini;
+extern "C" void rtl_arena_fini (void);
+extern "C" void rtl_arena_init (void);
+namespace
@ -289,11 +268,36 @@ index 5bc174e..f079676 100644
+ rtl_arena_fini();
+ }
+ };
+ class theArenaSingleton : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{};
+ class theArenaSingleton
+ : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{};
+}
+extern "C" void ensureArenaSingleton()
+{
+ theArenaSingleton::get();
+}
-static RTL_Memory_Fini rtl_Memory_Fini;
+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: */
@ -301,155 +305,56 @@ diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c
index 70504ac..fb95e83 100644
--- a/sal/rtl/source/alloc_global.c
+++ b/sal/rtl/source/alloc_global.c
@@ -29,6 +29,7 @@
#include "alloc_impl.h"
@@ -28,6 +28,7 @@
#include "rtl/alloc.h"
#include <sal/macros.h>
+#include <osl/diagnose.h>
#ifndef INCLUDED_STRING_H
#include <string.h>
#include <stdio.h>
@@ -66,7 +67,6 @@ static void determine_alloc_mode(void)
@@ -49,7 +50,6 @@
#include "alloc_impl.h"
#include "internal/once.h"
#include "sal/macros.h"
-#include "osl/diagnose.h"
/* ================================================================= *
*
@@ -108,60 +108,7 @@ static rtl_cache_type * g_alloc_table[RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SH
static rtl_arena_type * gp_alloc_arena = 0;
@@ -97,8 +97,8 @@
*
* ================================================================= */
-/* ================================================================= *
- *
- * custom allocator initialization / finalization.
- *
- * ================================================================= */
-
-static void
-rtl_memory_once_init (void)
-{
- {
- /* global memory arena */
- OSL_ASSERT(gp_alloc_arena == 0);
-
- gp_alloc_arena = rtl_arena_create (
- "rtl_alloc_arena",
- 2048, /* quantum */
- 0, /* w/o quantum caching */
- 0, /* default source */
- rtl_arena_alloc,
- rtl_arena_free,
- 0 /* flags */
- );
- OSL_ASSERT(gp_alloc_arena != 0);
- }
- {
- sal_Size size;
- int i, n = RTL_MEMORY_CACHED_SIZES;
-
- for (i = 0; i < n; i++)
- {
- char name[RTL_CACHE_NAME_LENGTH + 1];
- (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]);
- g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0);
- }
-
- size = RTL_MEMALIGN;
- for (i = 0; i < n; i++)
- {
- while (size <= g_alloc_sizes[i])
- {
- g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i];
- size += RTL_MEMALIGN;
- }
- }
- }
+void
+rtl_memory_init (void)
{
{
/* global memory arena */
@@ -136,36 +136,10 @@
}
}
}
-}
-
-static int
-rtl_memory_init (void)
-{
- static sal_once_type g_once = SAL_ONCE_INIT;
- SAL_ONCE(&g_once, rtl_memory_once_init);
- return (gp_alloc_arena != 0);
-}
+extern void ensureMemorySingleton();
/* ================================================================= *
*
@@ -198,7 +145,8 @@ try_alloc:
}
else if (gp_alloc_arena == 0)
{
- if (rtl_memory_init())
+ ensureMemorySingleton();
+ if (gp_alloc_arena)
{
/* try again */
goto try_alloc;
@@ -256,28 +204,58 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT
#endif
+/* ================================================================= *
+ *
+ * custom allocator initialization / finalization.
+ *
+ * ================================================================= */
+
+void rtl_memory_init (void)
+{
+#if !defined(FORCE_SYSALLOC)
+ {
+ /* global memory arena */
+ OSL_ASSERT(gp_alloc_arena == 0);
+
+ gp_alloc_arena = rtl_arena_create (
+ "rtl_alloc_arena",
+ 2048, /* quantum */
+ 0, /* w/o quantum caching */
+ 0, /* default source */
+ rtl_arena_alloc,
+ rtl_arena_free,
+ 0 /* flags */
+ );
+ OSL_ASSERT(gp_alloc_arena != 0);
+ }
+ {
+ sal_Size size;
+ int i, n = RTL_MEMORY_CACHED_SIZES;
+
+ for (i = 0; i < n; i++)
+ {
+ char name[RTL_CACHE_NAME_LENGTH + 1];
+ (void) snprintf (name, sizeof(name), "rtl_alloc_%lu", g_alloc_sizes[i]);
+ g_alloc_caches[i] = rtl_cache_create (name, g_alloc_sizes[i], 0, NULL, NULL, NULL, NULL, NULL, 0);
+ }
+
+ size = RTL_MEMALIGN;
+ for (i = 0; i < n; i++)
+ {
+ while (size <= g_alloc_sizes[i])
+ {
+ g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT] = g_alloc_caches[i];
+ size += RTL_MEMALIGN;
+ }
+ }
+ }
+#endif
+ OSL_TRACE("rtl_memory_init completed");
+}
+
/* ================================================================= */
}
-/* ================================================================= */
-
-/*
- Issue http://udk.openoffice.org/issues/show_bug.cgi?id=92388
-
- Mac OS X does not seem to support "__cxa__atexit", thus leading
- to the situation that "__attribute__((destructor))__" functions
- (in particular "rtl_memory_fini") become called _before_ global
- (in particular "rtl_memory_fini") become called _before_ global
- C++ object d'tors.
-
- Delegated the call to "rtl_memory_fini" into a dummy C++ object,
@ -462,53 +367,128 @@ index 70504ac..fb95e83 100644
-static void rtl_memory_fini (void);
-#endif /* __GNUC__ || __SUNPRO_C */
-
-void
-rtl_memory_fini (void)
+void rtl_memory_fini (void)
void
rtl_memory_fini (void)
{
#if !defined(FORCE_SYSALLOC)
int i, n;
@@ -302,6 +280,7 @@ rtl_memory_fini (void)
@@ -190,6 +164,7 @@
rtl_arena_destroy (gp_alloc_arena);
gp_alloc_arena = 0;
}
#endif
+ OSL_TRACE("rtl_memory_fini completed");
}
/* ================================================================= *
@@ -198,6 +173,8 @@
*
* ================================================================= */
+extern void ensureMemorySingleton();
+
void *
SAL_CALL rtl_allocateMemory (sal_Size n) SAL_THROW_EXTERN_C()
{
@@ -227,7 +204,8 @@
}
else if (gp_alloc_arena == 0)
{
- if (rtl_memory_init())
+ ensureMemorySingleton();
+ if (gp_alloc_arena)
{
/* try again */
goto try_alloc;
diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk
index 67ae7f8..9c3921d 100644
--- a/sal/rtl/source/makefile.mk
+++ b/sal/rtl/source/makefile.mk
@@ -100,12 +100,8 @@ SLOFILES= \
@@ -95,11 +95,8 @@
$(SLO)$/math.obj \
$(SLO)$/alloc_global.obj\
$(SLO)$/alloc_cache.obj \
- $(SLO)$/alloc_arena.obj
-
-.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX"
-SLOFILES+=$(SLO)$/alloc_fini.obj
-SLOFILES+=$(SLO)$/memory_fini.obj
-.ENDIF
-
+ $(SLO)$/alloc_arena.obj \
+ $(SLO)$/alloc_fini.obj
+ $(SLO)$/memory_fini.obj
OBJFILES= \
$(OBJ)$/memory.obj \
@@ -132,11 +128,8 @@ OBJFILES= \
#.IF "$(UPDATER)"=="YES"
@@ -128,11 +125,8 @@
$(OBJ)$/math.obj \
$(OBJ)$/alloc_global.obj\
$(OBJ)$/alloc_cache.obj \
- $(OBJ)$/alloc_arena.obj
-
-.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX"
-OBJFILES+=$(OBJ)$/alloc_fini.obj
-OBJFILES+=$(OBJ)$/memory_fini.obj
-.ENDIF
+ $(OBJ)$/alloc_arena.obj \
+ $(OBJ)$/alloc_fini.obj
+ $(OBJ)$/memory_fini.obj
APP1TARGET=gen_makefile
--
1.7.4.1
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);

Loading…
Cancel
Save