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.
This commit is contained in:
Jason Felds
2015-09-19 11:30:38 -04:00
parent 7535961cc1
commit 5313a880e2
3 changed files with 9 additions and 8 deletions
+1
View File
@@ -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)
+5 -8
View File
@@ -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
}
/*
+3
View File
@@ -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)