ubsan: aarch64: left shift of negative value
[deliverable/binutils-gdb.git] / gnulib / import / m4 / getlogin_r.m4
CommitLineData
5e8754f9 1#serial 11
6ec2e0f5 2
5e8754f9 3# Copyright (C) 2005-2007, 2009-2016 Free Software Foundation, Inc.
6ec2e0f5
SDJ
4#
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.
8
9dnl From Derek Price
10dnl
11dnl Provide getlogin_r when the system lacks it.
12dnl
13
14AC_DEFUN([gl_FUNC_GETLOGIN_R],
15[
16 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
17
18 dnl Persuade glibc <unistd.h> to declare getlogin_r().
19 dnl Persuade Solaris <unistd.h> to provide the POSIX compliant declaration of
20 dnl getlogin_r().
21 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
22
23 AC_CHECK_DECLS_ONCE([getlogin_r])
24 if test $ac_cv_have_decl_getlogin_r = no; then
25 HAVE_DECL_GETLOGIN_R=0
26 fi
27
28 AC_CHECK_FUNCS_ONCE([getlogin_r])
29 if test $ac_cv_func_getlogin_r = no; then
30 HAVE_GETLOGIN_R=0
31 else
32 HAVE_GETLOGIN_R=1
5e8754f9
SDJ
33 dnl On OSF/1 5.1, getlogin_r returns a truncated result if the buffer is
34 dnl not large enough.
6ec2e0f5
SDJ
35 AC_REQUIRE([AC_CANONICAL_HOST])
36 AC_CACHE_CHECK([whether getlogin_r works with small buffers],
37 [gl_cv_func_getlogin_r_works],
38 [
39 dnl Initial guess, used when cross-compiling.
40changequote(,)dnl
41 case "$host_os" in
5e8754f9
SDJ
42 # Guess no on OSF/1.
43 osf*) gl_cv_func_getlogin_r_works="guessing no" ;;
44 # Guess yes otherwise.
45 *) gl_cv_func_getlogin_r_works="guessing yes" ;;
6ec2e0f5
SDJ
46 esac
47changequote([,])dnl
48 AC_RUN_IFELSE(
49 [AC_LANG_SOURCE([[
50#include <stddef.h>
51#include <unistd.h>
52#if !HAVE_DECL_GETLOGIN_R
53extern
54# ifdef __cplusplus
55"C"
56# endif
57int getlogin_r (char *, size_t);
58#endif
59int
60main (void)
61{
62 int result = 0;
63 char buf[100];
64
65 if (getlogin_r (buf, 0) == 0)
5e8754f9 66 result |= 16;
6ec2e0f5 67 if (getlogin_r (buf, 1) == 0)
5e8754f9 68 result |= 17;
6ec2e0f5
SDJ
69 return result;
70}]])],
71 [gl_cv_func_getlogin_r_works=yes],
5e8754f9
SDJ
72 [case $? in
73 16 | 17) gl_cv_func_getlogin_r_works=no ;;
74 esac
75 ],
6ec2e0f5
SDJ
76 [:])
77 ])
78 case "$gl_cv_func_getlogin_r_works" in
79 *yes) ;;
80 *) REPLACE_GETLOGIN_R=1 ;;
81 esac
82 fi
83])
84
85AC_DEFUN([gl_PREREQ_GETLOGIN_R],
86[
87 AC_CHECK_DECLS_ONCE([getlogin])
88])
This page took 0.197041 seconds and 4 git commands to generate.