diff options
author | James Laird <jlaird@hdfgroup.org> | 2005-04-01 14:57:46 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2005-04-01 14:57:46 (GMT) |
commit | bcc99d9328d2110c1603b13948aeb72e084e40ef (patch) | |
tree | bdc0f50e32ecfbb4efb51e411cea9173cb40f0d3 | |
parent | c89839ea8dded4b8b598f4c64b53f762a9305d7b (diff) | |
download | hdf5-bcc99d9328d2110c1603b13948aeb72e084e40ef.zip hdf5-bcc99d9328d2110c1603b13948aeb72e084e40ef.tar.gz hdf5-bcc99d9328d2110c1603b13948aeb72e084e40ef.tar.bz2 |
[svn-r10532]
Purpose:
Bug fix
Description:
Ported big.c "overlap" fix to 1.6 branch.
Platforms tested:
sleipnir, eirene, modi4
-rw-r--r-- | test/big.c | 38 |
1 files changed, 32 insertions, 6 deletions
@@ -29,6 +29,8 @@ const char *FILENAME[] = { #define WRT_SIZE 4*1024 #define FAMILY_SIZE 1024*1024*1024 +#define MAX_TRIES 100 + #if H5_SIZEOF_LONG_LONG >= 8 # define GB8LL ((unsigned long_long)8*1024*1024*1024) #else @@ -38,6 +40,7 @@ const char *FILENAME[] = { /* Protocols */ static void usage(void); +static hsize_t values_used[WRT_N]; /*------------------------------------------------------------------------- * Function: randll @@ -56,13 +59,36 @@ static void usage(void); *------------------------------------------------------------------------- */ static hsize_t -randll(hsize_t limit) +randll(hsize_t limit, int current_index) { - - hsize_t acc = rand (); - acc *= rand (); + hsize_t acc; + int overlap = 1; + int i; + int tries = 0; + + /* Generate up to MAX_TRIES random numbers until one of them */ + /* does not overlap with any previous writes */ + while(overlap != 0 && tries < MAX_TRIES) + { + acc = rand (); + acc *= rand (); + acc = acc % limit; + overlap = 0; + + for(i = 0; i < current_index; i++) + { + if((acc >= values_used[i]) && (acc < values_used[i]+WRT_SIZE)) + overlap = 1; + if((acc+WRT_SIZE >= values_used[i]) && (acc+WRT_SIZE < values_used[i +]+WRT_SIZE)) + overlap = 1; + } + tries++; + } - return acc % limit; + values_used[current_index]=acc; + + return acc; } @@ -240,7 +266,7 @@ writer (hid_t fapl, int wrt_n) hs_size[0] = WRT_SIZE; if ((mem_space = H5Screate_simple (1, hs_size, hs_size))<0) goto error; for (i=0; i<wrt_n; i++) { - hs_start[0] = randll (size2[0]); + hs_start[0] = randll (size2[0], i); HDfprintf (out, "#%03d 0x%016Hx\n", i, hs_start[0]); if (H5Sselect_hyperslab (space2, H5S_SELECT_SET, hs_start, NULL, hs_size, NULL)<0) goto error; |