]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Remove dependence on <linux/spinlock.h>
authorRichard Curnow <rc@rc0.org.uk>
Mon, 11 Oct 2004 22:37:04 +0000 (22:37 +0000)
committerRichard P. Curnow <rc@rc0.org.uk>
Thu, 19 Jan 2006 21:37:13 +0000 (21:37 +0000)
Use local definitions for the ioctl codes needed to access the RTC.

Note : not tested.  Some architectures not handled yet.

configure
faq.txt
io_linux.h [new file with mode: 0644]
rtc_linux.c

index f591912cd40684752ffef40f75c8d50613c505dc..786e9e1c9743e507752e5c4999ba7ad483099989 100755 (executable)
--- 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 <spinlock.h>, using that"
-        else
-            echo "The system does not have <spinlock.h>, 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 659519fd86c27a756d46a00b45b3361ddf1faa96..ec8d88c6cb2b1d27706fd42bff8efe0703e7d309 100644 (file)
--- 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 (file)
index 0000000..f6f1a93
--- /dev/null
@@ -0,0 +1,63 @@
+/* Taken from <asm-$foo/ioctl.h> 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
+
index a73f363a6aad402e7c770698ee58185bea1c3dec..4b4ca1889acc360b1feb87799f4e78b640c2ae8a 100644 (file)
 #include <sys/time.h>
 #include <sys/types.h>
 
-#ifdef HAS_SPINLOCK_H
-#include <linux/spinlock.h>
-#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 <linux/types.h>
-#ifdef __alpha__
-typedef __u8  u8;
-typedef __u16 u16;
-typedef __u32 u32;
-typedef __u64 u64;
-#endif
-
-#if defined(__i386__) /* || defined(__sparc__) */
-#include <linux/mc146818rtc.h>
-#else
-#include <linux/rtc.h>
-#define RTC_UIE 0x10           /* update-finished interrupt enable */
-#endif
-
 #include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
@@ -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 */