Feature #1983: Made CmiWallTimer monotonic in the common case
[charm.git] / src / libs / ck-libs / ampi / romio / adio / ad_xfs / ad_xfs_done.c
blob8ac16426456ce17aa95f65116d5c8cf174310606
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3 * $Id$
5 * Copyright (C) 1997 University of Chicago.
6 * See COPYRIGHT notice in top-level directory.
7 */
9 #include "ad_xfs.h"
11 int ADIOI_XFS_ReadDone(ADIO_Request *request, ADIO_Status *status, int *error_code)
13 int err, done=0;
14 #ifndef PRINT_ERR_MSG
15 static char myname[] = "ADIOI_XFS_READDONE";
16 #endif
18 if (*request == ADIO_REQUEST_NULL) {
19 *error_code = MPI_SUCCESS;
20 return 1;
23 if ((*request)->queued) {
24 errno = aio_error64((const aiocb64_t *) (*request)->handle);
25 if (errno == EINPROGRESS) {
26 done = 0;
27 *error_code = MPI_SUCCESS;
29 else {
30 err = aio_return64((aiocb64_t *) (*request)->handle);
31 (*request)->nbytes = err;
32 errno = aio_error64((const aiocb64_t *) (*request)->handle);
34 done = 1;
35 #ifdef PRINT_ERR_MSG
36 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
37 #else
38 if (err == -1) {
39 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
40 myname, "I/O Error", "%s", strerror(errno));
41 ADIOI_Error((*request)->fd, *error_code, myname);
43 else *error_code = MPI_SUCCESS;
44 #endif
47 else {
48 done = 1;
49 *error_code = MPI_SUCCESS;
51 #ifdef HAVE_STATUS_SET_BYTES
52 if (done && ((*request)->nbytes != -1))
53 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
54 #endif
56 if (done) {
57 /* if request is still queued in the system, it is also there
58 on ADIOI_Async_list. Delete it from there. */
59 if ((*request)->queued) ADIOI_Del_req_from_list(request);
61 (*request)->fd->async_count--;
62 if ((*request)->handle) ADIOI_Free((*request)->handle);
63 ADIOI_Free_request((ADIOI_Req_node *) (*request));
64 *request = ADIO_REQUEST_NULL;
65 /* status to be filled */
67 return done;
71 int ADIOI_XFS_WriteDone(ADIO_Request *request, ADIO_Status *status, int *error_code)
73 return ADIOI_XFS_ReadDone(request, status, error_code);