Remove dependence on <linux/spinlock.h>

Use local definitions for the ioctl codes needed to access the RTC.

Note : not tested.  Some architectures not handled yet.
This commit is contained in:
Richard Curnow 2004-10-11 22:37:04 +00:00 committed by Richard P. Curnow
parent 6ff561dd23
commit 29953d6ddb
4 changed files with 83 additions and 36 deletions

14
configure vendored
View file

@ -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 )

View file

@ -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

63
io_linux.h Normal file
View file

@ -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

View file

@ -43,32 +43,6 @@
#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 */