Skip to content

Commit 1febd21

Browse files
committed
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.
1 parent f7f12e4 commit 1febd21

21 files changed

+150
-0
lines changed

include/aio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sige
6262
#define off64_t off_t
6363
#endif
6464

65+
#if _REDIR_TIME64
66+
__REDIR(aio_suspend, __aio_suspend_time64);
67+
#endif
68+
6569
#ifdef __cplusplus
6670
}
6771
#endif

include/features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@
3535
#define _Noreturn
3636
#endif
3737

38+
#define __REDIR(x,y) __typeof__(x) x __asm__(#y)
39+
3840
#endif

include/mqueue.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, c
3030
int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *);
3131
int mq_unlink(const char *);
3232

33+
#if _REDIR_TIME64
34+
__REDIR(mq_timedreceive, __mq_timedreceive_time64);
35+
__REDIR(mq_timedsend, __mq_timedsend_time64);
36+
#endif
37+
3338
#ifdef __cplusplus
3439
}
3540
#endif

include/poll.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ int poll (struct pollfd *, nfds_t, int);
4444
int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
4545
#endif
4646

47+
#if _REDIR_TIME64
48+
#ifdef _GNU_SOURCE
49+
__REDIR(ppoll, __ppoll_time64);
50+
#endif
51+
#endif
52+
4753
#ifdef __cplusplus
4854
}
4955
#endif

include/pthread.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ int pthread_tryjoin_np(pthread_t, void **);
224224
int pthread_timedjoin_np(pthread_t, void **, const struct timespec *);
225225
#endif
226226

227+
#if _REDIR_TIME64
228+
__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64);
229+
__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64);
230+
__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64);
231+
__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64);
232+
#ifdef _GNU_SOURCE
233+
__REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64);
234+
#endif
235+
#endif
236+
227237
#ifdef __cplusplus
228238
}
229239
#endif

include/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ __CPU_op_func_S(XOR, ^)
133133

134134
#endif
135135

136+
#if _REDIR_TIME64
137+
__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64);
138+
#endif
139+
136140
#ifdef __cplusplus
137141
}
138142
#endif

include/semaphore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ int sem_trywait(sem_t *);
2929
int sem_unlink(const char *);
3030
int sem_wait(sem_t *);
3131

32+
#if _REDIR_TIME64
33+
__REDIR(sem_timedwait, __sem_timedwait_time64);
34+
#endif
35+
3236
#ifdef __cplusplus
3337
}
3438
#endif

include/signal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ typedef int sig_atomic_t;
271271
void (*signal(int, void (*)(int)))(int);
272272
int raise(int);
273273

274+
#if _REDIR_TIME64
275+
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
276+
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
277+
|| defined(_BSD_SOURCE)
278+
__REDIR(sigtimedwait, __sigtimedwait_time64);
279+
#endif
280+
#endif
281+
274282
#ifdef __cplusplus
275283
}
276284
#endif

include/sys/resource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
104104
#define rlim64_t rlim_t
105105
#endif
106106

107+
#if _REDIR_TIME64
108+
__REDIR(getrusage, __getrusage_time64);
109+
#endif
110+
107111
#ifdef __cplusplus
108112
}
109113
#endif

include/sys/select.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, co
3535
#define NFDBITS (8*(int)sizeof(long))
3636
#endif
3737

38+
#if _REDIR_TIME64
39+
__REDIR(select, __select_time64);
40+
__REDIR(pselect, __pselect_time64);
41+
#endif
42+
3843
#ifdef __cplusplus
3944
}
4045
#endif

0 commit comments

Comments
 (0)