This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Correct ttyslot header declaration conditions (bug 20051)


UNIX98 and XPG4 have ttyslot in <stdlib.h>.  glibc, however, has it in
<unistd.h>, for __USE_MISC || (__USE_XOPEN_EXTENDED && !__USE_UNIX98),
but no supported standard has it in <unistd.h>.

This patch adds a properly conditioned declaration to <stdlib.h> (only
enabled for the relevant standards, not for __USE_MISC or __USE_GNU).
The <unistd.h> declaration is restricted to __USE_MISC.  The
conformtest expectation is adjusted not to expect it for XPG3, only
for XPG4 and UNIX98.  The conformtest XFAIL for <stdlib.h> for UNIX98
is removed (other affected <stdlib.h> and <unistd.h> tests still have
other reasons for failure remaining so this patch doesn't by itself
enable those other XFAILs to be removed).

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

2016-05-05  Joseph Myers  <joseph@codesourcery.com>

	[BZ #20051]
	* posix/unistd.h [__USE_XOPEN_EXTENDED && !__USE_UNIX98]
	(ttyslot): Do not declare.
	* stdlib/stdlib.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K]
	(ttyslot): New prototype.
	* conform/data/stdlib.h-data (ttyslot): Do not expect for [XPG3].
	* conform/Makefile (test-xfail-UNIX98/stdlib.h/conform): Remove
	variable.

diff --git a/conform/Makefile b/conform/Makefile
index d5273c1..e68753f 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -194,7 +194,6 @@ test-xfail-UNIX98/arpa/inet.h/conform = yes
 test-xfail-UNIX98/netdb.h/conform = yes
 test-xfail-UNIX98/netinet/in.h/conform = yes
 test-xfail-UNIX98/signal.h/conform = yes
-test-xfail-UNIX98/stdlib.h/conform = yes
 test-xfail-UNIX98/sys/wait.h/conform = yes
 test-xfail-UNIX98/ucontext.h/conform = yes
 test-xfail-UNIX98/unistd.h/conform = yes
diff --git a/conform/data/stdlib.h-data b/conform/data/stdlib.h-data
index abe296a..423358d 100644
--- a/conform/data/stdlib.h-data
+++ b/conform/data/stdlib.h-data
@@ -162,7 +162,7 @@ function {long long int} strtoll (const char*, char**, int)
 function {unsigned long long int} strtoull (const char*, char**, int)
 #endif
 function int system (const char*)
-#if defined XPG3 || defined XPG4 || defined UNIX98
+#if defined XPG4 || defined UNIX98
 function int ttyslot (void)
 #endif
 #if !defined ISO && !defined ISO99 && !defined ISO11 && !defined POSIX && !defined POSIX2008
diff --git a/posix/unistd.h b/posix/unistd.h
index 405638c..261587b 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -781,8 +781,7 @@ extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
    with a terminal, zero if not.  */
 extern int isatty (int __fd) __THROW;
 
-#if defined __USE_MISC \
-    || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)
+#ifdef __USE_MISC
 /* Return the index into the active-logins file (utmp) for
    the controlling terminal.  */
 extern int ttyslot (void) __THROW;
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index d0c78fa..5c0c982 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -912,6 +912,12 @@ extern int getloadavg (double __loadavg[], int __nelem)
      __THROW __nonnull ((1));
 #endif
 
+#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K
+/* Return the index into the active-logins file (utmp) for
+   the controlling terminal.  */
+extern int ttyslot (void) __THROW;
+#endif
+
 #include <bits/stdlib-float.h>
 
 /* Define some macros helping to catch buffer overflows.  */

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]