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]

Fix pthreads getrlimit, gettimeofday namespace (bug 17682)


Some pthreads functions use getrlimit and gettimeofday, but these
functions are XSI, not base POSIX; this is a namespace issue for
dynamic linking as well as static linking.  This patch makes them use
__getrlimit and __gettimeofday instead - the former needed to be newly
exported from libc.so at GLIBC_PRIVATE (and so now needs
libc_hidden_proto / libc_hidden_def), the latter was already exported.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

2014-12-05  Joseph Myers  <joseph@codesourcery.com>

	[BZ #17682]
	* resource/Versions (libc): Add __getrlimit at GLIBC_PRIVATE.
	* resource/getrlimit.c (__getrlimit): Use libc_hidden_def.
	* sysdeps/mach/hurd/getrlimit.c (__getrlimit): Likewise.
	* include/sys/resource.h (__getrlimit): Use libc_hidden_proto.
	* nptl/nptl-init.c (__pthread_initialize_minimal_internal): Use
	__getrlimit instead of getrlimit.
	* nptl/pthread_cond_timedwait.c (__pthread_cond_timedwait): Use
	__gettimeofday instead of gettimeofday.
	* nptl/pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
	Likewise.
	* nptl/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
	Likewise.
	* sysdeps/pthread/aio_misc.c (handle_fildes_io): Likewise.
	* conform/Makefile (test-xfail-POSIX2008/aio.h/linknamespace):
	Remove variable.
	(test-xfail-POSIX2008/pthread.h/linknamespace): Likewise.
	(test-xfail-POSIX2008/time.h/linknamespace): Likewise.

diff --git a/conform/Makefile b/conform/Makefile
index a73b217..f99c30c 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -424,18 +424,15 @@ test-xfail-XOPEN2K/syslog.h/linknamespace = yes
 test-xfail-XOPEN2K/ucontext.h/linknamespace = yes
 test-xfail-XOPEN2K/unistd.h/linknamespace = yes
 test-xfail-XOPEN2K/wordexp.h/linknamespace = yes
-test-xfail-POSIX2008/aio.h/linknamespace = yes
 test-xfail-POSIX2008/ctype.h/linknamespace = yes
 test-xfail-POSIX2008/dirent.h/linknamespace = yes
 test-xfail-POSIX2008/fcntl.h/linknamespace = yes
 test-xfail-POSIX2008/grp.h/linknamespace = yes
 test-xfail-POSIX2008/mqueue.h/linknamespace = yes
 test-xfail-POSIX2008/netdb.h/linknamespace = yes
-test-xfail-POSIX2008/pthread.h/linknamespace = yes
 test-xfail-POSIX2008/regex.h/linknamespace = yes
 test-xfail-POSIX2008/semaphore.h/linknamespace = yes
 test-xfail-POSIX2008/spawn.h/linknamespace = yes
-test-xfail-POSIX2008/time.h/linknamespace = yes
 test-xfail-POSIX2008/unistd.h/linknamespace = yes
 test-xfail-XOPEN2K8/dirent.h/linknamespace = yes
 test-xfail-XOPEN2K8/fcntl.h/linknamespace = yes
diff --git a/include/sys/resource.h b/include/sys/resource.h
index c35df43..1ce190f 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -9,6 +9,7 @@ libc_hidden_proto (getrlimit64)
 /* Now define the internal interfaces.  */
 extern int __getrlimit (enum __rlimit_resource __resource,
 			struct rlimit *__rlimits);
+libc_hidden_proto (__getrlimit)
 extern int __getrusage (enum __rusage_who __who, struct rusage *__usage)
 	attribute_hidden;
 
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index dcb77c5..8e90f05 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -433,7 +433,7 @@ __pthread_initialize_minimal_internal (void)
   /* Determine the default allowed stack size.  This is the size used
      in case the user does not specify one.  */
   struct rlimit limit;
-  if (getrlimit (RLIMIT_STACK, &limit) != 0
+  if (__getrlimit (RLIMIT_STACK, &limit) != 0
       || limit.rlim_cur == RLIM_INFINITY)
     /* The system limit is not usable.  Use an architecture-specific
        default.  */
diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c
index 1c53bdd..989f0a6 100644
--- a/nptl/pthread_cond_timedwait.c
+++ b/nptl/pthread_cond_timedwait.c
@@ -131,7 +131,7 @@ __pthread_cond_timedwait (cond, mutex, abstime)
 # else
 	/* Get the current time.  So far we support only one clock.  */
 	struct timeval tv;
-	(void) gettimeofday (&tv, NULL);
+	(void) __gettimeofday (&tv, NULL);
 
 	/* Convert the absolute timeout value to a relative timeout.  */
 	rt.tv_sec = abstime->tv_sec - tv.tv_sec;
diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c
index d3044fb..822ac8b 100644
--- a/nptl/pthread_rwlock_timedrdlock.c
+++ b/nptl/pthread_rwlock_timedrdlock.c
@@ -90,7 +90,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
      || !defined lll_futex_timed_wait_bitset)
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
-      (void) gettimeofday (&tv, NULL);
+      (void) __gettimeofday (&tv, NULL);
 
       /* Convert the absolute timeout value to a relative timeout.  */
       struct timespec rt;
diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c
index 560403f..22f9ad5 100644
--- a/nptl/pthread_rwlock_timedwrlock.c
+++ b/nptl/pthread_rwlock_timedwrlock.c
@@ -81,7 +81,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime)
      || !defined lll_futex_timed_wait_bitset)
       /* Get the current time.  So far we support only one clock.  */
       struct timeval tv;
-      (void) gettimeofday (&tv, NULL);
+      (void) __gettimeofday (&tv, NULL);
 
       /* Convert the absolute timeout value to a relative timeout.  */
       struct timespec rt;
diff --git a/resource/Versions b/resource/Versions
index caff6a2..d6c2cce 100644
--- a/resource/Versions
+++ b/resource/Versions
@@ -22,4 +22,7 @@ libc {
     # s*
     setrlimit64;
   }
+  GLIBC_PRIVATE {
+    __getrlimit;
+  }
 }
diff --git a/resource/getrlimit.c b/resource/getrlimit.c
index 6920622..799ee6e 100644
--- a/resource/getrlimit.c
+++ b/resource/getrlimit.c
@@ -27,6 +27,7 @@ __getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__getrlimit)
 weak_alias (__getrlimit, getrlimit)
 
 stub_warning (getrlimit)
diff --git a/sysdeps/mach/hurd/getrlimit.c b/sysdeps/mach/hurd/getrlimit.c
index 0dc7518..141135b 100644
--- a/sysdeps/mach/hurd/getrlimit.c
+++ b/sysdeps/mach/hurd/getrlimit.c
@@ -43,4 +43,5 @@ __getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
 
   return 0;
 }
+libc_hidden_def (__getrlimit)
 weak_alias (__getrlimit, getrlimit)
diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c
index 5ebceee..4aed16a 100644
--- a/sysdeps/pthread/aio_misc.c
+++ b/sysdeps/pthread/aio_misc.c
@@ -631,7 +631,7 @@ handle_fildes_io (void *arg)
 	  struct timespec wakeup_time;
 
 	  ++idle_thread_count;
-	  gettimeofday (&now, NULL);
+	  __gettimeofday (&now, NULL);
 	  wakeup_time.tv_sec = now.tv_sec + optim.aio_idle_time;
 	  wakeup_time.tv_nsec = now.tv_usec * 1000;
 	  if (wakeup_time.tv_nsec >= 1000000000)

-- 
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]