Skip to content

Commit d0931ec

Browse files
committed
remove unnecessary indirection
1 parent c632701 commit d0931ec

File tree

8 files changed

+24
-52
lines changed

8 files changed

+24
-52
lines changed

libc/src/__support/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
add_subdirectory(annex_k)
22
add_subdirectory(CPP)
33
add_subdirectory(macros)
4-
add_subdirectory(stdio)
54

65
add_header_library(
76
libc_errno

libc/src/__support/annex_k/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ add_header_library(
22
helper_macros
33
HDRS
44
helper_macros.h
5+
DEPENDS
6+
.libc_constraint_handler
7+
libc.src.__support.libc_errno
58
)
69

710
add_header_library(
@@ -10,5 +13,7 @@ add_header_library(
1013
libc_constraint_handler.h
1114
DEPENDS
1215
.abort_handler_s
13-
libc.hdr.types.errno_t
16+
libc.hdr.types.constraint_handler_t
17+
libc.src.__support.common
18+
libc.src.stdlib.abort_handler_s
1419
)

libc/src/__support/annex_k/helper_macros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_HELPER_MACROS_H
1111

1212
#include "libc_constraint_handler.h"
13+
#include "src/__support/libc_errno.h"
1314

1415
#define _CONSTRAINT_VIOLATION(msg, error_code, ret_code) \
1516
{ \

libc/src/__support/stdio/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

libc/src/__support/stdio/fopen.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

libc/src/stdio/generic/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ add_generic_entrypoint_object(
162162
HDRS
163163
../fopen.h
164164
DEPENDS
165-
libc.src.__support.stdio.fopen
165+
libc.hdr.types.FILE
166+
libc.src.__support.File.file
167+
libc.src.__support.File.platform_file
166168
)
167169

168170
add_generic_entrypoint_object(
@@ -172,7 +174,7 @@ add_generic_entrypoint_object(
172174
HDRS
173175
../fopen_s.h
174176
DEPENDS
175-
libc.src.__support.stdio.fopen
177+
libc.src.stdio.fopen
176178
libc.src.__support.macros.config
177179
libc.src.__support.annex_k.helper_macros
178180
)

libc/src/stdio/generic/fopen.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/stdio/fopen.h"
10+
#include "src/__support/File/file.h"
11+
12+
#include "hdr/types/FILE.h"
13+
#include "src/__support/libc_errno.h"
1014
#include "src/__support/macros/config.h"
11-
#include "src/__support/stdio/fopen.h"
1215

1316
namespace LIBC_NAMESPACE_DECL {
1417

1518
LLVM_LIBC_FUNCTION(::FILE *, fopen,
1619
(const char *__restrict name, const char *__restrict mode)) {
17-
return stdio_internal::fopen(name, mode);
20+
auto result = LIBC_NAMESPACE::openfile(name, mode);
21+
if (!result.has_value()) {
22+
libc_errno = result.error();
23+
return nullptr;
24+
}
25+
return reinterpret_cast<::FILE *>(result.value());
1826
}
1927

2028
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/generic/fopen_s.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "src/stdio/fopen_s.h"
1010
#include "src/__support/annex_k/helper_macros.h"
1111
#include "src/__support/macros/config.h"
12-
#include "src/__support/stdio/fopen.h"
12+
#include "src/stdio/fopen.h"
1313

1414
namespace LIBC_NAMESPACE_DECL {
1515

@@ -24,13 +24,13 @@ LLVM_LIBC_FUNCTION(errno_t, fopen_s,
2424
FILE *ret = nullptr;
2525

2626
if (mode[0] == 'u') {
27-
ret = stdio_internal::fopen(filename, mode + 1);
27+
ret = fopen(filename, mode + 1);
2828
if (!ret) {
2929
*streamptr = nullptr;
3030
return -1;
3131
}
3232
} else {
33-
ret = stdio_internal::fopen(filename, mode);
33+
ret = fopen(filename, mode);
3434
if (!ret) {
3535
*streamptr = nullptr;
3636
return -1;

0 commit comments

Comments
 (0)