[v3] remaining steps for time64 switchover

Submitted by Rich Felker on Nov. 2, 2019, 4:34 p.m.

Details

Message ID 20191102163426.GS16318@brightrain.aerifal.cx
State New
Series "remaining steps for time64 switchover"
Headers show

Commit Message

Rich Felker Nov. 2, 2019, 4:34 p.m.
On Fri, Nov 01, 2019 at 09:39:11PM -0400, Rich Felker wrote:
> A couple errors in the v2 patchset motivated me to factor the changes
> to sys/socket.h and arch/generic/ioctl.h out of the main switchover
> commit, so that the latter only touches arch dirs, and acts uniformly
> on them. The final result with all patches applied is almost the same,
> except now the powerpc and mips[n32] socket.h bits omit the time64
> socket options, letting the top-level header's defaults take effect.
> 
> All archs I have toolchains handy for, which includes the oddballs
> (mips, powerpc) and a few 64-bit ones, have been tested to build
> successfully and get the right values of the sockopt and ioctl macros,
> utilizing a horrible hack (uncommitted of course) dropped into the
> source tree while building.
> 
> Hopefully this is "final" now and ready for push.

compat/time32/adjtimex_time32.c was inconsistent with what was later
done for struct timex (see commit
928674dcd0c5c643b8a4440466103be841151f5e). Two very helpful reviewers
on #musl pointed this out, and I'll be squashing the attached fix. (I
tried to avoid having many time32 compat shims call each other rather
than directly calling the real functions in libc, but this one would
involve a lot of duplication (and the duplication initially led to
this error) so...
From a653b89da5ffcfe2c55588b297f05f7d673f70cb Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Sat, 2 Nov 2019 00:36:26 -0400
Subject: [PATCH] compat fixup: adjtimex_time32

---
 compat/time32/adjtimex_time32.c | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

Patch hide | download patch | download mbox

diff --git a/compat/time32/adjtimex_time32.c b/compat/time32/adjtimex_time32.c
index d7541da8..9c6f190a 100644
--- a/compat/time32/adjtimex_time32.c
+++ b/compat/time32/adjtimex_time32.c
@@ -1,37 +1,10 @@ 
 #include "time32.h"
 #include <time.h>
-#include <sys/time.h>
 #include <sys/timex.h>
-#include <string.h>
-#include <stddef.h>
 
-struct oldtimex {
-	unsigned modes;
-	long offset, freq, maxerror, esterror;
-	int status;
-	long constant, precision, tolerance;
-	long time_sec, time_usec;
-	long tick, ppsfreq, jitter;
-	int shift;
-	long stabil, jitcnt, calcnt, errcnt, stbcnt;
-	int tai;
-	int __padding[11];
-};
+struct timex32;
 
-int __adjtimex_time32(struct timex *tx32)
+int __adjtimex_time32(struct timex32 *tx32)
 {
-	struct timex utx;
-	memcpy(&utx, tx32, sizeof(struct oldtimex));
-	utx.time.tv_sec =
-		*(long *)((char *)tx32 + offsetof(struct oldtimex,time_sec));
-	utx.time.tv_usec =
-		*(long *)((char *)tx32 + offsetof(struct oldtimex,time_usec));
-	int r = adjtimex(&utx);
-	if (r<0) return r;
-	memcpy(tx32, &utx, sizeof(struct oldtimex));
-	*(long *)((char *)tx32 + offsetof(struct oldtimex,time_sec)) =
-		utx.time.tv_sec;
-	*(long *)((char *)tx32 + offsetof(struct oldtimex,time_usec)) =
-		utx.time.tv_usec;
-	return r;
+	return __clock_adjtime32(CLOCK_REALTIME, tx32);
 }