From 29953d6ddb03506747b10d871398c0d12186ebef Mon Sep 17 00:00:00 2001 From: Richard Curnow Date: Mon, 11 Oct 2004 22:37:04 +0000 Subject: [PATCH] Remove dependence on Use local definitions for the ioctl codes needed to access the RTC. Note : not tested. Some architectures not handled yet. --- configure | 14 ++++-------- faq.txt | 3 +++ io_linux.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ rtc_linux.c | 39 +++++++++++---------------------- 4 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 io_linux.h diff --git a/configure b/configure index f591912..786e9e1 100755 --- a/configure +++ b/configure @@ -241,17 +241,11 @@ case $SYSTEM in EXTRA_OBJECTS="sys_linux.o wrap_adjtimex.o rtc_linux.o" SYSDEFS="-DLINUX" echo "Configuring for " $SYSTEM - if [ -r /usr/include/linux/spinlock.h ]; then - SYSDEFS="$SYSDEFS -DHAS_SPINLOCK_H" - echo "The system has , using that" - else - echo "The system does not have , using private definition for spinlock_t" + if [ "${MACHINE}" = "alpha" ]; then + echo "Enabling -mieee" + # FIXME: Should really test for GCC + SYSDEFS="$SYSDEFS -mieee -DALPHA" fi - if [ "${MACHINE}" = "alpha" ]; then - echo "Enabling -mieee" - # FIXME: Should really test for GCC - SYSDEFS="$SYSDEFS -mieee -DALPHA" - fi ;; BSD/386-i[3456]86 ) diff --git a/faq.txt b/faq.txt index 659519f..ec8d88c 100644 --- a/faq.txt +++ b/faq.txt @@ -154,6 +154,9 @@ There have also been reports that just replacing the file /usr/src/linux/spinlock.h by the equivalent file from a vanilla kernel source tree is sufficient to fix the problem. +Note : from version 1.21 onwards, this problem no longer exists. The kernel +header files are no longer included. + S: Selection of NTP servers Q: I have several computers on a LAN. Should I make one the master, or make them all clients of an external server? I think the best configuration is to make one computer the master, with the diff --git a/io_linux.h b/io_linux.h new file mode 100644 index 0000000..f6f1a93 --- /dev/null +++ b/io_linux.h @@ -0,0 +1,63 @@ +/* Taken from in the Linux kernel sources. + * The ioctl.h file is pretty similar from one architecture to another. + * */ +#ifndef IO_LINUX_H +#define IO_LINUX_H + +/* Hmm. These constants vary a bit between systems. */ +/* (__sh__ includes both sh and sh64) */ +#if defined(__i386__) || defined(__sh__) +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 + +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U +#elif defined(__alpha__) || defined(__sparc__) +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 13 +#define _IOC_DIRBITS 2 + +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U +#else +#error "I don't know the values of the _IOC_* constants for your architecture" +#endif + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */ +#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */ + +#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ +#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ + +/* From mc146818.h */ +#define RTC_UIE 0x10 /* update-finished interrupt enable */ + +#endif + diff --git a/rtc_linux.c b/rtc_linux.c index a73f363..4b4ca18 100644 --- a/rtc_linux.c +++ b/rtc_linux.c @@ -43,32 +43,6 @@ #include #include -#ifdef HAS_SPINLOCK_H -#include -#else -/* Include dummy definition of spinlock_t to cope with earlier kernels. */ -typedef int spinlock_t; -#endif - -/* This is a complete hack since the alpha sys/io.h needs these types - * but does not arrange them to be defined. This is almost certainly - * not how one should do these things. -- broonie - */ -#include -#ifdef __alpha__ -typedef __u8 u8; -typedef __u16 u16; -typedef __u32 u32; -typedef __u64 u64; -#endif - -#if defined(__i386__) /* || defined(__sparc__) */ -#include -#else -#include -#define RTC_UIE 0x10 /* update-finished interrupt enable */ -#endif - #include #include #include @@ -84,10 +58,23 @@ typedef __u64 u64; #include "regress.h" #include "rtc.h" #include "rtc_linux.h" +#include "io_linux.h" #include "conf.h" #include "memory.h" #include "mkdirpp.h" +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + /* ================================================== */ /* Forward prototypes */