You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. /*
  2. Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. #include <fcntl.h>
  15. #if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
  16. #warning "using fs_fadvise_posix.icpp"
  17. #include "fs_fadvise_posix.icpp"
  18. #else
  19. #warning "using fs_fadvise_unsupported.icpp"
  20. #include "fs_fadvise_unsupported.icpp"
  21. #endif
  22. #ifndef POSIX_FADV_NORMAL
  23. # define POSIX_FADV_NORMAL 0
  24. #endif
  25. #ifndef POSIX_FADV_RANDOM
  26. # define POSIX_FADV_RANDOM 1
  27. #endif
  28. #ifndef POSIX_FADV_SEQUENTIAL
  29. # define POSIX_FADV_SEQUENTIAL 2
  30. #endif
  31. #ifndef POSIX_FADV_WILLNEED
  32. # define POSIX_FADV_WILLNEED 3
  33. #endif
  34. #ifndef POSIX_FADV_DONTNEED
  35. # define POSIX_FADV_DONTNEED 4
  36. #endif
  37. #ifndef POSIX_FADV_NOREUSE
  38. # define POSIX_FADV_NOREUSE 5
  39. #endif
  40. namespace fs
  41. {
  42. int
  43. fadvise_dontneed(const int fd_,
  44. const off_t offset_,
  45. const off_t len_)
  46. {
  47. return fs::fadvise(fd_,offset_,len_,POSIX_FADV_DONTNEED);
  48. }
  49. int
  50. fadvise_willneed(const int fd_,
  51. const off_t offset_,
  52. const off_t len_)
  53. {
  54. return fs::fadvise(fd_,offset_,len_,POSIX_FADV_WILLNEED);
  55. }
  56. int
  57. fadvise_sequential(const int fd_,
  58. const off_t offset_,
  59. const off_t len_)
  60. {
  61. return fs::fadvise(fd_,offset_,len_,POSIX_FADV_SEQUENTIAL);
  62. }
  63. }