[libcxx-commits] [libcxx] r367316 - libcxx: Define __STDCPP_THREADS__ to 1, not to __cplusplus.
Nico Weber via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 30 07:32:48 PDT 2019
Author: nico
Date: Tue Jul 30 07:32:47 2019
New Revision: 367316
URL: http://llvm.org/viewvc/llvm-project?rev=367316&view=rev
Log:
libcxx: Define __STDCPP_THREADS__ to 1, not to __cplusplus.
[cpp.predefined]p2:
__STDCPP_THREADS__
Defined, and has the value integer literal 1, if and only if a program
can have more than one thread of execution .
Also define it only if it's not defined already, since it's supposed
to be defined by the compiler.
Also move it from thread to __config (which requires setting it only
if _LIBCPP_HAS_NO_THREADS is not defined).
Part of PR33230. The intent is to eventually make the compiler define
this instead.
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/thread
libcxx/trunk/test/std/thread/macro.pass.cpp
Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=367316&r1=367315&r2=367316&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Jul 30 07:32:47 2019
@@ -1097,6 +1097,14 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
_LIBCPP_HAS_NO_THREADS is defined.
#endif
+#if defined(__STDCPP_THREADS__) && defined(_LIBCPP_HAS_NO_THREADS)
+#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
+#define __STDCPP_THREADS__ 1
+#endif
+
// The glibc and Bionic implementation of pthreads implements
// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
// mutexes have no destroy mechanism.
Modified: libcxx/trunk/include/thread
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=367316&r1=367315&r2=367316&view=diff
==============================================================================
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Tue Jul 30 07:32:47 2019
@@ -14,8 +14,6 @@
thread synopsis
-#define __STDCPP_THREADS__ __cplusplus
-
namespace std
{
@@ -107,8 +105,6 @@ void sleep_for(const chrono::duration<Re
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-#define __STDCPP_THREADS__ __cplusplus
-
#ifdef _LIBCPP_HAS_NO_THREADS
#error <thread> is not supported on this single threaded system
#else // !_LIBCPP_HAS_NO_THREADS
Modified: libcxx/trunk/test/std/thread/macro.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/macro.pass.cpp?rev=367316&r1=367315&r2=367316&view=diff
==============================================================================
--- libcxx/trunk/test/std/thread/macro.pass.cpp (original)
+++ libcxx/trunk/test/std/thread/macro.pass.cpp Tue Jul 30 07:32:47 2019
@@ -10,7 +10,7 @@
// <thread>
-// #define __STDCPP_THREADS__ __cplusplus
+// #define __STDCPP_THREADS__ 1
#include <thread>
@@ -20,6 +20,8 @@ int main(int, char**)
{
#ifndef __STDCPP_THREADS__
#error __STDCPP_THREADS__ is not defined
+#elif __STDCPP_THREADS__ != 1
+#error __STDCPP_THREADS__ has the wrong value
#endif
return 0;
More information about the libcxx-commits
mailing list