| [chrony-dev] [RFC PATCH v1 02/17] sysincl: Saneify libc and linux kernel headers |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 02/17] sysincl: Saneify libc and linux kernel headers
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:10:48 +0000
- Cc: christopher.s.hall@xxxxxxxxx, david.zage@xxxxxxxxx, yoong.siang.song@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765002153; x=1796538153; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1KBjdm6n2o7tBup2Uqe9Cu6qTG/slearOOPK3Fe5hnw=; b=R7cTaPMMcUZ5hBTvxwVopdDuCySpzSK7MDtGPUMvl7p5qeOeaT7EzHLC eJlAt1qtqICEvgHB6wyeEdoMRqSXI/bNk2fPk5AIJjGhLc2cUckX80EpI WAvs7F6T/g10W3w8pSF3zGxGfHvt6n+8OA1hW1uYfN8roBg+Y5rckEFbr LXSroYv0fy6nHMMJpcocwIlMlozmUdc6yZJy7Hkm3eWVtK0TID7Y5vTIn HM1MJnrgAuUYwr8x1nGmbqFt80dAtigsypa+SwARg+VRXufsuTApkTFfF Xqzk6uvrIS3PDS0sgoLKXnLP15wiJm9Z/S3ktCImLK76IDlDND8fTXiHW Q==;
Support for Linux auxiliary clocks requires definitions contained in /usr/include/linux as well as the libc
headers. This creates issues with struct redefinitions and generates compile errors. For example,
both /usr/include/bits/timex.h and /usr/include/linux/timex.h (re)define the timex struct. This patch
moves some of the include directives for Linux compilation from sysincl.h to the source files where they
are referenced.
---
client.c | 5 +++++
leapdb.c | 4 ++++
local.c | 4 ++++
logging.c | 4 ++++
privops.c | 4 ++++
refclock_sock.c | 4 ++++
reference.c | 4 ++++
rtc_linux.c | 1 +
sched.c | 4 ++++
socket.c | 4 ++++
sys_generic.c | 4 ++++
sys_linux.c | 4 +++-
sys_linux.h | 2 ++
sys_timex.c | 4 ++++
sys_timex.h | 4 ++++
sysincl.h | 21 ++++++++++++++++++++-
util.c | 3 +++
util.h | 5 +++++
18 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/client.c b/client.c
index 1d6d3d5..da66ea5 100644
--- a/client.c
+++ b/client.c
@@ -43,6 +43,11 @@
#include "socket.h"
#include "util.h"
+#ifdef LINUX
+#include <sys/select.h>
+#include <sys/time.h>
+#endif
+
#ifdef FEAT_READLINE
#include <editline/readline.h>
#endif
diff --git a/leapdb.c b/leapdb.c
index 80da808..eaf13f0 100644
--- a/leapdb.c
+++ b/leapdb.c
@@ -33,6 +33,10 @@
#include "logging.h"
#include "util.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
/* ================================================== */
/* Source of leap second data */
diff --git a/local.c b/local.c
index 9745f4f..1e004b5 100644
--- a/local.c
+++ b/local.c
@@ -32,6 +32,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#include "conf.h"
#include "local.h"
#include "localp.h"
diff --git a/logging.c b/logging.c
index 269f1cd..d0f3e92 100644
--- a/logging.c
+++ b/logging.c
@@ -29,6 +29,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#include <syslog.h>
#include "conf.h"
diff --git a/privops.c b/privops.c
index 3bc76d1..c96a833 100644
--- a/privops.c
+++ b/privops.c
@@ -29,6 +29,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#include "conf.h"
#include "nameserv.h"
#include "logging.h"
diff --git a/refclock_sock.c b/refclock_sock.c
index da0b020..4bbc5d3 100644
--- a/refclock_sock.c
+++ b/refclock_sock.c
@@ -29,6 +29,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#include "refclock.h"
#include "logging.h"
#include "util.h"
diff --git a/reference.c b/reference.c
index 960e011..464dc58 100644
--- a/reference.c
+++ b/reference.c
@@ -30,6 +30,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#include "memory.h"
#include "reference.h"
#include "util.h"
diff --git a/rtc_linux.c b/rtc_linux.c
index 08ba5b5..3ae82f2 100644
--- a/rtc_linux.c
+++ b/rtc_linux.c
@@ -32,6 +32,7 @@
#include "sysincl.h"
+#include <time.h>
#include <linux/rtc.h>
#include "logging.h"
diff --git a/sched.c b/sched.c
index 973bcaa..a97eb79 100644
--- a/sched.c
+++ b/sched.c
@@ -30,6 +30,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <sys/select.h>
+#endif
+
#include "array.h"
#include "sched.h"
#include "memory.h"
diff --git a/socket.c b/socket.c
index ec1a597..ed80d0b 100644
--- a/socket.c
+++ b/socket.c
@@ -32,6 +32,10 @@
#include "sysincl.h"
+#ifdef LINUX
+#include <time.h>
+#endif
+
#ifdef HAVE_LINUX_TIMESTAMPING
#include <linux/errqueue.h>
#include <linux/net_tstamp.h>
diff --git a/sys_generic.c b/sys_generic.c
index 5c42df1..18cc6c0 100644
--- a/sys_generic.c
+++ b/sys_generic.c
@@ -38,6 +38,10 @@
#include "sched.h"
#include "util.h"
+#ifdef LINUX
+#include <sys/timex.h>
+#endif
+
/* ================================================== */
/* System clock drivers */
diff --git a/sys_linux.c b/sys_linux.c
index cb7cb87..fec61bd 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -33,6 +33,8 @@
#include "sysincl.h"
#include <sys/utsname.h>
+#include <linux/timex.h>
+
#if defined(FEAT_PHC) || defined(HAVE_LINUX_TIMESTAMPING)
#include <linux/ptp_clock.h>
@@ -42,7 +44,7 @@
#ifdef HAVE_LINUX_TIMESTAMPING
#include <linux/sockios.h>
#include <linux/ethtool.h>
-#include <net/if.h>
+#include <linux/if.h>
#endif
#ifdef FEAT_SCFILTER
diff --git a/sys_linux.h b/sys_linux.h
index b0567a8..9760281 100644
--- a/sys_linux.h
+++ b/sys_linux.h
@@ -29,6 +29,8 @@
#include "sys.h"
+struct timespec;
+
extern void SYS_Linux_Initialise(void);
extern void SYS_Linux_Finalise(void);
diff --git a/sys_timex.c b/sys_timex.c
index 0f1eef2..3c2eb52 100644
--- a/sys_timex.c
+++ b/sys_timex.c
@@ -34,6 +34,10 @@
#include "sys_generic.h"
#include "sys_timex.h"
#include "logging.h"
+#ifdef LINUX
+#include <time.h>
+#include <sys/timex.h>
+#endif
#ifdef PRIVOPS_ADJUSTTIMEX
#define NTP_ADJTIME PRV_AdjustTimex
diff --git a/sys_timex.h b/sys_timex.h
index b8617a2..f3b3a80 100644
--- a/sys_timex.h
+++ b/sys_timex.h
@@ -29,6 +29,10 @@
#include "localp.h"
+#ifdef LINUX
+struct timex;
+#endif
+
extern void SYS_Timex_Initialise(void);
/* Initialise with some driver functions replaced with special versions */
diff --git a/sysincl.h b/sysincl.h
index e26b236..ecae33e 100644
--- a/sysincl.h
+++ b/sysincl.h
@@ -28,6 +28,17 @@
#ifndef GOT_SYSINCL_H
#define GOT_SYSINCL_H
+#if defined(LINUX)
+#include <features.h>
+#ifdef __USE_MISC
+#undef __USE_MISC
+#include <sys/types.h>
+#define __USE_MISC 1
+#else
+#include <sys/types.h>
+#endif /* __USE_MISC */
+#endif /* LINUX */
+
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
@@ -39,9 +50,13 @@
#include <inttypes.h>
#include <limits.h>
#include <math.h>
+#ifndef LINUX
#include <netinet/in.h>
+#endif
#include <pwd.h>
+#ifndef LINUX
#include <signal.h>
+#endif
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
@@ -50,15 +65,19 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#ifndef LINUX
#include <sys/time.h>
#include <sys/types.h>
+#endif
#include <sys/un.h>
#include <sys/shm.h>
#include <sys/wait.h>
+#ifndef LINUX
#include <time.h>
+#endif
#include <unistd.h>
-#if defined(LINUX) || defined(FREEBSD) || defined(NETBSD) || defined(SOLARIS) || defined(HAVE_MACOS_SYS_TIMEX)
+#if defined(FREEBSD) || defined(NETBSD) || defined(SOLARIS) || defined(HAVE_MACOS_SYS_TIMEX)
#include <sys/timex.h>
#endif
diff --git a/util.c b/util.c
index 404e5b7..5388caa 100644
--- a/util.c
+++ b/util.c
@@ -39,6 +39,9 @@
#include "memory.h"
#include "util.h"
#include "hash.h"
+#ifdef LINUX
+#include <time.h>
+#endif
#define NSEC_PER_SEC 1000000000
diff --git a/util.h b/util.h
index 682c58f..843b9fc 100644
--- a/util.h
+++ b/util.h
@@ -35,6 +35,11 @@
#include "cmac.h"
#include "hash.h"
+#if defined(LINUX)
+struct timespec;
+struct timeval;
+#endif
+
/* Zero a timespec */
extern void UTI_ZeroTimespec(struct timespec *ts);
--
2.34.1
--
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.