* @file sys/ioccom.h
* @brief Definitions & maros common to ioctl
*/
#ifndef _SYS_IOCCOM_H
#define _SYS_IOCCOM_H
#include <features.h>
#ifdef _DEFAULT_SOURCE
* @defgroup IOCTL_common sys/ioccom.h
* @brief Definitions & maros common to ioctl()
* @ingroup OpenBeOS_POSIX
* @ingroup IOCTL
* Ioctl values passed as the command (2nd) variable have the
* command encoded in the lower word and the size of any parameters
* in the upper word (in or out).
* The high 3 bits are used to encode whether it's in or out.
* Due to this you can't just give an ioctl value, you need to encode
* it using macros described in
* @ref IOCTL_macros
* @{
*/
* @ingroup IOCTL_common
* @{
*/
#define IOC_VOID (ulong)0x20000000
#define IOC_OUT (ulong)0x40000000
#define IOC_IN (ulong)0x80000000
#define IOC_INOUT (IOC_IN|IOC_OUT)
#define IOC_DIRMASK (ulong)0xe0000000
* @defgroup IOCTL_macros IOCTL macros
* These should be used to define the values passed in as cmd to
* ioctl()
* @ingroup IOCTL_common
* @{
*/
#define IOCPARM_MASK 0x1fff
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
#define IOCGROUP(x) (((x) >> 8) & 0xff)
#define IOCPARM_MAX 20
* @defgroup IOCTL_createmacros macro's to create ioctl() values
* @brief these macro's should be used to create new ioctl() values
* @ingroup IOCTL_common
* @{
*/
#define _IOC(inout, group, num, len) \
(inout | ((len & IOCPARM_MASK)<<16) | ((group) << 8) | (num))
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
#define _IOW(g,n,t) _IOC(IOC_IN , (g), (n), sizeof(t))
* @note this isn't _IORW as this causes name conflicts on some systems */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
#endif
#endif