[chrony-dev] [PATCH] sys_timex: add workaround for broken ntp_adjtime() on macOS |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH] sys_timex: add workaround for broken ntp_adjtime() on macOS
- From: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Date: Mon, 31 Aug 2020 19:56:45 +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=tu0Ey1+b6400dk65d/3TvhsnQxo20UBXasbSBwRxUI4=; b=2yLHm7/N6X1xcnTjGfF+U4Gto8 fOjYZDdX7DvgTVVf5dYC3OFA4eE0tj37+7aTbi13rOlIhuGYz+9XJNVejf/+p1QJZVKgYaW6S6jAs laeCBaUFUcjBN18Esy6ixJeIxlvDCyGZ+QEE7YsivtU6f08tTMkFLVvYBhvBZexwZav9jUcw+UW2V kJnMkSKKjIX36TaG1N7TdvHL58uqQUW4ux2YEwkkJFd4gdvu5A7yfK1rmincQBUa0GhDxNUoP9V+T kZZE+dsACMq+euQX3mAa54/LZq8zwuajsP8uUmJU7yqUAA03bTc90moCng0mY/WZpIli2lh/gGRYe EWD8vmrA==;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whatroute.net; i=@whatroute.net; q=dns/txt; s=s149811; t=1598860628; h=from : subject : to : message-id : date; bh=tu0Ey1+b6400dk65d/3TvhsnQxo20UBXasbSBwRxUI4=; b=bjCdLlIgeVifVBIJ6ZE5NWkC1Pw2QV2DavqsEsF1UgG7jCpVax5NoUjT/2UOYKcYVFPT9U 2NJZu7CRtButrhQffQS5j1z/SMWQoh/KxneWUuDNDYzAe8C9qJ3MgBozSw1CWc+q74PtA44d y9Xk1iVgjgiNGp+7Kbq0cgOxFoXIdJdyPgIdAt8ra/rwztaAkgkIumOvfczVT+LBF3A5RN/X zWb3MyxIMtKbMty+M79gfbNnXCgoku7VGYH9+w6AFu0eX2KOMZCUwWblhyKaGgyRF5NtpwiW sUjAOshNBH139o8SzmGcbqxFq5rg54rHteKoQ+jCtk/7X9fqeVr3cPCQ==
- Feedback-id: 149811m:149811acx33YQ:149811sFuDoLVSYO
On macOS 11.0 (Big Sur) beta, ntp_adjtime() 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).
---
sys_timex.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/sys_timex.c b/sys_timex.c
index 0a6b438..be47a12 100644
--- a/sys_timex.c
+++ b/sys_timex.c
@@ -68,6 +68,25 @@ static int sys_tai_offset;
/* ================================================== */
+static double
+convert_timex_frequency(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 convert_timex_frequency(&txc);
}
/* ================================================== */
@@ -92,7 +111,7 @@ set_frequency(double freq_ppm)
SYS_Timex_Adjust(&txc, 0);
- return txc.freq / -FREQ_SCALE;
+ return convert_timex_frequency(&txc);
}
/* ================================================== */
--
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.