1dnl
2dnl Definitions for using shared memory
3dnl
4
5dnl/*D
6dnl PAC_ARG_SHARED_MEMORY - add --with-shared-memory=kind to configure
7dnl
8dnl Synopsis:
9dnl PAC_ARG_SHARED_MEMORY
10dnl
11dnl Output effects:
12dnl Adds '--with-shared-memory' to the command line. Checks for available
13dnl shared memory functionality.
14dnl
15dnl Supported values of 'kind' include \:
16dnl+    auto - default
17dnl.    mmap - use mmap and munmap
18dnl-    sysv - use sysv shared memory functions
19dnl D*/
20AC_DEFUN([PAC_ARG_SHARED_MEMORY],[
21
22# check how to allocate shared memory
23AC_ARG_WITH(shared-memory,
24    AC_HELP_STRING([--with-shared-memory[=auto|sysv|mmap]], [create shared memory using sysv or mmap (default is auto)]),,
25    with_shared_memory=auto)
26
27if test "$with_shared_memory" = auto -o "$with_shared_memory" = mmap; then
28    found_mmap_funcs=yes
29    AC_CHECK_FUNCS(mmap munmap, , found_mmap_funcs=no)
30    if test "$found_mmap_funcs" = yes ; then
31        with_shared_memory=mmap
32        AC_DEFINE(USE_MMAP_SHM,1,[Define if we have sysv shared memory])
33        AC_MSG_NOTICE([Using a memory-mapped file for shared memory])
34    elif test "$with_shared_memory" = mmap ; then
35        AC_MSG_ERROR([cannot support shared memory:  mmap() or munmap() not found])
36    fi
37fi
38if test "$with_shared_memory" = auto -o "$with_shared_memory" = sysv; then
39    found_sysv_shm_funcs=yes
40    AC_CHECK_FUNCS(shmget shmat shmctl shmdt, , found_sysv_shm_funcs=no)
41    if test "$found_sysv_shm_funcs" = yes ; then
42        with_shared_memory=sysv
43        AC_DEFINE(USE_SYSV_SHM,1,[Define if we have sysv shared memory])
44        AC_MSG_NOTICE([Using SYSV shared memory])
45    elif test "$with_shared_memory" = sysv ; then
46        AC_MSG_ERROR([cannot support shared memory:  sysv shared memory functions functions not found])
47    fi
48fi
49if test "$with_shared_memory" = nt ; then
50    AC_DEFINE(USE_NT_SHM,1,[Define if use Windows shared memory])
51fi
52
53if test "$with_shared_memory" = "auto" ; then
54    AC_MSG_ERROR([cannot support shared memory:  need either sysv shared memory functions or mmap in order to support shared memory])
55fi
56])
57