1 # ptsname_r.m4 serial 3
2 dnl Copyright (C) 2010-2014 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_PTSNAME_R],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
11 dnl Persuade glibc <stdlib.h> to declare ptsname_r().
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14 AC_CHECK_FUNCS_ONCE([ptsname_r])
15 if test $ac_cv_func_ptsname_r = no; then
18 dnl On OSF/1 5.1, the type of the third argument is 'int', not 'size_t',
19 dnl and the declaration is missing if _REENTRANT is not defined.
20 AC_CACHE_CHECK([whether ptsname_r has the same signature as in glibc],
21 [gl_cv_func_ptsname_r_signature_ok],
26 /* Test whether ptsname_r is declared at all. */
27 int (*f) (int, char *, size_t) = ptsname_r;
28 /* Test whether it has the same declaration as in glibc. */
34 int ptsname_r (int, char *, size_t);
36 [[return f (0, NULL, 0);]])
38 [gl_cv_func_ptsname_r_signature_ok=yes],
39 [gl_cv_func_ptsname_r_signature_ok=no])
41 if test $gl_cv_func_ptsname_r_signature_ok = no; then
47 # Prerequisites of lib/ptsname.c.
48 AC_DEFUN([gl_PREREQ_PTSNAME_R], [
49 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
50 AC_CACHE_CHECK([whether isatty sets errno when it fails],
51 [gl_cv_func_isatty_sets_errno],
55 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
66 [gl_cv_func_isatty_sets_errno=yes],
67 [gl_cv_func_isatty_sets_errno=no],
69 irix* | solaris* | mingw*)
70 gl_cv_func_isatty_sets_errno="guessing no";;
72 gl_cv_func_isatty_sets_errno="guessing yes";;
76 case "$gl_cv_func_isatty_sets_errno" in
79 AC_DEFINE([ISATTY_FAILS_WITHOUT_SETTING_ERRNO], [1],
80 [Define to 1 if isatty() may fail without setting errno.])