[mythtv] _IOWR Function

Mario L superm1 at gmail.com
Mon Sep 27 14:00:31 EDT 2004


In attempting to compile the frontend in windows, I'm running into a
bit of a road block, vsync.cpp in libmythTV is referring to a function
_IOWR not valid in cygwin.

>From what I have found comparing linux and cygwin header files,

On Linux:
vsync.cpp includes /usr/include/sys/ioctl.h which includes
/usr/includes/bits/ioctl-typesh which includes
/usr/include/asm/ioctls.h which includes /usr/include/asm/ioctl.h
which seems to be where _IOWR is defined.

On cygwin
/usr/include/sys/ioctl.h doesnt include any of those files, nor does
the _IOWR function exist in any files when I tried to grep for it.

Now my understanding of this function is a bit rudimentary, so could
someone explain exactly what it it used for?
#define _IOC_NRBITS     8
#define _IOC_TYPEBITS   8
#define _IOC_SIZEBITS   14
#define _IOC_DIRBITS    2

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

/*
 * Direction bits.
 */
#define _IOC_NONE       0U
#define _IOC_WRITE      1U
#define _IOC_READ       2U
 
#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))


More information about the mythtv-dev mailing list