void * usbSubmitRequest ( UsbDevice *device, unsigned char endpointAddress, void *buffer, size_t length, void *context ) { UsbEndpoint *endpoint; if ((endpoint = usbGetEndpoint(device, endpointAddress))) { UsbEndpointExtension *eptx = endpoint->extension; UsbAsynchronousRequest *request; if ((request = malloc(sizeof(*request) + length))) { UsbEndpointDirection direction = USB_ENDPOINT_DIRECTION(endpoint->descriptor); request->endpoint = endpoint; request->context = context; request->buffer = (request->length = length)? (request + 1): NULL; request->result.aio_return = AIO_INPROGRESS; switch (direction) { case UsbEndpointDirection_Input: if (aioread(eptx->data, request->buffer, request->length, 0, SEEK_CUR, &request->result) != -1) return request; logSystemError("USB asynchronous read"); break; case UsbEndpointDirection_Output: if (request->buffer) memcpy(request->buffer, buffer, length); if (aiowrite(eptx->data, request->buffer, request->length, 0, SEEK_CUR, &request->result) != -1) return request; logSystemError("USB asynchronous write"); break; default: logMessage(LOG_ERR, "USB unsupported asynchronous direction: %02X", direction); errno = ENOSYS; break; } free(request); } else { logSystemError("USB asynchronous request allocate"); } } return NULL; }
static int fio_solarisaio_queue(struct thread_data fio_unused *td, struct io_u *io_u) { struct solarisaio_data *sd = td->io_ops->data; struct fio_file *f = io_u->file; off_t off; int ret; fio_ro_check(td, io_u); if (io_u->ddir == DDIR_SYNC) { if (sd->nr) return FIO_Q_BUSY; if (fsync(f->fd) < 0) io_u->error = errno; return FIO_Q_COMPLETED; } if (io_u->ddir == DDIR_DATASYNC) { if (sd->nr) return FIO_Q_BUSY; if (fdatasync(f->fd) < 0) io_u->error = errno; return FIO_Q_COMPLETED; } if (sd->nr == sd->max_depth) return FIO_Q_BUSY; off = io_u->offset; if (io_u->ddir == DDIR_READ) ret = aioread(f->fd, io_u->xfer_buf, io_u->xfer_buflen, off, SEEK_SET, &io_u->resultp); else ret = aiowrite(f->fd, io_u->xfer_buf, io_u->xfer_buflen, off, SEEK_SET, &io_u->resultp); if (ret) { io_u->error = errno; td_verror(td, io_u->error, "xfer"); return FIO_Q_COMPLETED; } sd->nr++; return FIO_Q_QUEUED; }
int ACE_SUN_Proactor::start_aio_i (ACE_POSIX_Asynch_Result *result) { ACE_TRACE ("ACE_SUN_Proactor::start_aio_i"); int ret_val; const ACE_TCHAR *ptype; // ****** from Sun man pages ********************* // Upon completion of the operation both aio_return and aio_errno // are set to reflect the result of the operation. // AIO_INPROGRESS is not a value used by the system // so the client may detect a change in state // by initializing aio_return to this value. result->aio_resultp.aio_return = AIO_INPROGRESS; result->aio_resultp.aio_errno = EINPROGRESS; // Start IO switch (result->aio_lio_opcode) { case LIO_READ : ptype = ACE_TEXT ("read"); ret_val = aioread (result->aio_fildes, (char *) result->aio_buf, result->aio_nbytes, result->aio_offset, SEEK_SET, &result->aio_resultp); break; case LIO_WRITE : ptype = ACE_TEXT ("write"); ret_val = aiowrite (result->aio_fildes, (char *) result->aio_buf, result->aio_nbytes, result->aio_offset, SEEK_SET, &result->aio_resultp); break; default: ptype = ACE_TEXT ("?????"); ret_val = -1; break; } if (ret_val == 0) { this->num_started_aio_++; if (this->num_started_aio_ == 1) // wake up condition this->condition_.broadcast (); } else // if (ret_val == -1) { if (errno == EAGAIN || errno == ENOMEM) // Defer - retry this later. ret_val = 1; else ACE_ERROR ((LM_ERROR, ACE_TEXT ("%N:%l:(%P | %t)::start_aio: aio%s %p\n"), ptype, ACE_TEXT ("queueing failed\n"))); } return ret_val; }
int ADIOI_SCI_aio(ADIO_File fd, void *buf, int len, ADIO_Offset offset, int wr, void *handle) { int err=-1, fd_sys; #ifndef NO_AIO int error_code; #ifdef AIO_SUN aio_result_t *result; #else struct aiocb *aiocbp; #endif #endif fd_sys = fd->fd_sys; #ifdef AIO_SUN result = (aio_result_t *) ADIOI_Malloc(sizeof(aio_result_t)); result->aio_return = AIO_INPROGRESS; if (wr) err = aiowrite(fd_sys, buf, len, offset, SEEK_SET, result); else err = aioread(fd_sys, buf, len, offset, SEEK_SET, result); if (err == -1) { if (errno == EAGAIN) { /* the man pages say EPROCLIM, but in reality errno is set to EAGAIN! */ /* exceeded the max. no. of outstanding requests. complete all previous async. requests and try again.*/ ADIOI_Complete_async(&error_code); if (wr) err = aiowrite(fd_sys, buf, len, offset, SEEK_SET, result); else err = aioread(fd_sys, buf, len, offset, SEEK_SET, result); while (err == -1) { if (errno == EAGAIN) { /* sleep and try again */ sleep(1); if (wr) err = aiowrite(fd_sys, buf, len, offset, SEEK_SET, result); else err = aioread(fd_sys, buf, len, offset, SEEK_SET, result); } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } *((aio_result_t **) handle) = result; #endif #ifdef NO_FD_IN_AIOCB /* IBM */ aiocbp = (struct aiocb *) ADIOI_Malloc(sizeof(struct aiocb)); aiocbp->aio_whence = SEEK_SET; aiocbp->aio_offset = offset; aiocbp->aio_buf = buf; aiocbp->aio_nbytes = len; if (wr) err = aio_write(fd_sys, aiocbp); else err = aio_read(fd_sys, aiocbp); if (err == -1) { if (errno == EAGAIN) { /* exceeded the max. no. of outstanding requests. complete all previous async. requests and try again. */ ADIOI_Complete_async(&error_code); if (wr) err = aio_write(fd_sys, aiocbp); else err = aio_read(fd_sys, aiocbp); while (err == -1) { if (errno == EAGAIN) { /* sleep and try again */ sleep(1); if (wr) err = aio_write(fd_sys, aiocbp); else err = aio_read(fd_sys, aiocbp); } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } *((struct aiocb **) handle) = aiocbp; #elif (!defined(NO_AIO) && !defined(AIO_SUN)) /* DEC, SGI IRIX 5 and 6 */ aiocbp = (struct aiocb *) ADIOI_Calloc(sizeof(struct aiocb), 1); aiocbp->aio_fildes = fd_sys; aiocbp->aio_offset = offset; aiocbp->aio_buf = buf; aiocbp->aio_nbytes = len; #ifdef AIO_PRIORITY_DEFAULT /* DEC */ aiocbp->aio_reqprio = AIO_PRIO_DFL; /* not needed in DEC Unix 4.0 */ aiocbp->aio_sigevent.sigev_signo = 0; #else aiocbp->aio_reqprio = 0; #endif #ifdef AIO_SIGNOTIFY_NONE /* SGI IRIX 6 */ aiocbp->aio_sigevent.sigev_notify = SIGEV_NONE; #else aiocbp->aio_sigevent.sigev_signo = 0; #endif if (wr) err = aio_write(aiocbp); else err = aio_read(aiocbp); if (err == -1) { if (errno == EAGAIN) { /* exceeded the max. no. of outstanding requests. complete all previous async. requests and try again. */ ADIOI_Complete_async(&error_code); if (wr) err = aio_write(aiocbp); else err = aio_read(aiocbp); while (err == -1) { if (errno == EAGAIN) { /* sleep and try again */ sleep(1); if (wr) err = aio_write(aiocbp); else err = aio_read(aiocbp); } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } } else { FPRINTF(stderr, "Unknown errno %d in ADIOI_SCI_aio\n", errno); MPI_Abort(MPI_COMM_WORLD, 1); } } *((struct aiocb **) handle) = aiocbp; #endif return err; }