From: Eric Blake Date: Thu, 18 Mar 2010 19:49:25 +0000 (-0600) Subject: forkpty, openpty: split functions into new modules X-Git-Tag: v0.1~4482 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=9d84afa467b0a9abcd6e0d90fc7d1608f07bf2f1;p=gnulib.git forkpty, openpty: split functions into new modules The pty module was doing too much - replacing the header and checking for functions. In the future, when we provide a working forkpty for Solaris and HP-UX, and a stub for mingw, then the separation will be even more useful. * modules/pty (Makefile.am): Substitute new witnesses. (Libraries): Move library detection... * modules/forkpty: ...into new module. * modules/openpty: Another new module. * modules/pty-tests: Rename and split... * modules/forkpty-tests: ...to this... * modules/openpty-tests: ...and this. * tests/test-pty.c: Rename and split... * tests/test-forkpty.c: ...to this... * tests/test-openpty.c: ...and this. * m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses. (gl_PTY): Split library searching... * m4/pty.m4 (gl_PTY_LIB): ...into new file. (gl_FORKPTY, gl_OPENPTY): New macros. * lib/pty.in.h (forkpty, openpty): Honor new witnesses. * NEWS: Mention the split. * MODULES.html.sh (Misc): Document the modules. * doc/glibc-functions/forkpty.texi (forkpty): Likewise. * doc/glibc-functions/openpty.texi (openpty): Likewise. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index bbb04445f..8c1820aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2010-03-19 Eric Blake + forkpty, openpty: split functions into new modules + * modules/pty (Makefile.am): Substitute new witnesses. + (Libraries): Move library detection... + * modules/forkpty: ...into new module. + * modules/openpty: Another new module. + * modules/pty-tests: Rename and split... + * modules/forkpty-tests: ...to this... + * modules/openpty-tests: ...and this. + * tests/test-pty.c: Rename and split... + * tests/test-forkpty.c: ...to this... + * tests/test-openpty.c: ...and this. + * m4/pty_h.m4 (gl_PTY_H_DEFAULTS): Add new witnesses. + (gl_PTY): Split library searching... + * m4/pty.m4 (gl_PTY_LIB): ...into new file. + (gl_FORKPTY, gl_OPENPTY): New macros. + * lib/pty.in.h (forkpty, openpty): Honor new witnesses. + * NEWS: Mention the split. + * MODULES.html.sh (Misc): Document the modules. + * doc/glibc-functions/forkpty.texi (forkpty): Likewise. + * doc/glibc-functions/openpty.texi (openpty): Likewise. + pty: improve replacement header * lib/pty.in.h: New file. * modules/pty (Files): Ship it. diff --git a/MODULES.html.sh b/MODULES.html.sh index 080c60a52..b0fbe392d 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -3143,6 +3143,7 @@ func_all_modules () func_module exitfail func_module error func_module extensions + func_module forkpty func_module getdomainname func_module xgetdomainname func_module getloadavg @@ -3150,9 +3151,11 @@ func_all_modules () func_module getusershell func_module lib-symbol-visibility func_module nproc + func_module openpty func_module physmem func_module posixver func_module progname + func_module pty func_module quotearg func_module quote func_module readutmp diff --git a/NEWS b/NEWS index ad639dd8f..0074492c5 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ User visible incompatible changes Date Modules Changes +2010-03-18 pty This module now only declares the pty.h header. + Use the new modules 'forkpty' or 'openpty' to + get the functions that were previously provided. + 2010-03-05 exit This module is deprecated, use 'stdlib' directly instead. It will be removed 2011-01-01. diff --git a/doc/glibc-functions/forkpty.texi b/doc/glibc-functions/forkpty.texi index 7701a3826..8a8651158 100644 --- a/doc/glibc-functions/forkpty.texi +++ b/doc/glibc-functions/forkpty.texi @@ -2,7 +2,7 @@ @subsection @code{forkpty} @findex forkpty -Gnulib module: pty +Gnulib module: forkpty Portability problems fixed by Gnulib: @itemize diff --git a/doc/glibc-functions/openpty.texi b/doc/glibc-functions/openpty.texi index 83975a96a..7eb528efd 100644 --- a/doc/glibc-functions/openpty.texi +++ b/doc/glibc-functions/openpty.texi @@ -2,7 +2,7 @@ @subsection @code{openpty} @findex openpty -Gnulib module: pty +Gnulib module: openpty Portability problems fixed by Gnulib: @itemize diff --git a/lib/pty.in.h b/lib/pty.in.h index 8d80f8aac..1b7bf8205 100644 --- a/lib/pty.in.h +++ b/lib/pty.in.h @@ -44,21 +44,21 @@ /* Declare overridden functions. */ -#if 1 /* FIXME - split forkpty into separate module */ +#if @GNULIB_FORKPTY@ #elif defined GNULIB_POSIXCHECK # undef forkpty # if HAVE_RAW_DECL_FORKPTY _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module forkpty for portability"); # endif #endif -#if 1 /* FIXME - split openpty into separate module */ +#if @GNULIB_OPENPTY@ #elif defined GNULIB_POSIXCHECK # undef openpty # if HAVE_RAW_DECL_OPENPTY _GL_WARN_ON_USE (openpty, "openpty is not declared consistently - " - "use gnulib module pty for portability"); + "use gnulib module openpty for portability"); # endif #endif diff --git a/m4/pty.m4 b/m4/pty.m4 new file mode 100644 index 000000000..f2a5664f8 --- /dev/null +++ b/m4/pty.m4 @@ -0,0 +1,31 @@ +# pty.m4 serial 1 +dnl Copyright (C) 2010 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. + +# gl_PTY_LIB +# ---------- +# Define automake variable PTY_LIB to the library needed (if any). +AC_DEFUN([gl_PTY_LIB], +[ + # Check for the library required for forkpty. + PTY_LIB= + save_LIBS="$LIBS" + AC_SEARCH_LIBS([forkpty], [util], + [if test "$ac_cv_search_forkpty" != "none required"; then + PTY_LIB="$ac_cv_search_forkpty" + fi]) + LIBS="$save_LIBS" + AC_SUBST([PTY_LIB]) +]) + +AC_DEFUN([gl_FORKPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +]) + +AC_DEFUN([gl_OPENPTY], +[ + AC_REQUIRE([gl_PTY_LIB]) +]) diff --git a/m4/pty_h.m4 b/m4/pty_h.m4 index 3b6d91018..05ac3575c 100644 --- a/m4/pty_h.m4 +++ b/m4/pty_h.m4 @@ -1,4 +1,4 @@ -# pty_h.m4 serial 2 +# pty_h.m4 serial 3 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,13 +7,11 @@ dnl with or without modifications, as long as this notice is preserved. # gl_PTY # ------ # Make sure that pty.h provides forkpty, or sets up a replacement header. -# Also define automake variable PTY_LIB to the library needed (if any). AC_DEFUN_ONCE([gl_PTY], [ AC_REQUIRE([gl_PTY_H_DEFAULTS]) - PTY_LIB='' - # First make sure that pty.h provides forkpty, or setup the replacement. + # Make sure that pty.h provides forkpty, or setup the replacement. AC_CHECK_HEADERS_ONCE([pty.h]) if test $ac_cv_header_pty_h != yes; then HAVE_PTY_H=0 @@ -24,6 +22,7 @@ AC_DEFUN_ONCE([gl_PTY], if test $ac_cv_header_libutil_h = yes; then HAVE_LIBUTIL_H=1 fi + dnl FIXME - move this into forkpty module, when replacement is provided AC_CHECK_DECLS([forkpty],,, [[ #if HAVE_UTIL_H # include @@ -42,15 +41,6 @@ AC_DEFUN_ONCE([gl_PTY], dnl is always overridden, because of GNULIB_POSIXCHECK. gl_CHECK_NEXT_HEADERS([pty.h]) - # Second check for the library required for forkpty. - save_LIBS="$LIBS" - AC_SEARCH_LIBS([forkpty], [util], - [if test "$ac_cv_search_forkpty" != "none required"; then - PTY_LIB="$ac_cv_search_forkpty" - fi]) - LIBS="$save_LIBS" - AC_SUBST([PTY_LIB]) - dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[ @@ -75,6 +65,8 @@ AC_DEFUN([gl_PTY_MODULE_INDICATOR], AC_DEFUN([gl_PTY_H_DEFAULTS], [ + GNULIB_FORKPTY=0; AC_SUBST([GNULIB_FORKPTY]) + GNULIB_OPENPTY=0; AC_SUBST([GNULIB_OPENPTY]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H]) HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H]) diff --git a/modules/forkpty b/modules/forkpty new file mode 100644 index 000000000..5bfe0a5de --- /dev/null +++ b/modules/forkpty @@ -0,0 +1,26 @@ +Description: +Provide the forkpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_FORKPTY +gl_PTY_MODULE_INDICATOR([forkpty]) + +Makefile.am: + +Include: + + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson diff --git a/modules/forkpty-tests b/modules/forkpty-tests new file mode 100644 index 000000000..744d68486 --- /dev/null +++ b/modules/forkpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-forkpty.c + +Makefile.am: +TESTS += test-forkpty +check_PROGRAMS += test-forkpty +test_forkpty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/modules/openpty b/modules/openpty new file mode 100644 index 000000000..68e00db4a --- /dev/null +++ b/modules/openpty @@ -0,0 +1,26 @@ +Description: +Provide the openpty() function. + +Files: +m4/pty.m4 + +Depends-on: +pty + +configure.ac: +gl_OPENPTY +gl_PTY_MODULE_INDICATOR([openpty]) + +Makefile.am: + +Include: + + +Link: +$(PTY_LIB) + +License: +LGPL + +Maintainer: +Simon Josefsson diff --git a/modules/openpty-tests b/modules/openpty-tests new file mode 100644 index 000000000..8b730e68b --- /dev/null +++ b/modules/openpty-tests @@ -0,0 +1,8 @@ +Files: +tests/signature.h +tests/test-openpty.c + +Makefile.am: +TESTS += test-openpty +check_PROGRAMS += test-openpty +test_openpty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/modules/pty b/modules/pty index ef064be8e..8ea7ed3e3 100644 --- a/modules/pty +++ b/modules/pty @@ -25,6 +25,8 @@ pty.h: pty.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_PTY_H''@|$(NEXT_PTY_H)|g' \ + -e 's|@''GNULIB_FORKPTY''@|$(GNULIB_FORKPTY)|g' \ + -e 's|@''GNULIB_OPENPTY''@|$(GNULIB_OPENPTY)|g' \ -e 's|@''HAVE_UTIL_H''@|$(HAVE_UTIL_H)|g' \ -e 's|@''HAVE_LIBUTIL_H''@|$(HAVE_LIBUTIL_H)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ diff --git a/modules/pty-tests b/modules/pty-tests deleted file mode 100644 index 870d5182f..000000000 --- a/modules/pty-tests +++ /dev/null @@ -1,8 +0,0 @@ -Files: -tests/signature.h -tests/test-pty.c - -Makefile.am: -TESTS += test-pty -check_PROGRAMS += test-pty -test_pty_LDADD = $(LDADD) $(PTY_LIB) diff --git a/tests/test-forkpty.c b/tests/test-forkpty.c new file mode 100644 index 000000000..d87a10754 --- /dev/null +++ b/tests/test-forkpty.c @@ -0,0 +1,51 @@ +/* Test of pty.h and forkpty function. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Simon Josefsson , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, + struct winsize *)); + +#include + +int +main () +{ + int res; + int amaster; + + res = forkpty (&amaster, NULL, NULL, NULL); + if (res == 0) + { + /* child process */ + } + else if (res > 0) + { + /* parent */ + } + else + { + printf ("forkpty returned %d\n", res); + return 1; + } + + return 0; +} diff --git a/tests/test-openpty.c b/tests/test-openpty.c new file mode 100644 index 000000000..255aeb0dd --- /dev/null +++ b/tests/test-openpty.c @@ -0,0 +1,44 @@ +/* Test of pty.h and openpty function. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Simon Josefsson , 2009. */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, + struct winsize *)); + +#include + +int +main () +{ + int res; + int amaster; + int aslave; + + res = openpty (&amaster, &aslave, NULL, NULL, NULL); + if (res != 0) + { + printf ("openpty returned %d\n", res); + return 1; + } + + return 0; +} diff --git a/tests/test-pty.c b/tests/test-pty.c deleted file mode 100644 index 72e126b10..000000000 --- a/tests/test-pty.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Test of pty.h and openpty/forkpty functions. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Simon Josefsson , 2009. */ - -#include - -#include - -#include "signature.h" -SIGNATURE_CHECK (forkpty, int, (int *, char *, struct termios *, - struct winsize *)); -SIGNATURE_CHECK (openpty, int, (int *, int *, char *, struct termios *, - struct winsize *)); - -#include - -int -main () -{ - int res; - int amaster; - int aslave; - - res = openpty (&amaster, &aslave, NULL, NULL, NULL); - if (res != 0) - { - printf ("openpty returned %d\n", res); - return 1; - } - - res = forkpty (&amaster, NULL, NULL, NULL); - if (res == 0) - { - /* child process */ - } - else if (res > 0) - { - /* parent */ - } - else - { - printf ("forkpty returned %d\n", res); - return 1; - } - - return 0; -}