vkalintiris created this revision.
vkalintiris added reviewers: clayborg, ovyalov.
vkalintiris added a subscriber: lldb-commits.

pthread_{get,set}name_np() are nonstandard GNU extensions which are
included only when _GNU_SOURCE is defined under GLIBC.

http://reviews.llvm.org/D13019

Files:
  source/Host/linux/HostThreadLinux.cpp

Index: source/Host/linux/HostThreadLinux.cpp
===================================================================
--- source/Host/linux/HostThreadLinux.cpp
+++ source/Host/linux/HostThreadLinux.cpp
@@ -30,18 +30,28 @@
 void
 HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     ::pthread_setname_np(thread, name.data());
+#else
+    (void) thread;
+    (void) name;
+#endif
 }
 
 void
 HostThreadLinux::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> 
&name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     // Read /proc/$TID/comm file.
     lldb::DataBufferSP buf_sp = 
process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm");
     const char *comm_str = (const char *)buf_sp->GetBytes();
     const char *cr_str = ::strchr(comm_str, '\n');
     size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
 
     name.clear();
     name.append(comm_str, comm_str + length);
+#else
+    (void) thread;
+    (void) name;
+#endif
 }


Index: source/Host/linux/HostThreadLinux.cpp
===================================================================
--- source/Host/linux/HostThreadLinux.cpp
+++ source/Host/linux/HostThreadLinux.cpp
@@ -30,18 +30,28 @@
 void
 HostThreadLinux::SetName(lldb::thread_t thread, llvm::StringRef name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     ::pthread_setname_np(thread, name.data());
+#else
+    (void) thread;
+    (void) name;
+#endif
 }
 
 void
 HostThreadLinux::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name)
 {
+#if defined(__GLIBC__) && defined(_GNU_SOURCE)
     // Read /proc/$TID/comm file.
     lldb::DataBufferSP buf_sp = process_linux::ProcFileReader::ReadIntoDataBuffer(thread, "comm");
     const char *comm_str = (const char *)buf_sp->GetBytes();
     const char *cr_str = ::strchr(comm_str, '\n');
     size_t length = cr_str ? (cr_str - comm_str) : strlen(comm_str);
 
     name.clear();
     name.append(comm_str, comm_str + length);
+#else
+    (void) thread;
+    (void) name;
+#endif
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to