[chrony-dev] [PATCH] macOS 11.0 (Big Sur) beta - Bug in implementation of ntp_adjtime() |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH] macOS 11.0 (Big Sur) beta - Bug in implementation of ntp_adjtime()
- From: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Date: Sun, 30 Aug 2020 09:49:22 +1200
- Cc: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a1-4; h=Feedback-ID:X-Smtpcorp-Track:Message-Id:Date: Subject:To:From:Reply-To:Sender:List-Unsubscribe; bh=QlEQQeIjlbfGQ25piPgRfxJM8YN+sEpuXNQSUwysPDk=; b=kqNrJhHmVVkDI0Ib/YxzF4aN2H 7wWsllPr26sSS0lOz/ACVejHUUYZ3Zq2Ktr5rrY3prcvBiyjoWDorEzXd5S/BNNGWRPxLNCkit5nI WIVi46NgXdv9WcOvJn1k8tTYjAo8LmVFCwlymL9/3mHt5S6cD64/W2zQuPBVWJGg5w4ShAk/Zg8HF oRsEUejOqZizuMnGdApmVakQU+AEgYhGJaXoGE6QwZToCjZP7ZmAYvW6Gw9X9KvbVwhMCUhW7M6aE HiwUyZGw9FrTJBUZmwGDHzOIi80NHhTVZYlQ2OlK8+QfWmOkV0AKIqnB+Ka2oGIsomwl+L19f0hAL XS16oGTQ==;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whatroute.net; i=@whatroute.net; q=dns/txt; s=s149811; t=1598737792; h=from : subject : to : message-id : date; bh=QlEQQeIjlbfGQ25piPgRfxJM8YN+sEpuXNQSUwysPDk=; b=W8m3enpDyGdDxPjRM/B9ucWybSULWFXGLa7lYfevV5NbH61LyNRLaKeuFm9lKUUiw8gB9z BpTRBF8GFOJL0fVhJZYwmrG+pIKj6a9YHaqa3iKzMVU1U9cMr+FBu3wAxyEaPV4MQbVSI7nX AsnbYmIQ605aImVj/yIXwdNvi+CdA5lp8SWgA0YpqhPoK/g/E66M193SW2vAaNeM6qIeI5eH q0AbyhkEw3XVTRnFubEh4Yawfi4nnIjWK4MzCE6AHUR6A/6MOo6ilxHs/EfOyAcCmS6u+SOb Kxkv6ji6tAitFpmVm+dQyn6zQNr8jVYootMlILCAeAZ/CpKCt/DQizUw==
- Feedback-id: 149811m:149811acx33YQ:149811sUME1R84vD
macOS 11.0 (Big Sur) beta incorrectly returns timex.freq as an unsigned number. This patch is a workaround for the bug and should be removed when Apple fix the problem (assuming they will). The patch also extends the ntpadjtime test to cover negative frequencies.
---
sys_timex.c | 23 +++++++++++++++++++++--
test/kernel/ntpadjtime.c | 2 +-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/sys_timex.c b/sys_timex.c
index 0a6b438..aa1508a 100644
--- a/sys_timex.c
+++ b/sys_timex.c
@@ -68,6 +68,25 @@ static int sys_tai_offset;
/* ================================================== */
+static inline double
+txc_freq(const struct timex *txc)
+{
+ double freq_ppm;
+
+ freq_ppm = txc->freq / FREQ_SCALE;
+
+#ifdef MACOSX
+ /* temporary work-around for Apple bug treating freq as unsigned number */
+ if (freq_ppm > 32767) {
+ freq_ppm -= 65536;
+ }
+#endif
+
+ return -freq_ppm;
+}
+
+/* ================================================== */
+
static double
read_frequency(void)
{
@@ -77,7 +96,7 @@ read_frequency(void)
SYS_Timex_Adjust(&txc, 0);
- return txc.freq / -FREQ_SCALE;
+ return txc_freq(&txc);
}
/* ================================================== */
@@ -92,7 +111,7 @@ set_frequency(double freq_ppm)
SYS_Timex_Adjust(&txc, 0);
- return txc.freq / -FREQ_SCALE;
+ return txc_freq(&txc);
}
/* ================================================== */
diff --git a/test/kernel/ntpadjtime.c b/test/kernel/ntpadjtime.c
index d6be154..96c069f 100644
--- a/test/kernel/ntpadjtime.c
+++ b/test/kernel/ntpadjtime.c
@@ -52,7 +52,7 @@ test_freqrange(void)
printf("freq range:\n");
- for (i = 0; i <= 1000; i += 50) {
+ for (i = -1000; i <= 1000; i += 50) {
t.modes = MOD_FREQUENCY;
t.freq = i << 16;
printf("%4d ppm => ", i);
--
2.24.3 (Apple Git-128)
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.