Skip to content

Commit 82a5fd8

Browse files
committed
[libc++][NFC] Move __memory/aligned_alloc.h into src/
1 parent 8f7efa0 commit 82a5fd8

File tree

7 files changed

+11
-33
lines changed

7 files changed

+11
-33
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ set(files
567567
__mdspan/mdspan.h
568568
__memory/addressof.h
569569
__memory/align.h
570-
__memory/aligned_alloc.h
571570
__memory/allocate_at_least.h
572571
__memory/allocation_guard.h
573572
__memory/allocator.h

libcxx/include/__config

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -670,27 +670,6 @@ typedef __char32_t char32_t;
670670
# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
671671
# endif
672672

673-
// It is not yet possible to use aligned_alloc() on all Apple platforms since
674-
// 10.15 was the first version to ship an implementation of aligned_alloc().
675-
# if defined(__APPLE__)
676-
# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
677-
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
678-
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
679-
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
680-
(defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
681-
__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \
682-
(defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000)
683-
# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
684-
# else
685-
# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
686-
# endif
687-
# elif defined(__ANDROID__) && __ANDROID_API__ < 28
688-
// Android only provides aligned_alloc when targeting API 28 or higher.
689-
# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
690-
# else
691-
# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
692-
# endif
693-
694673
# if defined(__APPLE__) || defined(__FreeBSD__)
695674
# define _LIBCPP_WCTYPE_IS_MASK
696675
# endif

libcxx/include/module.modulemap.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,6 @@ module std [system] {
16341634
module memory {
16351635
module addressof { header "__memory/addressof.h" }
16361636
module align { header "__memory/align.h" }
1637-
module aligned_alloc { header "__memory/aligned_alloc.h" }
16381637
module allocate_at_least { header "__memory/allocate_at_least.h" }
16391638
module allocation_guard { header "__memory/allocation_guard.h" }
16401639
module allocator {

libcxx/include/__memory/aligned_alloc.h renamed to libcxx/src/include/aligned_alloc.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___MEMORY_ALIGNED_ALLOC_H
10-
#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H
9+
#ifndef _LIBCPP_SRC_ALIGNED_ALLOC_H
10+
#define _LIBCPP_SRC_ALIGNED_ALLOC_H
1111

1212
#include <__config>
1313
#include <cstdlib>
@@ -29,7 +29,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
3030
# if defined(_LIBCPP_MSVCRT_LIKE)
3131
return ::_aligned_malloc(__size, __alignment);
32-
# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC
32+
33+
// Android only provides aligned_alloc when targeting API 28 or higher.
34+
# elif !defined(__ANDROID__) || __ANDROID_API__ >= 28
3335
// aligned_alloc() requires that __size is a multiple of __alignment,
3436
// but for C++ [new.delete.general], only states "if the value of an
3537
// alignment argument passed to any of these functions is not a valid
@@ -60,4 +62,4 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {
6062

6163
_LIBCPP_END_NAMESPACE_STD
6264

63-
#endif // _LIBCPP___MEMORY_ALIGNED_ALLOC_H
65+
#endif // _LIBCPP_SRC_ALIGNED_ALLOC_H

libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// GCC doesn't support the aligned-allocation flags.
2222
// XFAIL: gcc
2323

24+
// ADDITIONAL_COMPILE_FLAGS: -I %{libcxx-dir}/src -Wno-macro-redefined
25+
2426
// RUN: %{build} -faligned-allocation -fsized-deallocation
2527
// RUN: %{run}
2628
// RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
@@ -36,10 +38,7 @@
3638

3739
#include "test_macros.h"
3840

39-
TEST_DIAGNOSTIC_PUSH
40-
TEST_CLANG_DIAGNOSTIC_IGNORED("-Wprivate-header")
41-
#include <__memory/aligned_alloc.h>
42-
TEST_DIAGNOSTIC_POP
41+
#include "include/aligned_alloc.h"
4342

4443
struct alloc_stats {
4544
alloc_stats() { reset(); }

libcxxabi/src/fallback_malloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#endif
1717
#endif
1818

19-
#include <__memory/aligned_alloc.h>
19+
#include "include/aligned_alloc.h" // from libc++
2020
#include <__assert>
2121
#include <stdlib.h> // for malloc, calloc, free
2222
#include <string.h> // for memset

libcxxabi/src/stdlib_new_delete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "__cxxabi_config.h"
1010
#include "abort_message.h"
11+
#include "include/aligned_alloc.h" // from libc++
1112
#include "include/overridable_function.h" // from libc++
12-
#include <__memory/aligned_alloc.h>
1313
#include <cstddef>
1414
#include <cstdlib>
1515
#include <new>

0 commit comments

Comments
 (0)