From 5313a880e289ad97ef2f75b5251160e3e5409900 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sat, 19 Sep 2015 11:30:38 -0400 Subject: [PATCH] Re-implement the check for HAVE_POSIX_FADVISE. It is unclear why this was removed. If this needs to be removed again, either do so through the config file or the definition checks. --- StepmaniaCore.cmake | 1 + src/RageFileManager_ReadAhead.cpp | 13 +++++-------- src/config.in.hpp | 3 +++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/StepmaniaCore.cmake b/StepmaniaCore.cmake index 4d63afccde..bb52cdb191 100644 --- a/StepmaniaCore.cmake +++ b/StepmaniaCore.cmake @@ -113,6 +113,7 @@ check_symbol_exists(M_PI math.h HAVE_M_PI) check_symbol_exists(size_t stddef.h HAVE_SIZE_T_STDDEF) check_symbol_exists(size_t stdlib.h HAVE_SIZE_T_STDLIB) check_symbol_exists(size_t stdio.h HAVE_SIZE_T_STDIO) +check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE) # Checks to make it easier to work with 32-bit/64-bit builds if required. include(CheckTypeSize) diff --git a/src/RageFileManager_ReadAhead.cpp b/src/RageFileManager_ReadAhead.cpp index c174f0bde0..fca564da56 100644 --- a/src/RageFileManager_ReadAhead.cpp +++ b/src/RageFileManager_ReadAhead.cpp @@ -79,14 +79,13 @@ private: void WorkerMain() { - RString sBuffer; int iFDCopy = dup( m_iFD ); if( iFDCopy != -1 ) { - char *pBuf = sBuffer.GetBuffer( m_iBytes ); + char [] buf = new char[m_iBytes]; lseek( iFDCopy, m_iFrom, SEEK_SET ); - read( iFDCopy, pBuf, m_iBytes ); - sBuffer.ReleaseBuffer( m_iBytes ); + read( iFDCopy, buf, m_iBytes ); + delete [] buf; close( iFDCopy ); LOG->Trace("read"); @@ -154,9 +153,9 @@ void RageFileManagerReadAhead::DiscardCache( RageFileBasic *pFile, int iRelative #endif #endif -#if defined(HAVE_POSIX_FADVISE) void RageFileManagerReadAhead::CacheHintStreaming( RageFileBasic *pFile ) { +#if defined(HAVE_POSIX_FADVISE) /* This guesses at the actual size of the file on disk, which may be smaller if this file is compressed. * Since this is usually used on music and video files, it generally shouldn't be. */ int iFD = pFile->GetFD(); @@ -166,10 +165,8 @@ void RageFileManagerReadAhead::CacheHintStreaming( RageFileBasic *pFile ) int iFrom = lseek( iFD, 0, SEEK_CUR ); int iBytes = pFile->GetFileSize() - iPos; posix_fadvise( iFD, iFrom, iBytes, POSIX_FADV_SEQUENTIAL ); -} -#else -void RageFileManagerReadAhead::CacheHintStreaming( RageFileBasic *pFile ) { } #endif +} /* diff --git a/src/config.in.hpp b/src/config.in.hpp index 46e181f040..4f81b40790 100644 --- a/src/config.in.hpp +++ b/src/config.in.hpp @@ -81,6 +81,9 @@ /* Defined to 1 if the underlying system provides the M_PI constant. */ #cmakedefine HAVE_M_PI 1 +/* Defined to 1 if the underlying system provides the posix_fadvise function. */ +#cmakedefine HAVE_POSIX_FADVISE 1 + /* Provide a fallback if intptr_t is not defined. */ #cmakedefine HAVE_SIZEOF_INTPTR_T 1 #if !defined(HAVE_SIZEOF_INTPTR_T)