add time32 ABI compat shims, compat source tree

these files provide the symbols for the traditional 32-bit time_t ABI
on existing 32-bit archs by wrapping the real, internal versions of
the corresponding functions, which always work with 64-bit time_t.
they are written to be as agnostic as possible to the implementation
details of the real functions, so that they can be written once and
mostly forgotten, but they are aware of details of the old (and
sometimes new) ABI, which is okay since ABI is fixed and cannot
change.

a new compat tree is added, separate from src, which the Makefile does
not see or use now, but which archs will be able to add to the build
process. we could also consider moving other things that are compat
shims here, like functions which are purely for glibc-ABI-compat, with
the goal of making it optional or just cleaning up the main src tree
to make the distinction between actual implementation/API files and
ABI-compat shims clear.
This commit is contained in:
Rich Felker
2019-11-02 18:30:56 -04:00
parent 0961bb9416
commit c045032094
64 changed files with 1039 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#include "time32.h"
#include <time.h>
int __timer_settime32(timer_t t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32)
{
struct itimerspec old;
int r = timer_settime(t, flags, (&(struct itimerspec){
.it_interval.tv_sec = val32->it_interval.tv_sec,
.it_interval.tv_nsec = val32->it_interval.tv_nsec,
.it_value.tv_sec = val32->it_value.tv_sec,
.it_value.tv_nsec = val32->it_value.tv_nsec}),
old32 ? &old : 0);
if (r) return r;
/* The above call has already committed to success by changing the
* timer setting, so we can't fail on out-of-range old value.
* Since these are relative times, values large enough to overflow
* don't make sense anyway. */
if (old32) {
old32->it_interval.tv_sec = old.it_interval.tv_sec;
old32->it_interval.tv_nsec = old.it_interval.tv_nsec;
old32->it_value.tv_sec = old.it_value.tv_sec;
old32->it_value.tv_nsec = old.it_value.tv_nsec;
}
return 0;
}