1 1.1 christos # mmap-anon.m4 serial 3 2 1.1 christos dnl Copyright (C) 2005 Free Software Foundation, Inc. 3 1.1 christos dnl This file is free software; the Free Software Foundation 4 1.1 christos dnl gives unlimited permission to copy and/or distribute it, 5 1.1 christos dnl with or without modifications, as long as this notice is preserved. 6 1.1 christos 7 1.1 christos AC_DEFUN([gl_FUNC_MMAP_ANON], 8 1.1 christos [ 9 1.1 christos dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. 10 1.1 christos AC_REQUIRE([AC_PROG_CPP]) 11 1.1 christos AC_REQUIRE([AC_PROG_EGREP]) 12 1.1 christos 13 1.1 christos dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. 14 1.1 christos AC_REQUIRE([AC_GNU_SOURCE]) 15 1.1 christos 16 1.1 christos # Check for mmap() 17 1.1 christos AC_FUNC_MMAP 18 1.1 christos 19 1.1 christos # Try to allow MAP_ANONYMOUS. 20 1.1 christos gl_have_mmap_anonymous=no 21 1.1 christos if test $ac_cv_func_mmap_fixed_mapped = yes; then 22 1.1 christos AC_MSG_CHECKING([for MAP_ANONYMOUS]) 23 1.1 christos AC_EGREP_CPP([I cant identify this map.], [ 24 1.1 christos #include <sys/mman.h> 25 1.1 christos #ifdef MAP_ANONYMOUS 26 1.1 christos I cant identify this map. 27 1.1 christos #endif 28 1.1 christos ], 29 1.1 christos [gl_have_mmap_anonymous=yes]) 30 1.1 christos if test $gl_have_mmap_anonymous != yes; then 31 1.1 christos AC_EGREP_CPP([I cant identify this map.], [ 32 1.1 christos #include <sys/mman.h> 33 1.1 christos #ifdef MAP_ANON 34 1.1 christos I cant identify this map. 35 1.1 christos #endif 36 1.1 christos ], 37 1.1 christos [AC_DEFINE(MAP_ANONYMOUS, MAP_ANON, 38 1.1 christos [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.]) 39 1.1 christos gl_have_mmap_anonymous=yes]) 40 1.1 christos fi 41 1.1 christos AC_MSG_RESULT($gl_have_mmap_anonymous) 42 1.1 christos if test $gl_have_mmap_anonymous = yes; then 43 1.1 christos AC_DEFINE(HAVE_MAP_ANONYMOUS, 1, 44 1.1 christos [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including 45 1.1 christos config.h and <sys/mman.h>.]) 46 1.1 christos fi 47 1.1 christos fi 48 1.1 christos ]) 49