[libc-commits] [libc] [libc] Implement freopen (PR #207837)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Wed Jul 8 07:50:47 PDT 2026
================
@@ -7,31 +7,41 @@
//===----------------------------------------------------------------------===//
///
/// \file
-/// Implementation of the POSIX fdopendir function.
+/// Implementation of freopen.
///
//===----------------------------------------------------------------------===//
-#include "fdopendir.h"
+#include "src/stdio/freopen.h"
+#include "src/__support/File/file.h"
-#include "src/__support/File/dir.h"
+#include "hdr/types/FILE.h"
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(DIR *, fdopendir, (int fd)) {
- int check = platform_check_dir(fd);
- if (check != 0) {
- libc_errno = check;
+LLVM_LIBC_FUNCTION(::FILE *, freopen,
+ (const char *__restrict filename,
+ const char *__restrict mode, ::FILE *__restrict stream)) {
+ if (stream == nullptr) {
----------------
kaladron wrote:
POSIX mentions filename (pathname) as a null pointer, but not stream. Should this be a LIBC_CRASH_ON_NULLPTR?
https://github.com/llvm/llvm-project/pull/207837
More information about the libc-commits
mailing list