From f5562fca6f341accafc32a5285a0262625df0fde Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 10 Nov 2011 13:48:16 +0100 Subject: [PATCH] ptsname_r: Avoid compilation error on OSF/1 5.1. * lib/stdlib.in.h (ptsname_r): Override if REPLACE_PTSNAME_R is 1. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_PTSNAME_R. * m4/ptsname_r.m4 (gl_FUNC_PTSNAME_R): Set REPLACE_PTSNAME_R if the function is not declared or incompatibly declared. * modules/stdlib (Makefile.am): Substitute REPLACE_PTSNAME_R. * modules/ptsname_r (Depends-on, configure.ac): Update. * doc/glibc-functions/ptsname_r.texi: Mention the OSF/1 problems. --- ChangeLog | 11 +++++++++++ doc/glibc-functions/ptsname_r.texi | 7 +++++++ lib/stdlib.in.h | 13 +++++++++++-- m4/ptsname_r.m4 | 29 ++++++++++++++++++++++++++++- m4/stdlib_h.m4 | 3 ++- modules/ptsname_r | 4 ++-- modules/stdlib | 1 + 7 files changed, 62 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7fe84d3b..5ac22c28f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-11-10 Bruno Haible + ptsname_r: Avoid compilation error on OSF/1 5.1. + * lib/stdlib.in.h (ptsname_r): Override if REPLACE_PTSNAME_R is 1. + * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_PTSNAME_R. + * m4/ptsname_r.m4 (gl_FUNC_PTSNAME_R): Set REPLACE_PTSNAME_R if the + function is not declared or incompatibly declared. + * modules/stdlib (Makefile.am): Substitute REPLACE_PTSNAME_R. + * modules/ptsname_r (Depends-on, configure.ac): Update. + * doc/glibc-functions/ptsname_r.texi: Mention the OSF/1 problems. + +2011-11-10 Bruno Haible + fstatat: Make cross-compilation guess succeed everywhere except on AIX. * m4/fstatat.m4 (gl_FUNC_FSTATAT): Require AC_CANONICAL_HOST. When cross-compiling, guess yes on all platforms except AIX. diff --git a/doc/glibc-functions/ptsname_r.texi b/doc/glibc-functions/ptsname_r.texi index 986e4910f..e51e5238d 100644 --- a/doc/glibc-functions/ptsname_r.texi +++ b/doc/glibc-functions/ptsname_r.texi @@ -11,6 +11,13 @@ This function is missing on some platforms: MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11 2010-11, Cygwin 1.7.9, mingw, MSVC 9, BeOS. +@item +This function is not declared unless @code{_REENTRANT} is defined, +on some platforms: +OSF/1 5.1. +@item +This function has an incompatible declaration on some platforms: +OSF/1 5.1. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 009b180cf..a59cb081e 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -459,10 +459,19 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - " /* Set the pathname of the pseudo-terminal slave associated with the master FD is open on and return 0, or set errno and return non-zero on errors. */ -# if !@HAVE_PTSNAME_R@ +# if @REPLACE_PTSNAME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ptsname_r +# define ptsname_r rpl_ptsname_r +# endif +_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); +_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); +# else +# if !@HAVE_PTSNAME_R@ _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); -# endif +# endif _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); +# endif _GL_CXXALIASWARN (ptsname_r); #elif defined GNULIB_POSIXCHECK # undef ptsname_r diff --git a/m4/ptsname_r.m4 b/m4/ptsname_r.m4 index fb070998e..695fe791b 100644 --- a/m4/ptsname_r.m4 +++ b/m4/ptsname_r.m4 @@ -1,4 +1,4 @@ -# ptsname_r.m4 serial 1 +# ptsname_r.m4 serial 2 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,6 +14,33 @@ 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 ]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index ebf7fb52a..0a8a9e563 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 38 +# stdlib_h.m4 serial 39 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -99,6 +99,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) + REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) diff --git a/modules/ptsname_r b/modules/ptsname_r index daf1d9812..7520847e1 100644 --- a/modules/ptsname_r +++ b/modules/ptsname_r @@ -8,11 +8,11 @@ m4/ptsname_r.m4 Depends-on: stdlib extensions -ttyname_r [test $HAVE_PTSNAME_R = 0] +ttyname_r [test $HAVE_PTSNAME_R = 0 || test $REPLACE_PTSNAME_R = 1] configure.ac: gl_FUNC_PTSNAME_R -if test $HAVE_PTSNAME_R = 0; then +if test $HAVE_PTSNAME_R = 0 || test $REPLACE_PTSNAME_R = 1; then AC_LIBOBJ([ptsname_r]) gl_PREREQ_PTSNAME_R fi diff --git a/modules/stdlib b/modules/stdlib index d46f66412..2beee3d2e 100644 --- a/modules/stdlib +++ b/modules/stdlib @@ -93,6 +93,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ + -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -- 2.11.0