提交 1febd21d 编写于 作者: R Rich Felker

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.
上级 f7f12e4c
......@@ -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
__REDIR(aio_suspend, __aio_suspend_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -35,4 +35,6 @@
#define _Noreturn
#endif
#define __REDIR(x,y) __typeof__(x) x __asm__(#y)
#endif
......@@ -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
__REDIR(mq_timedreceive, __mq_timedreceive_time64);
__REDIR(mq_timedsend, __mq_timedsend_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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
__REDIR(ppoll, __ppoll_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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
__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64);
__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64);
__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64);
__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64);
#ifdef _GNU_SOURCE
__REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -133,6 +133,10 @@ __CPU_op_func_S(XOR, ^)
#endif
#if _REDIR_TIME64
__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -29,6 +29,10 @@ int sem_trywait(sem_t *);
int sem_unlink(const char *);
int sem_wait(sem_t *);
#if _REDIR_TIME64
__REDIR(sem_timedwait, __sem_timedwait_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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)
__REDIR(sigtimedwait, __sigtimedwait_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -104,6 +104,10 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
#define rlim64_t rlim_t
#endif
#if _REDIR_TIME64
__REDIR(getrusage, __getrusage_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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
__REDIR(select, __select_time64);
__REDIR(pselect, __pselect_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -60,6 +60,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
__REDIR(semtimedop, __semtimedop_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -350,6 +350,12 @@ int setsockopt (int, int, int, const void *, socklen_t);
int sockatmark (int);
#if _REDIR_TIME64
#ifdef _GNU_SOURCE
__REDIR(recvmmsg, __recvmmsg_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -110,6 +110,15 @@ int lchmod(const char *, mode_t);
#define off64_t off_t
#endif
#if _REDIR_TIME64
__REDIR(stat, __stat_time64);
__REDIR(fstat, __fstat_time64);
__REDIR(lstat, __lstat_time64);
__REDIR(fstatat, __fstatat_time64);
__REDIR(futimens, __futimens_time64);
__REDIR(utimensat, __utimensat_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -56,6 +56,20 @@ int adjtime (const struct timeval *, struct timeval *);
(void)0 )
#endif
#if _REDIR_TIME64
__REDIR(gettimeofday, __gettimeofday_time64);
__REDIR(getitimer, __getitimer_time64);
__REDIR(setitimer, __setitimer_time64);
__REDIR(utimes, __utimes_time64);
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
__REDIR(futimes, __futimes_time64);
__REDIR(futimesat, __futimesat_time64);
__REDIR(lutimes, __lutimes_time64);
__REDIR(settimeofday, __settimeofday_time64);
__REDIR(adjtime, __adjtime64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -4,6 +4,8 @@
extern "C" {
#endif
#include <features.h>
#define __NEED_time_t
#include <bits/alltypes.h>
......@@ -16,6 +18,10 @@ struct timeb {
int ftime(struct timeb *);
#if _REDIR_TIME64
__REDIR(ftime, __ftime64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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
__REDIR(timerfd_settime, __timerfd_settime64);
__REDIR(timerfd_gettime, __timerfd_gettime64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -91,6 +91,11 @@ struct timex {
int adjtimex(struct timex *);
int clock_adjtime(clockid_t, struct timex *);
#if _REDIR_TIME64
__REDIR(adjtimex, __adjtimex_time64);
__REDIR(clock_adjtime, __clock_adjtime64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -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)
__REDIR(wait3, __wait3_time64);
__REDIR(wait4, __wait4_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -80,6 +80,12 @@ void tss_delete(tss_t);
int tss_set(tss_t, void *);
void *tss_get(tss_t);
#if _REDIR_TIME64
__REDIR(thrd_sleep, __thrd_sleep_time64);
__REDIR(mtx_timedlock, __mtx_timedlock_time64);
__REDIR(cnd_timedwait, __cnd_timedwait_time64);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -130,6 +130,34 @@ int stime(const time_t *);
time_t timegm(struct tm *);
#endif
#if _REDIR_TIME64
__REDIR(time, __time64);
__REDIR(difftime, __difftime64);
__REDIR(mktime, __mktime64);
__REDIR(gmtime, __gmtime64);
__REDIR(localtime, __localtime64);
__REDIR(ctime, __ctime64);
__REDIR(timespec_get, __timespec_get_time64);
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|| defined(_BSD_SOURCE)
__REDIR(gmtime_r, __gmtime64_r);
__REDIR(localtime_r, __localtime64_r);
__REDIR(ctime_r, __ctime64_r);
__REDIR(nanosleep, __nanosleep_time64);
__REDIR(clock_getres, __clock_getres_time64);
__REDIR(clock_gettime, __clock_gettime64);
__REDIR(clock_settime, __clock_settime64);
__REDIR(clock_nanosleep, __clock_nanosleep_time64);
__REDIR(timer_settime, __timer_settime64);
__REDIR(timer_gettime, __timer_gettime64);
#endif
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
__REDIR(stime, __stime64);
__REDIR(timegm, __timegm_time64);
#endif
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -5,6 +5,8 @@
extern "C" {
#endif
#include <features.h>
#define __NEED_time_t
#include <bits/alltypes.h>
......@@ -16,6 +18,10 @@ struct utimbuf {
int utime (const char *, const struct utimbuf *);
#if _REDIR_TIME64
__REDIR(utime, __utime64);
#endif
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册