Visible to Intel only — GUID: mwh1416946823623
Ixiasoft
Visible to Intel only — GUID: mwh1416946823623
Ixiasoft
7.7.1.1.1. Modifying the Global Error Status, errno
For example, the ioctl() function returns -ENOTTY if it cannot handle a request rather than set errno to ENOTTY directly. The HAL system routines that call these functions ensure that errno is set accordingly.
The function prototypes for these functions differ from their application level counterparts in that they each take an input file descriptor argument of type alt_fd* rather than int.
A new alt_fd structure is created on a call to open(). This structure instance is then passed as an input argument to all function calls made for the associated file descriptor.
The following code defines the alt_fd structure:
typedef struct { alt_dev* dev; void* priv; int fd_flags; } alt_fd;
where:
- dev is a pointer to the device structure for the device being used.
- fd_flags is the value of flags passed to open().
- priv is a reserved, implementation-dependent argument, defined by the driver. If the driver requires any special, non-HAL-defined values to be maintained for each file or stream, you can store them in a data structure, and use priv maintains a pointer to the structure. The HAL ignores priv.
Allocate storage for the data structure in your open() function (pointed to by the alt_dev structure). Free the storage in your close() function.