@@ -120,8 +120,6 @@ namespace llvm {
120120namespace sys {
121121namespace fs {
122122
123- const file_t kInvalidFile = -1 ;
124-
125123#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
126124 defined (__FreeBSD_kernel__) || defined(__linux__) || \
127125 defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || \
@@ -768,6 +766,10 @@ std::error_code status(const Twine &Path, file_status &Result, bool Follow) {
768766 return fillStatus (StatRet, Status, Result);
769767}
770768
769+ std::error_code status (file_t F, file_status &Result) {
770+ return status (F.get (), Result);
771+ }
772+
771773std::error_code status (int FD, file_status &Result) {
772774 struct stat Status;
773775 int StatRet = ::fstat (FD, &Status);
@@ -832,7 +834,7 @@ std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime,
832834#endif
833835}
834836
835- std::error_code mapped_file_region::init (int FD, uint64_t Offset,
837+ std::error_code mapped_file_region::init (file_t FD, uint64_t Offset,
836838 mapmode Mode) {
837839 assert (Size != 0 );
838840
@@ -861,13 +863,13 @@ std::error_code mapped_file_region::init(int FD, uint64_t Offset,
861863 }
862864#endif // #if defined (__APPLE__)
863865
864- Mapping = ::mmap (nullptr , Size, prot, flags, FD, Offset);
866+ Mapping = ::mmap (nullptr , Size, prot, flags, FD. get () , Offset);
865867 if (Mapping == MAP_FAILED)
866868 return errnoAsErrorCode ();
867869 return std::error_code ();
868870}
869871
870- mapped_file_region::mapped_file_region (int fd, mapmode mode, size_t length,
872+ mapped_file_region::mapped_file_region (file_t fd, mapmode mode, size_t length,
871873 uint64_t offset, std::error_code &ec)
872874 : Size (length), Mode (mode) {
873875 (void )Mode;
@@ -1128,9 +1130,9 @@ std::error_code openFile(const Twine &Name, int &ResultFD,
11281130 return std::error_code ();
11291131}
11301132
1131- Expected<int > openNativeFile (const Twine &Name, CreationDisposition Disp,
1132- FileAccess Access, OpenFlags Flags,
1133- unsigned Mode) {
1133+ Expected<file_t > openNativeFile (const Twine &Name, CreationDisposition Disp,
1134+ FileAccess Access, OpenFlags Flags,
1135+ unsigned Mode) {
11341136
11351137 int FD;
11361138 std::error_code EC = openFile (Name, FD, Disp, Access, Flags, Mode);
@@ -1183,7 +1185,7 @@ std::error_code openFileForRead(const Twine &Name, int &ResultFD,
11831185
11841186Expected<file_t > openNativeFileForRead (const Twine &Name, OpenFlags Flags,
11851187 SmallVectorImpl<char > *RealPath) {
1186- file_t ResultFD;
1188+ int ResultFD;
11871189 std::error_code EC = openFileForRead (Name, ResultFD, Flags, RealPath);
11881190 if (EC)
11891191 return errorCodeToError (EC);
@@ -1200,7 +1202,7 @@ Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) {
12001202#else
12011203 size_t Size = Buf.size ();
12021204#endif
1203- ssize_t NumRead = sys::RetryAfterSignal (-1 , ::read, FD, Buf.data (), Size);
1205+ ssize_t NumRead = sys::RetryAfterSignal (-1 , ::read, FD. get () , Buf.data (), Size);
12041206 if (NumRead == -1 )
12051207 return errorCodeToError (errnoAsErrorCode ());
12061208// The underlying operation on these platforms allow opening directories
@@ -1224,7 +1226,7 @@ Expected<size_t> readNativeFileSlice(file_t FD, MutableArrayRef<char> Buf,
12241226#endif
12251227#ifdef HAVE_PREAD
12261228 ssize_t NumRead =
1227- sys::RetryAfterSignal (-1 , ::pread, FD, Buf.data (), Size, Offset);
1229+ sys::RetryAfterSignal (-1 , ::pread, FD. get () , Buf.data (), Size, Offset);
12281230#else
12291231 if (lseek (FD, Offset, SEEK_SET) == -1 )
12301232 return errorCodeToError (errnoAsErrorCode ());
@@ -1297,8 +1299,8 @@ std::error_code unlockFile(int FD) {
12971299
12981300std::error_code closeFile (file_t &F) {
12991301 file_t TmpF = F;
1300- F = kInvalidFile ;
1301- return Process::SafelyCloseFileDescriptor (TmpF);
1302+ F = file_t ::Invalid ;
1303+ return Process::SafelyCloseFileDescriptor (TmpF. get () );
13021304}
13031305
13041306template <typename T>
0 commit comments