summaryrefslogtreecommitdiffstats
path: root/src/H5Fcontig.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-04-23 20:04:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-04-23 20:04:30 (GMT)
commit298276970f0324764feb920b3480f25c9e2b98a3 (patch)
treeafd1869dd7e53dceda08b8a775b09bf93f4ba6f3 /src/H5Fcontig.c
parentbd994799c3ea1603a723ee01edc406bf8ace7e59 (diff)
downloadhdf5-298276970f0324764feb920b3480f25c9e2b98a3.zip
hdf5-298276970f0324764feb920b3480f25c9e2b98a3.tar.gz
hdf5-298276970f0324764feb920b3480f25c9e2b98a3.tar.bz2
[svn-r3832] Purpose:
Bug Fix. Description: Setting a non-zero userblock size was causing raw data caching code to break. Solution: Changed from using absolute end-of-address-space offsets in cache size calculations to relative offsets. Platforms tested: FreeBSD 4.3 (hawkwind)
Diffstat (limited to 'src/H5Fcontig.c')
-rw-r--r--src/H5Fcontig.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c
index ce5d096..d24e086 100644
--- a/src/H5Fcontig.c
+++ b/src/H5Fcontig.c
@@ -46,7 +46,8 @@ herr_t
H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxpl_id,
void *buf/*out*/)
{
- haddr_t eoa; /*end of file address */
+ haddr_t abs_eoa; /* Absolute end of file address */
+ haddr_t rel_eoa; /* Relative end of file address */
FUNC_ENTER(H5F_contig_read, FAIL);
@@ -119,11 +120,16 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(eoa=H5FD_get_eoa(f->shared->lf))) {
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
"unable to determine file size");
}
- f->shared->sieve_size=MIN(eoa-addr,f->shared->sieve_buf_size);
+
+ /* Adjust absolute EOA address to relative EOA address */
+ rel_eoa=abs_eoa-f->shared->base_addr;
+
+ /* Compute the size of the sieve buffer */
+ f->shared->sieve_size=MIN(rel_eoa-addr,f->shared->sieve_buf_size);
/* Read the new sieve buffer */
if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
@@ -161,11 +167,16 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(eoa=H5FD_get_eoa(f->shared->lf))) {
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
"unable to determine file size");
}
- f->shared->sieve_size=MIN(eoa-addr,f->shared->sieve_buf_size);
+
+ /* Adjust absolute EOA address to relative EOA address */
+ rel_eoa=abs_eoa-f->shared->base_addr;
+
+ /* Compute the size of the sieve buffer */
+ f->shared->sieve_size=MIN(rel_eoa-addr,f->shared->sieve_buf_size);
/* Read the new sieve buffer */
if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
@@ -213,9 +224,10 @@ herr_t
H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size,
hid_t dxpl_id, const void *buf)
{
- haddr_t eoa; /*end of file address */
+ haddr_t abs_eoa; /* Absolute end of file address */
+ haddr_t rel_eoa; /* Relative end of file address */
- FUNC_ENTER(H5F_block_write, FAIL);
+ FUNC_ENTER(H5F_contig_write, FAIL);
assert (f);
assert (size<SIZET_MAX);
@@ -293,11 +305,16 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(eoa=H5FD_get_eoa(f->shared->lf))) {
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
"unable to determine file size");
}
- f->shared->sieve_size=MIN(eoa-addr,f->shared->sieve_buf_size);
+
+ /* Adjust absolute EOA address to relative EOA address */
+ rel_eoa=abs_eoa-f->shared->base_addr;
+
+ /* Compute the size of the sieve buffer */
+ f->shared->sieve_size=MIN(rel_eoa-addr,f->shared->sieve_buf_size);
/* Read the new sieve buffer */
if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
@@ -336,11 +353,16 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(eoa=H5FD_get_eoa(f->shared->lf))) {
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
"unable to determine file size");
}
- f->shared->sieve_size=MIN(eoa-addr,f->shared->sieve_buf_size);
+
+ /* Adjust absolute EOA address to relative EOA address */
+ rel_eoa=abs_eoa-f->shared->base_addr;
+
+ /* Compute the size of the sieve buffer */
+ f->shared->sieve_size=MIN(rel_eoa-addr,f->shared->sieve_buf_size);
/* Read the new sieve buffer */
if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {