--- a/ipc/chromium/src/base/platform_thread_posix.cc
+++ b/ipc/chromium/src/base/platform_thread_posix.cc
@@ -14,7 +14,7 @@
 #elif defined(OS_LINUX)
 #include <sys/syscall.h>
 #include <sys/prctl.h>
-#elif defined(OS_FREEBSD)
+#elif defined(OS_FREEBSD) && !defined(__GLIBC__)
 #include <sys/param.h>
 #include <sys/thr.h>
 #endif
@@ -23,7 +23,7 @@
 #include <unistd.h>
 #endif
 
-#if defined(OS_BSD) && !defined(OS_NETBSD)
+#if defined(OS_BSD) && !defined(OS_NETBSD) && !defined(__GLIBC__)
 #include <pthread_np.h>
 #endif
 
@@ -48,6 +48,10 @@
   mach_port_t port = mach_thread_self();
   mach_port_deallocate(mach_task_self(), port);
   return port;
+#elif defined(OS_LINUX)
+  return syscall(__NR_gettid);
+#elif defined(OS_OPENBSD) || defined(__GLIBC__)
+  return (intptr_t) (pthread_self());
 #elif defined(OS_NETBSD)
   return _lwp_self();
 #elif defined(OS_DRAGONFLY)
@@ -60,10 +64,6 @@
     thr_self(&lwpid);
     return lwpid;
 #  endif
-#elif defined(OS_OPENBSD)
-  return (intptr_t) (pthread_self());
-#elif defined(OS_LINUX)
-  return syscall(__NR_gettid);
 #endif
 }
 
@@ -104,12 +104,13 @@
   // Note that glibc also has a 'pthread_setname_np' api, but it may not be
   // available everywhere and it's only benefit over using prctl directly is
   // that it can set the name of threads other than the current thread.
-#if defined(OS_BSD) && !defined(OS_NETBSD)
-  pthread_set_name_np(pthread_self(), name);
+#if defined(OS_LINUX)
+  prctl(PR_SET_NAME, reinterpret_cast<uintptr_t>(name), 0, 0, 0); 
 #elif defined(OS_NETBSD)
   pthread_setname_np(pthread_self(), "%s", (void *)name);
+#elif defined(OS_BSD) && !defined(__GLIBC__)
+  pthread_set_name_np(pthread_self(), name);
 #else
-  prctl(PR_SET_NAME, reinterpret_cast<uintptr_t>(name), 0, 0, 0); 
 #endif
 }
 #endif // !OS_MACOSX