[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[util-linux PATCH v2] Support hwclock for GNU Hurd
From: |
Zhaoming Luo |
Subject: |
[util-linux PATCH v2] Support hwclock for GNU Hurd |
Date: |
Fri, 6 Dec 2024 11:03:26 +0800 |
* configure.ac: add HURD so it can be used in conditional in am files
* sys-utils/Makemodule.am: compile hwclock for GNU Hurd
* sys-utils/hwclock-cmos.c: avoid nested declaration warning
* sys-utils/hwclock-rtc.c: compile for GNU Hurd
* sys-utils/hwclock.c: compile for GNU Hurd
* sys-utils/hwclock.h: compile for GNU Hurd
---
configure.ac | 6 +++++-
sys-utils/Makemodule.am | 5 +++++
sys-utils/hwclock-cmos.c | 2 ++
sys-utils/hwclock-rtc.c | 15 ++++++++++++---
sys-utils/hwclock.c | 2 +-
sys-utils/hwclock.h | 3 +++
6 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 698da36..8de6af6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -263,16 +263,20 @@ AC_PATH_PROG([XSLTPROC], [xsltproc])
linux_os=no
bsd_os=no
+gnu_os=no
AS_CASE([${host_os}],
[*linux*],
[linux_os=yes],
[*darwin*],
[darwin_os=yes],
[*bsd*],
- [bsd_os=yes])
+ [bsd_os=yes],
+ [gnu*],
+ [gnu_os=yes])
AM_CONDITIONAL([LINUX], [test "x$linux_os" = xyes])
AM_CONDITIONAL([DARWIN], [test "x$darwin_os" = xyes])
AM_CONDITIONAL([BSD], [test "x$bsd_os" = xyes])
+AM_CONDITIONAL([HURD], [test "x$gnu_os" = xyes])
AS_IF([test "x$darwin_os" = xyes], [
AC_DEFINE([_DARWIN_C_SOURCE], [1], [Enable MAP_ANON in sys/mman.h on Mac OS
X])
diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index 209b656..8cc69be 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -570,6 +570,11 @@ hwclock_SOURCES += \
lib/monotonic.c
hwclock_LDADD += $(REALTIME_LIBS)
endif
+if HURD
+hwclock_SOURCES += \
+ sys-utils/hwclock-rtc.c \
+ lib/monotonic.c
+endif
if HAVE_AUDIT
hwclock_LDADD += -laudit
endif
diff --git a/sys-utils/hwclock-cmos.c b/sys-utils/hwclock-cmos.c
index 7e5eecc..cc672cb 100644
--- a/sys-utils/hwclock-cmos.c
+++ b/sys-utils/hwclock-cmos.c
@@ -352,7 +352,9 @@ static int i386_iopl(const int level)
# else
static int i386_iopl(const int level __attribute__ ((__unused__)))
{
+ #ifndef __gnu_hurd__
extern int ioperm(unsigned long from, unsigned long num, int turn_on);
+ #endif
return ioperm(clock_ctl_addr, 2, 1);
}
# endif
diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c
index 2796f2e..c285c42 100644
--- a/sys-utils/hwclock-rtc.c
+++ b/sys-utils/hwclock-rtc.c
@@ -8,10 +8,15 @@
*
* rtc.c - Use /dev/rtc for clock access
*/
+#ifdef __gnu_hurd__
+#include <sys/ioctl.h>
+#include <hurd/rtc.h>
+#else
#include <asm/ioctl.h>
-#include <errno.h>
#include <linux/rtc.h>
#include <linux/types.h>
+#endif /* GNU_HURD */
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -28,6 +33,7 @@
#include "hwclock.h"
+#ifndef __gnu_hurd__
#ifndef RTC_PARAM_GET
struct rtc_param {
__u64 param;
@@ -60,6 +66,7 @@ const struct hwclock_param *get_hwclock_params(void)
{
return hwclock_params;
}
+#endif /* GNU_HURD */
/*
* /dev/rtc is conventionally chardev 10/135
@@ -99,12 +106,12 @@ static int open_rtc(const struct hwclock_control *ctl)
/* --rtc option has been given */
if (ctl->rtc_dev_name) {
rtc_dev_name = ctl->rtc_dev_name;
- rtc_dev_fd = open(rtc_dev_name, O_RDONLY);
+ rtc_dev_fd = open(rtc_dev_name, O_RDWR);
} else {
for (i = 0; i < ARRAY_SIZE(fls); i++) {
if (ctl->verbose)
printf(_("Trying to open: %s\n"), fls[i]);
- rtc_dev_fd = open(fls[i], O_RDONLY);
+ rtc_dev_fd = open(fls[i], O_RDWR);
if (rtc_dev_fd < 0) {
if (errno == ENOENT || errno == ENODEV)
@@ -411,6 +418,7 @@ int set_epoch_rtc(const struct hwclock_control *ctl)
+#ifndef __gnu_hurd__
static int resolve_rtc_param_alias(const char *alias, __u64 *value)
{
const struct hwclock_param *param = &hwclock_params[0];
@@ -609,3 +617,4 @@ int rtc_vl_clear(const struct hwclock_control *ctl)
return 0;
}
+#endif /* GNU_HURD */
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 2b33dfb..e1a105e 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -989,7 +989,7 @@ static void determine_clock_access_method(const struct
hwclock_control *ctl)
if (ctl->directisa)
ur = probe_for_cmos_clock();
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__gnu_hurd__)
if (!ur)
ur = probe_for_rtc_clock(ctl);
#endif
diff --git a/sys-utils/hwclock.h b/sys-utils/hwclock.h
index 2522d6c..485e904 100644
--- a/sys-utils/hwclock.h
+++ b/sys-utils/hwclock.h
@@ -39,6 +39,9 @@ struct hwclock_control {
#ifdef __linux__
char *rtc_dev_name;
uint32_t param_idx; /* --param-index <n> */
+#endif
+#ifdef __gnu_hurd__
+ char *rtc_dev_name;
#endif
char *param_get_option;
char *param_set_option;
--
2.45.2
- [util-linux PATCH v2] Support hwclock for GNU Hurd,
Zhaoming Luo <=