Skip to content

Commit

Permalink
fs_helpers: Guard _POSIX_C_SOURCE check within #ifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Feb 23, 2025
1 parent 2ac0d37 commit b16a687
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/util/fs_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ void AllocateFileRange(FILE* file, unsigned int offset, unsigned int length)
}

FILE* AdviseSequential(FILE *file) {
#if _POSIX_C_SOURCE >= 200112L
#ifdef _POSIX_C_SOURCE
# if _POSIX_C_SOURCE >= 200112L
// Since this whole thing is advisory anyway, we can ignore any errors
// encountered up to and including the posix_fadvise call. However, we must
// rewind the file to the appropriate position if we've changed the seek
Expand All @@ -257,12 +258,14 @@ FILE* AdviseSequential(FILE *file) {
}
posix_fadvise(fd, start, 0, POSIX_FADV_WILLNEED);
posix_fadvise(fd, start, 0, POSIX_FADV_SEQUENTIAL);
# endif
#endif
return file;
}

int CloseAndUncache(FILE *file) {
#if _POSIX_C_SOURCE >= 200112L
#ifdef _POSIX_C_SOURCE
# if _POSIX_C_SOURCE >= 200112L
// Ignore any errors up to and including the posix_fadvise call since it's
// advisory.
if (file != nullptr) {
Expand All @@ -274,6 +277,7 @@ int CloseAndUncache(FILE *file) {
}
}
}
# endif
#endif
return std::fclose(file);
}
Expand Down

0 comments on commit b16a687

Please sign in to comment.