3 # Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
11 dnl Provide getlogin_r when the system lacks it.
14 AC_DEFUN([gl_FUNC_GETLOGIN_R],
16 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
18 dnl Persuade glibc <unistd.h> to declare getlogin_r().
19 dnl Persuade Solaris <unistd.h> to provide the POSIX compliant declaration of
21 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
23 AC_CHECK_DECLS_ONCE([getlogin_r])
24 if test $ac_cv_have_decl_getlogin_r = no; then
25 HAVE_DECL_GETLOGIN_R=0
28 AC_CHECK_FUNCS_ONCE([getlogin_r])
29 if test $ac_cv_func_getlogin_r = no; then
33 dnl On OSF/1 5.1, getlogin_r returns a truncated result if the buffer is
35 AC_REQUIRE([AC_CANONICAL_HOST])
36 AC_CACHE_CHECK([whether getlogin_r works with small buffers],
37 [gl_cv_func_getlogin_r_works],
39 dnl Initial guess, used when cross-compiling.
43 osf*) gl_cv_func_getlogin_r_works="guessing no" ;;
44 # Guess yes otherwise.
45 *) gl_cv_func_getlogin_r_works="guessing yes" ;;
52 #if !HAVE_DECL_GETLOGIN_R
57 int getlogin_r (char *, size_t);
65 if (getlogin_r (buf, 0) == 0)
67 if (getlogin_r (buf, 1) == 0)
71 [gl_cv_func_getlogin_r_works=yes],
73 16 | 17) gl_cv_func_getlogin_r_works=no ;;
78 case "$gl_cv_func_getlogin_r_works" in
80 *) REPLACE_GETLOGIN_R=1 ;;
85 AC_DEFUN([gl_PREREQ_GETLOGIN_R],
87 AC_CHECK_DECLS_ONCE([getlogin])