[09/12] Finish move of clock_* functions to libc.

Message ID 20190820132152.24100-10-zackw@panix.com
State Superseded
Headers

Commit Message

Zack Weinberg Aug. 20, 2019, 1:21 p.m. UTC
  In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
clock_gettime, clock_nanosleep, and clock_settime were moved from
librt.so to libc.so, leaving compatibility stubs behind.  Now that the
dynamic linker no longer insists on finding versioned symbols in the
same library that originally defined them, we do not need the stubs
anymore, and this means we don’t need GLIBC_PRIVATE __-prefix aliases for
most of the functions anymore either.  (clock_gettime is still called
all over the place internally and therefore still needs one.)

While I’m at it, move the clock_*.c files and their tests from rt/ to
time/.

	* rt/clock-compat.c: Delete file.
	* rt/clock_getcpuclockid.c: Move to time/clock_getcpuclockid.c.
	* rt/clock_getres.c: Move to time/clock_getres.c.
	* rt/clock_gettime.c: Move to time/clock_gettime.c.
	* rt/clock_nanosleep.c: Move to time/clock_nanosleep.c.
	* rt/clock_settime.c: Move to time/clock_settime.c.
	* rt/tst-clock.c: Move to time/tst-clock.c.
	* rt/tst-clock2.c: Move to time/tst-clock2.c.
	* rt/tst-clock_nanosleep.c: Move to time/tst-clock_nanosleep.c.
	* rt/tst-cpuclock1.c: Move to time/tst-cpuclock1.c.
	* include/time.h: Remove internal prototypes for __clock_getres,
	__clock_nanosleep, and __clock_getcpuclockid.

	* rt/Makefile (routines, clock-routines): Delete.
	(librt-routines): Remove clock-compat.
	(tests): Remove tst-clock, tst-clock2, tst-clock_nanosleep, and
	tst-cpuclock1.
	* time/Makefile (routines): Add clock_getcpuclockid, clock_getres,
	clock_gettime, clock_settime, and clock_nanosleep.
	(tests): Add tst-clock, tst-clock2, tst-clock_nanosleep, and
	tst-cpuclock1.

	* rt/Versions (libc GLIBC_PRIVATE): Remove __clock_getres,
	__clock_settime, __clock_getcpuclockid, and __clock_nanosleep.
	(librt GLIBC_2.2): Remove clock_getres, clock_gettime,
	clock_settime, clock_getcpuclockid, and clock_nanosleep.
	* sysdeps/**/librt.abilist: Update to match.
---
 include/time.h                                |  3 -
 rt/Makefile                                   | 15 ++---
 rt/Versions                                   |  7 +--
 rt/clock-compat.c                             | 63 -------------------
 sysdeps/mach/hurd/i386/librt.abilist          |  5 --
 sysdeps/unix/sysv/linux/alpha/librt.abilist   |  5 --
 sysdeps/unix/sysv/linux/arm/librt.abilist     |  5 --
 sysdeps/unix/sysv/linux/hppa/librt.abilist    |  5 --
 sysdeps/unix/sysv/linux/i386/librt.abilist    |  5 --
 sysdeps/unix/sysv/linux/ia64/librt.abilist    |  5 --
 .../sysv/linux/m68k/coldfire/librt.abilist    |  5 --
 .../unix/sysv/linux/m68k/m680x0/librt.abilist |  5 --
 .../unix/sysv/linux/microblaze/librt.abilist  |  5 --
 .../unix/sysv/linux/mips/mips32/librt.abilist |  5 --
 .../unix/sysv/linux/mips/mips64/librt.abilist |  5 --
 .../linux/powerpc/powerpc32/librt.abilist     |  5 --
 .../linux/powerpc/powerpc64/be/librt.abilist  |  5 --
 .../sysv/linux/s390/s390-32/librt.abilist     |  5 --
 .../sysv/linux/s390/s390-64/librt.abilist     |  5 --
 sysdeps/unix/sysv/linux/sh/librt.abilist      |  5 --
 .../sysv/linux/sparc/sparc32/librt.abilist    |  5 --
 .../sysv/linux/sparc/sparc64/librt.abilist    |  5 --
 .../unix/sysv/linux/x86_64/64/librt.abilist   |  5 --
 .../unix/sysv/linux/x86_64/x32/librt.abilist  |  5 --
 time/Makefile                                 |  8 ++-
 {rt => time}/clock_getcpuclockid.c            |  0
 {rt => time}/clock_getres.c                   |  0
 {rt => time}/clock_gettime.c                  |  0
 {rt => time}/clock_nanosleep.c                |  0
 {rt => time}/clock_settime.c                  |  0
 {rt => time}/tst-clock.c                      |  0
 {rt => time}/tst-clock2.c                     |  0
 {rt => time}/tst-clock_nanosleep.c            |  0
 {rt => time}/tst-cpuclock1.c                  |  0
 34 files changed, 11 insertions(+), 185 deletions(-)
 delete mode 100644 rt/clock-compat.c
 rename {rt => time}/clock_getcpuclockid.c (100%)
 rename {rt => time}/clock_getres.c (100%)
 rename {rt => time}/clock_gettime.c (100%)
 rename {rt => time}/clock_nanosleep.c (100%)
 rename {rt => time}/clock_settime.c (100%)
 rename {rt => time}/tst-clock.c (100%)
 rename {rt => time}/tst-clock2.c (100%)
 rename {rt => time}/tst-clock_nanosleep.c (100%)
 rename {rt => time}/tst-cpuclock1.c (100%)
  

Comments

Joseph Myers Aug. 20, 2019, 3:13 p.m. UTC | #1
On Tue, 20 Aug 2019, Zack Weinberg wrote:

> In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
> clock_gettime, clock_nanosleep, and clock_settime were moved from
> librt.so to libc.so, leaving compatibility stubs behind.  Now that the
> dynamic linker no longer insists on finding versioned symbols in the
> same library that originally defined them, we do not need the stubs
> anymore, and this means we don’t need GLIBC_PRIVATE __-prefix aliases for
> most of the functions anymore either.  (clock_gettime is still called
> all over the place internally and therefore still needs one.)

But my understanding is that moving a function to libc like that only 
works if libc has the symbol *at the same version* as it had in the 
library from which it was removed.  And I don't see anything in this patch 
to add the older symbol version for these functions to libc (in the 
implementation and the ABI test baselines) (so libc would then have these 
functions at two symbol versions on most platforms, with both versions 
pointing to the same function implementations).
  
Zack Weinberg Aug. 20, 2019, 3:18 p.m. UTC | #2
On Tue, Aug 20, 2019 at 11:13 AM Joseph Myers <joseph@codesourcery.com> wrote:
> On Tue, 20 Aug 2019, Zack Weinberg wrote:
>
> > In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
> > clock_gettime, clock_nanosleep, and clock_settime were moved from
> > librt.so to libc.so, leaving compatibility stubs behind.  Now that the
> > dynamic linker no longer insists on finding versioned symbols in the
> > same library that originally defined them, we do not need the stubs
> > anymore, and this means we don’t need GLIBC_PRIVATE __-prefix aliases for
> > most of the functions anymore either.  (clock_gettime is still called
> > all over the place internally and therefore still needs one.)
>
> But my understanding is that moving a function to libc like that only
> works if libc has the symbol *at the same version* as it had in the
> library from which it was removed.  And I don't see anything in this patch
> to add the older symbol version for these functions to libc (in the
> implementation and the ABI test baselines) (so libc would then have these
> functions at two symbol versions on most platforms, with both versions
> pointing to the same function implementations).

I thought so too, at first, but Florian's patches to remove forwarding
stubs from libpthread have not been adding older symbol versions to
libc.so either, so that made me think it wasn't necessary after all.
Florian, can you comment?

zw
  
Florian Weimer Aug. 20, 2019, 3:21 p.m. UTC | #3
* Joseph Myers:

> On Tue, 20 Aug 2019, Zack Weinberg wrote:
>
>> In glibc 2.17, the functions clock_getcpuclockid, clock_getres,
>> clock_gettime, clock_nanosleep, and clock_settime were moved from
>> librt.so to libc.so, leaving compatibility stubs behind.  Now that the
>> dynamic linker no longer insists on finding versioned symbols in the
>> same library that originally defined them, we do not need the stubs
>> anymore, and this means we don’t need GLIBC_PRIVATE __-prefix aliases for
>> most of the functions anymore either.  (clock_gettime is still called
>> all over the place internally and therefore still needs one.)
>
> But my understanding is that moving a function to libc like that only 
> works if libc has the symbol *at the same version* as it had in the 
> library from which it was removed.

Correct.  We also need to add a new symbol version (at the next glibc
release) for the symbols, so that applications which use the functions
from libc directly are correctly depending on a glibc version which
actually has these symbols in libc.  My understanding is that this part
already happened in glibc 2.17, so the new symbol versions are not
required in this particularly instance, but the compatibility symbols
are definitely needed.

The pthread cleanup patches I posted replace existing forwarders, which
were added at the same time to libc and libpthread, so these
requirements are not apparent in these patches.

Thanks,
Florian
  
Zack Weinberg Aug. 20, 2019, 3:24 p.m. UTC | #4
On Tue, Aug 20, 2019 at 11:21 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> The pthread cleanup patches I posted replace existing forwarders, which
> were added at the same time to libc and libpthread, so these
> requirements are not apparent in these patches.

Oh, I see.  I'll fix this in the next revision of the patch series.

zw
  

Patch

diff --git a/include/time.h b/include/time.h
index c0421c7a28..dcf91855ad 100644
--- a/include/time.h
+++ b/include/time.h
@@ -18,13 +18,10 @@  libc_hidden_proto (localtime)
 libc_hidden_proto (strftime)
 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;
 libc_hidden_proto (__clock_settime)
-extern __typeof (clock_nanosleep) __clock_nanosleep;
-extern __typeof (clock_getcpuclockid) __clock_getcpuclockid;
 
 /* Now define the internal interfaces.  */
 struct tm;
diff --git a/rt/Makefile b/rt/Makefile
index 9ea8394565..e6fbc32438 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -28,9 +28,6 @@  aio-routines   := aio_cancel aio_error aio_fsync aio_misc aio_read	\
 		  aio_read64 aio_return aio_suspend aio_write		\
 		  aio_write64 lio_listio lio_listio64 aio_sigqueue	\
 		  aio_notify
-clock-routines := clock_getcpuclockid					\
-		  clock_getres clock_gettime clock_settime		\
-		  clock_nanosleep
 timer-routines := timer_create timer_delete timer_getoverr		\
 		  timer_gettime timer_settime
 shm-routines   := shm_open shm_unlink
@@ -38,22 +35,18 @@  mq-routines    := mq_open mq_close mq_unlink mq_getattr mq_setattr	\
 		  mq_notify mq_send mq_receive mq_timedsend		\
 		  mq_timedreceive
 
-routines = $(clock-routines)
-
 librt-routines = $(aio-routines) \
 		 $(timer-routines) \
-		 $(shm-routines) $(mq-routines) \
-		 clock-compat
+		 $(shm-routines) $(mq-routines)
 
-tests := tst-shm tst-clock tst-clock_nanosleep tst-timer tst-timer2 \
+tests := tst-shm tst-timer tst-timer2 \
 	 tst-aio tst-aio64 tst-aio2 tst-aio3 tst-aio4 tst-aio5 tst-aio6 \
 	 tst-aio7 tst-aio8 tst-aio9 tst-aio10 \
 	 tst-mqueue1 tst-mqueue2 tst-mqueue3 tst-mqueue4 \
 	 tst-mqueue5 tst-mqueue6 tst-mqueue7 tst-mqueue8 tst-mqueue9 \
 	 tst-timer3 tst-timer4 tst-timer5 \
-	 tst-cpuclock1 tst-cpuclock2 \
-	 tst-cputimer1 tst-cputimer2 tst-cputimer3 \
-	 tst-clock2 tst-shm-cancel
+	 tst-cpuclock2 tst-cputimer1 tst-cputimer2 tst-cputimer3 \
+	 tst-shm-cancel
 
 extra-libs := librt
 extra-libs-others := $(extra-libs)
diff --git a/rt/Versions b/rt/Versions
index 91e3fd2a20..c74d5162a1 100644
--- a/rt/Versions
+++ b/rt/Versions
@@ -5,8 +5,7 @@  libc {
     clock_nanosleep;
   }
   GLIBC_PRIVATE {
-    __clock_getres; __clock_gettime; __clock_settime; __clock_getcpuclockid;
-    __clock_nanosleep;
+    __clock_gettime;
   }
 }
 
@@ -18,10 +17,6 @@  librt {
     aio_suspend64; aio_write; aio_write64; lio_listio; lio_listio64;
   }
   GLIBC_2.2 {
-    # These have moved to libc and are still here only for compatibility.
-    clock_getres; clock_gettime; clock_settime; clock_getcpuclockid;
-    clock_nanosleep;
-
     # s*
     shm_open; shm_unlink;
 
diff --git a/rt/clock-compat.c b/rt/clock-compat.c
deleted file mode 100644
index d8ced3cdc1..0000000000
--- a/rt/clock-compat.c
+++ /dev/null
@@ -1,63 +0,0 @@ 
-/* ABI compatibility redirects for clock_* symbols in librt.
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <shlib-compat.h>
-
-/* The clock_* symbols were originally defined in librt and so
-   are part of its ABI.  As of 2.17, they have moved to libc.
-   So we supply definitions for librt that just redirect to
-   their libc counterparts.  */
-
-#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_17)
-
-#include <time.h>
-
-#if HAVE_IFUNC
-# undef INIT_ARCH
-# define INIT_ARCH()
-# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name) \
-    compat_symbol (librt, name, name, GLIBC_2_2);
-#else
-# define COMPAT_REDIRECT(name, proto, arglist)				      \
-  int									      \
-  name proto								      \
-  {									      \
-    return __##name arglist;						      \
-  }									      \
-  compat_symbol (librt, name, name, GLIBC_2_2);
-#endif
-
-COMPAT_REDIRECT (clock_getres,
-		 (clockid_t clock_id, struct timespec *res),
-		 (clock_id, res))
-COMPAT_REDIRECT (clock_gettime,
-		 (clockid_t clock_id, struct timespec *tp),
-		 (clock_id, tp))
-COMPAT_REDIRECT (clock_settime,
-		 (clockid_t clock_id, const struct timespec *tp),
-		 (clock_id, tp))
-COMPAT_REDIRECT (clock_getcpuclockid,
-		 (pid_t pid, clockid_t *clock_id),
-		 (pid, clock_id))
-COMPAT_REDIRECT (clock_nanosleep,
-		 (clockid_t clock_id, int flags,
-		  const struct timespec *req,
-		  struct timespec *rem),
-		 (clock_id, flags, req, rem))
-
-#endif
diff --git a/sysdeps/mach/hurd/i386/librt.abilist b/sysdeps/mach/hurd/i386/librt.abilist
index d5fe32b3a9..3726e41f06 100644
--- a/sysdeps/mach/hurd/i386/librt.abilist
+++ b/sysdeps/mach/hurd/i386/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.2.6 aio_suspend F
 GLIBC_2.2.6 aio_suspend64 F
 GLIBC_2.2.6 aio_write F
 GLIBC_2.2.6 aio_write64 F
-GLIBC_2.2.6 clock_getcpuclockid F
-GLIBC_2.2.6 clock_getres F
-GLIBC_2.2.6 clock_gettime F
-GLIBC_2.2.6 clock_nanosleep F
-GLIBC_2.2.6 clock_settime F
 GLIBC_2.2.6 lio_listio F
 GLIBC_2.2.6 lio_listio64 F
 GLIBC_2.2.6 shm_open F
diff --git a/sysdeps/unix/sysv/linux/alpha/librt.abilist b/sysdeps/unix/sysv/linux/alpha/librt.abilist
index d7a049cf60..71f86e03ce 100644
--- a/sysdeps/unix/sysv/linux/alpha/librt.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/arm/librt.abilist b/sysdeps/unix/sysv/linux/arm/librt.abilist
index cfbbd27557..3c0647b251 100644
--- a/sysdeps/unix/sysv/linux/arm/librt.abilist
+++ b/sysdeps/unix/sysv/linux/arm/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.4 aio_suspend F
 GLIBC_2.4 aio_suspend64 F
 GLIBC_2.4 aio_write F
 GLIBC_2.4 aio_write64 F
-GLIBC_2.4 clock_getcpuclockid F
-GLIBC_2.4 clock_getres F
-GLIBC_2.4 clock_gettime F
-GLIBC_2.4 clock_nanosleep F
-GLIBC_2.4 clock_settime F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.4 mq_close F
diff --git a/sysdeps/unix/sysv/linux/hppa/librt.abilist b/sysdeps/unix/sysv/linux/hppa/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/hppa/librt.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/i386/librt.abilist b/sysdeps/unix/sysv/linux/i386/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/i386/librt.abilist
+++ b/sysdeps/unix/sysv/linux/i386/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/ia64/librt.abilist b/sysdeps/unix/sysv/linux/ia64/librt.abilist
index 804622a14a..08384c9065 100644
--- a/sysdeps/unix/sysv/linux/ia64/librt.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
index cfbbd27557..3c0647b251 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.4 aio_suspend F
 GLIBC_2.4 aio_suspend64 F
 GLIBC_2.4 aio_write F
 GLIBC_2.4 aio_write64 F
-GLIBC_2.4 clock_getcpuclockid F
-GLIBC_2.4 clock_getres F
-GLIBC_2.4 clock_gettime F
-GLIBC_2.4 clock_nanosleep F
-GLIBC_2.4 clock_settime F
 GLIBC_2.4 lio_listio F
 GLIBC_2.4 lio_listio64 F
 GLIBC_2.4 mq_close F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/microblaze/librt.abilist b/sysdeps/unix/sysv/linux/microblaze/librt.abilist
index fb85d8729e..889dfbc0ee 100644
--- a/sysdeps/unix/sysv/linux/microblaze/librt.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/librt.abilist
@@ -14,11 +14,6 @@  GLIBC_2.18 aio_suspend F
 GLIBC_2.18 aio_suspend64 F
 GLIBC_2.18 aio_write F
 GLIBC_2.18 aio_write64 F
-GLIBC_2.18 clock_getcpuclockid F
-GLIBC_2.18 clock_getres F
-GLIBC_2.18 clock_gettime F
-GLIBC_2.18 clock_nanosleep F
-GLIBC_2.18 clock_settime F
 GLIBC_2.18 lio_listio F
 GLIBC_2.18 lio_listio64 F
 GLIBC_2.18 mq_close F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
index 84837c8a2e..1539c1cef9 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.2 aio_suspend F
 GLIBC_2.2 aio_suspend64 F
 GLIBC_2.2 aio_write F
 GLIBC_2.2 aio_write64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 lio_listio F
 GLIBC_2.2 lio_listio64 F
 GLIBC_2.2 shm_open F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/librt.abilist b/sysdeps/unix/sysv/linux/mips/mips64/librt.abilist
index 84837c8a2e..1539c1cef9 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/librt.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.2 aio_suspend F
 GLIBC_2.2 aio_suspend64 F
 GLIBC_2.2 aio_write F
 GLIBC_2.2 aio_write64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 lio_listio F
 GLIBC_2.2 lio_listio64 F
 GLIBC_2.2 shm_open F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/librt.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/librt.abilist
index e76b7eb495..6a5bd96963 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/librt.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.3 aio_suspend F
 GLIBC_2.3 aio_suspend64 F
 GLIBC_2.3 aio_write F
 GLIBC_2.3 aio_write64 F
-GLIBC_2.3 clock_getcpuclockid F
-GLIBC_2.3 clock_getres F
-GLIBC_2.3 clock_gettime F
-GLIBC_2.3 clock_nanosleep F
-GLIBC_2.3 clock_settime F
 GLIBC_2.3 lio_listio F
 GLIBC_2.3 lio_listio64 F
 GLIBC_2.3 shm_open F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/librt.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/librt.abilist
index 41be3bb84b..5905498a48 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/librt.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.2 aio_suspend F
 GLIBC_2.2 aio_suspend64 F
 GLIBC_2.2 aio_write F
 GLIBC_2.2 aio_write64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 lio_listio F
 GLIBC_2.2 lio_listio64 F
 GLIBC_2.2 shm_open F
diff --git a/sysdeps/unix/sysv/linux/sh/librt.abilist b/sysdeps/unix/sysv/linux/sh/librt.abilist
index 595f1b712a..bb03781dcc 100644
--- a/sysdeps/unix/sysv/linux/sh/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sh/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
index cb874f4147..38f0aad791 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/librt.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/librt.abilist
index d7a049cf60..71f86e03ce 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/librt.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/librt.abilist
@@ -15,11 +15,6 @@  GLIBC_2.1 aio_write F
 GLIBC_2.1 aio_write64 F
 GLIBC_2.1 lio_listio F
 GLIBC_2.1 lio_listio64 F
-GLIBC_2.2 clock_getcpuclockid F
-GLIBC_2.2 clock_getres F
-GLIBC_2.2 clock_gettime F
-GLIBC_2.2 clock_nanosleep F
-GLIBC_2.2 clock_settime F
 GLIBC_2.2 shm_open F
 GLIBC_2.2 shm_unlink F
 GLIBC_2.2 timer_create F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/librt.abilist b/sysdeps/unix/sysv/linux/x86_64/64/librt.abilist
index e2e8b60bf8..95e3f22daa 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/librt.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/librt.abilist
@@ -13,11 +13,6 @@  GLIBC_2.2.5 aio_suspend F
 GLIBC_2.2.5 aio_suspend64 F
 GLIBC_2.2.5 aio_write F
 GLIBC_2.2.5 aio_write64 F
-GLIBC_2.2.5 clock_getcpuclockid F
-GLIBC_2.2.5 clock_getres F
-GLIBC_2.2.5 clock_gettime F
-GLIBC_2.2.5 clock_nanosleep F
-GLIBC_2.2.5 clock_settime F
 GLIBC_2.2.5 lio_listio F
 GLIBC_2.2.5 lio_listio64 F
 GLIBC_2.2.5 shm_open F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/librt.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/librt.abilist
index 94e84e4dcf..66969fb9ab 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/librt.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/librt.abilist
@@ -14,11 +14,6 @@  GLIBC_2.16 aio_suspend F
 GLIBC_2.16 aio_suspend64 F
 GLIBC_2.16 aio_write F
 GLIBC_2.16 aio_write64 F
-GLIBC_2.16 clock_getcpuclockid F
-GLIBC_2.16 clock_getres F
-GLIBC_2.16 clock_gettime F
-GLIBC_2.16 clock_nanosleep F
-GLIBC_2.16 clock_settime F
 GLIBC_2.16 lio_listio F
 GLIBC_2.16 lio_listio64 F
 GLIBC_2.16 mq_close F
diff --git a/time/Makefile b/time/Makefile
index d78bff85e6..7dddb5a858 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -36,14 +36,18 @@  routines := offtime asctime clock ctime ctime_r difftime \
 	    stime dysize timegm ftime			 \
 	    getdate strptime strptime_l			 \
 	    strftime wcsftime strftime_l wcsftime_l	 \
-	    timespec_get settimezone
+	    timespec_get settimezone 			 \
+	    clock_getcpuclockid clock_getres 		 \
+	    clock_gettime clock_settime clock_nanosleep
+
 aux :=	    era alt_digit lc-time-cleanup
 
 tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
 	   tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
 	   tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \
-	   tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3
+	   tst-tzname tst-y2039 bug-mktime4 tst-strftime2 tst-strftime3 \
+	   tst-clock tst-clock2 tst-clock_nanosleep tst-cpuclock1
 
 include ../Rules
 
diff --git a/rt/clock_getcpuclockid.c b/time/clock_getcpuclockid.c
similarity index 100%
rename from rt/clock_getcpuclockid.c
rename to time/clock_getcpuclockid.c
diff --git a/rt/clock_getres.c b/time/clock_getres.c
similarity index 100%
rename from rt/clock_getres.c
rename to time/clock_getres.c
diff --git a/rt/clock_gettime.c b/time/clock_gettime.c
similarity index 100%
rename from rt/clock_gettime.c
rename to time/clock_gettime.c
diff --git a/rt/clock_nanosleep.c b/time/clock_nanosleep.c
similarity index 100%
rename from rt/clock_nanosleep.c
rename to time/clock_nanosleep.c
diff --git a/rt/clock_settime.c b/time/clock_settime.c
similarity index 100%
rename from rt/clock_settime.c
rename to time/clock_settime.c
diff --git a/rt/tst-clock.c b/time/tst-clock.c
similarity index 100%
rename from rt/tst-clock.c
rename to time/tst-clock.c
diff --git a/rt/tst-clock2.c b/time/tst-clock2.c
similarity index 100%
rename from rt/tst-clock2.c
rename to time/tst-clock2.c
diff --git a/rt/tst-clock_nanosleep.c b/time/tst-clock_nanosleep.c
similarity index 100%
rename from rt/tst-clock_nanosleep.c
rename to time/tst-clock_nanosleep.c
diff --git a/rt/tst-cpuclock1.c b/time/tst-cpuclock1.c
similarity index 100%
rename from rt/tst-cpuclock1.c
rename to time/tst-cpuclock1.c