[libc-commits] [libc] [libc] Add the implementation of the fdopen function (PR #94186)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed Jun 5 16:26:46 PDT 2024


================
@@ -0,0 +1,76 @@
+//===-- Implementation of fprintf -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdio/fdopen.h"
+
+#include "include/llvm-libc-macros/generic-error-number-macros.h"
+#include "include/llvm-libc-macros/linux/fcntl-macros.h"
+#include "src/__support/File/linux/file.h"
+#include "src/errno/libc_errno.h"
+#include "src/fcntl/fcntl.h"
----------------
michaelrj-google wrote:

generally we try to avoid calling the public versions of libc functions from one another. The preferred pattern if you need the same functionality in multiple places is to create a shared helper and call that helper (see `str_to_integer.h` as an example). For `fcntl` I'd recommend putting this in `__support/OSUtil/`, and for `fseek` you can just call `FILE->seek` to get the same functionality.

https://github.com/llvm/llvm-project/pull/94186


More information about the libc-commits mailing list