Skip to content

Commit 1530034

Browse files
authored
[libc++] Remove unnecessary includes from <atomic> (#82880)
This reduces the include time of `<atomic>` from 135ms to 88ms.
1 parent 1a7776a commit 1530034

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

libcxx/include/__atomic/aliases.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <__type_traits/make_unsigned.h>
1919
#include <cstddef>
2020
#include <cstdint>
21-
#include <cstdlib>
2221

2322
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2423
# pragma GCC system_header

libcxx/include/__config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,11 @@ _LIBCPP_HARDENING_MODE_DEBUG
460460
# define __has_constexpr_builtin(x) 0
461461
# endif
462462

463+
// This checks wheter a Clang module is built
464+
# ifndef __building_module
465+
# define __building_module(...) 0
466+
# endif
467+
463468
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
464469
// the compiler and '1' otherwise.
465470
# ifndef __is_identifier

libcxx/include/__thread/support/pthread.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
// so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the
3131
// module with <math.h> and makes atomic_wide_counter.h invisible.
3232
// Include <math.h> here to work around that.
33-
#include <math.h>
33+
// This checks wheter a Clang module is built
34+
#if __building_module(std)
35+
# include <math.h>
36+
#endif
3437

3538
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
3639
# pragma GCC system_header

libcxx/include/atomic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ template <class T>
620620
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
621621
# include <cmath>
622622
# include <compare>
623+
# include <cstdlib>
623624
# include <cstring>
624625
# include <type_traits>
625626
#endif

libcxx/test/libcxx/transitive_includes/cxx23.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ array stdexcept
3030
array version
3131
atomic cstddef
3232
atomic cstdint
33-
atomic cstdlib
3433
atomic cstring
3534
atomic ctime
3635
atomic limits

libcxx/test/libcxx/transitive_includes/cxx26.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ array stdexcept
3030
array version
3131
atomic cstddef
3232
atomic cstdint
33-
atomic cstdlib
3433
atomic cstring
3534
atomic ctime
3635
atomic limits

0 commit comments

Comments
 (0)