Mercurial > hg > octave-kai > gnulib-hg
changeset 16074:cd0ee16f47e9
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 10 Nov 2011 13:48:16 +0100 |
parents | e5c3172699de |
children | e3c3fdcd0910 |
files | ChangeLog doc/glibc-functions/ptsname_r.texi lib/stdlib.in.h m4/ptsname_r.m4 m4/stdlib_h.m4 modules/ptsname_r modules/stdlib |
diffstat | 7 files changed, 62 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-11-10 Bruno Haible <bruno@clisp.org> + + 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 <bruno@clisp.org> fstatat: Make cross-compilation guess succeed everywhere except on AIX.
--- a/doc/glibc-functions/ptsname_r.texi +++ b/doc/glibc-functions/ptsname_r.texi @@ -11,6 +11,13 @@ 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:
--- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -459,10 +459,19 @@ /* 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 +_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); # endif -_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); _GL_CXXALIASWARN (ptsname_r); #elif defined GNULIB_POSIXCHECK # undef ptsname_r
--- 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_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 <stddef.h> + #include <stdlib.h> + /* 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 ])
--- 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 @@ 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])
--- a/modules/ptsname_r +++ b/modules/ptsname_r @@ -8,11 +8,11 @@ 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
--- a/modules/stdlib +++ b/modules/stdlib @@ -93,6 +93,7 @@ -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' \