public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Add getpt(3)
@ 2011-12-30  6:45 Yaakov (Cygwin/X)
  2011-12-30 17:58 ` Christopher Faylor
  0 siblings, 1 reply; 2+ messages in thread
From: Yaakov (Cygwin/X) @ 2011-12-30  6:45 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

getpt(3) is a GNU extension which predates posix_openpt(3):

http://www.kernel.org/doc/man-pages/online/pages/man3/getpt.3.html

The code itself is quite simple, but let me preempt some questions:

1) Yes, portable code should use posix_openpt(3).  Unfortunately not all
code is written with portability in mind.

2) A macro is insufficient as it will not be discovered by an Autoconf
AC_CHECK_FUNC or CMake CHECK_FUNCTION_EXISTS test (which is exactly how
I came across this issue in the first place).

Patches for winsup/cygwin and winsup/doc attached.


Yaakov


[-- Attachment #2: cygwin-getpt.patch --]
[-- Type: text/x-patch, Size: 3197 bytes --]

2011-12-30  Yaakov Selkowitz  <yselkowitz@...>

	* cygwin.din (getpt): Export.
	* posix.sgml (std-gnu): Add getpt.
	* tty.cc (getpt): New function.
	* include/cygwin/stdlib.h [!__STRICT_ANSI__] (getpt): Declare.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

Index: cygwin.din
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.249
diff -u -p -r1.249 cygwin.din
--- cygwin.din	7 Nov 2011 20:05:48 -0000	1.249
+++ cygwin.din	17 Nov 2011 01:29:52 -0000
@@ -759,6 +759,7 @@ getprogname NOSIGFE
 getprotobyname = cygwin_getprotobyname SIGFE
 getprotobynumber = cygwin_getprotobynumber SIGFE
 getprotoent = cygwin_getprotoent SIGFE
+getpt SIGFE
 getpwduid NOSIGFE
 _getpwduid = getpwduid NOSIGFE
 getpwent SIGFE
Index: posix.sgml
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/posix.sgml,v
retrieving revision 1.72
diff -u -p -r1.72 posix.sgml
--- posix.sgml	8 Nov 2011 09:24:58 -0000	1.72
+++ posix.sgml	17 Nov 2011 01:29:52 -0000
@@ -1116,6 +1116,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008)
     get_nprocs_conf
     getopt_long
     getopt_long_only
+    getpt
     getxattr
     lgetxattr
     listxattr
Index: tty.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/tty.cc,v
retrieving revision 1.91
diff -u -p -r1.91 tty.cc
--- tty.cc	30 Oct 2011 04:50:35 -0000	1.91
+++ tty.cc	17 Nov 2011 01:29:53 -0000
@@ -26,6 +26,12 @@ details. */
 HANDLE NO_COPY tty_list::mutex = NULL;
 
 extern "C" int
+getpt (void)
+{
+  return open ("/dev/ptmx", O_RDWR | O_NOCTTY);
+}
+
+extern "C" int
 posix_openpt (int oflags)
 {
   return open ("/dev/ptmx", oflags);
Index: include/cygwin/stdlib.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stdlib.h,v
retrieving revision 1.11
diff -u -p -r1.11 stdlib.h
--- include/cygwin/stdlib.h	8 Nov 2011 05:50:18 -0000	1.11
+++ include/cygwin/stdlib.h	17 Nov 2011 01:29:53 -0000
@@ -31,6 +31,7 @@ char *setstate (const char *state);
 void srandom (unsigned);
 char *ptsname (int);
 int ptsname_r(int, char *, size_t);
+int getpt (void);
 int grantpt (int);
 int unlockpt (int);
 #endif /*__STRICT_ANSI__*/
Index: include/cygwin/version.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v
retrieving revision 1.356
diff -u -p -r1.356 version.h
--- include/cygwin/version.h	7 Nov 2011 20:05:49 -0000	1.356
+++ include/cygwin/version.h	17 Nov 2011 01:29:53 -0000
@@ -425,12 +425,13 @@ details. */
       254: Export getgrouplist.
       255: Export ptsname_r.
       256: Add CW_ALLOC_DRIVE_MAP, CW_MAP_DRIVE_MAP, CW_FREE_DRIVE_MAP.
+      257: Export getpt.
      */
 
      /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
 
 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 256
+#define CYGWIN_VERSION_API_MINOR 257
 
      /* There is also a compatibity version number associated with the
 	shared memory regions.  It is incremented when incompatible

[-- Attachment #3: doc-getpt.patch --]
[-- Type: text/x-patch, Size: 752 bytes --]

2011-12-30  Yaakov Selkowitz  <yselkowitz@...>

	* new-features.sgml (ov-new1.7.10): Document getpt.

Index: new-features.sgml
===================================================================
RCS file: /cvs/src/src/winsup/doc/new-features.sgml,v
retrieving revision 1.94
diff -u -p -r1.94 new-features.sgml
--- new-features.sgml	13 Dec 2011 03:54:59 -0000	1.94
+++ new-features.sgml	30 Dec 2011 06:41:31 -0000
@@ -101,7 +101,7 @@ dlopen now supports the Glibc-specific R
 </para></listitem>
 
 <listitem><para>
-Other new API: clock_settime, __fpurge, getgrouplist, ppoll, psiginfo,
+Other new API: clock_settime, __fpurge, getgrouplist, getpt, ppoll, psiginfo,
 psignal, ptsname_r, sys_siglist, pthread_setschedprio, sysinfo.
 </para></listitem>
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add getpt(3)
  2011-12-30  6:45 [PATCH] Add getpt(3) Yaakov (Cygwin/X)
@ 2011-12-30 17:58 ` Christopher Faylor
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Faylor @ 2011-12-30 17:58 UTC (permalink / raw)
  To: cygwin-patches

On Fri, Dec 30, 2011 at 12:44:57AM -0600, Yaakov (Cygwin/X) wrote:
>getpt(3) is a GNU extension which predates posix_openpt(3):
>
>http://www.kernel.org/doc/man-pages/online/pages/man3/getpt.3.html
>
>The code itself is quite simple, but let me preempt some questions:
>
>1) Yes, portable code should use posix_openpt(3).  Unfortunately not all
>code is written with portability in mind.
>
>2) A macro is insufficient as it will not be discovered by an Autoconf
>AC_CHECK_FUNC or CMake CHECK_FUNCTION_EXISTS test (which is exactly how
>I came across this issue in the first place).
>
>Patches for winsup/cygwin and winsup/doc attached.

>2011-12-30  Yaakov Selkowitz  <yselkowitz@...>
>
>	* cygwin.din (getpt): Export.
>	* posix.sgml (std-gnu): Add getpt.
>	* tty.cc (getpt): New function.
>	* include/cygwin/stdlib.h [!__STRICT_ANSI__] (getpt): Declare.
>	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

Looks good.  Please commit.

Thanks.

cgf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-30 17:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-30  6:45 [PATCH] Add getpt(3) Yaakov (Cygwin/X)
2011-12-30 17:58 ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).