mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Rearrange bsd_getpt vs bsd_openpt and implement posix_openpt on BSD
* sysdeps/unix/bsd/getpt.c (__getpt): Add oflag parameter, pass it to the _open call and rename to... (__bsd_openpt): ... new function. (__getpt): Reimplement on top of __bsd_openpt. (__posix_openpt): Replace stub with implementation on top of __bsd_openpt. (posix_openpt): Remove stub warning.
This commit is contained in:
@ -41,7 +41,7 @@ const char __libc_ptyname2[] attribute_hidden = PTYNAME2;
|
|||||||
|
|
||||||
/* Open a master pseudo terminal and return its file descriptor. */
|
/* Open a master pseudo terminal and return its file descriptor. */
|
||||||
int
|
int
|
||||||
__getpt (void)
|
__bsd_openpt (int oflag)
|
||||||
{
|
{
|
||||||
char buf[sizeof (_PATH_PTY) + 2];
|
char buf[sizeof (_PATH_PTY) + 2];
|
||||||
const char *p, *q;
|
const char *p, *q;
|
||||||
@ -61,7 +61,7 @@ __getpt (void)
|
|||||||
|
|
||||||
s[1] = *q;
|
s[1] = *q;
|
||||||
|
|
||||||
fd = __open (buf, O_RDWR);
|
fd = __open (buf, oflag);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
@ -74,18 +74,16 @@ __getpt (void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef __getpt
|
int
|
||||||
|
__getpt (void)
|
||||||
|
{
|
||||||
|
return __bsd_openpt (O_RDWR);
|
||||||
|
}
|
||||||
weak_alias (__getpt, getpt)
|
weak_alias (__getpt, getpt)
|
||||||
|
|
||||||
#ifndef HAVE_POSIX_OPENPT
|
|
||||||
/* We cannot define posix_openpt in general for BSD systems. */
|
|
||||||
int
|
int
|
||||||
__posix_openpt (int oflag)
|
__posix_openpt (int oflag)
|
||||||
{
|
{
|
||||||
__set_errno (ENOSYS);
|
return __bsd_openpt (oflag);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
weak_alias (__posix_openpt, posix_openpt)
|
weak_alias (__posix_openpt, posix_openpt)
|
||||||
|
|
||||||
stub_warning (posix_openpt)
|
|
||||||
#endif
|
|
||||||
|
Reference in New Issue
Block a user