llvm.org GIT mirror llvm / c2fe96c
delete dead code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209938 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
3 changed file(s) with 0 addition(s) and 64 deletion(s). Raw diff Collapse all Expand all
721721 static int alignment();
722722 };
723723
724 /// @brief Memory maps the contents of a file
725 ///
726 /// @param path Path to file to map.
727 /// @param file_offset Byte offset in file where mapping should begin.
728 /// @param size Byte length of range of the file to map.
729 /// @param map_writable If true, the file will be mapped in r/w such
730 /// that changes to the mapped buffer will be flushed back
731 /// to the file. If false, the file will be mapped read-only
732 /// and the buffer will be read-only.
733 /// @param result Set to the start address of the mapped buffer.
734 /// @returns errc::success if result has been successfully set, otherwise a
735 /// platform specific error_code.
736 error_code map_file_pages(const Twine &path, off_t file_offset, size_t size,
737 bool map_writable, void *&result);
738
739
740 /// @brief Memory unmaps the contents of a file
741 ///
742 /// @param base Pointer to the start of the buffer.
743 /// @param size Byte length of the range to unmmap.
744 /// @returns errc::success if result has been successfully set, otherwise a
745 /// platform specific error_code.
746 error_code unmap_file_pages(void *base, size_t size);
747
748724 /// Return the path to the main executable, given the value of argv[0] from
749725 /// program startup and the address of main itself. In extremis, this function
750726 /// may fail and return an empty path.
652652 return error_code::success();
653653 }
654654
655 error_code map_file_pages(const Twine &path, off_t file_offset, size_t size,
656 bool map_writable, void *&result) {
657 SmallString<128> path_storage;
658 StringRef name = path.toNullTerminatedStringRef(path_storage);
659 int oflags = map_writable ? O_RDWR : O_RDONLY;
660 int ofd = ::open(name.begin(), oflags);
661 if ( ofd == -1 )
662 return error_code(errno, system_category());
663 AutoFD fd(ofd);
664 int flags = map_writable ? MAP_SHARED : MAP_PRIVATE;
665 int prot = map_writable ? (PROT_READ|PROT_WRITE) : PROT_READ;
666 #ifdef MAP_FILE
667 flags |= MAP_FILE;
668 #endif
669 result = ::mmap(nullptr, size, prot, flags, fd, file_offset);
670 if (result == MAP_FAILED) {
671 return error_code(errno, system_category());
672 }
673
674 return error_code::success();
675 }
676
677 error_code unmap_file_pages(void *base, size_t size) {
678 if ( ::munmap(base, size) == -1 )
679 return error_code(errno, system_category());
680
681 return error_code::success();
682 }
683
684655 error_code openFileForRead(const Twine &Name, int &ResultFD) {
685656 SmallString<128> Storage;
686657 StringRef P = Name.toNullTerminatedStringRef(Storage);
790790 return error_code::success();
791791 }
792792
793 error_code map_file_pages(const Twine &path, off_t file_offset, size_t size,
794 bool map_writable, void *&result) {
795 assert(0 && "NOT IMPLEMENTED");
796 return windows_error::invalid_function;
797 }
798
799 error_code unmap_file_pages(void *base, size_t size) {
800 assert(0 && "NOT IMPLEMENTED");
801 return windows_error::invalid_function;
802 }
803
804793 error_code openFileForRead(const Twine &Name, int &ResultFD) {
805794 SmallString<128> PathStorage;
806795 SmallVector PathUTF16;