1 dnl Autoconf macros used by PINENTRY
3 dnl Copyright (C) 2002 g10 Code GmbH
6 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
7 dnl Check whether a typedef exists and create a #define $2 if it exists
9 AC_DEFUN([GNUPG_CHECK_TYPEDEF],
10 [ AC_MSG_CHECKING(for $1 typedef)
11 AC_CACHE_VAL(gnupg_cv_typedef_$1,
12 [AC_TRY_COMPILE([#define _GNU_SOURCE 1
14 #include <sys/types.h>], [
17 ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
18 AC_MSG_RESULT($gnupg_cv_typedef_$1)
19 if test "$gnupg_cv_typedef_$1" = yes; then
20 AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
25 ######################################################################
26 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
27 # is not called from uid 0 (not tested whether uid 0 works)
28 # For DECs Tru64 we have also to check whether mlock is in librt
29 # mlock is there a macro using memlk()
30 ######################################################################
33 define([GNUPG_CHECK_MLOCK],
34 [ AC_CHECK_FUNCS(mlock)
35 if test "$ac_cv_func_mlock" = "no"; then
36 AC_CHECK_HEADERS(sys/mman.h)
37 if test "$ac_cv_header_sys_mman_h" = "yes"; then
39 AC_CHECK_LIB(rt, memlk)
40 AC_CACHE_CHECK([whether mlock is in sys/mman.h],
41 gnupg_cv_mlock_is_in_sys_mman,
44 #ifdef HAVE_SYS_MMAN_H
50 /* glibc defines this for functions which it implements
51 * to always fail with ENOSYS. Some functions are actually
52 * named something starting with __ and the normal name
54 #if defined (__stub_mlock) || defined (__stub___mlock)
61 gnupg_cv_mlock_is_in_sys_mman=yes,
62 gnupg_cv_mlock_is_in_sys_mman=no)])
63 if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
64 AC_DEFINE(HAVE_MLOCK,1,
65 [Defined if the system supports an mlock() call])
69 if test "$ac_cv_func_mlock" = "yes"; then
70 AC_MSG_CHECKING(whether mlock is broken)
71 AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
77 #include <sys/types.h>
84 long int pgsize = getpagesize();
86 pool = malloc( 4096 + pgsize );
89 pool += (pgsize - ((long int)pool % pgsize));
91 err = mlock( pool, 4096 );
92 if( !err || errno == EPERM )
99 gnupg_cv_have_broken_mlock="no",
100 gnupg_cv_have_broken_mlock="yes",
101 gnupg_cv_have_broken_mlock="assume-no"
104 if test "$gnupg_cv_have_broken_mlock" = "yes"; then
105 AC_DEFINE(HAVE_BROKEN_MLOCK,1,
106 [Defined if the mlock() call does not work])
108 AC_CHECK_FUNCS(plock)
110 if test "$gnupg_cv_have_broken_mlock" = "no"; then
113 AC_MSG_RESULT(assuming no)