summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hornsey <fred@hornsey.us>2019-04-11 23:43:38 -0500
committerFred Hornsey <fred@hornsey.us>2019-04-11 23:43:38 -0500
commit14531f70716a70092d65052e3d3334f52f05c519 (patch)
tree5d567b9c2869e9abd8ace7f1fd8663b8588f50bc
parente06e966e10b4edb27f9813ddffc34529abd4bb91 (diff)
downloadATCD-14531f70716a70092d65052e3d3334f52f05c519.tar.gz
Log_Msg: Shorten %t Output for non-Windows systems
On Linux systems that supports it, use gettid() to get a much smaller number for the thread id. This is guaranteed to be unique system-wide thread id where the previous thread id, at least for pthreads, is not. On everywhere else except Windows, since might to be an address like it was on Linux, so use hex output just to make it shorter.
-rw-r--r--ACE/NEWS3
-rw-r--r--ACE/ace/Log_Msg.cpp17
2 files changed, 16 insertions, 4 deletions
diff --git a/ACE/NEWS b/ACE/NEWS
index dd5a0c3fd96..72380ca2be3 100644
--- a/ACE/NEWS
+++ b/ACE/NEWS
@@ -1,6 +1,9 @@
USER VISIBLE CHANGES BETWEEN ACE-6.5.5 and ACE-6.5.6
====================================================
+. Shorten output from `%t` (current thread id) for ACE_Log_Msg on non-Windows
+ systems
+
USER VISIBLE CHANGES BETWEEN ACE-6.5.4 and ACE-6.5.5
====================================================
diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp
index 190c6d7815d..a0ac80cce71 100644
--- a/ACE/ace/Log_Msg.cpp
+++ b/ACE/ace/Log_Msg.cpp
@@ -1791,16 +1791,25 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
ACE_OS::sprintf (bp,
format,
static_cast <unsigned> (ACE_Thread::self ()));
-#elif defined ACE_USES_WCHAR
+#else
+
+# ifdef ACE_HAS_GETTID
+# define ACE_LOG_MSG_GET_THREAD_ID ACE_OS::thr_gettid
+# else
+# define ACE_LOG_MSG_GET_THREAD_ID ACE_OS::thr_id
+# endif
+
+# if defined ACE_USES_WCHAR
{
char tid_buf[32] = {};
- ACE_OS::thr_id (tid_buf, sizeof tid_buf);
+ ACE_LOG_MSG_GET_THREAD_ID (tid_buf, sizeof tid_buf);
this_len = ACE_OS::strlen (tid_buf);
ACE_OS::strncpy (bp, ACE_TEXT_CHAR_TO_TCHAR (tid_buf),
bspace);
}
-#else
- this_len = ACE_OS::thr_id (bp, bspace);
+# else
+ this_len = ACE_LOG_MSG_GET_THREAD_ID (bp, bspace);
+# endif /* ACE_USES_WCHAR */
#endif /* ACE_WIN32 */
ACE_UPDATE_COUNT (bspace, this_len);
break;