Skip to content

Commit

Permalink
[libc++] Remove unnecessary includes from <atomic> (llvm#82880)
Browse files Browse the repository at this point in the history
This reduces the include time of `<atomic>` from 135ms to 88ms.
  • Loading branch information
philnik777 authored Feb 28, 2024
1 parent 1a7776a commit 1530034
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion libcxx/include/__atomic/aliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <__type_traits/make_unsigned.h>
#include <cstddef>
#include <cstdint>
#include <cstdlib>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down
5 changes: 5 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ _LIBCPP_HARDENING_MODE_DEBUG
# define __has_constexpr_builtin(x) 0
# endif

// This checks wheter a Clang module is built
# ifndef __building_module
# define __building_module(...) 0
# endif

// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
# ifndef __is_identifier
Expand Down
5 changes: 4 additions & 1 deletion libcxx/include/__thread/support/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
// so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the
// module with <math.h> and makes atomic_wide_counter.h invisible.
// Include <math.h> here to work around that.
#include <math.h>
// This checks wheter a Clang module is built
#if __building_module(std)
# include <math.h>
#endif

#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ template <class T>
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cmath>
# include <compare>
# include <cstdlib>
# include <cstring>
# include <type_traits>
#endif
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx23.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ array stdexcept
array version
atomic cstddef
atomic cstdint
atomic cstdlib
atomic cstring
atomic ctime
atomic limits
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx26.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ array stdexcept
array version
atomic cstddef
atomic cstdint
atomic cstdlib
atomic cstring
atomic ctime
atomic limits
Expand Down

0 comments on commit 1530034

Please sign in to comment.