llvm.org GIT mirror llvm / 4b3d007
Re-commit r289184, "Support: Use a 64-bit seek in raw_fd_ostream::seek()." with a configure-time check for lseek64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289187 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
3 changed file(s) with 12 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
172172 if( HAVE_SYS_UIO_H )
173173 check_symbol_exists(writev sys/uio.h HAVE_WRITEV)
174174 endif()
175 set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE")
176 check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64)
177 set(CMAKE_REQUIRED_DEFINITIONS "")
175178 check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
176179 check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
177180 check_symbol_exists(malloc_zone_statistics malloc/malloc.h
119119 /* Define to 1 if you have the header file. */
120120 #cmakedefine HAVE_LINK_H ${HAVE_LINK_H}
121121
122 /* Define to 1 if you have the `lseek64' function. */
123 #cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64}
124
122125 /* Define to 1 if you have the header file. */
123126 #cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H}
124127
597597 uint64_t raw_fd_ostream::seek(uint64_t off) {
598598 assert(SupportsSeeking && "Stream does not support seeking!");
599599 flush();
600 #ifdef LLVM_ON_WIN32
601 pos = ::_lseeki64(FD, off, SEEK_SET);
602 #elif defined(HAVE_LSEEK64)
603 pos = ::lseek64(FD, off, SEEK_SET);
604 #else
600605 pos = ::lseek(FD, off, SEEK_SET);
606 #endif
601607 if (pos == (uint64_t)-1)
602608 error_detected();
603609 return pos;