|
From: Carlo W. <li...@us...> - 2001-12-31 01:04:06
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2001-11-31 01:04:04 UTC
Modified files:
libcwd/debugmalloc.cc libcwd/include/libcw/macro_Libcwd_macros.h
Log message:
Bug fixes.
---------------------- diff included ----------------------
Index: src/libcwd/debugmalloc.cc
diff -u src/libcwd/debugmalloc.cc:1.64 src/libcwd/debugmalloc.cc:1.65
--- src/libcwd/debugmalloc.cc:1.64 Sat Dec 29 20:17:46 2001
+++ src/libcwd/debugmalloc.cc Sun Dec 30 17:03:54 2001
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.64 2001/12/30 04:17:46 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/debugmalloc.cc,v 1.65 2001/12/31 01:03:54 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -1196,41 +1196,18 @@
{
if (WST_initialization_state <= 0) // Only true prior to initialization of std::ios_base::Init.
{
- // This block is Single Threaded.
- if (WST_initialization_state == 0) // Only true once.
- {
- __libcwd_tsd.internal = 1;
- memblk_map.MT_unsafe = new memblk_map_ct; // MT-safe: There are no threads created yet when we get here.
- WST_initialization_state = -1;
- __libcwd_tsd.internal = 0;
- }
-#ifdef __GLIBCPP__
- // "ios_base" is always initialized for libstdc++ version 2.
- if (!_private_::WST_ios_base_initialized && !_private_::inside_ios_base_Init_Init())
-#endif // __GLIBCPP__
- {
- WST_initialization_state = 1; // ST_initialize_globals() calls malloc again of course.
-#ifdef DEBUGDEBUGMALLOC
- --__libcwd_tsd.recursive; // Allow that.
-#endif
#ifdef DEBUGDEBUG
- bool continued_debug_output = (__libcwd_tsd.library_call == 0 && libcw_do._off < 0);
-#endif
- libcw::debug::ST_initialize_globals(); // This doesn't belong in the malloc department at all, but malloc() happens
- // to be a function that is called _very_ early - and hence this is a good moment
- // to initialize ALL of libcwd.
-#ifdef DEBUGDEBUGMALLOC
- ++__libcwd_tsd.recursive;
+ bool continued_debug_output = (__libcwd_tsd.library_call == 0 && libcw_do._off < 0);
#endif
+ init_debugmalloc();
#ifdef DEBUGDEBUG
- // It is possible that libcwd is not initialized at this point, libcw_do._off == 0 (turned off)
- // and thus no unfinished debug output was printed before entering this function.
- // Initialization of libcwd with DEBUGDEBUG defined turns on libcwd_do. In order to balance the
- // continued stack, we print an unfinished debug message here.
- if (continued_debug_output != (__libcwd_tsd.library_call == 0 && libcw_do._off < 0))
- DoutInternal( dc_malloc|continued_cf, "internal_malloc(" << size << ", " << flag << ") = " );
+ // It is possible that libcwd is not initialized at this point, libcw_do._off == 0 (turned off)
+ // and thus no unfinished debug output was printed before entering this function.
+ // Initialization of libcwd with DEBUGDEBUG defined turns on libcwd_do. In order to balance the
+ // continued stack, we print an unfinished debug message here.
+ if (continued_debug_output != (__libcwd_tsd.library_call == 0 && libcw_do._off < 0))
+ DoutInternal( dc_malloc|continued_cf, "internal_malloc(" << size << ", " << flag << ") = " );
#endif
- }
}
register void* mptr;
@@ -1299,7 +1276,7 @@
++__libcwd_tsd.recursive;
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
@@ -1499,13 +1476,33 @@
void init_debugmalloc(void)
{
- if (WST_initialization_state == 0)
+ if (WST_initialization_state <= 0)
{
LIBCWD_TSD_DECLARATION
- _private_::set_alloc_checking_off(LIBCWD_TSD);
- memblk_map.MT_unsafe = new memblk_map_ct; // MT-safe: `init_debugmalloc' is called before any threads are created.
- WST_initialization_state = -1;
- _private_::set_alloc_checking_on(LIBCWD_TSD);
+ // This block is Single Threaded.
+ if (WST_initialization_state == 0) // Only true once.
+ {
+ _private_::set_alloc_checking_off(LIBCWD_TSD);
+ memblk_map.MT_unsafe = new memblk_map_ct; // MT-safe: There are no threads created yet when we get here.
+ WST_initialization_state = -1;
+ _private_::set_alloc_checking_on(LIBCWD_TSD);
+ }
+#ifdef __GLIBCPP__
+ // "ios_base" is always initialized for libstdc++ version 2.
+ if (!_private_::WST_ios_base_initialized && !_private_::inside_ios_base_Init_Init())
+#endif // __GLIBCPP__
+ {
+ WST_initialization_state = 1; // ST_initialize_globals() calls malloc again of course.
+#ifdef DEBUGDEBUGMALLOC
+ --__libcwd_tsd.recursive; // Allow that.
+#endif
+ libcw::debug::ST_initialize_globals(); // This doesn't belong in the malloc department at all, but malloc() happens
+ // to be a function that is called _very_ early - and hence this is a good moment
+ // to initialize ALL of libcwd.
+#ifdef DEBUGDEBUGMALLOC
+ ++__libcwd_tsd.recursive;
+#endif
+ }
}
}
@@ -2118,7 +2115,7 @@
#endif
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
@@ -2195,7 +2192,7 @@
#endif
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
@@ -2283,7 +2280,7 @@
#endif
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
if (__libcwd_tsd.internal)
{
@@ -2647,7 +2644,7 @@
++__libcwd_tsd.recursive;
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
#ifdef DEBUGDEBUGMALLOC
--__libcwd_tsd.recursive;
@@ -2668,7 +2665,7 @@
++__libcwd_tsd.recursive;
#endif
#if defined(DEBUGDEBUGMALLOC) && defined(__GLIBCPP__) && !defined(DEBUGMALLOCEXTERNALCLINKAGE)
- LIBCWD_ASSERT( _private_::WST_ios_base_initialized );
+ LIBCWD_ASSERT( _private_::WST_ios_base_initialized || __libcwd_tsd.internal );
#endif
#ifdef DEBUGDEBUGMALLOC
--__libcwd_tsd.recursive;
Index: src/libcwd/include/libcw/macro_Libcwd_macros.h
diff -u src/libcwd/include/libcw/macro_Libcwd_macros.h:1.2 src/libcwd/include/libcw/macro_Libcwd_macros.h:1.3
--- src/libcwd/include/libcw/macro_Libcwd_macros.h:1.2 Sat Dec 29 20:17:50 2001
+++ src/libcwd/include/libcw/macro_Libcwd_macros.h Sun Dec 30 17:03:54 2001
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.2 2001/12/30 04:17:50 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/macro_Libcwd_macros.h,v 1.3 2001/12/31 01:03:54 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -57,7 +57,7 @@
#define LIBCWD_STR1(x) #x
#define LIBCWD_STR2(x) LIBCWD_STR1(x)
#define LIBCWD_STR3 "LibcwDout at " __FILE__ ":" LIBCWD_STR2(__LINE__) "\n"
-#define DEBUGDEBUGLIBCWDOUTMARKER ::write(2, LIBCWD_STR3, sizeof(LIBCWD_STR3));
+#define DEBUGDEBUGLIBCWDOUTMARKER ::write(2, LIBCWD_STR3, sizeof(LIBCWD_STR3) - 1);
#else // !DEBUGDEBUGOUTPUT
#define DEBUGDEBUGLIBCWDOUTMARKER
#endif // !DEBUGDEBUGOUTPUT
@@ -100,7 +100,7 @@
#ifndef DEBUGDEBUGLIBCWDOUTFATALMARKER
#ifdef DEBUGDEBUGOUTPUT
#define LIBCWD_STR4 "LibcwDoutFatal at " __FILE__ ":" LIBCWD_STR2(__LINE__) "\n"
-#define DEBUGDEBUGLIBCWDOUTFATALMARKER ::write(2, LIBCWD_STR4, sizeof(LIBCWD_STR4));
+#define DEBUGDEBUGLIBCWDOUTFATALMARKER ::write(2, LIBCWD_STR4, sizeof(LIBCWD_STR4) - 1);
#else
#define DEBUGDEBUGLIBCWDOUTFATALMARKER
#endif
----------------------- End of diff -----------------------
|