/src/libeio/libeio.m4

http://github.com/jacksonh/manos · m4 · 156 lines · 117 code · 11 blank · 28 comment · 0 complexity · 0abdd3200ea80d234b4325ecaff1bc8b MD5 · raw file

  1. AC_SEARCH_LIBS(
  2. pthread_create,
  3. [pthread pthreads pthreadVC2],
  4. ,
  5. [AC_MSG_ERROR(pthread functions not found)]
  6. )
  7. AC_CACHE_CHECK(for utimes, ac_cv_utimes, [AC_LINK_IFELSE([[
  8. #include <sys/types.h>
  9. #include <sys/time.h>
  10. #include <utime.h>
  11. struct timeval tv[2];
  12. int res;
  13. int main (void)
  14. {
  15. res = utimes ("/", tv);
  16. return 0;
  17. }
  18. ]],ac_cv_utimes=yes,ac_cv_utimes=no)])
  19. test $ac_cv_utimes = yes && AC_DEFINE(HAVE_UTIMES, 1, utimes(2) is available)
  20. AC_CACHE_CHECK(for futimes, ac_cv_futimes, [AC_LINK_IFELSE([[
  21. #include <sys/types.h>
  22. #include <sys/time.h>
  23. #include <utime.h>
  24. struct timeval tv[2];
  25. int res;
  26. int fd;
  27. int main (void)
  28. {
  29. res = futimes (fd, tv);
  30. return 0;
  31. }
  32. ]],ac_cv_futimes=yes,ac_cv_futimes=no)])
  33. test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available)
  34. AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([
  35. #include <fcntl.h>
  36. int main (void)
  37. {
  38. int fd = 0;
  39. size_t count = 2;
  40. ssize_t res;
  41. res = readahead (fd, 0, count);
  42. return 0;
  43. }
  44. ],ac_cv_readahead=yes,ac_cv_readahead=no)])
  45. test $ac_cv_readahead = yes && AC_DEFINE(HAVE_READAHEAD, 1, readahead(2) is available (linux))
  46. AC_CACHE_CHECK(for fdatasync, ac_cv_fdatasync, [AC_LINK_IFELSE([
  47. #include <unistd.h>
  48. int main (void)
  49. {
  50. int fd = 0;
  51. fdatasync (fd);
  52. return 0;
  53. }
  54. ],ac_cv_fdatasync=yes,ac_cv_fdatasync=no)])
  55. test $ac_cv_fdatasync = yes && AC_DEFINE(HAVE_FDATASYNC, 1, fdatasync(2) is available)
  56. AC_CACHE_CHECK(for pread and pwrite, ac_cv_preadwrite, [AC_LINK_IFELSE([
  57. #include <unistd.h>
  58. int main (void)
  59. {
  60. int fd = 0;
  61. size_t count = 1;
  62. char buf;
  63. off_t offset = 1;
  64. ssize_t res;
  65. res = pread (fd, &buf, count, offset);
  66. res = pwrite (fd, &buf, count, offset);
  67. return 0;
  68. }
  69. ],ac_cv_preadwrite=yes,ac_cv_preadwrite=no)])
  70. test $ac_cv_preadwrite = yes && AC_DEFINE(HAVE_PREADWRITE, 1, pread(2) and pwrite(2) are available)
  71. AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
  72. # include <sys/types.h>
  73. #if __linux
  74. # include <sys/sendfile.h>
  75. #elif __FreeBSD__ || defined __APPLE__
  76. # include <sys/socket.h>
  77. # include <sys/uio.h>
  78. #elif __hpux
  79. # include <sys/socket.h>
  80. #else
  81. # error unsupported architecture
  82. #endif
  83. int main (void)
  84. {
  85. int fd = 0;
  86. off_t offset = 1;
  87. size_t count = 2;
  88. ssize_t res;
  89. #if __linux
  90. res = sendfile (fd, fd, offset, count);
  91. #elif __FreeBSD__
  92. res = sendfile (fd, fd, offset, count, 0, &offset, 0);
  93. #elif __hpux
  94. res = sendfile (fd, fd, offset, count, 0, 0);
  95. #endif
  96. return 0;
  97. }
  98. ],ac_cv_sendfile=yes,ac_cv_sendfile=no)])
  99. test $ac_cv_sendfile = yes && AC_DEFINE(HAVE_SENDFILE, 1, sendfile(2) is available and supported)
  100. AC_CACHE_CHECK(for sync_file_range, ac_cv_sync_file_range, [AC_LINK_IFELSE([
  101. #include <fcntl.h>
  102. int main (void)
  103. {
  104. int fd = 0;
  105. off64_t offset = 1;
  106. off64_t nbytes = 1;
  107. unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER;
  108. ssize_t res;
  109. res = sync_file_range (fd, offset, nbytes, flags);
  110. return 0;
  111. }
  112. ],ac_cv_sync_file_range=yes,ac_cv_sync_file_range=no)])
  113. test $ac_cv_sync_file_range = yes && AC_DEFINE(HAVE_SYNC_FILE_RANGE, 1, sync_file_range(2) is available)
  114. dnl #############################################################################
  115. dnl # these checks exist for the benefit of IO::AIO
  116. dnl at least uclibc defines _POSIX_ADVISORY_INFO without *any* of the required
  117. dnl functionality actually being present. ugh.
  118. AC_CACHE_CHECK(for posix_madvise, ac_cv_posix_madvise, [AC_LINK_IFELSE([
  119. #include <sys/mman.h>
  120. int main (void)
  121. {
  122. int res = posix_madvise ((void *)0, (size_t)0, POSIX_MADV_NORMAL);
  123. int a = POSIX_MADV_SEQUENTIAL;
  124. int b = POSIX_MADV_RANDOM;
  125. int c = POSIX_MADV_WILLNEED;
  126. int d = POSIX_MADV_DONTNEED;
  127. return 0;
  128. }
  129. ],ac_cv_posix_madvise=yes,ac_cv_posix_madvise=no)])
  130. test $ac_cv_posix_madvise = yes && AC_DEFINE(HAVE_POSIX_MADVISE, 1, posix_madvise(2) is available)
  131. AC_CACHE_CHECK(for posix_fadvise, ac_cv_posix_fadvise, [AC_LINK_IFELSE([
  132. #define _XOPEN_SOURCE 600
  133. #include <fcntl.h>
  134. int main (void)
  135. {
  136. int res = posix_fadvise ((int)0, (off_t)0, (off_t)0, POSIX_FADV_NORMAL);
  137. int a = POSIX_FADV_SEQUENTIAL;
  138. int b = POSIX_FADV_NOREUSE;
  139. int c = POSIX_FADV_RANDOM;
  140. int d = POSIX_FADV_WILLNEED;
  141. int e = POSIX_FADV_DONTNEED;
  142. return 0;
  143. }
  144. ],ac_cv_posix_fadvise=yes,ac_cv_posix_fadvise=no)])
  145. test $ac_cv_posix_fadvise = yes && AC_DEFINE(HAVE_POSIX_FADVISE, 1, posix_fadvise(2) is available)