Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 2020 01:29:45 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366866 - in head: include lib/libc/stdlib
Message-ID:  <202010200129.09K1Tj91058693@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Tue Oct 20 01:29:45 2020
New Revision: 366866
URL: https://svnweb.freebsd.org/changeset/base/366866

Log:
  Further refinements of ptsname_r(3) interface:
  
   - Hide ptsname_r under __BSD_VISIBLE for now as the specification
     is not finalized at this time.
   - Keep Symbol.map sorted.
   - Avoid the interposing of ptsname_r(3) from an user application
     from breaking ptsname(3) by making the implementation a static
     method and call the static function from ptsname(3) instead.
  
  Reported by:	kib
  Reviewed by:	kib, jilles
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D26845

Modified:
  head/include/stdlib.h
  head/lib/libc/stdlib/Symbol.map
  head/lib/libc/stdlib/ptsname.c

Modified: head/include/stdlib.h
==============================================================================
--- head/include/stdlib.h	Mon Oct 19 22:32:36 2020	(r366865)
+++ head/include/stdlib.h	Tue Oct 20 01:29:45 2020	(r366866)
@@ -211,7 +211,6 @@ double	 drand48(void);
 double	 erand48(unsigned short[3]);
 /* char	*fcvt(double, int, int * __restrict, int * __restrict); */
 /* char	*gcvt(double, int, int * __restrict, int * __restrict); */
-int	 grantpt(int);
 char	*initstate(unsigned int, char *, size_t);
 long	 jrand48(unsigned short[3]);
 char	*l64a(long);
@@ -223,9 +222,6 @@ char	*mktemp(char *);
 #endif
 long	 mrand48(void);
 long	 nrand48(unsigned short[3]);
-int	 posix_openpt(int);
-char	*ptsname(int);
-int	 ptsname_r(int, char *, size_t);
 int	 putenv(char *);
 long	 random(void);
 unsigned short
@@ -233,8 +229,18 @@ unsigned short
 char	*setstate(/* const */ char *);
 void	 srand48(long);
 void	 srandom(unsigned int);
+#endif /* __XSI_VISIBLE */
+
+#if __XSI_VISIBLE
+int	 grantpt(int);
+int	 posix_openpt(int);
+char	*ptsname(int);
 int	 unlockpt(int);
 #endif /* __XSI_VISIBLE */
+#if __BSD_VISIBLE
+/* ptsname_r will be included in POSIX issue 8 */
+int	 ptsname_r(int, char *, size_t);
+#endif
 
 #if __BSD_VISIBLE
 extern const char *malloc_conf;

Modified: head/lib/libc/stdlib/Symbol.map
==============================================================================
--- head/lib/libc/stdlib/Symbol.map	Mon Oct 19 22:32:36 2020	(r366865)
+++ head/lib/libc/stdlib/Symbol.map	Tue Oct 20 01:29:45 2020	(r366866)
@@ -122,10 +122,10 @@ FBSD_1.5 {
 };
 
 FBSD_1.6 {
+	ptsname_r;
 	qsort_s;
 	rand;
 	srand;
-	ptsname_r;
 };
 
 FBSDprivate_1.0 {

Modified: head/lib/libc/stdlib/ptsname.c
==============================================================================
--- head/lib/libc/stdlib/ptsname.c	Mon Oct 19 22:32:36 2020	(r366865)
+++ head/lib/libc/stdlib/ptsname.c	Tue Oct 20 01:29:45 2020	(r366866)
@@ -76,7 +76,7 @@ __strong_reference(__isptmaster, unlockpt);
  *              associated with the specified master.
  */
 int
-ptsname_r(int fildes, char *buffer, size_t buflen)
+__ptsname_r(int fildes, char *buffer, size_t buflen)
 {
 
 	if (buflen <= sizeof(_PATH_DEV)) {
@@ -101,6 +101,8 @@ ptsname_r(int fildes, char *buffer, size_t buflen)
 	return (0);
 }
 
+__strong_reference(__ptsname_r, ptsname_r);
+
 /*
  * ptsname():  return the pathname of the slave pseudo-terminal device
  *             associated with the specified master.
@@ -108,10 +110,10 @@ ptsname_r(int fildes, char *buffer, size_t buflen)
 char *
 ptsname(int fildes)
 {
-	static char pt_slave[sizeof _PATH_DEV + SPECNAMELEN];
+	static char pt_slave[sizeof(_PATH_DEV) + SPECNAMELEN];
 
-	if (ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0)
+	if (__ptsname_r(fildes, pt_slave, sizeof(pt_slave)) == 0)
 		return (pt_slave);
-	else
-		return (NULL);
+
+	return (NULL);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010200129.09K1Tj91058693>