Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
stropts.h File Reference

Go to the source code of this file.

Macros

#define IOC_NONE   0U
 ioctl key value for operation (not read or write)
 
#define IOC_WRITE   1U
 ioctl key write bit
 
#define IOC_READ   2U
 ioctl key read bit
 
#define IOC(_dir, _type, _num, _size)    (((_dir) << 30) | ((_type) << 8) | ((_num)) | ((_size) << 16))
 create an ioctl.
 
#define IO(_type, _num)   IOC(IOC_NONE, (_type), (_num), 0)
 create an operation ioctl
 
#define IOR(_type, _num, _size)   IOC(IOC_READ, (_type), (_num), (_size))
 create an operation ioctl
 
#define IOW(_type, _num, _size)   IOC(IOC_WRITE, (_type), (_num), (_size))
 create an operation ioctl
 
#define IOWR(_type, _num, _size)   IOC(IOC_WRITE | IOC_READ, (_type), (_num), (_size))
 create an operation ioctl
 
#define IOC_DIR(_num)   (((_num) >> 30) & 0x00000003)
 Decode ioctl number direction.
 
#define IOC_TYPE(_num)   (((_num) >> 8) & 0x000000FF)
 Decode ioctl type.
 
#define IOC_NR(_num)   (((_num) >> 0) & 0x000000FF)
 Decode ioctl number.
 
#define IOC_SIZE(_num)   (((_num) >> 16) & 0x00003FFF)
 Decode ioctl size.
 
#define IOC_SIZEBITS   14
 Number of bits that make up the size field.
 

Functions

int ioctl (int fd, unsigned long int key,...)
 Request and ioctl transaction.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file implements ioctl() prototypes and defines.

Author
Stuart W. Baker
Date
2 November 2013

Definition in file freertos/stropts.h.

Macro Definition Documentation

◆ IO

#define IO (   _type,
  _num 
)    IOC(IOC_NONE, (_type), (_num), 0)

create an operation ioctl

Parameters
_typedevice driver unique number
_numioctl index number

Definition at line 74 of file freertos/stropts.h.

◆ IOC

#define IOC (   _dir,
  _type,
  _num,
  _size 
)     (((_dir) << 30) | ((_type) << 8) | ((_num)) | ((_size) << 16))

create an ioctl.

Parameters
_dirdirection
_typedevice driver unique number
_numioctl index number
_sizesize of ioctl data in bytes

Definition at line 67 of file freertos/stropts.h.

◆ IOC_DIR

#define IOC_DIR (   _num)    (((_num) >> 30) & 0x00000003)

Decode ioctl number direction.

Parameters
_numencoded ioctl value
Returns
IOC_NONE, IOC_WRITE, IOC_READ, or IOC_WRITE | IOC_READ

Definition at line 101 of file freertos/stropts.h.

◆ IOC_NONE

#define IOC_NONE   0U

ioctl key value for operation (not read or write)

Definition at line 53 of file freertos/stropts.h.

◆ IOC_NR

#define IOC_NR (   _num)    (((_num) >> 0) & 0x000000FF)

Decode ioctl number.

Parameters
_numencoded ioctl value
Returns
ioctl index number

Definition at line 113 of file freertos/stropts.h.

◆ IOC_READ

#define IOC_READ   2U

ioctl key read bit

Definition at line 59 of file freertos/stropts.h.

◆ IOC_SIZE

#define IOC_SIZE (   _num)    (((_num) >> 16) & 0x00003FFF)

Decode ioctl size.

Parameters
_numencoded ioctl value
Returns
size of ioctl data in bytes

Definition at line 119 of file freertos/stropts.h.

◆ IOC_SIZEBITS

#define IOC_SIZEBITS   14

Number of bits that make up the size field.

Definition at line 122 of file freertos/stropts.h.

◆ IOC_TYPE

#define IOC_TYPE (   _num)    (((_num) >> 8) & 0x000000FF)

Decode ioctl type.

Parameters
_numencoded ioctl value
Returns
device driver unique number

Definition at line 107 of file freertos/stropts.h.

◆ IOC_WRITE

#define IOC_WRITE   1U

ioctl key write bit

Definition at line 56 of file freertos/stropts.h.

◆ IOR

#define IOR (   _type,
  _num,
  _size 
)    IOC(IOC_READ, (_type), (_num), (_size))

create an operation ioctl

Parameters
_typedevice driver unique number
_numioctl index number
_sizesize of ioctl data in bytes

Definition at line 81 of file freertos/stropts.h.

◆ IOW

#define IOW (   _type,
  _num,
  _size 
)    IOC(IOC_WRITE, (_type), (_num), (_size))

create an operation ioctl

Parameters
_typedevice driver unique number
_numioctl index number
_sizesize of ioctl data in bytes

Definition at line 88 of file freertos/stropts.h.

◆ IOWR

#define IOWR (   _type,
  _num,
  _size 
)    IOC(IOC_WRITE | IOC_READ, (_type), (_num), (_size))

create an operation ioctl

Parameters
_typedevice driver unique number
_numioctl index number
_sizesize of ioctl data in bytes

Definition at line 95 of file freertos/stropts.h.

Function Documentation

◆ ioctl()

int ioctl ( int  fd,
unsigned long int  key,
  ... 
)

Request and ioctl transaction.

Parameters
fdfile descriptor
keyioctl key
...key data (as a pointer or unsigned long type)
fdfile descriptor
keyioctl key
...key data
Returns
0 upon success, -1 upon failure with errno containing the cause

Definition at line 452 of file Fileio.cxx.