aio_init_done = True;
}
-static Bool was_a_successful_aio_read = False;
-
PRE(aio_return)
{
struct vki_aiocb* aiocbp = (struct vki_aiocb*)ARG1;
// contents of the struct.
PRINT( "aio_return ( %#lx )", ARG1 );
PRE_REG_READ1(long, "aio_return", struct vki_aiocb*, aiocbp);
-
- if (!aio_init_done) aio_init();
- was_a_successful_aio_read = VG_(OSetWord_Remove)(aiocbp_table, (UWord)aiocbp);
-}
-POST(aio_return)
-{
- // If we found the aiocbp in our own table it must have been an aio_read(),
- // so mark the buffer as written. If we didn't find it, it must have been
- // an aio_write() or a bogus aio_return() (eg. a second one on the same
- // aiocbp). Either way, the buffer won't have been written so we don't
- // have to mark the buffer as written.
- if (was_a_successful_aio_read) {
- struct vki_aiocb* aiocbp = (struct vki_aiocb*)ARG1;
- POST_MEM_WRITE((Addr)aiocbp->aio_buf, aiocbp->aio_nbytes);
- was_a_successful_aio_read = False;
+ if (ML_(safe_to_deref)((struct vki_aiocb *)ARG1, sizeof(struct vki_aiocb))) {
+ SET_STATUS_from_SysRes(VG_(do_syscall1)(SYSNO, ARG1));
+ if (SUCCESS && RES >= 0) {
+ struct vki_aiocb* aiocbp = (struct vki_aiocb*)ARG1;
+ if (!aio_init_done) {
+ aio_init();
+ }
+ if (VG_(OSetWord_Remove)(aiocbp_table, (UWord)aiocbp)) {
+ POST_MEM_WRITE((Addr)aiocbp->aio_buf, aiocbp->aio_nbytes);
+ }
+ }
+ } else {
+ SET_STATUS_Failure(VKI_EINVAL);
}
+
}
PRE(aio_suspend)
_____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(308)), // old __pthread_cond_timedwait
#endif
// _____(__NR_aio_fsync),
- MACXY(__NR_aio_return, aio_return),
+ MACX_(__NR_aio_return, aio_return),
MACX_(__NR_aio_suspend, aio_suspend),
// _____(__NR_aio_cancel),
MACX_(__NR_aio_error, aio_error),