OSDN Git Service

61187cfa5648502437e173e4d47783f70ed6eb17
[pf3gnuchains/gcc-fork.git] / libffi / acinclude.m4
1 sinclude(../libtool.m4)
2 dnl The lines below arrange for aclocal not to bring libtool.m4
3 dnl AC_PROG_LIBTOOL into aclocal.m4, while still arranging for automake
4 dnl to add a definition of LIBTOOL to Makefile.in.
5 ifelse(yes,no,[
6 AC_DEFUN([AC_PROG_LIBTOOL],)
7 AC_DEFUN([AM_PROG_LIBTOOL],)
8 AC_SUBST(LIBTOOL)
9 ])
10
11 # mmap(2) blacklisting.  Some platforms provide the mmap library routine
12 # but don't support all of the features we need from it.
13 AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
14 [
15 AC_CHECK_HEADER([sys/mman.h],
16                 [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
17 AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
18 if test "$libffi_header_sys_mman_h" != yes \
19  || test "$libffi_func_mmap" != yes; then
20    ac_cv_func_mmap_file=no
21    ac_cv_func_mmap_dev_zero=no
22    ac_cv_func_mmap_anon=no
23 else
24    AC_CACHE_CHECK([whether read-only mmap of a plain file works],
25   ac_cv_func_mmap_file,
26   [# Add a system to this blacklist if
27    # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
28    # memory area containing the same data that you'd get if you applied
29    # read() to the same fd.  The only system known to have a problem here
30    # is VMS, where text files have record structure.
31    case "$host_os" in
32      vms* | ultrix*)
33         ac_cv_func_mmap_file=no ;;
34      *)
35         ac_cv_func_mmap_file=yes;;
36    esac])
37    AC_CACHE_CHECK([whether mmap from /dev/zero works],
38   ac_cv_func_mmap_dev_zero,
39   [# Add a system to this blacklist if it has mmap() but /dev/zero
40    # does not exist, or if mmapping /dev/zero does not give anonymous
41    # zeroed pages with both the following properties:
42    # 1. If you map N consecutive pages in with one call, and then
43    #    unmap any subset of those pages, the pages that were not
44    #    explicitly unmapped remain accessible.
45    # 2. If you map two adjacent blocks of memory and then unmap them
46    #    both at once, they must both go away.
47    # Systems known to be in this category are Windows (all variants),
48    # VMS, and Darwin.
49    case "$host_os" in
50      vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
51         ac_cv_func_mmap_dev_zero=no ;;
52      *)
53         ac_cv_func_mmap_dev_zero=yes;;
54    esac])
55
56    # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
57    AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
58     [AC_TRY_COMPILE(
59 [#include <sys/types.h>
60 #include <sys/mman.h>
61 #include <unistd.h>
62
63 #ifndef MAP_ANONYMOUS
64 #define MAP_ANONYMOUS MAP_ANON
65 #endif
66 ],
67 [int n = MAP_ANONYMOUS;],
68     ac_cv_decl_map_anon=yes,
69     ac_cv_decl_map_anon=no)])
70
71    if test $ac_cv_decl_map_anon = no; then
72      ac_cv_func_mmap_anon=no
73    else
74      AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
75      ac_cv_func_mmap_anon,
76   [# Add a system to this blacklist if it has mmap() and MAP_ANON or
77    # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
78    # doesn't give anonymous zeroed pages with the same properties listed
79    # above for use of /dev/zero.
80    # Systems known to be in this category are Windows, VMS, and SCO Unix.
81    case "$host_os" in
82      vms* | cygwin* | pe | mingw* | sco* | udk* )
83         ac_cv_func_mmap_anon=no ;;
84      *)
85         ac_cv_func_mmap_anon=yes;;
86    esac])
87    fi
88 fi
89
90 if test $ac_cv_func_mmap_file = yes; then
91   AC_DEFINE(HAVE_MMAP_FILE, 1,
92             [Define if read-only mmap of a plain file works.])
93 fi
94 if test $ac_cv_func_mmap_dev_zero = yes; then
95   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
96             [Define if mmap of /dev/zero works.])
97 fi
98 if test $ac_cv_func_mmap_anon = yes; then
99   AC_DEFINE(HAVE_MMAP_ANON, 1,
100             [Define if mmap with MAP_ANON(YMOUS) works.])
101 fi
102 ])
103
104 sinclude(../config/accross.m4)