check-getpwuid_r-posix.m4 revision 1.1 1 1.1 christos dnl Id
2 1.1 christos dnl
3 1.1 christos dnl check for getpwuid_r, and if it's posix or not
4 1.1 christos
5 1.1 christos AC_DEFUN([AC_CHECK_GETPWUID_R_POSIX],[
6 1.1 christos AC_FIND_FUNC_NO_LIBS(getpwuid_r,c_r)
7 1.1 christos if test "$ac_cv_func_getpwuid_r" = yes; then
8 1.1 christos AC_CACHE_CHECK(if getpwuid_r is posix,ac_cv_func_getpwuid_r_posix,
9 1.1 christos ac_libs="$LIBS"
10 1.1 christos LIBS="$LIBS $LIB_getpwuid_r"
11 1.1 christos AC_RUN_IFELSE([AC_LANG_SOURCE([[
12 1.1 christos #define _POSIX_PTHREAD_SEMANTICS
13 1.1 christos #include <pwd.h>
14 1.1 christos int main(int argc, char **argv)
15 1.1 christos {
16 1.1 christos struct passwd pw, *pwd;
17 1.1 christos return getpwuid_r(0, &pw, 0, 0, &pwd) < 0;
18 1.1 christos }
19 1.1 christos ]])],[ac_cv_func_getpwuid_r_posix=yes],[ac_cv_func_getpwuid_r_posix=no],[:])
20 1.1 christos LIBS="$ac_libs")
21 1.1 christos AC_CACHE_CHECK(if _POSIX_PTHREAD_SEMANTICS is needed,ac_cv_func_getpwuid_r_posix_def,
22 1.1 christos ac_libs="$LIBS"
23 1.1 christos LIBS="$LIBS $LIB_getpwuid_r"
24 1.1 christos AC_RUN_IFELSE([AC_LANG_SOURCE([[
25 1.1 christos #include <pwd.h>
26 1.1 christos int main(int argc, char **argv)
27 1.1 christos {
28 1.1 christos struct passwd pw, *pwd;
29 1.1 christos return getpwuid_r(0, &pw, 0, 0, &pwd) < 0;
30 1.1 christos }
31 1.1 christos ]])],[ac_cv_func_getpwuid_r_posix_def=no],[ac_cv_func_getpwuid_r_posix_def=yes],[:])
32 1.1 christos LIBS="$ac_libs")
33 1.1 christos if test "$ac_cv_func_getpwuid_r_posix" = yes; then
34 1.1 christos AC_DEFINE(POSIX_GETPWUID_R, 1, [Define if getpwuid_r has POSIX flavour.])
35 1.1 christos fi
36 1.1 christos if test "$ac_cv_func_getpwuid_r_posix" = yes -a "$ac_cv_func_getpwuid_r_posix_def" = yes; then
37 1.1 christos AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to get POSIX getpwuid_r in some systems.])
38 1.1 christos fi
39 1.1 christos fi
40 1.1 christos ])
41