From 756b05669ff1178967c840734ac42e2e7d2b8db2 Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Wed, 17 Apr 2019 22:48:47 -0500 Subject: Respond to PR comments --- ACE/NEWS | 4 ++-- ACE/ace/OS_NS_Thread.cpp | 10 ++++------ ACE/ace/OS_NS_Thread.h | 14 ++++++++------ ACE/ace/OS_NS_Thread.inl | 4 +--- 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 (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 (ACE_OS::thr_gettid())); } -#endif ACE_INLINE ACE_thread_t ACE_OS::thr_self (void) -- cgit v1.2.1