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]

[PATCH] Add hidden definition for __clock_gettime


Hi,

__clock_gettime is an exported symbol (GLIBC_PRIVATE) so any reference
to it currently results in an extra PLT reference.  This probably
never figured because there's no code that uses this.  There's
timespec_get, but it doesn't finally result in a function call in
x86_64 (due to the overloaded definition resulting in a direct VDSO
call).  I also quickly looked on ppc64 and even there the
clock_gettime call is optimized out, giving us a false positive.

This patch adds a libc_hidden_proto and libc_hidden_def for
__clock_gettime so that a future user of __clock_gettime (I'm writing
one now) does not cause an extra PLT reference.  Verified that this
does not cause any regressions on x86_64.  OK to commit?

Siddhesh

	* include/time.h (__clock_gettime): Add libc_hidden_proto.
	* rt/clock_gettime.c (__clock_gettime): Add libc_hidden_def.
	* sysdeps/unix/clock_gettime.c (__clock_gettime): Likewise.

diff --git a/include/time.h b/include/time.h
index 9be15b9..8dd10dc 100644
--- a/include/time.h
+++ b/include/time.h
@@ -21,6 +21,7 @@ libc_hidden_proto (strptime)
 
 extern __typeof (clock_getres) __clock_getres;
 extern __typeof (clock_gettime) __clock_gettime;
+libc_hidden_proto (__clock_gettime)
 extern __typeof (clock_settime) __clock_settime;
 extern __typeof (clock_nanosleep) __clock_nanosleep;
 extern __typeof (clock_getcpuclockid) __clock_getcpuclockid;
diff --git a/rt/clock_gettime.c b/rt/clock_gettime.c
index cc7936d..1a530ae 100644
--- a/rt/clock_gettime.c
+++ b/rt/clock_gettime.c
@@ -27,4 +27,5 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
   return -1;
 }
 strong_alias (clock_gettime, __clock_gettime)
+libc_hidden_def (__clock_gettime)
 stub_warning (clock_gettime)
diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index 1c64f07..71616ef 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -133,3 +133,4 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)
   return retval;
 }
 strong_alias (clock_gettime, __clock_gettime)
+libc_hidden_def (__clock_gettime)


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