diff options
author | Robb Matzke <matzke@llnl.gov> | 1999-07-28 18:25:43 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1999-07-28 18:25:43 (GMT) |
commit | e4834c43ce6528308ebd5375bd4c7a0df88af427 (patch) | |
tree | 0039040d95cc92fdb197b2902436e32a020a7b6f /src/H5Flow.c | |
parent | 139688863f191366fe27fbab9654a52285e63c11 (diff) | |
download | hdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.zip hdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.tar.gz hdf5-e4834c43ce6528308ebd5375bd4c7a0df88af427.tar.bz2 |
[svn-r1548] Changes since 19990727
----------------------
./src/H5.c [1.3]
./src/H5AC.c [1.3]
./src/H5ACprivate.h [1.3]
./src/H5B.c [1.3]
./src/H5Bprivate.h [1.3]
./src/H5D.c [1.3]
./src/H5F.c [1.3]
./src/H5Farray.c [1.3]
./src/H5Fcore.c [1.3]
./src/H5Ffamily.c [1.3]
./src/H5Fistore.c [1.3]
./src/H5Flow.c [1.3]
./src/H5Fmpio.c [1.3]
./src/H5Fprivate.h [1.3]
./src/H5Fsec2.c [1.3]
./src/H5Fsplit.c [1.3]
./src/H5Fstdio.c [1.3]
./src/H5G.c [1.3]
./src/H5Gent.c [1.3]
./src/H5Gnode.c [1.3]
./src/H5Gprivate.h [1.3]
./src/H5Gstab.c [1.3]
./src/H5HG.c [1.3]
./src/H5HGprivate.h [1.3]
./src/H5HL.c [1.3]
./src/H5HLprivate.h [1.3]
./src/H5MF.c [1.3]
./src/H5MFprivate.h [1.3]
./src/H5O.c [1.3]
./src/H5Oattr.c [1.3]
./src/H5Ocont.c [1.3]
./src/H5Odtype.c [1.3]
./src/H5Oefl.c [1.3]
./src/H5Olayout.c [1.3]
./src/H5Oprivate.h [1.3]
./src/H5Oshared.c [1.3]
./src/H5Ostab.c [1.3]
./src/H5P.c [1.3]
./src/H5R.c [1.3]
./src/H5Smpio.c [1.3]
./src/H5T.c [1.3]
./src/H5Tvlen.c [1.3]
./src/H5private.h [1.3]
./test/dtypes.c [1.3]
./test/gheap.c [1.3]
./test/istore.c [1.3]
./test/lheap.c [1.3]
./test/ohdr.c [1.3]
./tools/h5debug.c [1.3]
File addresses (the `haddr_t' type) are passed by value
instead of by reference. The type is no longer a struct. This
is one of the preliminary changes needed for the Virtual File
Layer stuff.
./src/H5Fprivate.h [1.3]
./src/H5Flow.c [1.3]
Some address functions were rewritten as macros.
Diffstat (limited to 'src/H5Flow.c')
-rw-r--r-- | src/H5Flow.c | 323 |
1 files changed, 98 insertions, 225 deletions
diff --git a/src/H5Flow.c b/src/H5Flow.c index 3ac4cf1..c54f845 100644 --- a/src/H5Flow.c +++ b/src/H5Flow.c @@ -15,8 +15,6 @@ #include <H5Fprivate.h> #include <H5MMprivate.h> -#define addr_defined(X) (((uint64_t)(-1)!=(X)->offset) ? TRUE : FALSE) - #define PABLO_MASK H5Flow_mask static intn interface_initialize_g = 0; #define INTERFACE_INIT NULL @@ -209,22 +207,24 @@ H5F_low_close(H5F_low_t *lf, const H5F_access_t *access_parms) * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * Albert Cheng, 1998-06-02 + * Added XFER_MODE argument. * + * Robb Matzke, 1999-07-28 + * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5F_low_read(H5F_low_t *lf, const H5F_access_t *access_parms, - const H5F_xfer_t *xfer_parms, const haddr_t *addr, - size_t size, uint8_t *buf/*out*/) + const H5F_xfer_t *xfer_parms, haddr_t addr, size_t size, + uint8_t *buf/*out*/) { herr_t ret_value = FAIL; FUNC_ENTER(H5F_low_read, FAIL); assert(lf && lf->type); - assert(addr && addr_defined(addr)); + assert(H5F_addr_defined(addr)); assert(buf); if (lf->type->read) { @@ -259,20 +259,23 @@ H5F_low_read(H5F_low_t *lf, const H5F_access_t *access_parms, * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * Albert Cheng, 1998-06-02 + * Added XFER_MODE argument. * - * rky 980816 + * rky, 1998-08-16 * Accommodate fancy MPI derived datatype writes. * - * rky 980902 + * rky, 1998-09-02 * For non-block parallel writes, don't change value of lf->eof. + * + * Robb Matzke, 1999-07-28 + * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, - const H5F_xfer_t *xfer_parms, const haddr_t *addr, - size_t size, const uint8_t *buf) + const H5F_xfer_t *xfer_parms, haddr_t addr, size_t size, + const uint8_t *buf) { herr_t ret_value = FAIL; haddr_t tmp_addr; @@ -280,17 +283,17 @@ H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms, FUNC_ENTER(H5F_low_write, FAIL); assert(lf && lf->type); - assert(addr && addr_defined(addr)); + assert(H5F_addr_defined(addr)); assert(buf); /* check for writing past the end of file marker */ - tmp_addr = *addr; + tmp_addr = addr; H5F_addr_inc(&tmp_addr, (hsize_t)size); - if (H5F_addr_gt(&tmp_addr, &(lf->eof))) + if (H5F_addr_gt(tmp_addr, lf->eof)) HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, ret_value, "write past end of logical file"); /* Check if the last byte of the logical file has been written */ - if (!lf->eof_written && H5F_addr_eq(&tmp_addr, &(lf->eof))) + if (!lf->eof_written && H5F_addr_eq(tmp_addr, lf->eof)) lf->eof_written=1; /* Write the data */ @@ -342,15 +345,16 @@ H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms) /* Make sure the last block of the file has been allocated on disk */ H5F_addr_reset(&last_byte); - if (!lf->eof_written && addr_defined(&(lf->eof)) && H5F_addr_gt(&(lf->eof), &last_byte)) { + if (!lf->eof_written && H5F_addr_defined(lf->eof) && + H5F_addr_gt(lf->eof, last_byte)) { last_byte = lf->eof; - last_byte.offset -= 1; - if (H5F_low_read(lf, access_parms, &H5F_xfer_dflt, &last_byte, + last_byte -= 1; + if (H5F_low_read(lf, access_parms, &H5F_xfer_dflt, last_byte, 1, buf) >= 0) { #ifdef HAVE_PARALLEL H5F_mpio_tas_allsame( lf, TRUE ); /* only p0 will write */ #endif /* HAVE_PARALLEL */ - H5F_low_write(lf, access_parms, &H5F_xfer_dflt, &last_byte, + H5F_low_write(lf, access_parms, &H5F_xfer_dflt, last_byte, 1, buf); } else @@ -401,17 +405,17 @@ H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms) *------------------------------------------------------------------------- */ hsize_t -H5F_low_size(H5F_low_t *lf, haddr_t *eof/*out*/) +H5F_low_size(H5F_low_t *lf, haddr_t *eof_p/*out*/) { hsize_t size = (hsize_t)(-1); /*max possible size */ FUNC_ENTER(H5F_low_size, 0); assert(lf && lf->type); - assert(eof); + assert(eof_p); - *eof = lf->eof; - if (eof->offset < size) size = eof->offset; + *eof_p = lf->eof; + if (*eof_p < size) size = *eof_p; FUNC_LEAVE(size); } @@ -516,7 +520,7 @@ H5F_low_access(const H5F_low_class_t *type, const char *name, * providing its own allocation method. * * Return: Success: Non-negative. The address of the old - * end-of-file is returned through the ADDR + * end-of-file is returned through the ADDR_P * argument and the logical size of the file has * been extended by SIZE bytes. * @@ -531,24 +535,24 @@ H5F_low_access(const H5F_low_class_t *type, const char *name, */ herr_t H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms, intn op, - hsize_t size, haddr_t *addr/*out*/) + hsize_t size, haddr_t *addr_p/*out*/) { FUNC_ENTER(H5F_low_alloc, FAIL); assert(lf); assert(size > 0); - assert(addr); + assert(addr_p); /* Reset the EOF written flag */ lf->eof_written=0; if (lf->type->extend) { - if ((lf->type->extend) (lf, access_parms, op, size, addr/*out*/) < 0) { + if ((lf->type->extend) (lf, access_parms, op, size, addr_p/*out*/)<0) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend file"); } } else { - *addr = lf->eof; + *addr_p = lf->eof; H5F_addr_inc(&(lf->eof), size); } @@ -572,7 +576,8 @@ H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms, intn op, * ADDR will be the address within the free * block where the request can be satisfied. * - * Failure: Negative with the output value of ADDR undefined. + * Failure: Negative with the output value of ADDR_P + * undefined. * * Programmer: Robb Matzke * Tuesday, June 9, 1998 @@ -583,7 +588,7 @@ H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms, intn op, */ intn H5F_low_alloc (H5F_low_t *lf, intn op, hsize_t alignment, hsize_t threshold, - hsize_t size, H5MF_free_t *blk, haddr_t *addr/*out*/) + hsize_t size, H5MF_free_t *blk, haddr_t *addr_p/*out*/) { intn ret_value = FAIL; hsize_t wasted; @@ -593,25 +598,25 @@ H5F_low_alloc (H5F_low_t *lf, intn op, hsize_t alignment, hsize_t threshold, assert (alignment>0); assert (size>0); assert (blk); - assert (addr); + assert (addr_p); if (lf->type->alloc) { ret_value = (lf->type->alloc)(lf, op, alignment, threshold, size, blk, - addr/*out*/); + addr_p/*out*/); } else { if (size>=threshold) { - wasted = blk->addr.offset % alignment; + wasted = blk->addr % alignment; } else { wasted = 0; } if (0==wasted && size==blk->size) { /* exact match */ - *addr = blk->addr; + *addr_p = blk->addr; ret_value = 1; } else if (blk->size>wasted && blk->size-wasted>=size) { /* over-satisfied */ - *addr = blk->addr; - H5F_addr_inc (addr, wasted); + *addr_p = blk->addr; + H5F_addr_inc (addr_p, wasted); ret_value = 0; } } @@ -631,18 +636,19 @@ H5F_low_alloc (H5F_low_t *lf, intn op, hsize_t alignment, hsize_t threshold, * Thursday, November 13, 1997 * * Modifications: - * + * Robb Matzke, 1999-07-28 + * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t -H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr) +H5F_low_seteof(H5F_low_t *lf, haddr_t addr) { FUNC_ENTER(H5F_low_seteof, FAIL); assert(lf); - assert(addr && addr_defined(addr)); + assert(H5F_addr_defined(addr)); - lf->eof = *addr; + lf->eof = addr; FUNC_LEAVE(SUCCEED); } @@ -662,113 +668,24 @@ H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr) * Friday, November 7, 1997 * * Modifications: - * + * Robb Matzke, 1999-07-28 + * The A1 and A2 arguments are passed by value. *------------------------------------------------------------------------- */ intn -H5F_addr_cmp(const haddr_t *a1, const haddr_t *a2) +H5F_addr_cmp(haddr_t a1, haddr_t a2) { FUNC_ENTER(H5F_addr_cmp, FAIL); - assert(a1 && addr_defined(a1)); - assert(a2 && addr_defined(a2)); + assert(H5F_addr_defined(a1)); + assert(H5F_addr_defined(a2)); - if (a1->offset < a2->offset) - HRETURN(-1); - if (a1->offset > a2->offset) - HRETURN(1); + if (a1 < a2) HRETURN(-1); + if (a1 > a2) HRETURN(1); FUNC_LEAVE(0); } - -/*------------------------------------------------------------------------- - * Function: H5F_addr_undef - * - * Purpose: Cause an address to become undefined. - * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -H5F_addr_undef(haddr_t *addr/*out*/) -{ - assert(addr); - addr->offset = (uint64_t)(-1); -} - -/*------------------------------------------------------------------------- - * Function: H5F_addr_defined - * - * Purpose: Determines if an address has a defined value. - * - * Return: Success: TRUE or FALSE - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -htri_t -H5F_addr_defined(const haddr_t *addr) -{ - FUNC_ENTER(H5F_addr_defined, FAIL); - FUNC_LEAVE(addr_defined(addr)); -} - -/*------------------------------------------------------------------------- - * Function: H5F_addr_reset - * - * Purpose: Reset the address to zero. - * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -H5F_addr_reset(haddr_t *addr/*out*/) -{ - assert(addr); - addr->offset = 0; -} - -/*------------------------------------------------------------------------- - * Function: H5F_addr_zerop - * - * Purpose: Determines if an address is zero. - * - * Return: Success: TRUE or FALSE - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -htri_t -H5F_addr_zerop(const haddr_t *addr) -{ - FUNC_ENTER(H5F_addr_zerop, FAIL); - FUNC_LEAVE(0 == addr->offset ? TRUE : FALSE); -} /*------------------------------------------------------------------------- * Function: H5F_addr_encode @@ -783,26 +700,26 @@ H5F_addr_zerop(const haddr_t *addr) * Friday, November 7, 1997 * * Modifications: - * + * Robb Matzke, 1999-07-28 + * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ void -H5F_addr_encode(H5F_t *f, uint8_t **pp, const haddr_t *addr) +H5F_addr_encode(H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) { uintn i; haddr_t tmp; assert(f); assert(pp && *pp); - assert(addr); - if (addr_defined(addr)) { - tmp = *addr; + if (H5F_addr_defined(addr)) { + tmp = addr; for (i=0; i<H5F_SIZEOF_ADDR(f); i++) { - *(*pp)++ = (uint8_t)(tmp.offset & 0xff); - tmp.offset >>= 8; + *(*pp)++ = (uint8_t)(tmp & 0xff); + tmp >>= 8; } - assert("overflow" && 0 == tmp.offset); + assert("overflow" && 0 == tmp); } else { for (i=0; i<H5F_SIZEOF_ADDR(f); i++) { @@ -810,6 +727,7 @@ H5F_addr_encode(H5F_t *f, uint8_t **pp, const haddr_t *addr) } } } + /*------------------------------------------------------------------------- * Function: H5F_addr_decode @@ -831,7 +749,7 @@ H5F_addr_encode(H5F_t *f, uint8_t **pp, const haddr_t *addr) *------------------------------------------------------------------------- */ void -H5F_addr_decode(H5F_t *f, const uint8_t **pp, haddr_t *addr/*out*/) +H5F_addr_decode(H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) { uintn i; haddr_t tmp; @@ -840,46 +758,23 @@ H5F_addr_decode(H5F_t *f, const uint8_t **pp, haddr_t *addr/*out*/) assert(f); assert(pp && *pp); - assert(addr); + assert(addr_p); - addr->offset = 0; + *addr_p = 0; for (i=0; i<H5F_SIZEOF_ADDR(f); i++) { c = *(*pp)++; if (c != 0xff) all_zero = FALSE; - if (i<sizeof(addr->offset)) { - tmp.offset = c; - tmp.offset <<= i * 8; /*use tmp to get casting right */ - addr->offset |= tmp.offset; + if (i<sizeof(*addr_p)) { + tmp = c; + tmp <<= i * 8; /*use tmp to get casting right */ + *addr_p |= tmp; } else if (!all_zero) { assert(0 == **pp); /*overflow */ } } - if (all_zero) H5F_addr_undef(addr); -} - -/*------------------------------------------------------------------------- - * Function: H5F_addr_print - * - * Purpose: Print an address - * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void -H5F_addr_print(FILE *stream, const haddr_t *addr) -{ - assert(stream); - assert(addr); - - HDfprintf(stream, "%a", addr); + if (all_zero) H5F_addr_undef(addr_p); } @@ -898,14 +793,15 @@ H5F_addr_print(FILE *stream, const haddr_t *addr) *------------------------------------------------------------------------- */ void -H5F_addr_pow2(uintn n, haddr_t *addr /*out */ ) +H5F_addr_pow2(uintn n, haddr_t *addr_p/*out*/) { - assert(addr); - assert(n < 8 * sizeof(addr->offset)); + assert(addr_p); + assert(n < 8*sizeof(haddr_t)); - addr->offset = 1; - addr->offset <<= n; + *addr_p = 1; + *addr_p <<= n; } + /*------------------------------------------------------------------------- * Function: H5F_addr_inc @@ -922,12 +818,12 @@ H5F_addr_pow2(uintn n, haddr_t *addr /*out */ ) *------------------------------------------------------------------------- */ void -H5F_addr_inc(haddr_t *addr/*in,out*/, hsize_t inc) +H5F_addr_inc(haddr_t *addr_p/*in,out*/, hsize_t inc) { - assert(addr && addr_defined(addr)); - assert(addr->offset <= addr->offset + inc); + assert(addr_p && H5F_addr_defined(*addr_p)); + assert(*addr_p <= *addr_p + inc); - addr->offset += inc; + *addr_p += inc; } @@ -946,18 +842,18 @@ H5F_addr_inc(haddr_t *addr/*in,out*/, hsize_t inc) *------------------------------------------------------------------------- */ void -H5F_addr_adj(haddr_t *addr/*in,out */, hssize_t adj) +H5F_addr_adj(haddr_t *addr_p/*in,out */, hssize_t adj) { #ifndef NDEBUG - assert(addr && addr_defined(addr)); + assert(addr_p && H5F_addr_defined(*addr_p)); if (adj>=0) { - assert(addr->offset <= addr->offset + adj); + assert(*addr_p <= *addr_p + adj); } else { - assert (addr->offset > addr->offset + adj); + assert (*addr_p > *addr_p + adj); } #endif - addr->offset += adj; + *addr_p += adj; } @@ -972,42 +868,18 @@ H5F_addr_adj(haddr_t *addr/*in,out */, hssize_t adj) * Friday, November 7, 1997 * * Modifications: - * + * Robb Matzke, 1999-07-28 + * The A2 argument is passed by value. *------------------------------------------------------------------------- */ void -H5F_addr_add(haddr_t *a1 /*in,out */ , const haddr_t *a2) +H5F_addr_add(haddr_t *a1/*in,out*/, haddr_t a2) { - assert(a1 && addr_defined(a1)); - assert(a2 && addr_defined(a2)); - a1->offset += a2->offset; + assert(a1 && H5F_addr_defined(*a1)); + assert(H5F_addr_defined(a2)); + *a1 += a2; } - -/*------------------------------------------------------------------------- - * Function: H5F_addr_hash - * - * Purpose: Computes a hash value of an address between 0 and MOD-1, - * inclusive. - * - * Return: Success: The hash value - * - * Failure: never fails - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -uintn -H5F_addr_hash(const haddr_t *addr, uintn mod) -{ - assert(addr && addr_defined(addr)); - assert(mod > 0); - return (unsigned)(addr->offset % mod); /*ignore file number */ -} /*------------------------------------------------------------------------- * Function: H5F_addr_pack @@ -1028,15 +900,16 @@ H5F_addr_hash(const haddr_t *addr, uintn mod) *------------------------------------------------------------------------- */ herr_t -H5F_addr_pack(H5F_t UNUSED *f, haddr_t *addr, const unsigned long objno[2]) +H5F_addr_pack(H5F_t UNUSED *f, haddr_t *addr_p/*out*/, + const unsigned long objno[2]) { assert(f); assert(objno); - assert(addr); + assert(addr_p); - addr->offset = objno[0]; + *addr_p = objno[0]; #if SIZEOF_LONG<SIZEOF_UINT64_T - addr->offset |= ((uint64_t)objno[1]) << (8*sizeof(long)); + *addr_p |= ((uint64_t)objno[1]) << (8*sizeof(long)); #endif return(SUCCEED); |