diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
commit | f1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch) | |
tree | ebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /src/H5FDint.c | |
parent | 10343c197906415388f2a4c8d292e21d25cf7381 (diff) | |
download | hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5FDint.c')
-rw-r--r-- | src/H5FDint.c | 146 |
1 files changed, 66 insertions, 80 deletions
diff --git a/src/H5FDint.c b/src/H5FDint.c index 8a2148a..b651c23 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -24,56 +24,46 @@ /* Module Setup */ /****************/ -#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ - +#include "H5FDmodule.h" /* This source code file is part of the H5FD module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ - +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ /****************/ - /******************/ /* Local Typedefs */ /******************/ - /********************/ /* Package Typedefs */ /********************/ - /********************/ /* Local Prototypes */ /********************/ - /*********************/ /* Package Variables */ /*********************/ - /*****************************/ /* Library Private Variables */ /*****************************/ - /*******************/ /* Local Variables */ /*******************/ - - /*------------------------------------------------------------------------- * Function: H5FD_locate_signature * @@ -88,13 +78,13 @@ herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) { - haddr_t addr = HADDR_UNDEF; - haddr_t eoa = HADDR_UNDEF; - haddr_t eof = HADDR_UNDEF; - uint8_t buf[H5F_SIGNATURE_LEN]; - unsigned n; - unsigned maxpow; - herr_t ret_value = SUCCEED; /* Return value */ + haddr_t addr = HADDR_UNDEF; + haddr_t eoa = HADDR_UNDEF; + haddr_t eof = HADDR_UNDEF; + uint8_t buf[H5F_SIGNATURE_LEN]; + unsigned n; + unsigned maxpow; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -103,33 +93,33 @@ H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr) HDassert(sig_addr); /* Find the least N such that 2^N is larger than the file size */ - eof = H5FD_get_eof(file, H5FD_MEM_SUPER); - eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); + eof = H5FD_get_eof(file, H5FD_MEM_SUPER); + eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER); addr = MAX(eof, eoa); - if(HADDR_UNDEF == addr) + if (HADDR_UNDEF == addr) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to obtain EOF/EOA value") - for(maxpow = 0; addr; maxpow++) + for (maxpow = 0; addr; maxpow++) addr >>= 1; maxpow = MAX(maxpow, 9); /* Search for the file signature at format address zero followed by * powers of two larger than 9. */ - for(n = 8; n < maxpow; n++) { + for (n = 8; n < maxpow; n++) { addr = (8 == n) ? 0 : (haddr_t)1 << n; - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, addr + H5F_SIGNATURE_LEN) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to set EOA value for file signature") - if(H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) + if (H5FD_read(file, H5FD_MEM_SUPER, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to read file signature") - if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) + if (!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN)) break; } /* If the signature was not found then reset the EOA value and return * HADDR_UNDEF. */ - if(n >= maxpow) { - if(H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) + if (n >= maxpow) { + if (H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to reset EOA value") *sig_addr = HADDR_UNDEF; } @@ -141,7 +131,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_locate_signature() */ - /*------------------------------------------------------------------------- * Function: H5FD_read * @@ -152,10 +141,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/) +H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id = H5I_INVALID_HID; /* DXPL for operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -173,7 +162,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ @@ -183,25 +172,26 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*o * objects being written within the file by the application performing * SWMR write operations. */ - if(!(file->access_flags & H5F_ACC_SWMR_READ)) { - haddr_t eoa; + if (!(file->access_flags & H5F_ACC_SWMR_READ)) { + haddr_t eoa; - if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - if((addr + file->base_addr + size) > eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", (unsigned long long)(addr + file->base_addr), (unsigned long long)size, (unsigned long long)eoa) + if ((addr + file->base_addr + size) > eoa) + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size = %llu, eoa = %llu", + (unsigned long long)(addr + file->base_addr), (unsigned long long)size, + (unsigned long long)eoa) } /* Dispatch to driver */ - if((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->read)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_read() */ - /*------------------------------------------------------------------------- * Function: H5FD_write * @@ -214,9 +204,9 @@ done: herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - hid_t dxpl_id; /* DXPL for operation */ - haddr_t eoa = HADDR_UNDEF; /* EOA for file */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t dxpl_id; /* DXPL for operation */ + haddr_t eoa = HADDR_UNDEF; /* EOA for file */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -234,25 +224,25 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, haddr_t addr, size_t size, const void * Do not return early for Parallel mode since the I/O could be a * collective transfer. */ - if(0 == size) + if (0 == size) HGOTO_DONE(SUCCEED) #endif /* H5_HAVE_PARALLEL */ - if(HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (eoa = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver get_eoa request failed") - if((addr + file->base_addr + size) > eoa) + if ((addr + file->base_addr + size) > eoa) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow, addr = %llu, size=%llu, eoa=%llu", - (unsigned long long)(addr+ file->base_addr), (unsigned long long)size, (unsigned long long)eoa) + (unsigned long long)(addr + file->base_addr), (unsigned long long)size, + (unsigned long long)eoa) /* Dispatch to driver */ - if((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) + if ((file->cls->write)(file, type, dxpl_id, addr + file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_write() */ - /*------------------------------------------------------------------------- * Function: H5FD_set_eoa * @@ -270,7 +260,7 @@ done: herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -278,14 +268,13 @@ H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) HDassert(H5F_addr_defined(addr) && addr <= file->maxaddr); /* Dispatch to driver, convert to absolute address */ - if((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) + if ((file->cls->set_eoa)(file, type, addr + file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_set_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eoa * @@ -305,14 +294,14 @@ done: haddr_t H5FD_get_eoa(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) + if (HADDR_UNDEF == (ret_value = (file->cls->get_eoa)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") /* Adjust for base address in file (convert to relative address) */ @@ -322,7 +311,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eoa() */ - /*------------------------------------------------------------------------- * Function: H5FD_get_eof * @@ -342,15 +330,15 @@ done: haddr_t H5FD_get_eof(const H5FD_t *file, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) HDassert(file && file->cls); /* Dispatch to driver */ - if(file->cls->get_eof) { - if(HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) + if (file->cls->get_eof) { + if (HADDR_UNDEF == (ret_value = (file->cls->get_eof)(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, HADDR_UNDEF, "driver get_eof request failed") } else @@ -363,23 +351,22 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eof() */ - /*------------------------------------------------------------------------- -* Function: H5FD_driver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver is passed in -* as a parameter. -* -* Return: SUCCEED/FAIL -* -*------------------------------------------------------------------------- -*/ + * Function: H5FD_driver_query + * + * Purpose: Similar to H5FD_query(), but intended for cases when we don't + * have a file available (e.g. before one is opened). Since we + * can't use the file to get the driver, the driver is passed in + * as a parameter. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ herr_t -H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) +H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -387,11 +374,10 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) HDassert(flags); /* Check for the driver to query and then query it */ - if(driver->query) + if (driver->query) ret_value = (driver->query)(NULL, flags); else *flags = 0; FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_driver_query() */ - |