X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fptsname_r.m4;h=95c13b8b1088b1d048775c3688ab5283c70b4140;hb=da8054d48dc22e1c051db54049e005d51a006e69;hp=fb070998edc97ce851d0abe38699c9cad9fd22f9;hpb=78232883c8c01a22307bb38793928f2b9a5a6159;p=gnulib.git diff --git a/m4/ptsname_r.m4 b/m4/ptsname_r.m4 index fb070998e..95c13b8b1 100644 --- a/m4/ptsname_r.m4 +++ b/m4/ptsname_r.m4 @@ -1,5 +1,5 @@ -# ptsname_r.m4 serial 1 -dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. +# ptsname_r.m4 serial 3 +dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -14,10 +14,70 @@ AC_DEFUN([gl_FUNC_PTSNAME_R], AC_CHECK_FUNCS_ONCE([ptsname_r]) if test $ac_cv_func_ptsname_r = no; then HAVE_PTSNAME_R=0 + else + dnl On OSF/1 5.1, the type of the third argument is 'int', not 'size_t', + dnl and the declaration is missing if _REENTRANT is not defined. + AC_CACHE_CHECK([whether ptsname_r has the same signature as in glibc], + [gl_cv_func_ptsname_r_signature_ok], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + /* Test whether ptsname_r is declared at all. */ + int (*f) (int, char *, size_t) = ptsname_r; + /* Test whether it has the same declaration as in glibc. */ + #undef ptsname_r + extern + #ifdef __cplusplus + "C" + #endif + int ptsname_r (int, char *, size_t); + ]], + [[return f (0, NULL, 0);]]) + ], + [gl_cv_func_ptsname_r_signature_ok=yes], + [gl_cv_func_ptsname_r_signature_ok=no]) + ]) + if test $gl_cv_func_ptsname_r_signature_ok = no; then + REPLACE_PTSNAME_R=1 + fi fi ]) # Prerequisites of lib/ptsname.c. AC_DEFUN([gl_PREREQ_PTSNAME_R], [ - : + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether isatty sets errno when it fails], + [gl_cv_func_isatty_sets_errno], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + # include + #else + # include + #endif + ]], + [[errno = 0; + isatty (-1); + return errno == 0; + ]]) + ], + [gl_cv_func_isatty_sets_errno=yes], + [gl_cv_func_isatty_sets_errno=no], + [case "$host_os" in + irix* | solaris* | mingw*) + gl_cv_func_isatty_sets_errno="guessing no";; + *) + gl_cv_func_isatty_sets_errno="guessing yes";; + esac + ]) + ]) + case "$gl_cv_func_isatty_sets_errno" in + *yes) ;; + *) + AC_DEFINE([ISATTY_FAILS_WITHOUT_SETTING_ERRNO], [1], + [Define to 1 if isatty() may fail without setting errno.]) + ;; + esac ])