cca227d2929386ee11e4aa23464681ef35eb9679Aki TuomiAC_DEFUN([DOVECOT_GLIBC], [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_CACHE_CHECK([whether we have glibc],i_cv_have_glibc,[
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_TRY_COMPILE([
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #include <stdlib.h>
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #ifdef __GLIBC__
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi we have glibc
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #endif
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ],, [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_have_glibc=no
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ], [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_have_glibc=yes
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if test "$i_cv_have_glibc" = "yes"; then
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_DEFINE(PREAD_WRAPPERS,, [Define if pread/pwrite needs _XOPEN_SOURCE 500])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi fi
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi dnl * Old glibcs have broken posix_fallocate(). Make sure not to use it.
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi dnl * It may also be broken in AIX.
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_CACHE_CHECK([whether posix_fallocate() works],i_cv_posix_fallocate_works,[
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_TRY_RUN([
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #define _XOPEN_SOURCE 600
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #include <stdio.h>
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #include <stdlib.h>
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #include <fcntl.h>
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #include <unistd.h>
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #if defined(__GLIBC__) && (__GLIBC__ < 2 || __GLIBC_MINOR__ < 7)
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi possibly broken posix_fallocate
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi #endif
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi int main() {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi int fd = creat("conftest.temp", 0600);
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi int ret;
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if (fd == -1) {
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi perror("creat()");
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi return 2;
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi }
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ret = posix_fallocate(fd, 1024, 1024) < 0 ? 1 : 0;
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi unlink("conftest.temp");
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi return ret;
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi }
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ], [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_posix_fallocate_works=yes
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ], [
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi i_cv_posix_fallocate_works=no
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi ])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi if test $i_cv_posix_fallocate_works = yes; then
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi AC_DEFINE(HAVE_POSIX_FALLOCATE,, [Define if you have a working posix_fallocate()])
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi fi
cca227d2929386ee11e4aa23464681ef35eb9679Aki Tuomi])