[libc-commits] [libc] [libc] Implement tmpfile and corresponding tests (PR #213396)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Sat Aug 1 00:37:49 PDT 2026


================
@@ -0,0 +1,37 @@
+//===-- Implementation of tmpfile --------------------------------*- 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/tmpfile.h"
+#include "hdr/fcntl_macros.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/open.h"
+#include "hdr/types/FILE.h"
+
+#include "src/__support/File/linux/file.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+constexpr char TMPDIR[] = "/tmp";
+
+LLVM_LIBC_FUNCTION(::FILE *, tmpfile, (void)) {
+  auto fd = linux_syscalls::open(TMPDIR, O_RDWR | O_TMPFILE | O_EXCL, 0600);
----------------
kaladron wrote:

Please use P_tmpdir instead of defining a custom TMPDIR

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


More information about the libc-commits mailing list