[llvm] [llvm][Support] Make sys::fs::file_t into a seperate type (PR #160588)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 06:27:04 PST 2025
================
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// This file declares llvm::sys::fs::file_t type.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_FILE_H
+#define LLVM_SUPPORT_FILE_H
+
+#include "llvm/Support/Compiler.h"
+
+namespace llvm::sys::fs {
+
+/// This class wraps the platform specific file handle/descriptor type to
+/// provide an unified representation.
+struct file_t {
+#if defined(_WIN32)
+ // A Win32 HANDLE is a typedef of void*
+ using value_type = void *;
+#else
+ // A file descriptor on UNIX.
+ using value_type = int;
+#endif
+ value_type Value;
+
+ LLVM_ABI static const value_type Invalid;
----------------
aganea wrote:
It looks like the invalid value is -1 on both Unix and Windows platforms. Can we not make this a constexpr returning that?
https://github.com/llvm/llvm-project/pull/160588
More information about the llvm-commits
mailing list