added QSE_FIO_NOCACHE.
map QSE_FIO_SEQUENTIAL and QSE_FIO_RANDOM to some posix_fadvise flags if available
This commit is contained in:
parent
595aab7555
commit
1e36d2c141
@ -59,9 +59,10 @@ enum qse_fio_open_flag_t
|
|||||||
QSE_FIO_NOSHRD = (1 << 24),
|
QSE_FIO_NOSHRD = (1 << 24),
|
||||||
QSE_FIO_NOSHWR = (1 << 25),
|
QSE_FIO_NOSHWR = (1 << 25),
|
||||||
|
|
||||||
/* for WIN32 only. harmless(no effect) when used on other platforms */
|
/* hints to OS. harmless(no effect) when used on unsupported platforms */
|
||||||
QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */
|
QSE_FIO_RANDOM = (1 << 26), /* hint that access be random */
|
||||||
QSE_FIO_SEQUENTIAL = (1 << 27) /* hint that access is sequential */
|
QSE_FIO_SEQUENTIAL = (1 << 27), /* hint that access is sequential */
|
||||||
|
QSE_FIO_NOCACHE = (1 << 28) /* no system I/O cache */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum qse_fio_std_t
|
enum qse_fio_std_t
|
||||||
|
@ -155,6 +155,8 @@ int qse_fio_init (
|
|||||||
flag_and_attr |= FILE_FLAG_RANDOM_ACCESS;
|
flag_and_attr |= FILE_FLAG_RANDOM_ACCESS;
|
||||||
if (flags & QSE_FIO_SEQUENTIAL)
|
if (flags & QSE_FIO_SEQUENTIAL)
|
||||||
flag_and_attr |= FILE_FLAG_SEQUENTIAL_SCAN;
|
flag_and_attr |= FILE_FLAG_SEQUENTIAL_SCAN;
|
||||||
|
if (flags & QSE_FIO_NOCACHE)
|
||||||
|
flag_and_attr |= FILE_FLAG_NO_BUFFERING;
|
||||||
|
|
||||||
handle = CreateFile (
|
handle = CreateFile (
|
||||||
path, desired_access, share_mode,
|
path, desired_access, share_mode,
|
||||||
@ -369,6 +371,20 @@ int qse_fio_init (
|
|||||||
|
|
||||||
if (handle == -1) return -1;
|
if (handle == -1) return -1;
|
||||||
|
|
||||||
|
/* set some file access hints */
|
||||||
|
#if defined(POSIX_FADV_RANDOM)
|
||||||
|
if (flags & QSE_FIO_RANDOM)
|
||||||
|
posix_fadvise (handle, 0, 0, POSIX_FADV_RANDOM);
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX_FADV_SEQUENTIAL)
|
||||||
|
if (flags & QSE_FIO_SEQUENTIAL)
|
||||||
|
posix_fadvise (handle, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX_FADV_DONTNEED)
|
||||||
|
if (flags & QSE_FIO_NOCACHE)
|
||||||
|
posix_fadvise (handle, 0, 0, POSIX_FADV_DONTNEED);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags & QSE_FIO_TEXT)
|
if (flags & QSE_FIO_TEXT)
|
||||||
|
Loading…
Reference in New Issue
Block a user