From: Christopher Dykes Date: Fri, 14 Apr 2017 20:53:52 +0000 (-0700) Subject: Add FOLLY_HAVE_PTRHEAD X-Git-Tag: v2017.04.17.00~8 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1244eb2496071f4438ca1dd3d95c56e09e99cd43;p=folly.git Add FOLLY_HAVE_PTRHEAD Summary: Folly is gaining support for compiling without PThread support on Windows, but we need a way to know that at compile-time for certain APIs. This also includes changes to guard the only API outside of portability/PThread.h that needs to be guarded on the existence of PThread. Reviewed By: yfeldblum Differential Revision: D4889526 fbshipit-source-id: 21175ad90f60a47718c7e2775e3b429b2aad62e2 --- diff --git a/folly/ThreadName.h b/folly/ThreadName.h index 0a5e5998..ad773033 100644 --- a/folly/ThreadName.h +++ b/folly/ThreadName.h @@ -21,6 +21,7 @@ #include #include +#include #include namespace folly { @@ -43,9 +44,11 @@ namespace folly { template inline bool setThreadName(T /* id */, StringPiece /* name */) { static_assert( +#if FOLLY_HAVE_PTHREAD std::is_same::value || - std::is_same::value || - std::is_same::value, +#endif + std::is_same::value || + std::is_same::value, "type must be pthread_t, std::thread::id or " "std::thread::native_handle_type"); return false; @@ -70,6 +73,7 @@ inline bool setThreadName(pthread_t id, StringPiece name) { } #endif +#if FOLLY_HAVE_PTHREAD template < typename = folly::_t::value>>> @@ -88,5 +92,10 @@ inline bool setThreadName(std::thread::id id, StringPiece name) { inline bool setThreadName(StringPiece name) { return setThreadName(pthread_self(), name); } +#else +inline bool setThreadName(StringPiece name) { + return false; +} +#endif } diff --git a/folly/configure.ac b/folly/configure.ac index 22e2f9fa..4e951b74 100644 --- a/folly/configure.ac +++ b/folly/configure.ac @@ -326,6 +326,8 @@ if test "$folly_cv_lib_liblinux_vdso" = yes; then AC_DEFINE([HAVE_LINUX_VDSO], [1], [Define to 1 if liblinux-vdso is available]) fi +AC_DEFINE([HAVE_PTHREAD], [1], [Define to 1 if pthread is avaliable]) + AC_CACHE_CHECK( [for usable std::is_trivially_copyable], [folly_cv_decl_std_is_trivially_copyable],