|
From: Carlo W. <li...@us...> - 2002-02-08 04:03:59
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2002-01-08 04:03:58 UTC
Modified files:
libcwd/NEWS libcwd/debug.cc libcwd/demangle3.cc
libcwd/threading.cc libcwd/wrapcnclpnts.cc
libcwd/documentation/html.footer
libcwd/documentation/doxygen-examples/markers.cc
libcwd/documentation/tutorial/channel.cc
libcwd/documentation/tutorial/faq.m4
libcwd/documentation/tutorial/hello_world.cc
libcwd/documentation/tutorial/log_file.cc
libcwd/documentation/tutorial/tut1.m4
libcwd/documentation/tutorial/tut2.m4
libcwd/documentation/tutorial/tut3.m4
libcwd/documentation/tutorial/tut6.m4
libcwd/documentation/tutorial/examples5/sys.h
libcwd/documentation/tutorial/examples7/sys.h
libcwd/example-project/sys.h libcwd/include/libcw/class_debug.h
libcwd/include/libcw/private_threading.h
libcwd/include/libcw/struct_debug_tsd.h
libcwd/include/libcw/sysd.ho.in libcwd/include/libcw/type_info.h
libcwd/tests/lines.cc libcwd/tests/stabs.cc libcwd/tests/sys.h
libcwd/testsuite/module.cc libcwd/testsuite/libcwd.tst/sys.h
Log message:
Bug fixes for doxygen.
Added debug_ct::keep_tsd
Added documentation about the need to define _GNU_SOURCE and
updated all sys.h related things.
---------------------- diff included ----------------------
Index: src/libcwd/NEWS
diff -u src/libcwd/NEWS:1.65 src/libcwd/NEWS:1.66
--- src/libcwd/NEWS:1.65 Fri Jan 18 21:08:53 2002
+++ src/libcwd/NEWS Thu Feb 7 20:03:46 2002
@@ -61,6 +61,17 @@
Reason: the temporary stringstream that was returned was only valid
inside a Dout to begin with. The use of get_os() was dangerous.
+ You will need to add
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE
+ #endif
+ to your "sys.h" file, prior to including any other header file,
+ just before including <libcw/sysd.h>. This is needed because libcwd
+ uses GNU extensions. Of course, it is not necessary to define
+ _GNU_SOURCE when CWDEBUG isn't defined, so you may put it inside the
+ #ifdef CWDEBUG ... #endif.
+ If you don't understand this, read documentation/html/preparation.html.
+
Bug fixes:
When using .stabs, each first line of code after a source file scope change
Index: src/libcwd/debug.cc
diff -u src/libcwd/debug.cc:1.62 src/libcwd/debug.cc:1.63
--- src/libcwd/debug.cc:1.62 Tue Feb 5 16:46:07 2002
+++ src/libcwd/debug.cc Thu Feb 7 20:03:46 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.62 2002/02/06 00:46:07 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/debug.cc,v 1.63 2002/02/08 04:03:46 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -284,6 +284,7 @@
channels::dc::system.NS_initialize("SYSTEM");
libcw_do.NS_init(); // Initialize debug code.
+ libcw_do.keep_tsd(true);
// Unlimit core size.
#ifdef RLIMIT_CORE
@@ -1069,7 +1070,7 @@
}
/**
- * \fn void list_channels_on(debug_ct const& debug_object)
+ * \fn void list_channels_on(debug_ct& debug_object)
* \ingroup group_special
*
* \brief List all %debug %channels to a given %debug object.
@@ -1425,6 +1426,16 @@
core_dump(); // off() and on() where called and not in equal pairs.
LIBCWD_TSD_MEMBER_OFF = state._off; // Restore.
}
+
+#ifdef LIBCWD_THREAD_SAFE
+ bool debug_ct::keep_tsd(bool keep)
+ {
+ LIBCWD_TSD_DECLARATION
+ bool old = LIBCWD_TSD_MEMBER(tsd_keep);
+ LIBCWD_TSD_MEMBER(tsd_keep) = keep;
+ return old;
+ }
+#endif
void channel_ct::force_on(channel_ct::OnOffState& state, char const* label)
{
Index: src/libcwd/demangle3.cc
diff -u src/libcwd/demangle3.cc:1.13 src/libcwd/demangle3.cc:1.14
--- src/libcwd/demangle3.cc:1.13 Wed Jan 9 08:16:04 2002
+++ src/libcwd/demangle3.cc Thu Feb 7 20:03:46 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.13 2002/01/09 16:16:04 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.14 2002/02/08 04:03:46 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -249,7 +249,7 @@
};
enum param_qualifier_nt {
- vendor_extention = 'U',
+ vendor_extension = 'U',
array = 'A',
pointer_to_member = 'M'
};
@@ -1240,7 +1240,7 @@
failure = true;
break;
}
- qualifiers->add_qualifier_start(vendor_extention, start_pos, source_name, M_inside_substitution);
+ qualifiers->add_qualifier_start(vendor_extension, start_pos, source_name, M_inside_substitution);
continue;
}
case 'A':
@@ -1816,7 +1816,7 @@
|| (M_pos += decode_encoding(M_str + M_pos, output)) < 0)
FAILURE;
RETURN;
- case 'C': // GNU extention?
+ case 'C': // GNU extension?
{
internal_string first;
output += "construction vtable for ";
Index: src/libcwd/documentation/doxygen-examples/markers.cc
diff -u src/libcwd/documentation/doxygen-examples/markers.cc:1.2 src/libcwd/documentation/doxygen-examples/markers.cc:1.3
--- src/libcwd/documentation/doxygen-examples/markers.cc:1.2 Sat Dec 29 20:17:47 2001
+++ src/libcwd/documentation/doxygen-examples/markers.cc Thu Feb 7 20:03:47 2002
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
Index: src/libcwd/documentation/html.footer
diff -u src/libcwd/documentation/html.footer:1.2 src/libcwd/documentation/html.footer:1.3
--- src/libcwd/documentation/html.footer:1.2 Sat Dec 29 20:17:47 2001
+++ src/libcwd/documentation/html.footer Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-<ADDRESS>Copyright © 2001 Carlo Wood. All rights reserved.</ADDRESS>
+<ADDRESS>Copyright © 2001, 2002 Carlo Wood. All rights reserved.</ADDRESS>
</DIV>
</BODY>
Index: src/libcwd/documentation/tutorial/channel.cc
diff -u src/libcwd/documentation/tutorial/channel.cc:1.2 src/libcwd/documentation/tutorial/channel.cc:1.3
--- src/libcwd/documentation/tutorial/channel.cc:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/channel.cc Thu Feb 7 20:03:47 2002
@@ -2,17 +2,16 @@
// Please see the "example-project" in the source distribution of libcwd
// for a better Real Life example.
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#define DEBUGCHANNELS ::example // Where we'll put our namespace dc
#include <libcw/debug.h>
-#ifdef CWDEBUG
namespace example { // namespace dc cannot be put in ::
namespace dc {
libcw::debug::channel_ct ghost("GHOST"); // Create our own Debug Channel
}
}
-#endif
int main(void)
{
Index: src/libcwd/documentation/tutorial/examples5/sys.h
diff -u src/libcwd/documentation/tutorial/examples5/sys.h:1.1 src/libcwd/documentation/tutorial/examples5/sys.h:1.2
--- src/libcwd/documentation/tutorial/examples5/sys.h:1.1 Sat Dec 29 17:22:09 2001
+++ src/libcwd/documentation/tutorial/examples5/sys.h Thu Feb 7 20:03:47 2002
@@ -1,6 +1,11 @@
-#ifdef HAVE_CONFIG_H // This is just an example of what you could do
-#include "config.h" // when using autoconf for your project.
+// This is just an example of what you could do when using autoconf for your project.
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
-#ifdef CWDEBUG // This is needed so that others can compile
-#include <libcw/sysd.h> // your application without having libcwd installed.
+// This is needed so that others can compile your application without having libcwd installed.
+#ifdef CWDEBUG
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // Libcwd uses GNU extensions.
+#endif
+#include <libcw/sysd.h>
#endif
Index: src/libcwd/documentation/tutorial/examples7/sys.h
diff -u src/libcwd/documentation/tutorial/examples7/sys.h:1.2 src/libcwd/documentation/tutorial/examples7/sys.h:1.3
--- src/libcwd/documentation/tutorial/examples7/sys.h:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/examples7/sys.h Thu Feb 7 20:03:47 2002
@@ -1,3 +1,10 @@
+#ifdef CWDEBUG
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <libcw/sysd.h>
+#endif
+
// Bug workaround for libstdc++, avoid warnings like
// /usr/include/g++-3/iostream.h:253:5: "_G_CLOG_CONFLICT" is not defined
#include <_G_config.h>
@@ -6,8 +13,4 @@
#endif
#ifndef _G_HAS_LABS
#define _G_HAS_LABS 1
-#endif
-
-#ifdef CWDEBUG
-#include <libcw/sysd.h>
#endif
Index: src/libcwd/documentation/tutorial/faq.m4
diff -u src/libcwd/documentation/tutorial/faq.m4:1.3 src/libcwd/documentation/tutorial/faq.m4:1.4
--- src/libcwd/documentation/tutorial/faq.m4:1.3 Fri Jan 18 21:08:54 2002
+++ src/libcwd/documentation/tutorial/faq.m4 Thu Feb 7 20:03:47 2002
@@ -14,8 +14,22 @@
<HR SIZE=1 NOSHADE>
+<A name="GNU_SOURCE"></A>
+<H3>1. Won't this define make my code non-portable?</H3>
+
+<P>No, not unless you actually use the GNU extensions in parts of your
+application that need to be portable (like non-debugging code).
+While debugging the application you will only benefit from using as
+much compiler support as you can get, allowing the compiler to tell you
+what could possibly be wrong with your code.
+Once the application works, you don't have to define _GNU_SOURCE
+because you won't be including the debug code anymore, nor link with
+libcwd. Of course, when you are not sure whether or not new code
+that you added is a GNU extension or not, you should try to compile it
+with CWDEBUG undefined.</P>
+
<A name="sysd.h"></A>
-<H3>1. Why do I have to include "libcw/sysd.h" as first header file?</H3>
+<H3>2. Why do I have to include "libcw/sysd.h" as first header file?</H3>
<P>This header file is used to fix operating systems bugs, including bugs
in the system header files. The only way it can do this is when it
@@ -32,7 +46,7 @@
will definitely lead to compile errors in that header file. </P>
<A name="libcwd"></A>
-<H3>2. What is this <SPAN class="H3code">libcw</SPAN> talk?
+<H3>3. What is this <SPAN class="H3code">libcw</SPAN> talk?
Aren't you forgetting the <U><SPAN class="H3code">d</SPAN></U> of
<SPAN class="H3code">libcw<U>d</U></SPAN>?</H3>
@@ -49,7 +63,7 @@
guessed that ;) ].</P>
<A name="dir"></A>
-<H3>3. Why do I need to type "<SPAN class="H3code">libcw/sysd.h</SPAN>"
+<H3>4. Why do I need to type "<SPAN class="H3code">libcw/sysd.h</SPAN>"
and not just "<SPAN class="H3code">sysd.h</SPAN>"?</H3>
<P>The header file names of libcw are not unique. In order to uniquely
@@ -63,20 +77,20 @@
collision in that case.</P>
<A name="debug.h"></A>
-<H3>4. What is defined <EM>exactly</EM> in <SPAN class="H3code">libcw/debug.h</SPAN>?</H3>
+<H3>5. What is defined <EM>exactly</EM> in <SPAN class="H3code">libcw/debug.h</SPAN>?</H3>
<P>Everything.
Go and read the <A HREF="../html/reference.html>Reference Manual</A> to get <EM>all</EM> gory details if you dare.</P>
<A name="macros"></A>
-<H3>5. Why are you using macros for <SPAN class="H3code">Debug</SPAN> and <SPAN class="H3code">Dout</SPAN>?</H3>
+<H3>6. Why are you using macros for <SPAN class="H3code">Debug</SPAN> and <SPAN class="H3code">Dout</SPAN>?</H3>
<P>Because it is the only way to easy remove debugging code from an application as function of a macro
and because it allows for the fastest possible code even without optimisation, which is often the case
while debugging. A more detailed explanation is given in the <A HREF="../html/page_why_macro.html">Reference Manual</A>.</P>
<A name="Debug"></A>
-<H3>6. Why do I need to type the <SPAN class="H3code">Debug( )</SPAN> around it?</H3>
+<H3>7. Why do I need to type the <SPAN class="H3code">Debug( )</SPAN> around it?</H3>
<P>The macro <SPAN class="code">Debug()</SPAN> is used for two things. 1) The code inside it is only included
when the macro <SPAN class="code">CWDEBUG</SPAN> is defined. 2) It includes the namespace <SPAN class="code">libcw::debug</SPAN>.</P>
@@ -101,7 +115,7 @@
explanation of <SPAN class="code">DEBUGCHANNELS</SPAN>.</P>
<A name="DebugChannels"></A>
-<H3>7. Which Debug Channels exist? Can I make my own?</H3>
+<H3>8. Which Debug Channels exist? Can I make my own?</H3>
<P>This question is covered in chapter
<A HREF="../html/group__group__debug__channels.html">Controlling The Output Level (Debug Channels)</A>
@@ -139,7 +153,7 @@
with the source distribution of libcwd for a Real Life example.</P>
<A name="recursive"></A>
-<H3>8. Can I turn Debug Channels off again? Can I do that recursively?</H3>
+<H3>9. Can I turn Debug Channels off again? Can I do that recursively?</H3>
<P>Debug channels can be switched on and off at any time. At the start of your program you should
turn on the channels of your choice by calling <SPAN class="code">Debug(dc::<EM>channel</EM>.on())</SPAN>
@@ -163,7 +177,7 @@
<SPAN class="code">off()</SPAN> and <SPAN class="code">on()</SPAN> only respectively increment and decrement a counter.</P>
<A name="Channel"></A>
-<H3>9. Why do you call it a Debug <EM>Channel</EM>? What <EM>is</EM> a Debug Channel?</H3>
+<H3>10. Why do you call it a Debug <EM>Channel</EM>? What <EM>is</EM> a Debug Channel?</H3>
<P>A Debug Channel is a fictious "news channel". It should contain information of a certain kind that is
interesting or not interesting as a whole. A Debug Channel is not a device or stream, a single debug channel is best
@@ -173,7 +187,7 @@
to the output stream of the underlaying debug object.</P>
<A name="OwnDebugObject"></A>
-<H3>10. Can I make my own Debug Object?</H3>
+<H3>11. Can I make my own Debug Object?</H3>
<P><A HREF="../html/group__chapter__custom__do.html">Yes</A>, you can make as many debug objects as you like.
Each debug object is associated with one ostream. However, the default debug output macros <CODE>Dout</CODE> and
@@ -193,7 +207,7 @@
</PRE>
<A name="recursive2"></A>
-<H3>11. Can I turn Debug Objects off again? Can I do that recursively?</H3>
+<H3>12. Can I turn Debug Objects off again? Can I do that recursively?</H3>
<P>Debug objects can be switched on and off at any time. At the start of your program you should
turn on the debug object(s) by calling <SPAN class="code">Debug(<EM>debugobject</EM>.on())</SPAN>
@@ -214,7 +228,7 @@
<SPAN class="code">off()</SPAN> and <SPAN class="code">on()</SPAN> only respectively increment and decrement a counter.</P>
<A name="SetOstream"></A>
-<H3>12. How do I set a new <SPAN class="H3code">ostream</SPAN> for a given Debug Object?</H3>
+<H3>13. How do I set a new <SPAN class="H3code">ostream</SPAN> for a given Debug Object?</H3>
<P>You can change the <SPAN class="code">ostream</SPAN> that is associated with a Debug Object at any time.
For example, changing the <SPAN class="code">ostream</SPAN> of <SPAN class="code">libcw_do</SPAN> from the
@@ -227,7 +241,7 @@
<P>See also <A HREF="tut3.html">tutorial 3</A>.</P>
<A name="WhyOff"></A>
-<H3>13. Why are Debug Objects turned off at creation?</H3>
+<H3>14. Why are Debug Objects turned off at creation?</H3>
<P>The Debug Objects and Debug Channels are global objects. Because libcwd could not be
dependant of libcw, they do not use libcw's <CODE>Global<></CODE> template.
@@ -239,7 +253,7 @@
in the state <EM>off</EM>.</P>
<A name="Order"></A>
-<H3>14. Why do you turn on the debug object after you enable a debug channel, why not the other way around?</H3>
+<H3>15. Why do you turn on the debug object after you enable a debug channel, why not the other way around?</H3>
<P>The order in which Debug Channels and Debug Objects are turned on does not matter at all.
At most, when you think about the Debug Object as the «main switch» then it seems to make
@@ -248,7 +262,7 @@
<EM>on</EM> before I forget it. That is a bit <EM>too</EM> fuzzy (logic) for me though ;)</P>
<A name="Object"></A>
-<H3>15. Why do you call it a Debug <EM>Object</EM>? What <EM>is</EM> a Debug Object?</H3>
+<H3>16. Why do you call it a Debug <EM>Object</EM>? What <EM>is</EM> a Debug Object?</H3>
<P>Good question. It can't be because I wasn't creative, I am very creative.
Note that I didn't think of <EM>Object</EM> as in OOP (<EM>that</EM> would be uncreative)
@@ -263,7 +277,7 @@
<SPAN class="code">ostream</SPAN>.</P>
<A name="semicolon"></A>
-<H3>16. Do I need to type that semi-colon after the macro? Why isn't it part of the macro?</H3>
+<H3>17. Do I need to type that semi-colon after the macro? Why isn't it part of the macro?</H3>
<P>Yes, that colon needs to be there.
It was chosen not to include the semi-colon in the macro because this way it looks
@@ -309,7 +323,7 @@
</PRE>
<A name="LibcwDout"></A>
-<H3>17. I made my own Debug Object, can I still use <SPAN class="H3code">Dout</SPAN>?</H3>
+<H3>18. I made my own Debug Object, can I still use <SPAN class="H3code">Dout</SPAN>?</H3>
<P>No, macro <SPAN class="code">Dout</SPAN> et al. use exclusively the debug object that
comes with libcwd. It is easy to define your own macros however (see <A HREF="#OwnDebugObject">above</A>).
@@ -319,7 +333,7 @@
to redefine it).</P>
<A name="evaluation"></A>
-<H3>18. Is the second field of the macro still evaluated when the Debug Channel and/or Debug Object are turned off?</H3>
+<H3>19. Is the second field of the macro still evaluated when the Debug Channel and/or Debug Object are turned off?</H3>
<P>No! And that is a direct result of the fact that <SPAN class="code">Dout</SPAN> et al. are <EM>macros</EM>.
Indeed this fact could therefore be a little confusing.
@@ -338,19 +352,19 @@
In the production version of your application all debug code will be removed and you don't want it to behave differently then!</P>
<A name="suppress"></A>
-<H3>19. Can I suppress that new-line character?</H3>
+<H3>20. Can I suppress that new-line character?</H3>
<P>Yes, and a lot more. See <A HREF="tut5.html#Formatting">tutorial 5.4</A>.</P>
<A name="label"></A>
-<H3>20. What is the maximum length of a label?</H3>
+<H3>21. What is the maximum length of a label?</H3>
<P>The maximum length of the label of a new Debug Channel is given
by the constant<SPAN class="code"> libcw::debug::max_label_len_c</SPAN>.
At this moment that is 16.</P>
<A name="prefix"></A>
-<H3>21. Why do I have to use the <SPAN class="H3code">dc::</SPAN> prefix?</H3>
+<H3>22. Why do I have to use the <SPAN class="H3code">dc::</SPAN> prefix?</H3>
<P>This is a complex reason. Basically because of a flaw in the design of namespaces in C++.
Namespaces have been introduced in order to avoid name collisions, which was a good thing.
@@ -422,13 +436,13 @@
in the <A HREF="../html/group__group__debug__channels.html">Reference Manual</A>.</P>
<A name="ownnamespace"></A>
-<H3>22. Can I put my debug channels in my own name space?</H3>
+<H3>23. Can I put my debug channels in my own name space?</H3>
<P>Yes. How, is described in the <A HREF="../html/group__group__debug__channels.html">Reference Manual</A>.
For some background information on why this has to be so complex, please read the <A HREF="#prefix">previous question</A>.</P>
<A name="labelwidth"></A>
-<H3>23. Why does it print spaces between the label and the colon? How is the field width of the label determined?</H3>
+<H3>24. Why does it print spaces between the label and the colon? How is the field width of the label determined?</H3>
<P>The colon is indented so it ends up in the same column for all existing debug channels.
Hence, the longest label of all existing/created debug channels determines the number of spaces.
Index: src/libcwd/documentation/tutorial/hello_world.cc
diff -u src/libcwd/documentation/tutorial/hello_world.cc:1.2 src/libcwd/documentation/tutorial/hello_world.cc:1.3
--- src/libcwd/documentation/tutorial/hello_world.cc:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/hello_world.cc Thu Feb 7 20:03:47 2002
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <libcw/sysd.h> // This must be the first header file
#include <libcw/debug.h>
Index: src/libcwd/documentation/tutorial/log_file.cc
diff -u src/libcwd/documentation/tutorial/log_file.cc:1.2 src/libcwd/documentation/tutorial/log_file.cc:1.3
--- src/libcwd/documentation/tutorial/log_file.cc:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/log_file.cc Thu Feb 7 20:03:47 2002
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <fstream>
#include <libcw/debug.h>
Index: src/libcwd/documentation/tutorial/tut1.m4
diff -u src/libcwd/documentation/tutorial/tut1.m4:1.2 src/libcwd/documentation/tutorial/tut1.m4:1.3
--- src/libcwd/documentation/tutorial/tut1.m4:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/tut1.m4 Thu Feb 7 20:03:47 2002
@@ -13,7 +13,8 @@
<P>Compile as: <SPAN class="shell-command">g++ -g -DCWDEBUG hello_world.cc -lcwd -o hello_world</SPAN></P>
<PRE>
-#include <libcw/sysd.h> // This must be the first header file
+#define _GNU_SOURCE // This must be defined before including <libcw/sysd.h>
+#include <libcw/sysd.h> // This must be the first header file
#include <libcw/debug.h>
int main(void)
@@ -28,6 +29,22 @@
</PRE>
<P>Each of the lines of code in this first example program are explained below:</P>
+
+<H3><CODE>#define _GNU_SOURCE</CODE></H3>
+
+<P>This define is necessary to tell the system headers that you
+want to use the GNU extensions (see /usr/include/features.h).
+In order to make you explicitely aware of the fact that it is
+defined, libcwd does not define this macro itself (which it could do inside <libcw/sysd.h>),
+but forces you to define it when using libcwd.
+Note you only really have to define it when you compiled libcwd with
+threading support.
+If you do not define this macro and libcwd needs it, then you will get
+a compile error in <libcw/sysd.h> telling you so.</P>
+
+<DIV class="faq-frame"><H4>FAQ</H4><UL class="faq">
+<LI><A HREF="faq.html#GNU_SOURCE">Won't this define make my code non-portable?</LI>
+</UL></DIV>
<H3><CODE>#include <libcw/sysd.h></CODE></H3>
Index: src/libcwd/documentation/tutorial/tut2.m4
diff -u src/libcwd/documentation/tutorial/tut2.m4:1.2 src/libcwd/documentation/tutorial/tut2.m4:1.3
--- src/libcwd/documentation/tutorial/tut2.m4:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/tut2.m4 Thu Feb 7 20:03:47 2002
@@ -17,6 +17,9 @@
#include "config.h" // when using autoconf for your project.
#endif
#ifdef CWDEBUG // This is needed so that others can compile
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include <libcw/sysd.h> // your application without having libcwd installed.
#endif
</PRE>
Index: src/libcwd/documentation/tutorial/tut3.m4
diff -u src/libcwd/documentation/tutorial/tut3.m4:1.2 src/libcwd/documentation/tutorial/tut3.m4:1.3
--- src/libcwd/documentation/tutorial/tut3.m4:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/tut3.m4 Thu Feb 7 20:03:47 2002
@@ -13,6 +13,7 @@
<P>Compile as: <CODE>g++ -DCWDEBUG log_file.cc -lcwd -o log_file</CODE></P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <fstream>
#include <libcw/debug.h>
Index: src/libcwd/documentation/tutorial/tut6.m4
diff -u src/libcwd/documentation/tutorial/tut6.m4:1.2 src/libcwd/documentation/tutorial/tut6.m4:1.3
--- src/libcwd/documentation/tutorial/tut6.m4:1.2 Sat Dec 29 20:17:49 2001
+++ src/libcwd/documentation/tutorial/tut6.m4 Thu Feb 7 20:03:47 2002
@@ -59,6 +59,7 @@
<P>Compile as: <CODE>g++ -DCWDEBUG amo.cc -lcwd -o amo</CODE></P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -84,6 +85,7 @@
<P>Now let us actually allocate some memory:</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -115,6 +117,7 @@
In order to find out what is wrong, we <EM>also turn on debug channel</EM><CODE> dc::bfd</CODE>:</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -180,6 +183,7 @@
your program is doing:</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -215,6 +219,7 @@
<P>Consider the following code:</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -254,6 +259,7 @@
<CODE>AllocTag_dynamic_description()</CODE>, which <EM>will</EM> work.</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
@@ -299,6 +305,7 @@
<CODE>AllocTag1(p)</CODE>:</P>
<PRE>
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
Index: src/libcwd/example-project/sys.h
diff -u src/libcwd/example-project/sys.h:1.4 src/libcwd/example-project/sys.h:1.5
--- src/libcwd/example-project/sys.h:1.4 Sat Dec 29 20:17:49 2001
+++ src/libcwd/example-project/sys.h Thu Feb 7 20:03:47 2002
@@ -7,7 +7,10 @@
#define CWDEBUG
#endif
// The following is the mandatory part of the custom "sys.h".
-// This must be included *before* any system header file is included.
+// This must be included *before* any system header file is included!
#ifdef CWDEBUG
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include <libcw/sysd.h>
#endif
Index: src/libcwd/include/libcw/class_debug.h
diff -u src/libcwd/include/libcw/class_debug.h:1.8 src/libcwd/include/libcw/class_debug.h:1.9
--- src/libcwd/include/libcw/class_debug.h:1.8 Tue Jan 22 20:03:44 2002
+++ src/libcwd/include/libcw/class_debug.h Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.8 2002/01/23 04:03:44 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/class_debug.h,v 1.9 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2000 - 2002, by
//
@@ -200,6 +200,42 @@
void force_on(OnOffState& state);
void restore(OnOffState const& state);
+
+#ifdef LIBCWD_THREAD_SAFE
+ /**
+ * \brief Keep Thread Specific Data after thread exit.
+ *
+ * Each %debug object has an array (of size PTHREAD_THREADS_MAX (= 1024))
+ * with pointers to the Thread Specific Data (TSD) for each thread id.
+ * The size of this TSD is about 640 bytes.
+ *
+ * When this data would not be freed when a thread exits, and when
+ * an application constantly creates new threads, then all 1024 entries
+ * will become used, causing in total 1024 * 640 bytes of memory to be used
+ * per %debug object instead of <i>number of running threads</i> * 640 bytes.
+ *
+ * However, freeing the Thread Specific Data can not be done at the
+ * very very last moment (for which there is a complicated reason).
+ * Therefore, libcwd deletes the TSD of %debug objects in <code>__pthread_destroy_specifics()</code>,
+ * which is called directly after <code>__pthread_perform_cleanup()</code> in <code>pthread_exit()</code>.
+ * <code>__pthread_destroy_specifics()</code> calls the destruction routines as set
+ * by <code>pthread_key_create()</code>.
+ * As you should know, the order in which these destruction routines
+ * are called is not specified.
+ * Therefore it is possible that additional %debug output done
+ * in other key destruction routines is lost.
+ *
+ * By calling <code>keep_tsd(true)</code>, the TSD is not deleted and %debug output
+ * will stay enabled till the very end.
+ * Because of the disadvantage that this costs about 640 kb of (swappable) memory,
+ * the default is <code>false</code> and the TSD will be freed, except for the
+ * default %debug object \ref libcw_do, allowing for the printing of calls to
+ * <code>%free()</code> done after the key destruction phase.
+ *
+ * \returns The previous value.
+ */
+ bool keep_tsd(bool keep);
+#endif
};
} // namespace debug
Index: src/libcwd/include/libcw/private_threading.h
diff -u src/libcwd/include/libcw/private_threading.h:1.20 src/libcwd/include/libcw/private_threading.h:1.21
--- src/libcwd/include/libcw/private_threading.h:1.20 Wed Feb 6 16:38:38 2002
+++ src/libcwd/include/libcw/private_threading.h Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.20 2002/02/07 00:38:38 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/private_threading.h,v 1.21 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2001 - 2002, by
//
@@ -41,8 +41,10 @@
#endif
#ifdef LIBCWD_HAVE_PTHREAD
+#ifndef __USE_GNU
+#error "__USE_GNU is not defined!"
+#endif
#include <pthread.h>
-#include <semaphore.h>
#if defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) && defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP)
#define LIBCWD_USE_LINUXTHREADS 1
#else
@@ -403,6 +405,7 @@
private:
static pthread_cond_t S_condition;
#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
+ static bool S_initialized;
private:
static void S_initialize(void) throw();
#endif
@@ -445,7 +448,7 @@
}
#endif // !LIBCWD_USE_LINUXTHREADS
-#if !LIBCWD_USE_LINUXTHREADS
+#if defined(DEBUGDEBUGTHREADS) || !LIBCWD_USE_LINUXTHREADS
template <int instance>
bool cond_tct<instance>::S_initialized = false;
#endif
Index: src/libcwd/include/libcw/struct_debug_tsd.h
diff -u src/libcwd/include/libcw/struct_debug_tsd.h:1.6 src/libcwd/include/libcw/struct_debug_tsd.h:1.7
--- src/libcwd/include/libcw/struct_debug_tsd.h:1.6 Tue Feb 5 16:46:08 2002
+++ src/libcwd/include/libcw/struct_debug_tsd.h Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.6 2002/02/06 00:46:08 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/struct_debug_tsd.h,v 1.7 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2002, by
//
@@ -62,6 +62,10 @@
bool tsd_initialized;
// Set after initialization is completed.
+
+ bool tsd_keep;
+ // Do not disable debug output and delete the TSD of the this debug object
+ // during the pthread key destruction phase.
#ifdef DEBUGDEBUGOUTPUT
// Since with DEBUGDEBUG defined we start with _off is -1 instead of 0,
@@ -108,9 +112,9 @@
// A value of 0 means directly behind the marker.
// Accessed from LibcwdDout.
- void start(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM);
- void finish(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM);
- void fatal_finish(debug_ct&, channel_set_data_st& LIBCWD_COMMA_TSD_PARAM) __attribute__ ((__noreturn__));
+ void start(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM);
+ void finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM);
+ void fatal_finish(debug_ct& debug_object, channel_set_data_st& channel_set LIBCWD_COMMA_TSD_PARAM) __attribute__ ((__noreturn__));
// Initialization and de-initialization.
void init(void);
@@ -118,7 +122,7 @@
#ifndef LIBCWD_THREAD_SAFE
_off(0),
#endif
- tsd_initialized(false) { }
+ tsd_initialized(false), tsd_keep(false) { }
~debug_tsd_st();
};
Index: src/libcwd/include/libcw/sysd.ho.in
diff -u src/libcwd/include/libcw/sysd.ho.in:1.5 src/libcwd/include/libcw/sysd.ho.in:1.6
--- src/libcwd/include/libcw/sysd.ho.in:1.5 Tue Jan 8 15:04:59 2002
+++ src/libcwd/include/libcw/sysd.ho.in Thu Feb 7 20:03:47 2002
@@ -1,5 +1,5 @@
// @configure_input@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/sysd.ho.in,v 1.5 2002/01/08 23:04:59 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/sysd.ho.in,v 1.6 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -57,7 +57,7 @@
// Abort when someone tries to use MT with libcwd without MT support.
#@CW_CONFIG_THREAD_SAFE@ LIBCWD_TMP_THREAD_SAFE
#if defined(_REENTRANT) && !defined(LIBCWD_TMP_THREAD_SAFE)
-#error "Recompile libcwd with --enable-threading to enable support for Multi-Threading."
+#error "Recompile libcwd with --enable-libcwd-threading to enable support for Multi-Threading."
#endif
#ifdef LIBCWD_TMP_THREAD_SAFE
@@ -67,7 +67,13 @@
#define LIBCWD_MT_VOLATILE
#endif
-// Was only needed for the two tests above.
+#if defined(LIBCWD_TMP_THREAD_SAFE) && !defined(_GNU_SOURCE)
+#error "Sorry, libcwd with --enable-libcwd-threading uses GNU extensions, also in the header files. "
+ "Therefore you must also define _GNU_SOURCE when you are linking with libcwd. "
+ "Please add #define _GNU_SOURCE to your \"sys.h\", see html/preparation.html#preparation_step2."
+#endif
+
+// Was only needed for the three tests above.
#undef LIBCWD_TMP_THREAD_SAFE
#endif /* LIBCW_SYSD_H */
Index: src/libcwd/include/libcw/type_info.h
diff -u src/libcwd/include/libcw/type_info.h:1.18 src/libcwd/include/libcw/type_info.h:1.19
--- src/libcwd/include/libcw/type_info.h:1.18 Wed Jan 30 20:42:08 2002
+++ src/libcwd/include/libcw/type_info.h Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/type_info.h,v 1.18 2002/01/31 04:42:08 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/include/libcw/type_info.h,v 1.19 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -220,19 +220,13 @@
{
LIBCWD_TSD_DECLARATION
#ifdef LIBCWD_THREAD_SAFE
- // MT: The critical area of spinlock contains no cancellation points:
- // extract_exact_name() doesn't and even the constructor of type_info_ct
- // that calls make_label, which calls demangle_type, do not print output.
- // However, if we are a-synchrone then cancellation can happen at any
- // point. Therefore we set the cancellation type to defer.
- int oldstate;
- pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldstate);
- _private_::cancel_buffer_t buffer;
- _private_::mutex_tct<_private_::type_info_of_instance>::lock(buffer);
+ LIBCWD_DEFER_CANCEL
+ _private_::mutex_tct<_private_::type_info_of_instance>::initialize();
+ _private_::mutex_tct<_private_::type_info_of_instance>::lock();
volatile static bool spin_lock = false;
while(spin_lock);
spin_lock = true;
- _private_::mutex_tct<_private_::type_info_of_instance>::unlock(buffer);
+ _private_::mutex_tct<_private_::type_info_of_instance>::unlock();
if (::libcwd_type_info_exact<T>::value_c.size() == 0) // Recheck now that we acquired the lock.
#endif
{
@@ -241,7 +235,7 @@
}
#ifdef LIBCWD_THREAD_SAFE
spin_lock = false;
- pthread_setcanceltype(oldstate, NULL);
+ LIBCWD_RESTORE_CANCEL
#endif
}
#endif // __GNUC__ == 2 && __GNUC_MINOR__ < 97
Index: src/libcwd/tests/lines.cc
diff -u src/libcwd/tests/lines.cc:1.1 src/libcwd/tests/lines.cc:1.2
--- src/libcwd/tests/lines.cc:1.1 Thu Jan 31 21:12:16 2002
+++ src/libcwd/tests/lines.cc Thu Feb 7 20:03:47 2002
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
Index: src/libcwd/tests/stabs.cc
diff -u src/libcwd/tests/stabs.cc:1.2 src/libcwd/tests/stabs.cc:1.3
--- src/libcwd/tests/stabs.cc:1.2 Sat Dec 29 20:17:50 2001
+++ src/libcwd/tests/stabs.cc Thu Feb 7 20:03:47 2002
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
Index: src/libcwd/tests/sys.h
diff -u src/libcwd/tests/sys.h:1.2 src/libcwd/tests/sys.h:1.3
--- src/libcwd/tests/sys.h:1.2 Wed Sep 19 16:34:50 2001
+++ src/libcwd/tests/sys.h Thu Feb 7 20:03:47 2002
@@ -1,10 +1,13 @@
+#ifdef CWDEBUG
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <libcw/sysd.h>
+#endif
#include <_G_config.h>
#ifndef _G_CLOG_CONFLICT
#define _G_CLOG_CONFLICT 0
#endif
#ifndef _G_HAS_LABS
#define _G_HAS_LABS 0
-#endif
-#ifdef CWDEBUG
-#include <libcw/sysd.h>
#endif
Index: src/libcwd/testsuite/libcwd.tst/sys.h
diff -u src/libcwd/testsuite/libcwd.tst/sys.h:1.3 src/libcwd/testsuite/libcwd.tst/sys.h:1.4
--- src/libcwd/testsuite/libcwd.tst/sys.h:1.3 Sun Dec 30 13:26:31 2001
+++ src/libcwd/testsuite/libcwd.tst/sys.h Thu Feb 7 20:03:47 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/sys.h,v 1.3 2001/12/30 21:26:31 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/testsuite/libcwd.tst/sys.h,v 1.4 2002/02/08 04:03:47 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -14,6 +14,11 @@
#ifndef TESTSUITE_SYS_H
#define TESTSUITE_SYS_H
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <libcw/sysd.h>
+
#include "../../config.h"
#ifdef HAVE__G_CONFIG_H
#include <_G_config.h>
@@ -24,7 +29,5 @@
#define _G_HAS_LABS 1
#endif
#endif // HAVE__G_CONFIG_H
-
-#include <libcw/sysd.h>
#endif // TESTSUITE_SYS_H
Index: src/libcwd/testsuite/module.cc
diff -u src/libcwd/testsuite/module.cc:1.3 src/libcwd/testsuite/module.cc:1.4
--- src/libcwd/testsuite/module.cc:1.3 Sat Dec 29 20:17:50 2001
+++ src/libcwd/testsuite/module.cc Thu Feb 7 20:03:47 2002
@@ -1,4 +1,5 @@
// A shared library
+#define _GNU_SOURCE
#include <libcw/sysd.h>
#include <libcw/debug.h>
Index: src/libcwd/threading.cc
diff -u src/libcwd/threading.cc:1.7 src/libcwd/threading.cc:1.8
--- src/libcwd/threading.cc:1.7 Wed Feb 6 16:38:38 2002
+++ src/libcwd/threading.cc Thu Feb 7 20:03:46 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.7 2002/02/07 00:38:38 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/threading.cc,v 1.8 2002/02/08 04:03:46 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -105,15 +105,16 @@
void TSD_st::cleanup_routine(void) throw()
{
- Dout(dc::always, "Thread " << tid << " is exiting.");
set_alloc_checking_off(*this);
for (int i = 0; i < LIBCWD_DO_MAX; ++i)
if (do_array[i])
{
- do_off_array[i] = 0; // Turn all debugging off! Now, hopefully, we won't use do_array[i] anymore.
debug_tsd_st* ptr = do_array[i];
- do_array[i] = NULL; // Be paranoid.
- delete ptr; // Free old objects.
+ if (ptr->tsd_keep)
+ continue;
+ do_off_array[i] = 0; // Turn all debugging off! Now, hopefully, we won't use do_array[i] anymore.
+ do_array[i] = NULL; // So we won't free it again.
+ delete ptr; // Free debug object TSD.
}
set_alloc_checking_on(*this);
}
Index: src/libcwd/wrapcnclpnts.cc
diff -u src/libcwd/wrapcnclpnts.cc:1.1 src/libcwd/wrapcnclpnts.cc:1.2
--- src/libcwd/wrapcnclpnts.cc:1.1 Sun Feb 3 19:50:36 2002
+++ src/libcwd/wrapcnclpnts.cc Thu Feb 7 20:03:46 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/wrapcnclpnts.cc,v 1.1 2002/02/04 03:50:36 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/wrapcnclpnts.cc,v 1.2 2002/02/08 04:03:46 libcw Exp $
//
// Copyright (C) 2002, by
//
@@ -13,7 +13,7 @@
#define _LARGEFILE64_SOURCE
-#include <libcw/sysd.h>
+#include "sys.h"
#include <libcw/debug_config.h> // Needed for DEBUGDEBUGTHREADS
#ifdef DEBUGDEBUGTHREADS
----------------------- End of diff -----------------------
|