diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2022-03-27 21:16:15 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2022-03-28 00:16:02 +0000 |
commit | c1a24b9dbeade11bfeedc91996672582f6ea32f2 (patch) | |
tree | 2293bfed1c12b121741db108ffbf0456ee25adc9 | |
parent | 8bcffb86c7d5cff1474b14449c01388cac8cbc3d (diff) | |
download | src-c1a24b9dbeade11bfeedc91996672582f6ea32f2.tar.gz src-c1a24b9dbeade11bfeedc91996672582f6ea32f2.zip |
sys/stdatomic.h: be nicer to c++
Use of stdatomic.h is undefined in C++, even the C++ 2020 standard does not
list stdatomic.h as a C library header supported by the language. More,
there are some subtle differences between the <atomic> C++ header, and
C11+ stdatomic.h provided features.
Nonetheless, it is a quality of the implementation aspect, so let mis-users
mis-use stdatomic.h as they want, by making a compat shim for _Bool.
PR: 262683
Reported by: yuri
Reviewed by: dim, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34686
-rw-r--r-- | sys/sys/stdatomic.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index 4dc6d680f934..f4fd1c6ae60e 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -163,6 +163,11 @@ atomic_signal_fence(memory_order __order __unused) #endif } +#if defined(__cplusplus) && !defined(_Bool) +#define _Bool bool +#define __bool_locally_defined +#endif + /* * 7.17.5 Lock-free property. */ @@ -406,4 +411,9 @@ atomic_flag_clear(volatile atomic_flag *__object) } #endif /* !_KERNEL */ +#ifdef __bool_locally_defined +#undef _Bool +#undef __bool_locally_defined +#endif + #endif /* !_STDATOMIC_H_ */ |