diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
commit | 4a17aff4085ad6ee265b95730aca3f493056dec8 (patch) | |
tree | 8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5FD.c | |
parent | 853ae26333592faf69cd8c454ef92ffea8549df5 (diff) | |
download | hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2 |
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5FD.c')
-rw-r--r-- | src/H5FD.c | 114 |
1 files changed, 71 insertions, 43 deletions
@@ -31,6 +31,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ @@ -1023,6 +1024,7 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_API(HADDR_UNDEF) @@ -1040,15 +1042,23 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, HADDR_UNDEF, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* Do the real work */ - if(HADDR_UNDEF == (ret_value = H5FD_alloc_real(file, dxpl_id, type, size, NULL, NULL))) + if(HADDR_UNDEF == (ret_value = H5FD__alloc_real(file, type, size, NULL, NULL))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") /* (Note compensating for base address subtraction in internal routine) */ ret_value += file->base_addr; done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, HADDR_UNDEF, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5FDalloc() */ @@ -1072,6 +1082,7 @@ done: herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1087,13 +1098,21 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* Do the real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_free_real(file, dxpl_id, type, addr - file->base_addr, size) < 0) + if(H5FD_free_real(file, type, addr - file->base_addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5FDfree() */ @@ -1359,7 +1378,7 @@ herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - H5FD_io_info_t fdio_info; /* File driver I/O object */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1378,27 +1397,21 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer") - /* Set up the file driver I/O info object */ - fdio_info.file = file; - if(H5FD_MEM_DRAW == type) { - if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - } /* end if */ - else { - if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - } /* end else */ +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* Do the real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_read(&fdio_info, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_read(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5FDread() */ @@ -1421,7 +1434,7 @@ herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_io_info_t fdio_info; /* File driver I/O object */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1439,27 +1452,21 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz if(!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer") - /* Set up the file driver I/O info object */ - fdio_info.file = file; - if(H5FD_MEM_DRAW == type) { - if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - } /* end if */ - else { - if(NULL == (fdio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(NULL == (fdio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - } /* end else */ +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* The real work */ /* (Note compensating for base address addition in internal routine) */ - if(H5FD_write(&fdio_info, type, addr - file->base_addr, size, buf) < 0) + if(H5FD_write(file, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5FDwrite() */ @@ -1482,6 +1489,7 @@ done: herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1495,14 +1503,22 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* Do the real work */ - if(H5FD_flush(file, dxpl_id, closing) < 0) + if(H5FD_flush(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFLUSH, FAIL, "file flush request failed") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) -} +} /* end H5FDflush() */ /*------------------------------------------------------------------------- @@ -1516,15 +1532,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_flush(H5FD_t *file, hid_t dxpl_id, hbool_t closing) +H5FD_flush(H5FD_t *file, hbool_t closing) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity checks */ HDassert(file && file->cls); - if(file->cls->flush && (file->cls->flush)(file, dxpl_id, closing) < 0) + if(file->cls->flush && (file->cls->flush)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed") done: @@ -1545,6 +1562,7 @@ done: herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1558,14 +1576,22 @@ H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set DXPL for operation */ +H5CX_set_dxpl(dxpl_id); /* Do the real work */ - if(H5FD_truncate(file, dxpl_id, closing) < 0) + if(H5FD_truncate(file, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_VFL, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) -} +} /* end H5FDtruncate() */ /*------------------------------------------------------------------------- @@ -1579,15 +1605,17 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) +H5FD_truncate(H5FD_t *file, hbool_t closing) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity checks */ HDassert(file && file->cls); - if(file->cls->truncate && (file->cls->truncate)(file, dxpl_id, closing) < 0) + /* Dispatch to driver */ + if(file->cls->truncate && (file->cls->truncate)(file, H5CX_get_dxpl(), closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver truncate request failed") done: |