Skip to content

Commit 8db7e5e

Browse files
committed
Re-commit r289184, "Support: Use a 64-bit seek in raw_fd_ostream::seek()." with a configure-time check for lseek64.
llvm-svn: 289187
1 parent c4f2b09 commit 8db7e5e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ endif()
173173
if( HAVE_SYS_UIO_H )
174174
check_symbol_exists(writev sys/uio.h HAVE_WRITEV)
175175
endif()
176+
set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE")
177+
check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64)
178+
set(CMAKE_REQUIRED_DEFINITIONS "")
176179
check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
177180
check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
178181
check_symbol_exists(malloc_zone_statistics malloc/malloc.h

llvm/include/llvm/Config/config.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
/* Define to 1 if you have the <link.h> header file. */
121121
#cmakedefine HAVE_LINK_H ${HAVE_LINK_H}
122122

123+
/* Define to 1 if you have the `lseek64' function. */
124+
#cmakedefine HAVE_LSEEK64 ${HAVE_LSEEK64}
125+
123126
/* Define to 1 if you have the <mach/mach.h> header file. */
124127
#cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H}
125128

llvm/lib/Support/raw_ostream.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,13 @@ void raw_fd_ostream::close() {
598598
uint64_t raw_fd_ostream::seek(uint64_t off) {
599599
assert(SupportsSeeking && "Stream does not support seeking!");
600600
flush();
601+
#ifdef LLVM_ON_WIN32
602+
pos = ::_lseeki64(FD, off, SEEK_SET);
603+
#elif defined(HAVE_LSEEK64)
604+
pos = ::lseek64(FD, off, SEEK_SET);
605+
#else
601606
pos = ::lseek(FD, off, SEEK_SET);
607+
#endif
602608
if (pos == (uint64_t)-1)
603609
error_detected();
604610
return pos;

0 commit comments

Comments
 (0)