diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-11-13 23:23:33 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-11-13 23:23:33 +0100 |
commit | 1d9a8675d379f02f5e39639f469ae8dfcf33fea9 (patch) | |
tree | e3c9446577fa53aa93cc9c390399227f11e9deed /gcc/c-family/c-cppbuiltin.c | |
parent | ccd56db89806a5f6eb3be99fc3b4fe364cf35e98 (diff) | |
download | gcc-1d9a8675d379f02f5e39639f469ae8dfcf33fea9.zip gcc-1d9a8675d379f02f5e39639f469ae8dfcf33fea9.tar.gz gcc-1d9a8675d379f02f5e39639f469ae8dfcf33fea9.tar.bz2 |
c++: Predefine __STDCPP_THREADS__ in the compiler if thread model is not single [PR63287]
The following patch predefines __STDCPP_THREADS__ macro to 1 if c++11 or
later and thread model (e.g. printed by gcc -v) is not single.
There are two targets not handled by this patch, those that define
THREAD_MODEL_SPEC. In one case - QNX - it looks just like a mistake
to me, instead of setting thread_model=posix in config.gcc it uses
THREAD_MODEL_SPEC macro to set it unconditionally to posix.
The other is hpux10, which uses -threads option to decide if threads
are enabled or not, but that option isn't really passed to the compiler.
I think that is something that really should be solved in config/pa/
instead, e.g. in the config/xxx/xxx-c.c targets usually set their own
predefined macros and it could handle this, and either pass the option
also to the compiler, or say predefine __STDCPP_THREADS__ if _DCE_THREADS
macro is defined already (or -D_DCE_THREADS found on the command line),
or whatever else.
2020-11-13 Jakub Jelinek <jakub@redhat.com>
PR c++/63287
* c-cppbuiltin.c: Include configargs.h.
(c_cpp_builtins): For C++11 and later if THREAD_MODEL_SPEC is not
defined, predefine __STDCPP_THREADS__ to 1 unless thread_model is
"single".
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 7229c59..8856a97 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "debug.h" /* For dwarf2out_do_cfi_asm. */ #include "common/common-target.h" #include "cppbuiltin.h" +#include "configargs.h" #ifndef TARGET_OS_CPP_BUILTINS # define TARGET_OS_CPP_BUILTINS() @@ -1034,6 +1035,12 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_threadsafe_static_init=200806L"); if (flag_char8_t) cpp_define (pfile, "__cpp_char8_t=201811L"); +#ifndef THREAD_MODEL_SPEC + /* Targets that define THREAD_MODEL_SPEC need to define + __STDCPP_THREADS__ in their config/XXX/XXX-c.c themselves. */ + if (cxx_dialect >= cxx11 && strcmp (thread_model, "single") != 0) + cpp_define (pfile, "__STDCPP_THREADS__=1"); +#endif } /* Note that we define this for C as well, so that we know if __attribute__((cleanup)) will interface with EH. */ |