Skip to content

Commit a7fdda0

Browse files
[libc++] Add missed <cstdalign> and <stdalign.h> headers
1 parent cd7e179 commit a7fdda0

File tree

9 files changed

+148
-1
lines changed

9 files changed

+148
-1
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ set(files
909909
coroutine
910910
csetjmp
911911
csignal
912+
cstdalign
912913
cstdarg
913914
cstdbool
914915
cstddef
@@ -992,6 +993,7 @@ set(files
992993
span
993994
sstream
994995
stack
996+
stdalign.h
995997
stdatomic.h
996998
stdbool.h
997999
stddef.h

libcxx/include/cstdalign

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP_CSTDALIGN
11+
#define _LIBCPP_CSTDALIGN
12+
13+
/*
14+
cstdalign synopsis
15+
16+
Macros:
17+
18+
__alignas_is_defined
19+
__alignof_is_defined
20+
21+
*/
22+
23+
#include <__config>
24+
25+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26+
# pragma GCC system_header
27+
#endif
28+
29+
#undef __alignas_is_defined
30+
#define __alignas_is_defined 1
31+
32+
#undef __alignof_is_defined
33+
#define __alignof_is_defined 1
34+
35+
#endif // _LIBCPP_CSTDALIGN

libcxx/include/module.modulemap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,11 @@ module std [system] {
11031103
export *
11041104
}
11051105

1106+
module cstdalign {
1107+
header "cstdalign"
1108+
export *
1109+
}
1110+
11061111
module cstdarg {
11071112
header "cstdarg"
11081113
export *
@@ -2187,6 +2192,10 @@ module std_math_h [system] {
21872192
header "math.h"
21882193
export *
21892194
}
2195+
module std_stdalign_h [system] {
2196+
// <stdalign.h>'s __alignas_is_defined and __alignof_is_defined macros require textual inclusion.
2197+
textual header "stdalign.h"
2198+
}
21902199
module std_stdatomic_h [system] {
21912200
header "stdatomic.h"
21922201
export *

libcxx/include/stdalign.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP_STDALIGN_H
11+
#define _LIBCPP_STDALIGN_H
12+
13+
/*
14+
stdalign.h synopsis
15+
16+
Macros:
17+
18+
__alignas_is_defined
19+
__alignof_is_defined
20+
21+
*/
22+
23+
#include <__config>
24+
25+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26+
# pragma GCC system_header
27+
#endif
28+
29+
#if __has_include_next(<stdalign.h>)
30+
# include_next <stdalign.h>
31+
#endif
32+
33+
#ifdef __cplusplus
34+
# undef alignas
35+
# undef alignof
36+
# undef __alignas_is_defined
37+
# undef __alignof_is_defined
38+
# define __alignas_is_defined 1
39+
# define __alignof_is_defined 1
40+
#endif
41+
42+
#endif // _LIBCPP_STDALIGN_H

libcxx/test/libcxx/include_as_c.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#endif
3535
#include <math.h>
3636
#include <setjmp.h>
37+
#include <stdalign.h>
3738
#include <stdatomic.h>
3839
#include <stdbool.h>
3940
#include <stddef.h>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// test <stdalign.h>
10+
11+
#include <stdalign.h>
12+
13+
#ifndef __alignas_is_defined
14+
# error __alignas_is_defined not defined
15+
#endif
16+
17+
#ifndef __alignof_is_defined
18+
# error __alignof_is_defined not defined
19+
#endif
20+
21+
#ifdef alignas
22+
# error alignas should not be defined
23+
#endif
24+
25+
#ifdef alignof
26+
# error alignof should not be defined
27+
#endif
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// test <cstdalign>
10+
11+
#include <cstdalign>
12+
13+
#ifndef __alignas_is_defined
14+
# error __alignas_is_defined not defined
15+
#endif
16+
17+
#ifndef __alignof_is_defined
18+
# error __alignof_is_defined not defined
19+
#endif
20+
21+
#ifdef alignas
22+
# error alignas should not be defined
23+
#endif
24+
25+
#ifdef alignof
26+
# error alignof should not be defined
27+
#endif
28+
29+
int main(int, char**) { return 0; }

libcxx/utils/libcxx/header_information.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def is_modulemap_header(header):
202202
for header in toplevel_headers
203203
if not header.endswith(".h") and is_public_header(header)
204204
# These headers have been removed in C++20 so are never part of a module.
205-
and not header in ["ccomplex", "ciso646", "cstdbool", "ctgmath"]
205+
and not header in ["ccomplex", "ciso646", "cstdalign", "cstdbool", "ctgmath"]
206206
]
207207

208208
# The C headers used in the std and std.compat modules.

llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ if (current_toolchain == default_toolchain) {
981981
"coroutine",
982982
"csetjmp",
983983
"csignal",
984+
"cstdalign",
984985
"cstdarg",
985986
"cstdbool",
986987
"cstddef",
@@ -1064,6 +1065,7 @@ if (current_toolchain == default_toolchain) {
10641065
"span",
10651066
"sstream",
10661067
"stack",
1068+
"stdalign.h",
10671069
"stdatomic.h",
10681070
"stdbool.h",
10691071
"stddef.h",

0 commit comments

Comments
 (0)