Skip to content

Commit 5aed6d6

Browse files
Reland: [libc] Move off_t and stdio macros to proxy hdrs (#98384)
reland of #98215 Additionally adds proxy headers for FILE and the fopencookie types The arm32 build has been failing due to redefinitions of the off_t type. This patch fixes this by moving off_t to a proper proxy header. To do this, it also moves stdio macros to a proxy header to hopefully avoid including this proxy header alongside this public stdio.h.
1 parent 05b7b22 commit 5aed6d6

File tree

140 files changed

+415
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+415
-233
lines changed

libc/config/gpu/api.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ def FenvAPI: PublicAPI<"fenv.h"> {
5959
}
6060

6161
def StdIOAPI : PublicAPI<"stdio.h"> {
62-
let Macros = [
63-
SimpleMacroDef<"_IOFBF", "0">,
64-
SimpleMacroDef<"_IOLBF", "1">,
65-
SimpleMacroDef<"_IONBF", "2">,
66-
];
6762
let Types = [
6863
"FILE",
6964
"off_t",

libc/config/linux/api.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
7676
SimpleMacroDef<"stderr", "stderr">,
7777
SimpleMacroDef<"stdin", "stdin">,
7878
SimpleMacroDef<"stdout", "stdout">,
79-
SimpleMacroDef<"_IOFBF", "0">,
80-
SimpleMacroDef<"_IOLBF", "1">,
81-
SimpleMacroDef<"_IONBF", "2">,
8279
];
8380
let Types = [
8481
"FILE",

libc/hdr/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ add_proxy_header_library(
6969
libc.include.signal
7070
)
7171

72+
add_proxy_header_library(
73+
stdio_macros
74+
HDRS
75+
stdio_macros.h
76+
FULL_BUILD_DEPENDS
77+
libc.include.stdio
78+
libc.include.llvm-libc-macros.stdio_macros
79+
libc.include.llvm-libc-macros.file_seek_macros
80+
)
81+
7282
add_proxy_header_library(
7383
sys_epoll_macros
7484
HDRS

libc/hdr/stdio_macros.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Definition of macros from stdio.h --------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_STDIO_MACROS_H
10+
#define LLVM_LIBC_HDR_STDIO_MACROS_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-macros/file-seek-macros.h"
15+
#include "include/llvm-libc-macros/stdio-macros.h"
16+
17+
#else // Overlay mode
18+
19+
#include <stdio.h>
20+
21+
#endif // LLVM_LIBC_FULL_BUILD
22+
23+
#endif // LLVM_LIBC_HDR_STDIO_MACROS_H

libc/hdr/types/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,30 @@ add_proxy_header_library(
135135
libc.include.llvm-libc-types.struct_sigaction
136136
libc.include.signal
137137
)
138+
139+
add_proxy_header_library(
140+
FILE
141+
HDRS
142+
FILE.h
143+
FULL_BUILD_DEPENDS
144+
libc.include.llvm-libc-types.FILE
145+
libc.include.stdio
146+
)
147+
148+
add_proxy_header_library(
149+
off_t
150+
HDRS
151+
off_t.h
152+
FULL_BUILD_DEPENDS
153+
libc.include.llvm-libc-types.off_t
154+
libc.include.stdio
155+
)
156+
157+
add_proxy_header_library(
158+
cookie_io_functions_t
159+
HDRS
160+
cookie_io_functions_t.h
161+
FULL_BUILD_DEPENDS
162+
libc.include.llvm-libc-types.cookie_io_functions_t
163+
libc.include.stdio
164+
)

libc/hdr/types/FILE.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for FILE ----------------------------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_TYPES_FILE_H
10+
#define LLVM_LIBC_HDR_TYPES_FILE_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/FILE.h"
15+
16+
#else // Overlay mode
17+
18+
#include <stdio.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_FILE_H
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for cookie_io_functions_t -----------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_TYPES_COOKIE_IO_FUNCTIONS_T_H
10+
#define LLVM_LIBC_HDR_TYPES_COOKIE_IO_FUNCTIONS_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/cookie_io_functions_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <stdio.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_COOKIE_IO_FUNCTIONS_T_H

libc/hdr/types/off_t.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for off_t ---------------------------------------------------===//
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+
#ifndef LLVM_LIBC_HDR_TYPES_OFF_T_H
10+
#define LLVM_LIBC_HDR_TYPES_OFF_T_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/off_t.h"
15+
16+
#else // Overlay mode
17+
18+
#include <stdio.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_OFF_T_H

libc/include/llvm-libc-macros/stdio-macros.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515

1616
#define BUFSIZ 1024
1717

18+
#define _IONBF 2
19+
#define _IOLBF 1
20+
#define _IOFBF 0
21+
1822
#endif // LLVM_LIBC_MACROS_STDIO_MACROS_H

libc/newhdrgen/yaml/stdio.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
header: stdio.h
22
macros:
3-
- macro_name: _IONBF
4-
macro_value: 2
5-
- macro_name: _IOLBF
6-
macro_value: 1
7-
- macro_name: _IOFBF
8-
macro_value: 0
93
- macro_name: stdout
104
macro_value: stdout
115
- macro_name: stdin

0 commit comments

Comments
 (0)