summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-05-19 12:50:28 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-05-19 23:39:21 +0100
commit6f038efd93593da6e661b829d1bd3877e75550f1 (patch)
tree647d25b401c1b0ada6f122d6e9a440b82c8e786b /libstdc++-v3
parentlibstdc++: Only include <ext/atomicity.h> for COW string (diff)
downloadgcc-6f038efd93593da6e661b829d1bd3877e75550f1.tar.gz
gcc-6f038efd93593da6e661b829d1bd3877e75550f1.tar.bz2
gcc-6f038efd93593da6e661b829d1bd3877e75550f1.tar.xz
libstdc++: Avoid including <cstdint> for std::char_traits
We should prefer the __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ macros, if available, so that we don't need all of <cstdint> in every header that uses std::char_traits. libstdc++-v3/ChangeLog: * include/bits/char_traits.h: Only include <cstdint> when necessary. * include/std/stacktrace: Use __UINTPTR_TYPE__ instead of uintptr_t. * src/c++11/cow-stdexcept.cc: Include <stdint.h>. * src/c++17/floating_to_chars.cc: Likewise. * testsuite/20_util/assume_aligned/1.cc: Include <cstdint>. * testsuite/20_util/assume_aligned/3.cc: Likewise. * testsuite/20_util/shared_ptr/creation/array.cc: Likewise.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/bits/char_traits.h17
-rw-r--r--libstdc++-v3/include/std/stacktrace13
-rw-r--r--libstdc++-v3/src/c++11/cow-stdexcept.cc4
-rw-r--r--libstdc++-v3/src/c++17/floating_to_chars.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/assume_aligned/1.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/assume_aligned/3.cc1
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc1
7 files changed, 25 insertions, 14 deletions
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index cac1326d4b5..b856b1da320 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -40,6 +40,9 @@
40#include <cwchar> // For WEOF, wmemmove, wmemset, etc. 40#include <cwchar> // For WEOF, wmemmove, wmemset, etc.
41#if __cplusplus >= 201103L 41#if __cplusplus >= 201103L
42# include <type_traits> 42# include <type_traits>
43#if !defined __UINT_LEAST16_TYPE__ || !defined __UINT_LEAST32_TYPE__
44# include <cstdint>
45#endif
43#endif 46#endif
44#if __cplusplus >= 202002L 47#if __cplusplus >= 202002L
45# include <compare> 48# include <compare>
@@ -728,8 +731,6 @@ _GLIBCXX_END_NAMESPACE_VERSION
728 731
729#if __cplusplus >= 201103L 732#if __cplusplus >= 201103L
730 733
731#include <cstdint>
732
733namespace std _GLIBCXX_VISIBILITY(default) 734namespace std _GLIBCXX_VISIBILITY(default)
734{ 735{
735_GLIBCXX_BEGIN_NAMESPACE_VERSION 736_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -738,10 +739,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
738 struct char_traits<char16_t> 739 struct char_traits<char16_t>
739 { 740 {
740 typedef char16_t char_type; 741 typedef char16_t char_type;
741#ifdef _GLIBCXX_USE_C99_STDINT_TR1 742#ifdef __UINT_LEAST16_TYPE__
742 typedef uint_least16_t int_type;
743#elif defined __UINT_LEAST16_TYPE__
744 typedef __UINT_LEAST16_TYPE__ int_type; 743 typedef __UINT_LEAST16_TYPE__ int_type;
744#elif defined _GLIBCXX_USE_C99_STDINT_TR1
745 typedef uint_least16_t int_type;
745#else 746#else
746 typedef make_unsigned<char16_t>::type int_type; 747 typedef make_unsigned<char16_t>::type int_type;
747#endif 748#endif
@@ -859,10 +860,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
859 struct char_traits<char32_t> 860 struct char_traits<char32_t>
860 { 861 {
861 typedef char32_t char_type; 862 typedef char32_t char_type;
862#ifdef _GLIBCXX_USE_C99_STDINT_TR1 863#ifdef __UINT_LEAST32_TYPE__
863 typedef uint_least32_t int_type;
864#elif defined __UINT_LEAST32_TYPE__
865 typedef __UINT_LEAST32_TYPE__ int_type; 864 typedef __UINT_LEAST32_TYPE__ int_type;
865#elif defined _GLIBCXX_USE_C99_STDINT_TR1
866 typedef uint_least32_t int_type;
866#else 867#else
867 typedef make_unsigned<char32_t>::type int_type; 868 typedef make_unsigned<char32_t>::type int_type;
868#endif 869#endif
diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace
index 1efaf253abb..39472d7236a 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -52,20 +52,20 @@ __glibcxx_backtrace_create_state(const char*, int,
52 52
53int 53int
54__glibcxx_backtrace_simple(__glibcxx_backtrace_state*, int, 54__glibcxx_backtrace_simple(__glibcxx_backtrace_state*, int,
55 int (*) (void*, uintptr_t), 55 int (*) (void*, __UINTPTR_TYPE__),
56 void(*)(void*, const char*, int), 56 void(*)(void*, const char*, int),
57 void*); 57 void*);
58int 58int
59__glibcxx_backtrace_pcinfo(__glibcxx_backtrace_state*, uintptr_t, 59__glibcxx_backtrace_pcinfo(__glibcxx_backtrace_state*, __UINTPTR_TYPE__,
60 int (*)(void*, uintptr_t, 60 int (*)(void*, __UINTPTR_TYPE__,
61 const char*, int, const char*), 61 const char*, int, const char*),
62 void(*)(void*, const char*, int), 62 void(*)(void*, const char*, int),
63 void*); 63 void*);
64 64
65int 65int
66__glibcxx_backtrace_syminfo(__glibcxx_backtrace_state*, uintptr_t addr, 66__glibcxx_backtrace_syminfo(__glibcxx_backtrace_state*, __UINTPTR_TYPE__ addr,
67 void (*) (void*, uintptr_t, const char*, 67 void (*) (void*, __UINTPTR_TYPE__, const char*,
68 uintptr_t, uintptr_t), 68 __UINTPTR_TYPE__, __UINTPTR_TYPE__),
69 void(*)(void*, const char*, int), 69 void(*)(void*, const char*, int),
70 void*); 70 void*);
71} 71}
@@ -225,6 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
225 class basic_stacktrace 225 class basic_stacktrace
226 { 226 {
227 using _AllocTraits = allocator_traits<_Allocator>; 227 using _AllocTraits = allocator_traits<_Allocator>;
228 using uintptr_t = __UINTPTR_TYPE__;
228 229
229 public: 230 public:
230 using value_type = stacktrace_entry; 231 using value_type = stacktrace_entry;
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 5ccf2ca2d74..9e8787485eb 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -200,6 +200,10 @@ _GLIBCXX_END_NAMESPACE_VERSION
200#if _GLIBCXX_USE_WEAK_REF 200#if _GLIBCXX_USE_WEAK_REF
201#ifdef _GLIBCXX_USE_C99_STDINT_TR1 201#ifdef _GLIBCXX_USE_C99_STDINT_TR1
202 202
203#include <stdint.h>
204
205using std::size_t;
206
203extern "C" { 207extern "C" {
204 208
205#ifndef _GLIBCXX_MANGLE_SIZE_T 209#ifndef _GLIBCXX_MANGLE_SIZE_T
diff --git a/libstdc++-v3/src/c++17/floating_to_chars.cc b/libstdc++-v3/src/c++17/floating_to_chars.cc
index 4599d68a39c..b1c915e8a68 100644
--- a/libstdc++-v3/src/c++17/floating_to_chars.cc
+++ b/libstdc++-v3/src/c++17/floating_to_chars.cc
@@ -85,6 +85,8 @@ using F128_type = __float128;
85using F128_type = void; 85using F128_type = void;
86#endif 86#endif
87 87
88#include <stdint.h>
89
88namespace 90namespace
89{ 91{
90#if defined __SIZEOF_INT128__ 92#if defined __SIZEOF_INT128__
diff --git a/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc b/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc
index 59379582cf9..0a1390d18e4 100644
--- a/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc
+++ b/libstdc++-v3/testsuite/20_util/assume_aligned/1.cc
@@ -19,6 +19,7 @@
19// { dg-do run { target c++2a } } 19// { dg-do run { target c++2a } }
20 20
21#include <memory> 21#include <memory>
22#include <cstdint>
22#include <testsuite_hooks.h> 23#include <testsuite_hooks.h>
23 24
24void 25void
diff --git a/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc b/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc
index e1abf17e90a..93ee86c666e 100644
--- a/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc
+++ b/libstdc++-v3/testsuite/20_util/assume_aligned/3.cc
@@ -20,6 +20,7 @@
20// { dg-final { scan-assembler-not "undefined" } } 20// { dg-final { scan-assembler-not "undefined" } }
21 21
22#include <memory> 22#include <memory>
23#include <cstdint>
23 24
24int* ptr(); 25int* ptr();
25extern "C" void undefined(); 26extern "C" void undefined();
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc
index cd614c0ce0a..5c11a8b6285 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/array.cc
@@ -65,6 +65,7 @@ test02()
65} 65}
66 66
67#include <vector> 67#include <vector>
68#include <cstdint>
68 69
69std::vector<std::uintptr_t> addresses; 70std::vector<std::uintptr_t> addresses;
70 71