llvm.org GIT mirror llvm / a99ff35
Remove unused member and simplify. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224309 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
2 changed file(s) with 3 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
639639 uint64_t Size;
640640 void *Mapping;
641641 #ifdef LLVM_ON_WIN32
642 int FileDescriptor;
643642 void *FileHandle;
644643 void *FileMappingHandle;
645644 #endif
459459
460460 std::error_code mapped_file_region::init(int FD, uint64_t Offset,
461461 mapmode Mode) {
462 FileDescriptor = FD;
463462 // Make sure that the requested size fits within SIZE_T.
464 if (Size > std::numeric_limits::max()) {
465 if (FileDescriptor) {
466 } else
467 ::CloseHandle(FileHandle);
463 if (Size > std::numeric_limits::max())
468464 return make_error_code(errc::invalid_argument);
469 }
470465
471466 DWORD flprotect;
472467 switch (Mode) {
482477 0);
483478 if (FileMappingHandle == NULL) {
484479 std::error_code ec = windows_error(GetLastError());
485 if (FileDescriptor) {
486 } else
487 ::CloseHandle(FileHandle);
488480 return ec;
489481 }
490482
502494 if (Mapping == NULL) {
503495 std::error_code ec = windows_error(GetLastError());
504496 ::CloseHandle(FileMappingHandle);
505 if (FileDescriptor) {
506 } else
507 ::CloseHandle(FileHandle);
508497 return ec;
509498 }
510499
515504 std::error_code ec = windows_error(GetLastError());
516505 ::UnmapViewOfFile(Mapping);
517506 ::CloseHandle(FileMappingHandle);
518 if (FileDescriptor) {
519 } else
520 ::CloseHandle(FileHandle);
521507 return ec;
522508 }
523509 Size = mbi.RegionSize;
526512 // Close all the handles except for the view. It will keep the other handles
527513 // alive.
528514 ::CloseHandle(FileMappingHandle);
529 if (FileDescriptor) {
530 } else
531 ::CloseHandle(FileHandle);
532515 return std::error_code();
533516 }
534517
535518 mapped_file_region::mapped_file_region(int fd, mapmode mode, uint64_t length,
536519 uint64_t offset, std::error_code &ec)
537 : Size(length), Mapping(), FileDescriptor(fd),
520 : Size(length), Mapping(),
538521 FileHandle(INVALID_HANDLE_VALUE), FileMappingHandle() {
539522 FileHandle = reinterpret_cast(_get_osfhandle(fd));
540523 if (FileHandle == INVALID_HANDLE_VALUE) {
541 FileDescriptor = 0;
542524 ec = make_error_code(errc::bad_file_descriptor);
543525 return;
544526 }
545527
546 ec = init(FileDescriptor, offset, mode);
528 ec = init(fd, offset, mode);
547529 if (ec) {
548530 Mapping = FileMappingHandle = 0;
549531 FileHandle = INVALID_HANDLE_VALUE;
550 FileDescriptor = 0;
551532 }
552533 }
553534