summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hornsey <fred@hornsey.us>2019-04-17 22:48:47 -0500
committerFred Hornsey <fred@hornsey.us>2019-04-17 22:48:47 -0500
commit756b05669ff1178967c840734ac42e2e7d2b8db2 (patch)
tree84ddcde112162c6cda859170930fa232a17eeae2
parent14531f70716a70092d65052e3d3334f52f05c519 (diff)
downloadATCD-756b05669ff1178967c840734ac42e2e7d2b8db2.tar.gz
Respond to PR comments
-rw-r--r--ACE/NEWS4
-rw-r--r--ACE/ace/OS_NS_Thread.cpp10
-rw-r--r--ACE/ace/OS_NS_Thread.h14
-rw-r--r--ACE/ace/OS_NS_Thread.inl4
4 files changed, 15 insertions, 17 deletions
diff --git a/ACE/NEWS b/ACE/NEWS
index 72380ca2be3..1fce8d2e2fd 100644
--- a/ACE/NEWS
+++ b/ACE/NEWS
@@ -1,8 +1,8 @@
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
+. On Linux, the ACE_Log_Msg format specifier `%t` is now replaced with the
+ system thread id provided by gettid(), instead of the much longer pthread id.
USER VISIBLE CHANGES BETWEEN ACE-6.5.4 and ACE-6.5.5
====================================================
diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp
index 315713a35a4..809b3657586 100644
--- a/ACE/ace/OS_NS_Thread.cpp
+++ b/ACE/ace/OS_NS_Thread.cpp
@@ -4807,17 +4807,15 @@ ACE_OS::unique_name (const void *object,
}
#endif
-#ifdef ACE_HAS_GETTID
pid_t
ACE_OS::thr_gettid ()
{
-# ifdef ACE_LINUX
+#if defined(ACE_LINUX) && defined(ACE_HAS_GETTID)
return syscall (SYS_gettid);
-# else
-# error "No implementation for thr_gettid(), please disable ACE_HAS_GETTID"
-# endif
-}
+#else
+ return static_cast<pid_t> (ACE_OS::thr_self ());
#endif
+}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h
index 061351c2dcd..d1cea0f96ac 100644
--- a/ACE/ace/OS_NS_Thread.h
+++ b/ACE/ace/OS_NS_Thread.h
@@ -1754,13 +1754,16 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t thr_id (char buffer[], size_t buffer_length);
-#ifdef ACE_HAS_GETTID
/**
- * Wrapper for pid_t gettid(). For systems that support it (only Linux as of
- * writing), get the system-wide thread id (TID) for the current thread.
+ * For systems that support it (Only Linux as of writing), this is wrapper
+ * for pid_t gettid().
*
- * These are similar to PIDs and, on x86 Linux at least, are much shorter
- * than the what is returned from thr_id(), which is represents a address.
+ * It returns the system-wide thread id (TID) for the current thread. These
+ * are similar to PIDs and, for x86 Linux at least, are much shorter than
+ * what is returned from thr_self(), which is an address.
+ *
+ * For older Linux (pre 2.4.11) and other systems that don't have gettid(),
+ * this returns thr_self().
*/
pid_t thr_gettid ();
@@ -1770,7 +1773,6 @@ namespace ACE_OS {
*/
ACE_NAMESPACE_INLINE_FUNCTION
ssize_t thr_gettid (char buffer[], size_t buffer_length);
-#endif
/// State is THR_CANCEL_ENABLE or THR_CANCEL_DISABLE
ACE_NAMESPACE_INLINE_FUNCTION
diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl
index 53866dde742..3a260b8474f 100644
--- a/ACE/ace/OS_NS_Thread.inl
+++ b/ACE/ace/OS_NS_Thread.inl
@@ -3178,20 +3178,18 @@ ACE_OS::thr_id (char buffer[], size_t buffer_length)
#else /* ACE_HAS_OPAQUE_PTHREAD_T */
return ACE_OS::snprintf (buffer,
buffer_length,
- "%lx",
+ "%lu",
(unsigned long) t_id);
#endif /* ACE_HAS_OPAQUE_PTHREAD_T */
#endif /* WIN32 */
}
-#ifdef ACE_HAS_GETTID
ACE_INLINE ssize_t
ACE_OS::thr_gettid (char buffer[], size_t buffer_length)
{
return ACE_OS::snprintf (buffer, buffer_length, "%u",
static_cast<unsigned> (ACE_OS::thr_gettid()));
}
-#endif
ACE_INLINE ACE_thread_t
ACE_OS::thr_self (void)