Developer Guide and Reference

Contents

Example for aio_error and aio_return Functions

The following example illustrates how the
aio_error()
and
aio_return()
functions can be used.
int aio_ex_3(HANDLE fd) {  static struct aiocb aio;  static struct aiocb *aio_list[] = {&aio};  int ret;  char *dat = "Hello from Ex-3\n";   /* Data initialization and asynchronously writing */    IC_AIO_DATA_INIT(aio, fd, dat, strlen(dat), 0);  if (aio_write(& aio) == -1) return errno;    ret = aio_error(&aio);  if ( ret == EINPROGRESS ) {  fprintf(stderr, "ERRNO=%d STR=%s\n", ret, strerror(ret));    ret = aio_suspend(aio_list, 1, NULL);  if (ret == -1) return errno;}  else if (ret)  return ret;    ret = aio_error(&aio);  if (ret) return ret;    ret = aio_return(&aio);  printf("ret=%d\n", ret);    return 0; }/* aio_ex_3 */
Result upon execution:
-bash-3.00$ ./a.out ERRNO=115 STR=Operation now in progress ret=16 -bash-3.00$ cat dat Hello from Ex-3
Remarks:
  1. In the example, the
    IC_AIO_DATA_INIT
    is defined as follows:
    #define IC_AIO_DATA_INIT(_aio, _fd, _dat, _len, _off)\  {memset(&_aio, 0, sizeof(_aio)); \  _aio.aio_fildes = _fd;  \  _aio.aio_buf = _dat;  \  _aio.aio_nbytes = _len;  \  _aio.aio_offset = _off;}
  2. The file descriptor
    fd
    is obtained as:
    HANDLE fd = CreateFile("dat",   GENERIC_READ | GENERIC_WRITE,   FILE_SHARE_READ,   NULL,   OPEN_ALWAYS,   FILE_ATTRIBUTE_NORMAL/*|FILE_FLAG_OVERLAPPED*/,   NULL);

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804