unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD
@ 2020-05-26 20:43 Samuel Thibault
  2020-05-27  9:16 ` Samuel Thibault
  2020-05-27  9:37 ` Florian Weimer via Libc-alpha
  0 siblings, 2 replies; 3+ messages in thread
From: Samuel Thibault @ 2020-05-26 20:43 UTC (permalink / raw)
  To: libc-alpha; +Cc: commit-hurd

* sysdeps/unix/sysv/linux/getpt.c (__getpt): Add oflag parameter, pass
it to the _open call and rename to...
(__bsd_openpt): ... new function.
[!HAVE_GETPT] (__getpt): Reimplement on top of __bsd_openpt.
(__posix_openpt): Replace stub with implementation on top of __bsd_openpt.
(posix_openpt): Remove stub warning.
* sysdeps/unix/bsd/getpt.c (__bsd_getpt): Replace prototype with
__bsd_openpt prototype.
(__getpt): Use __bsd_openpt instead of __bsd_getpt (as fallback when
_posix_openpt fails).
(getpt): Add alias
(__getpt): Do not define.
(HAVE_GETPT): Define.
---
 sysdeps/unix/bsd/getpt.c        | 18 ++++++++++--------
 sysdeps/unix/sysv/linux/getpt.c |  7 ++++---
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c
index 75489aef28..45c91005af 100644
--- a/sysdeps/unix/bsd/getpt.c
+++ b/sysdeps/unix/bsd/getpt.c
@@ -41,7 +41,7 @@ const char __libc_ptyname2[] attribute_hidden = PTYNAME2;
 
 /* Open a master pseudo terminal and return its file descriptor.  */
 int
-__getpt (void)
+__bsd_openpt (int oflag)
 {
   char buf[sizeof (_PATH_PTY) + 2];
   const char *p, *q;
@@ -61,7 +61,7 @@ __getpt (void)
 
 	  s[1] = *q;
 
-	  fd = __open (buf, O_RDWR);
+	  fd = __open (buf, oflag);
 	  if (fd != -1)
 	    return fd;
 
@@ -74,18 +74,20 @@ __getpt (void)
   return -1;
 }
 
-#undef __getpt
+#ifndef HAVE_GETPT
+int
+__getpt (void)
+{
+  return __bsd_openpt (O_RDWR);
+}
 weak_alias (__getpt, getpt)
+#endif
 
 #ifndef HAVE_POSIX_OPENPT
-/* We cannot define posix_openpt in general for BSD systems.  */
 int
 __posix_openpt (int oflag)
 {
-  __set_errno (ENOSYS);
-  return -1;
+  return __bsd_openpt (oflag);
 }
 weak_alias (__posix_openpt, posix_openpt)
-
-stub_warning (posix_openpt)
 #endif
diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c
index 1803b232c9..3785f90db0 100644
--- a/sysdeps/unix/sysv/linux/getpt.c
+++ b/sysdeps/unix/sysv/linux/getpt.c
@@ -31,7 +31,7 @@
 #define _PATH_DEVPTS _PATH_DEV "pts"
 
 /* Prototype for function that opens BSD-style master pseudo-terminals.  */
-extern int __bsd_getpt (void) attribute_hidden;
+extern int __bsd_openpt (int oflag) attribute_hidden;
 
 /* Open a master pseudo terminal and return its file descriptor.  */
 int
@@ -88,14 +88,15 @@ __getpt (void)
 {
   int fd = __posix_openpt (O_RDWR);
   if (fd == -1)
-    fd = __bsd_getpt ();
+    fd = __bsd_openpt (O_RDWR);
   return fd;
 }
+weak_alias (__getpt, getpt)
 
 
 #define PTYNAME1 "pqrstuvwxyzabcde";
 #define PTYNAME2 "0123456789abcdef";
 
-#define __getpt __bsd_getpt
+#define HAVE_GETPT
 #define HAVE_POSIX_OPENPT
 #include <sysdeps/unix/bsd/getpt.c>
-- 
2.26.2


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

* Re: [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD
  2020-05-26 20:43 [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD Samuel Thibault
@ 2020-05-27  9:16 ` Samuel Thibault
  2020-05-27  9:37 ` Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2020-05-27  9:16 UTC (permalink / raw)
  To: libc-alpha; +Cc: commit-hurd

(Sorry, exchanged the two file names while writing the changelog)

Samuel Thibault, le mar. 26 mai 2020 22:43:00 +0200, a ecrit:
> * sysdeps/unix/sysv/linux/getpt.c (__getpt): Add oflag parameter, pass
> it to the _open call and rename to...
> (__bsd_openpt): ... new function.
> [!HAVE_GETPT] (__getpt): Reimplement on top of __bsd_openpt.
> (__posix_openpt): Replace stub with implementation on top of __bsd_openpt.
> (posix_openpt): Remove stub warning.

that was for sysdeps/unix/bsd/getpt.c


> * sysdeps/unix/bsd/getpt.c (__bsd_getpt): Replace prototype with
> __bsd_openpt prototype.
> (__getpt): Use __bsd_openpt instead of __bsd_getpt (as fallback when
> _posix_openpt fails).
> (getpt): Add alias
> (__getpt): Do not define.
> (HAVE_GETPT): Define.

and that was for sysdeps/unix/sysv/linux/getpt.c

> ---
>  sysdeps/unix/bsd/getpt.c        | 18 ++++++++++--------
>  sysdeps/unix/sysv/linux/getpt.c |  7 ++++---
>  2 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/sysdeps/unix/bsd/getpt.c b/sysdeps/unix/bsd/getpt.c
> index 75489aef28..45c91005af 100644
> --- a/sysdeps/unix/bsd/getpt.c
> +++ b/sysdeps/unix/bsd/getpt.c
> @@ -41,7 +41,7 @@ const char __libc_ptyname2[] attribute_hidden = PTYNAME2;
>  
>  /* Open a master pseudo terminal and return its file descriptor.  */
>  int
> -__getpt (void)
> +__bsd_openpt (int oflag)
>  {
>    char buf[sizeof (_PATH_PTY) + 2];
>    const char *p, *q;
> @@ -61,7 +61,7 @@ __getpt (void)
>  
>  	  s[1] = *q;
>  
> -	  fd = __open (buf, O_RDWR);
> +	  fd = __open (buf, oflag);
>  	  if (fd != -1)
>  	    return fd;
>  
> @@ -74,18 +74,20 @@ __getpt (void)
>    return -1;
>  }
>  
> -#undef __getpt
> +#ifndef HAVE_GETPT
> +int
> +__getpt (void)
> +{
> +  return __bsd_openpt (O_RDWR);
> +}
>  weak_alias (__getpt, getpt)
> +#endif
>  
>  #ifndef HAVE_POSIX_OPENPT
> -/* We cannot define posix_openpt in general for BSD systems.  */
>  int
>  __posix_openpt (int oflag)
>  {
> -  __set_errno (ENOSYS);
> -  return -1;
> +  return __bsd_openpt (oflag);
>  }
>  weak_alias (__posix_openpt, posix_openpt)
> -
> -stub_warning (posix_openpt)
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c
> index 1803b232c9..3785f90db0 100644
> --- a/sysdeps/unix/sysv/linux/getpt.c
> +++ b/sysdeps/unix/sysv/linux/getpt.c
> @@ -31,7 +31,7 @@
>  #define _PATH_DEVPTS _PATH_DEV "pts"
>  
>  /* Prototype for function that opens BSD-style master pseudo-terminals.  */
> -extern int __bsd_getpt (void) attribute_hidden;
> +extern int __bsd_openpt (int oflag) attribute_hidden;
>  
>  /* Open a master pseudo terminal and return its file descriptor.  */
>  int
> @@ -88,14 +88,15 @@ __getpt (void)
>  {
>    int fd = __posix_openpt (O_RDWR);
>    if (fd == -1)
> -    fd = __bsd_getpt ();
> +    fd = __bsd_openpt (O_RDWR);
>    return fd;
>  }
> +weak_alias (__getpt, getpt)
>  
>  
>  #define PTYNAME1 "pqrstuvwxyzabcde";
>  #define PTYNAME2 "0123456789abcdef";
>  
> -#define __getpt __bsd_getpt
> +#define HAVE_GETPT
>  #define HAVE_POSIX_OPENPT
>  #include <sysdeps/unix/bsd/getpt.c>
> -- 
> 2.26.2
> 

-- 
Samuel
<m> argh, pi est plus grand que 2. Ca casse tout
 -+- #ens-mim -+-

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

* Re: [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD
  2020-05-26 20:43 [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD Samuel Thibault
  2020-05-27  9:16 ` Samuel Thibault
@ 2020-05-27  9:37 ` Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-05-27  9:37 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: commit-hurd, libc-alpha

* Samuel Thibault:

Subject should have posix_openpt (not posix_openbt).

But I don't think this is the right direction.  I'm testing patches that
rework the Linux implementation not to be based on top of the BSD
version because Linux no longer has BSD pseudo-terminals anyway.

Then you can move the BSD implementation into the Hurd subdirectories if
you want, and customize it directory.

Thanks,
Florian


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

end of thread, other threads:[~2020-05-27  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 20:43 [PATCH] Rearrange bsd_getpt vs bsd_openpt and implement posix_openbt on BSD Samuel Thibault
2020-05-27  9:16 ` Samuel Thibault
2020-05-27  9:37 ` Florian Weimer via Libc-alpha

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).