From 84a4c907b8ea52e11f8edb9ccc1050e31753e5ca Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 31 Jul 2019 15:24:58 -0400 Subject: [PATCH 1/5] add time64 symbol name redirects to public headers, under arch control a _REDIR_TIME64 macro is introduced, which the arch's alltypes.h is expected to define, to control redirection of symbol names for interfaces that involve time_t and derived types. this ensures that object files will only be linked to libc interfaces matching the ABI whose headers they were compiled against. along with time32 compat shims, which will be introduced separately, the redirection also makes it possible for a single libc (static or shared) to be used with object files produced with either the old (32-bit time_t) headers or the new ones after 64-bit time_t switchover takes place. mixing of such object files (or shared libraries) in the same program will also be possible, but must be done with care; ABI between libc and a consumer of the libc interfaces is guaranteed to match by the the symbol name redirection, but pairwise ABI between consumers of libc that define interfaces between each other in terms of time_t is not guaranteed to match. this change adds a dependency on an additional "GNU C" feature to the public headers for existing 32-bit archs, which is generally undesirable; however, the feature is one which glibc has depended on for a long time, and thus which any viable alternative compiler is going to need to provide. 64-bit archs are not affected, nor will future 32-bit archs be, regardless of whether they are "new" on the kernel side (e.g. riscv32) or just newly-added (e.g. a new sparc or xtensa port). the same applies to newly-added ABIs for existing machine-level archs. --- include/aio.h | 4 ++++ include/mqueue.h | 5 +++++ include/poll.h | 6 ++++++ include/pthread.h | 10 ++++++++++ include/sched.h | 4 ++++ include/semaphore.h | 4 ++++ include/signal.h | 8 ++++++++ include/sys/resource.h | 4 ++++ include/sys/select.h | 5 +++++ include/sys/sem.h | 6 ++++++ include/sys/socket.h | 6 ++++++ include/sys/stat.h | 9 +++++++++ include/sys/time.h | 14 ++++++++++++++ include/sys/timeb.h | 4 ++++ include/sys/timerfd.h | 5 +++++ include/sys/timex.h | 5 +++++ include/sys/wait.h | 7 +++++++ include/threads.h | 6 ++++++ include/time.h | 28 ++++++++++++++++++++++++++++ include/utime.h | 4 ++++ 20 files changed, 144 insertions(+) diff --git a/include/aio.h b/include/aio.h index 19bc28a9..482b2a70 100644 --- a/include/aio.h +++ b/include/aio.h @@ -62,6 +62,10 @@ int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sige #define off64_t off_t #endif +#if _REDIR_TIME64 +int aio_suspend() __asm__("__aio_suspend_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/mqueue.h b/include/mqueue.h index f5cbe796..49525512 100644 --- a/include/mqueue.h +++ b/include/mqueue.h @@ -30,6 +30,11 @@ ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, c int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); +#if _REDIR_TIME64 +ssize_t mq_timedreceive() __asm__("__mq_timedreceive_time64"); +int mq_timedsend() __asm__("__mq_timedsend_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/poll.h b/include/poll.h index daccc760..2aa64ab9 100644 --- a/include/poll.h +++ b/include/poll.h @@ -44,6 +44,12 @@ int poll (struct pollfd *, nfds_t, int); int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *); #endif +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +int ppoll() __asm__("__ppoll_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/pthread.h b/include/pthread.h index e238321b..252ed607 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -224,6 +224,16 @@ int pthread_tryjoin_np(pthread_t, void **); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); #endif +#if _REDIR_TIME64 +int pthread_mutex_timedlock() __asm__("__pthread_mutex_timedlock_time64"); +int pthread_cond_timedwait() __asm__("__pthread_cond_timedwait_time64"); +int pthread_rwlock_timedrdlock() __asm__("__pthread_rwlock_timedrdlock_time64"); +int pthread_rwlock_timedwrlock() __asm__("__pthread_rwlock_timedwrlock_time64"); +#ifdef _GNU_SOURCE +int pthread_timedjoin_np() __asm__("__pthread_timedjoin_np_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/sched.h b/include/sched.h index 05d40b1e..6b0e1caa 100644 --- a/include/sched.h +++ b/include/sched.h @@ -130,6 +130,10 @@ __CPU_op_func_S(XOR, ^) #endif +#if _REDIR_TIME64 +int sched_rr_get_interval() __asm__("__sched_rr_get_interval_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/semaphore.h b/include/semaphore.h index 277c47d6..0f9b3a32 100644 --- a/include/semaphore.h +++ b/include/semaphore.h @@ -29,6 +29,10 @@ int sem_trywait(sem_t *); int sem_unlink(const char *); int sem_wait(sem_t *); +#if _REDIR_TIME64 +int sem_timedwait() __asm__("__sem_timedwait_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/signal.h b/include/signal.h index 5c48cb83..5697b291 100644 --- a/include/signal.h +++ b/include/signal.h @@ -271,6 +271,14 @@ typedef int sig_atomic_t; void (*signal(int, void (*)(int)))(int); int raise(int); +#if _REDIR_TIME64 +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +int sigtimedwait() __asm__("__sigtimedwait_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/resource.h b/include/sys/resource.h index 70d793d5..7f6771f2 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -104,6 +104,10 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); #define rlim64_t rlim_t #endif +#if _REDIR_TIME64 +int getrusage() __asm__("__getrusage_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/select.h b/include/sys/select.h index d34cbf10..b5de95d3 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -35,6 +35,11 @@ int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, co #define NFDBITS (8*(int)sizeof(long)) #endif +#if _REDIR_TIME64 +int select() __asm__("__select_time64"); +int pselect() __asm__("__pselect_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/sem.h b/include/sys/sem.h index 410c8774..f10bb2e8 100644 --- a/include/sys/sem.h +++ b/include/sys/sem.h @@ -62,6 +62,12 @@ int semop(int, struct sembuf *, size_t); int semtimedop(int, struct sembuf *, size_t, const struct timespec *); #endif +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +int semtimedop() __asm__("__semtimedop_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/socket.h b/include/sys/socket.h index 8692efa7..7391d48c 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -350,6 +350,12 @@ int setsockopt (int, int, int, const void *, socklen_t); int sockatmark (int); +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +int recvmmsg() __asm__("__recvmmsg_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/stat.h b/include/sys/stat.h index 9d096624..385faafe 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -110,6 +110,15 @@ int lchmod(const char *, mode_t); #define off64_t off_t #endif +#if _REDIR_TIME64 +int stat() __asm__("__stat_time64"); +int fstat() __asm__("__fstat_time64"); +int lstat() __asm__("__lstat_time64"); +int fstatat() __asm__("__fstatat_time64"); +int futimens() __asm__("__futimens_time64"); +int utimensat() __asm__("__utimensat_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/time.h b/include/sys/time.h index c5cab814..d4c5d024 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -56,6 +56,20 @@ int adjtime (const struct timeval *, struct timeval *); (void)0 ) #endif +#if _REDIR_TIME64 +int gettimeofday() __asm__("__gettimeofday_time64"); +int getitimer() __asm__("__getitimer_time64"); +int setitimer() __asm__("__setitimer_time64"); +int utimes() __asm__("__utimes_time64"); +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int futimes() __asm__("__futimes_time64"); +int futimesat() __asm__("__futimesat_time64"); +int lutimes() __asm__("__lutimes_time64"); +int settimeofday() __asm__("__settimeofday_time64"); +int adjtime() __asm__("__adjtime64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/timeb.h b/include/sys/timeb.h index 108c1f5c..8f4a01da 100644 --- a/include/sys/timeb.h +++ b/include/sys/timeb.h @@ -16,6 +16,10 @@ struct timeb { int ftime(struct timeb *); +#if _REDIR_TIME64 +int ftime() __asm__("__ftime64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/timerfd.h b/include/sys/timerfd.h index 2794d36a..54b5e3a4 100644 --- a/include/sys/timerfd.h +++ b/include/sys/timerfd.h @@ -20,6 +20,11 @@ int timerfd_create(int, int); int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *); int timerfd_gettime(int, struct itimerspec *); +#if _REDIR_TIME64 +int timerfd_settime() __asm__("__timerfd_settime64"); +int timerfd_gettime() __asm__("__timerfd_gettime64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/timex.h b/include/sys/timex.h index 2e688880..9a28d3ed 100644 --- a/include/sys/timex.h +++ b/include/sys/timex.h @@ -91,6 +91,11 @@ struct timex { int adjtimex(struct timex *); int clock_adjtime(clockid_t, struct timex *); +#if _REDIR_TIME64 +int adjtimex() __asm__("__adjtimex_time64"); +int clock_adjtime() __asm__("__clock_adjtime64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/sys/wait.h b/include/sys/wait.h index 50c5c709..2f40f15b 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -53,6 +53,13 @@ pid_t wait4 (pid_t, int *, int, struct rusage *); #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) #define WIFCONTINUED(s) ((s) == 0xffff) +#if _REDIR_TIME64 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +pid_t wait3() __asm__("__wait3_time64"); +pid_t wait4() __asm__("__wait4_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/threads.h b/include/threads.h index 8122b3b1..7d683024 100644 --- a/include/threads.h +++ b/include/threads.h @@ -80,6 +80,12 @@ void tss_delete(tss_t); int tss_set(tss_t, void *); void *tss_get(tss_t); +#if _REDIR_TIME64 +int thrd_sleep() __asm__("__thrd_sleep_time64"); +int mtx_timedlock() __asm__("__mtx_timedlock_time64"); +int cnd_timedwait() __asm__("__cnd_timedwait_time64"); +#endif + #ifdef __cplusplus } #endif diff --git a/include/time.h b/include/time.h index 672b3fc3..7fd7f8c4 100644 --- a/include/time.h +++ b/include/time.h @@ -130,6 +130,34 @@ int stime(const time_t *); time_t timegm(struct tm *); #endif +#if _REDIR_TIME64 +time_t time() __asm__("__time64"); +double difftime() __asm__("__difftime64"); +time_t mktime() __asm__("__mktime64"); +struct tm *gmtime() __asm__("__gmtime64"); +struct tm *localtime() __asm__("__localtime64"); +char *ctime() __asm__("__ctime64"); +int timespec_get() __asm__("__timespec_get_time64"); +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +struct tm *gmtime_r() __asm__("__gmtime64_r"); +struct tm *localtime_r() __asm__("__localtime64_r"); +char *ctime_r() __asm__("__ctime64_r"); +int nanosleep() __asm__("__nanosleep_time64"); +int clock_getres() __asm__("__clock_getres_time64"); +int clock_gettime() __asm__("__clock_gettime64"); +int clock_settime() __asm__("__clock_settime64"); +int clock_nanosleep() __asm__("__clock_nanosleep_time64"); +int timer_settime() __asm__("__timer_settime64"); +int timer_gettime() __asm__("__timer_gettime64"); +#endif +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +int stime() __asm__("__stime64"); +time_t timegm() __asm__("__timegm_time64"); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/include/utime.h b/include/utime.h index dd5ff927..7fc491de 100644 --- a/include/utime.h +++ b/include/utime.h @@ -16,6 +16,10 @@ struct utimbuf { int utime (const char *, const struct utimbuf *); +#if _REDIR_TIME64 +int utime() __asm__("__utime64"); +#endif + #ifdef __cplusplus } #endif -- 2.21.0