diff options
-rw-r--r-- | MANIFEST | 3 | ||||
-rwxr-xr-x | bin/bbrelease | 10 | ||||
-rwxr-xr-x | bin/chkcopyright | 2 | ||||
-rwxr-xr-x | bin/chkmanifest | 6 | ||||
-rwxr-xr-x | bin/release | 6 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.cpp | 191 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.h | 5 | ||||
-rw-r--r-- | hl/src/H5PT.c | 14 | ||||
-rw-r--r-- | hl/test/test_packet.c | 42 | ||||
-rw-r--r-- | hl/test/test_packet_vlen.c | 104 | ||||
-rw-r--r-- | tools/h5repack/CMakeLists.txt | 16 | ||||
-rw-r--r-- | tools/h5repack/CMakeTests.cmake | 3 | ||||
-rw-r--r-- | tools/h5repack/Makefile.am | 3 | ||||
-rw-r--r-- | tools/h5repack/dynlib_rpk.c | 50 | ||||
-rw-r--r-- | tools/h5repack/dynlib_vrpk.c | 104 | ||||
-rw-r--r-- | tools/h5repack/h5repack_plugin.sh.in | 55 | ||||
-rw-r--r-- | tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl | 158 | ||||
-rw-r--r-- | tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst | 14 | ||||
-rw-r--r-- | tools/perform/pio_engine.c | 1 | ||||
-rw-r--r-- | tools/perform/pio_perf.c | 11 | ||||
-rw-r--r-- | tools/perform/pio_perf.h | 3 | ||||
-rw-r--r-- | tools/perform/pio_standalone.c | 1 | ||||
-rw-r--r-- | tools/perform/pio_standalone.h | 445 | ||||
-rw-r--r-- | tools/perform/sio_standalone.h | 5 |
24 files changed, 995 insertions, 257 deletions
@@ -1309,6 +1309,7 @@ # h5repack sources ./tools/h5repack/Makefile.am ./tools/h5repack/dynlib_rpk.c +./tools/h5repack/dynlib_vrpk.c ./tools/h5repack/h5repack.sh.in ./tools/h5repack/h5repack_plugin.sh.in ./tools/h5repack/h5repack.c @@ -2308,12 +2309,14 @@ ./tools/h5repack/testfiles/deflate_limit.h5repack_layout.h5.ddl ./tools/h5repack/testfiles/plugin_none.h5repack_layout.UD.h5.tst ./tools/h5repack/testfiles/plugin_test.h5repack_layout.h5.tst +./tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst ./tools/h5repack/testfiles/h5repack-help.txt ./tools/h5repack/testfiles/h5repack_filters.h5-gzip_verbose_filters.tst ./tools/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst ./tools/h5repack/testfiles/h5repack_layout.h5.ddl ./tools/h5repack/testfiles/h5repack_layout.UD.h5-plugin_none.ddl ./tools/h5repack/testfiles/h5repack_layout.h5-plugin_test.ddl +./tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl ./tools/h5repack/testfiles/h5repack_layout.h5-plugin_zero.tst ./tools/h5repack/testfiles/1_vds.h5-vds_dset_chunk20x10x5-v.ddl ./tools/h5repack/testfiles/2_vds.h5-vds_chunk3x6x9-v.ddl diff --git a/bin/bbrelease b/bin/bbrelease index c5d562e..b06b243 100755 --- a/bin/bbrelease +++ b/bin/bbrelease @@ -190,7 +190,7 @@ today=`date +%Y%m%d` pmode='no' revmode='no' tmpdir="../#release_tmp.$$" # tmp work directory -DOC_URL=http://svn.hdfgroup.uiuc.edu/hdf5doc/trunk +DOC_URL=https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5doc.git CPPLUS_RM_NAME=cpplus_RM # Restore previous Version information @@ -334,7 +334,7 @@ done # trunk is different than branches. if [ "${DOCVERSION}" ]; then - DOC_URL=http://svn.hdfgroup.uiuc.edu/hdf5doc/branches/${DOCVERSION} + DOC_URL=https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5doc.git -b ${DOCVERSION} fi # Create the tar file @@ -371,11 +371,11 @@ for comp in $methods; do ;; doc) if [ "${DOCVERSION}" = "" ]; then - DOCVERSION=trunk + DOCVERSION=master fi test "$verbose" && echo " Creating docs..." 1>&2 - # Check out docs from svn repo - (cd $tmpdir; svn co $DOC_URL > /dev/null) || exit 1 + # Check out docs from git repo + (cd $tmpdir; git clone $DOC_URL > /dev/null) || exit 1 # Create doxygen C++ RM (cd c++/src && doxygen cpp_doc_config > /dev/null ) || exit 1 # Replace version of C++ RM with just-created version diff --git a/bin/chkcopyright b/bin/chkcopyright index 07fcb24..f6e910d 100755 --- a/bin/chkcopyright +++ b/bin/chkcopyright @@ -30,7 +30,7 @@ DIFF="diff" INITFILE=.h5chkright.ini EXCEPTIONS=/tmp/h5chkright.except.$$ tmpfile=/tmp/h5chkright_tmp.$$ -EXCEPTIONDIRS="-name CVS -o -name .svn" # at least skip CVS directories. +EXCEPTIONDIRS="-name .git" # at least skip .git directories. EXTRACTEDFILE=/tmp/h5chkright.extracted.$$ VERBOSE= # default no FIXIT= # default no diff --git a/bin/chkmanifest b/bin/chkmanifest index a0b51af..a01217d 100755 --- a/bin/chkmanifest +++ b/bin/chkmanifest @@ -14,8 +14,8 @@ # access to either file, you may request a copy from help@hdfgroup.org. # -# Check that all the files in MANIFEST exist and that (if this is a -# SVN checkout) that all the SVN-managed files appear in the +# Check that all the files in MANIFEST exist and (if this is a +# GIT checkout) that all the GIT-managed files appear in the # MANIFEST. # @@ -142,7 +142,7 @@ done if [ "X$fail" = "Xyes" ]; then cat 1>&2 <<EOF The MANIFEST is out of date. Files marked with a minus sign (-) no -longer exist; files marked with a plus sign (+) are SVN-managed but do +longer exist; files marked with a plus sign (+) are GIT-managed but do not appear in the MANIFEST. Please remedy the situation and try again. EOF exit 1 diff --git a/bin/release b/bin/release index 1d3c9c5..08779cb 100755 --- a/bin/release +++ b/bin/release @@ -168,7 +168,7 @@ release_date=`date +%F` today=`date +%Y%m%d` pmode='no' tmpdir="../#release_tmp.$$" # tmp work directory -DOC_URL=http://svn.hdfgroup.uiuc.edu/hdf5doc/trunk +DOC_URL=https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5doc.git CPPLUS_RM_NAME=cpplus_RM # Restore previous Version information @@ -316,8 +316,8 @@ for comp in $methods; do ;; doc) test "$verbose" && echo " Creating docs..." 1>&2 - # Check out docs from svn repo - (cd $tmpdir; svn co $DOC_URL > /dev/null) || exit 1 + # Check out docs from git repo + (cd $tmpdir; git clone $DOC_URL > /dev/null) || exit 1 # Create doxygen C++ RM (cd c++/src && doxygen cpp_doc_config > /dev/null ) || exit 1 # Replace version of C++ RM with just-created version diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index dd3d2ba..67efda5 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -38,23 +38,22 @@ int main(void) } else { - num_errors += BasicTest(); + num_errors += BasicTest(); - num_errors += TestCompoundDatatype(); + num_errors += TestCompoundDatatype(); - num_errors += TestGetPacket(); + num_errors += TestGetPacket(); - num_errors += TestGetNext(); + num_errors += TestGetNext(); - num_errors += TestCompress(); + num_errors += TestCompress(); - num_errors += TestErrors(); + num_errors += TestErrors(); - num_errors += SystemTest(); + num_errors += SystemTest(); -#ifdef VLPT_REMOVED - num_errors += VariableLengthTest(); -#endif /* VLPT_REMOVED */ + /* Test data corruption in packed structs */ + num_errors += TestHDFFV_9758(); /* Terminate access to the file. */ err = H5Fclose(fileID); @@ -562,73 +561,131 @@ error: return 1; } -#ifdef VLPT_REMOVED -int VariableLengthTest(void) +/*------------------------------------------------------------------------- + * TestHDFFV_9758(): Test that a packet table with compound datatype which + * contains string type can be created and written correctly. (HDFFV-9758) + * + * Notes: + * Previously, data of the field that follows the string was read back + * as garbage when #pragma pack(1) is used. + * 2016/10/20 -BMR + *------------------------------------------------------------------------- + */ +#pragma pack(1) // no padding +const char* ABHI_PT("/abhiTest"); +const hsize_t NUM_PACKETS = 5; +const int STRING_LENGTH = 19; // including terminating NULL +int TestHDFFV_9758() { - long test_long; - short test_short; - hvl_t read_buf; - VL_PacketTable* test_VLPT; - PacketTable* new_pt; - - TESTING("variable-length packet tables") - - /* Create a variable length table */ - test_VLPT = new VL_PacketTable(fileID, "/VariableLengthTest", 1); - - /* Verify that the creation succeeded */ - if(! test_VLPT->IsValid()) - goto error; - - /* Append some packets */ - test_short = 9; - test_VLPT->AppendPacket(&test_short, sizeof(short)); - test_long = 16; - test_VLPT->AppendPacket(&test_long, sizeof(long)); - - /* Read them back and make sure they are correct */ - test_VLPT->GetNextPackets(1, &read_buf); - - if(read_buf.len != sizeof(short)) - goto error; - if(*(short *)(read_buf.p) != test_short) - goto error; - - /* Free the memory used by the read */ - test_VLPT->FreeReadbuff(1, &read_buf); - - /* Read the second record */ - test_VLPT->GetNextPackets(1, &read_buf); - - if(read_buf.len != sizeof(long)) - goto error; - if(*(long *)(read_buf.p) != test_long) - goto error; - - /* Free the memory used by the read */ - test_VLPT->FreeReadbuff(1, &read_buf); - - /* Close the packet table */ - delete test_VLPT; + hid_t strtype; + hid_t compound_type; + herr_t err; + struct s1_t + { + int a; + float b; + double c; + char d[STRING_LENGTH]; // null terminated string + int e; + }; - /* Reopen the packet table and verify that it is variable length */ - new_pt = new PacketTable(fileID, "/VariableLengthTest"); + s1_t s1[NUM_PACKETS]; + + for (hsize_t i = 0; i < NUM_PACKETS; i++) + { + s1[i].a = i; + s1[i].b = 1.f * static_cast<float>(i * i); + s1[i].c = 1. / (i + 1); + sprintf(s1[i].d, "string%d", (int)i); + s1[i].e = 100+i; + } - /* Verify that the open succeeded */ - if(! new_pt->IsValid()) - goto error; + TESTING("data corruption in packed structs (HDFFV-9758)") + + // Build a compound datatype + compound_type = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + if (compound_type < 0) + goto error; + + err = H5Tinsert(compound_type, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); + if (err < 0) + goto error; + err = H5Tinsert(compound_type, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); + if (err < 0) + goto error; + err = H5Tinsert(compound_type, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + if (err < 0) + goto error; + + strtype = H5Tcopy (H5T_C_S1); + if (compound_type < 0) + goto error; + err = H5Tset_size (strtype, STRING_LENGTH); /* create string */ + if (err < 0) + goto error; + err = H5Tinsert(compound_type, "d_name", HOFFSET(s1_t, d), strtype); + if (err < 0) + goto error; + err = H5Tinsert(compound_type, "e_name", HOFFSET(s1_t, e), H5T_NATIVE_INT); + if (err < 0) + goto error; + + { // so ptable will go out of scope before PASSED + + // Create a packet table + FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); + if (!ptable.IsValid()) + goto error; + + // Add packets to the table + for (size_t i = 0; i < NUM_PACKETS; i++) + { + /* Appends one packet at the current position */ + err = ptable.AppendPacket(s1 + i); + if (err < 0) goto error; + } - if(new_pt->IsVariableLength() != 1) - goto error; + // Check packet count + const hsize_t count = ptable.GetPacketCount(err); + if (err < 0) + goto error; + + if (count != NUM_PACKETS) + { + std::cerr + << "Number of packets in packet table should be " << NUM_PACKETS + << " but is " << count << endl; + } - /* Close the packet table */ - delete new_pt; + // Read and verify the data + ptable.ResetIndex(); + for (size_t i = 0; i < NUM_PACKETS; i++) + { + s1_t s2; + memset(&s2, 0, sizeof(s1_t)); + err = ptable.GetNextPacket(&s2); + if (err < 0) + goto error; + + if (s2.a != s1[i].a || s2.e != s1[i].e) + goto error; + else if (HDstrcmp(s2.d, s1[i].d)) + goto error; + } + } // end of ptable block PASSED(); return 0; error: + + H5E_BEGIN_TRY { + H5Tclose(strtype); + H5Tclose(compound_type); + H5Fclose(fileID); + } H5E_END_TRY; + H5_FAILED(); return 1; } -#endif /* VLPT_REMOVED */ + diff --git a/hl/c++/test/ptableTest.h b/hl/c++/test/ptableTest.h index d351e34..60b55ca 100644 --- a/hl/c++/test/ptableTest.h +++ b/hl/c++/test/ptableTest.h @@ -52,7 +52,8 @@ int TestGetPacket(void); Test for unusual interactions between multiple packet tables. */ int SystemTest(void); -/* Test the variable length dataset functionality */ -int VariableLengthTest(void); +/* Create a packet table with compound type, which has a string type. Verify + that data was written and read correctly. */ +int TestHDFFV_9758(void); #endif /* PTABLETEST */ diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index 647cbe8..5f0f94f 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -141,7 +141,9 @@ hid_t H5PTcreate(hid_t loc_id, if(H5Pclose(plistcopy_id) < 0) goto error; - if((table->type_id = H5Tget_native_type(dtype_id, H5T_DIR_DEFAULT)) < 0) + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ + if((table->type_id = H5Tcopy(dtype_id)) < 0) goto error; H5PT_create_index(table); @@ -259,12 +261,11 @@ hid_t H5PTcreate_fl ( hid_t loc_id, if(H5Pclose(plist_id) < 0) goto error; + /* Make a copy of caller's datatype and save it in the table structure. + It will be closed when the table is closed */ if((table->type_id = H5Tcopy(dtype_id)) < 0) goto error; - if((table->type_id = H5Tget_native_type(table->type_id, H5T_DIR_DEFAULT)) < 0) - goto error; - H5PT_create_index(table); table->size = 0; @@ -352,8 +353,9 @@ hid_t H5PTopen( hid_t loc_id, if((type_id = H5Dget_type(table->dset_id)) < 0) goto error; - /* Get the table's native datatype */ - if((table->type_id = H5Tget_native_type(type_id, H5T_DIR_ASCEND)) < 0) + /* Make a copy of the datatype obtained and save it in the table structure. + It will be closed when the table is closed */ + if((table->type_id = H5Tcopy(type_id)) < 0) goto error; /* Close the disk datatype */ diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index e2ca2b5..f577947 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -95,8 +95,10 @@ make_particle_type(void) return FAIL; /* Insert fields. */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 ) return FAIL; @@ -133,8 +135,10 @@ static int create_hl_table(hid_t fid) herr_t status; /* Initialize the field field_type */ - string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, (size_t)16 ); + if ((string_type = H5Tcopy(H5T_C_S1)) < 0) + return FAIL; + if (H5Tset_size(string_type, (size_t)16) < 0) + return FAIL; field_type[0] = string_type; field_type[1] = H5T_NATIVE_INT; field_type[2] = H5T_NATIVE_INT; @@ -152,12 +156,14 @@ static int create_hl_table(hid_t fid) field_names, part_offset, field_type, chunk_size, fill_data, compress, testPart ); -if(status<0) - return FAIL; -else - return SUCCEED; -} + if (H5Tclose(string_type) < 0) + return FAIL; + if(status<0) + return FAIL; + else + return SUCCEED; +} /*------------------------------------------------------------------------- @@ -183,7 +189,8 @@ static int test_create_close(hid_t fid) /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); - H5Tclose(part_t); + if (H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; if( H5PTis_varlen(table) != 0) @@ -248,7 +255,7 @@ static int test_append(hid_t fid) { herr_t err; hid_t table; - hsize_t count; + hsize_t count = 0; TESTING("H5PTappend"); @@ -458,7 +465,8 @@ static int test_big_table(hid_t fid) /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1); - H5Tclose(part_t); + if (H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; @@ -536,7 +544,8 @@ static int test_opaque(hid_t fid) /* Create a new table */ table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1); - H5Tclose(part_t); + if( H5Tclose(part_t) < 0) + goto error; if( H5PTis_valid(table) < 0) goto error; @@ -743,9 +752,9 @@ static int test_rw_nonnative_dt(hid_t fid) /* Create a fixed-length packet table within the file */ /* This table's "packets" will be simple integers and it will use no compression */ if(H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) { - ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, -1); + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); } else { - ptable = H5PTcreate_fl(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, -1); + ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT); } if(ptable == H5I_INVALID_HID) goto error; @@ -973,7 +982,8 @@ int main(void) status = 1; /* Close the file */ - H5Fclose(fid); + if (H5Fclose(fid) < 0) + status = 1; return status; } diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index f1e4e00..b152a2c 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -28,7 +28,6 @@ #define PT_COMP_VLEN "Dataset with Compound Type of VL types" #define PT_VLEN_VLEN "Dataset with VL of VL types" #define PT_FIXED_LEN "Fixed-length Packet Table" -#define SPACE3_RANK 1 #define L1_INCM 16 #define L2_INCM 8 #define NAME_BUF_SIZE 80 @@ -149,6 +148,7 @@ static int test_VLof_atomic(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vltype > 0) H5Tclose(vltype); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -228,7 +228,9 @@ static int test_VLof_comptype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release the datatypes */ + if (H5Tclose(cmptype) < 0) + goto error; if (H5Tclose(vltype) < 0) goto error; @@ -286,6 +288,8 @@ static int test_VLof_comptype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (cmptype > 0) H5Tclose(cmptype); + if (vltype > 0) H5Tclose(vltype); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -311,13 +315,11 @@ static int test_compound_VL_VLtype(void) hvl_t v; } compVLVL_t; hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t space=H5I_INVALID_HID; /* Dataspace identifier */ hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing a VL of VL of atomic datatype */ - hsize_t dims1[] = {NRECORDS}; hsize_t count; /* Number of records in the table */ compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ @@ -356,11 +358,6 @@ static int test_compound_VL_VLtype(void) if (fid < 0) goto error; - /* Create dataspace for datasets */ - space = H5Screate_simple(SPACE3_RANK, dims1, NULL); - if (space < 0) - goto error; - /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) @@ -394,7 +391,11 @@ static int test_compound_VL_VLtype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; if (H5Tclose(comp_vlvl) < 0) goto error; @@ -459,12 +460,6 @@ static int test_compound_VL_VLtype(void) if (ret < 0) goto error; - /* Release datatypes */ - if (H5Tclose(vlatomic) < 0) - goto error; - if (H5Tclose(vlofvl) < 0) - goto error; - /* Close the file */ if (H5Fclose(fid) < 0) goto error; @@ -473,6 +468,9 @@ static int test_compound_VL_VLtype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vlatomic > 0) H5Tclose(vlatomic); + if (vlofvl > 0) H5Tclose(vlofvl); + if (comp_vlvl > 0) H5Tclose(comp_vlvl); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -547,7 +545,9 @@ static int test_VLof_VLtype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; if (H5Tclose(vlofvl) < 0) goto error; @@ -590,6 +590,8 @@ static int test_VLof_VLtype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vlatomic > 0) H5Tclose(vlatomic); + if (vlofvl > 0) H5Tclose(vlofvl); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -771,6 +773,10 @@ static int adding_attribute(hid_t fid, const char *table_name, const char *attr_ if (H5Aclose(attr_id) < 0) goto error; + /* Close the dataspace */ + if (H5Sclose(space_id) < 0) + goto error; + /* Close the packet table */ if (H5PTclose(ptable) < 0) goto error; @@ -778,6 +784,8 @@ static int adding_attribute(hid_t fid, const char *table_name, const char *attr_ return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (attr_id > 0) H5Aclose(attr_id); + if (space_id > 0) H5Sclose(space_id); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); return ret; } /* adding_attribute */ @@ -792,19 +800,12 @@ error: /* An error has occurred. Clean up and exit. */ static herr_t verify_attribute(hid_t fid, const char *table_name, const char *attr_name) { hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t space_id=H5I_INVALID_HID; /* Dataspace for the attribute */ hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */ - hsize_t dims[] = {ATTR_DIM}; /* Dimensions for dataspace */ int read_data[ATTR_DIM]; /* Output buffer */ int ii; herr_t ret = FAIL; /* Returned status from a callee */ - /* Create dataspace for attribute */ - space_id = H5Screate_simple(ATTR_RANK, dims, NULL); - if (space_id < 0) - goto error; - /* Open the named packet table */ ptable = H5PTopen(fid, table_name); if (ptable < 0) @@ -907,7 +908,7 @@ static int test_attributes(void) return(ret); error: /* An error has occurred. Clean up and exit. */ - H5Fclose(fid); + if (fid > 0) H5Fclose(fid); H5_FAILED(); return FAIL; } /* test_attributes */ @@ -929,9 +930,8 @@ error: /* An error has occurred. Clean up and exit. */ * 2016/01/27 -BMR *------------------------------------------------------------------------- */ -static herr_t verify_accessors(const char *table_name, herr_t expected_value) +static herr_t verify_accessors(hid_t fid, const char *table_name, herr_t expected_value) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */ hid_t dtype_id=H5I_INVALID_HID; /* Dataset identifier */ @@ -940,11 +940,6 @@ static herr_t verify_accessors(const char *table_name, herr_t expected_value) herr_t is_varlen = 0; herr_t ret = FAIL; /* Returned status from a callee */ - /* Open the file. */ - fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); - if (fid < 0) - goto error; - /* Open the named packet table. */ ptable = H5PTopen(fid, table_name); if (ptable < 0) @@ -993,7 +988,8 @@ static herr_t verify_accessors(const char *table_name, herr_t expected_value) error: /* An error has occurred. Clean up and exit. */ if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); - return ret; + H5_FAILED(); + return FAIL; } /* verify_accessors */ /*------------------------------------------------------------------------- @@ -1009,7 +1005,6 @@ error: /* An error has occurred. Clean up and exit. */ static int test_accessors(void) { hid_t fid=H5I_INVALID_HID; /* File identifier */ - hid_t ptable=H5I_INVALID_HID; /* File identifier */ herr_t ret = FAIL; /* Returned status from a callee */ TESTING("accessor functions"); @@ -1019,11 +1014,11 @@ static int test_accessors(void) if (fid < 0) goto error; - ret = verify_accessors(PT_VLEN_ATOMIC, TRUE); + ret = verify_accessors(fid, PT_VLEN_ATOMIC, TRUE); if (ret < 0) goto error; - ret = verify_accessors(PT_FIXED_LEN, FALSE); + ret = verify_accessors(fid, PT_FIXED_LEN, FALSE); if (ret < 0) goto error; @@ -1035,7 +1030,6 @@ static int test_accessors(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ - if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5_FAILED(); return FAIL; @@ -1150,6 +1144,7 @@ static int testfl_VLof_atomic(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vltype > 0) H5Tclose(vltype); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -1229,7 +1224,9 @@ static int testfl_VLof_comptype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release the datatypes */ + if (H5Tclose(cmptype) < 0) + goto error; if (H5Tclose(vltype) < 0) goto error; @@ -1287,6 +1284,8 @@ static int testfl_VLof_comptype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (cmptype > 0) H5Tclose(cmptype); + if (vltype > 0) H5Tclose(vltype); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -1312,13 +1311,11 @@ static int testfl_compound_VL_VLtype(void) hvl_t v; } compVLVL_t; hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t space=H5I_INVALID_HID; /* Dataspace identifier */ hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing a VL of VL of atomic datatype */ - hsize_t dims1[] = {NRECORDS}; hsize_t count; /* Number of records in the table */ compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ @@ -1357,11 +1354,6 @@ static int testfl_compound_VL_VLtype(void) if (fid < 0) goto error; - /* Create dataspace for datasets */ - space = H5Screate_simple(SPACE3_RANK, dims1, NULL); - if (space < 0) - goto error; - /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) @@ -1395,7 +1387,11 @@ static int testfl_compound_VL_VLtype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; + if (H5Tclose(vlofvl) < 0) + goto error; if (H5Tclose(comp_vlvl) < 0) goto error; @@ -1460,12 +1456,6 @@ static int testfl_compound_VL_VLtype(void) if (ret < 0) goto error; - /* Release datatypes */ - if (H5Tclose(vlatomic) < 0) - goto error; - if (H5Tclose(vlofvl) < 0) - goto error; - /* Close the file */ if (H5Fclose(fid) < 0) goto error; @@ -1474,6 +1464,9 @@ static int testfl_compound_VL_VLtype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vlatomic > 0) H5Tclose(vlatomic); + if (vlofvl > 0) H5Tclose(vlofvl); + if (comp_vlvl > 0) H5Tclose(comp_vlvl); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -1548,7 +1541,9 @@ static int testfl_VLof_VLtype(void) if (ptable == H5I_INVALID_HID) goto error; - /* Close the vlen datatype */ + /* Release datatypes */ + if (H5Tclose(vlatomic) < 0) + goto error; if (H5Tclose(vlofvl) < 0) goto error; @@ -1591,6 +1586,8 @@ static int testfl_VLof_VLtype(void) return SUCCEED; error: /* An error has occurred. Clean up and exit. */ + if (vlatomic > 0) H5Tclose(vlatomic); + if (vlofvl > 0) H5Tclose(vlofvl); if (H5PTis_valid(ptable) > 0) H5PTclose(ptable); if (fid > 0) H5Fclose(fid); H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); @@ -1654,7 +1651,6 @@ int test_packet_table_with_varlen(void) if (test_accessors() < 0) status = FAIL; - /************************************************************************** Calling test functions for deprecated function H5PTcreate_fl Mar 2016, -BMR diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 2f2e3e2..4a21605 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -51,6 +51,9 @@ if (BUILD_TESTING) set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + set (HDF5_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") + set (HDF5_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_VCORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_VTARGET ${HDF5_TOOL_PLUGIN_LIB_VCORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) @@ -59,6 +62,11 @@ if (BUILD_TESTING) target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + add_library (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED " " " ") + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TOOL_PLUGIN_LIB_VNAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") #----------------------------------------------------------------------------- @@ -72,6 +80,14 @@ if (BUILD_TESTING) "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" ) + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_VTARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + ) include (CMakeTests.cmake) diff --git a/tools/h5repack/CMakeTests.cmake b/tools/h5repack/CMakeTests.cmake index 666f28e..e8ee00f 100644 --- a/tools/h5repack/CMakeTests.cmake +++ b/tools/h5repack/CMakeTests.cmake @@ -116,6 +116,8 @@ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_test.h5repack_layout.h5.tst ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.UD.h5-plugin_none.ddl ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_none.h5repack_layout.UD.h5.tst + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5-plugin_version_test.ddl + ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/plugin_version_test.h5repack_layout.h5.tst ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/1_vds.h5-vds_dset_chunk20x10x5-v.ddl ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/2_vds.h5-vds_chunk3x6x9-v.ddl ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/3_1_vds.h5-vds_chunk2x5x8-v.ddl @@ -1133,6 +1135,7 @@ ############################################################################## ### P L U G I N T E S T S ############################################################################## + ADD_H5_UD_TEST (plugin_version_test 0 h5repack_layout.h5 -v -f UD=260,4,9,1,9,235) ADD_H5_UD_TEST (plugin_test 0 h5repack_layout.h5 -v -f UD=257,1,9) ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE) # check for no parameters diff --git a/tools/h5repack/Makefile.am b/tools/h5repack/Makefile.am index 21ac362..5f32d73 100644 --- a/tools/h5repack/Makefile.am +++ b/tools/h5repack/Makefile.am @@ -63,8 +63,9 @@ h5repack.sh.chkexe_: h5repacktst.chkexe_ if HAVE_SHARED_CONDITIONAL # Build it as shared library if configure is enabled for shared library. - lib_LTLIBRARIES=libdynlibadd.la + lib_LTLIBRARIES=libdynlibadd.la libdynlibvers.la libdynlibadd_la_SOURCES=dynlib_rpk.c + libdynlibvers_la_SOURCES=dynlib_vrpk.c install-exec-hook: $(RM) $(DESTDIR)$(libdir)/*dynlib* diff --git a/tools/h5repack/dynlib_rpk.c b/tools/h5repack/dynlib_rpk.c index 6e8a7b6..3469e58 100644 --- a/tools/h5repack/dynlib_rpk.c +++ b/tools/h5repack/dynlib_rpk.c @@ -12,10 +12,10 @@ * to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu - * 13 February 2013 + * Programmer: Raymond Lu + * 13 February 2013 * - * Purpose: Tests the plugin module (H5PL) + * Purpose: Tests the plugin module (H5PL) */ #include <stdlib.h> @@ -24,48 +24,36 @@ #define H5Z_FILTER_DYNLIB1 257 -/* gcc attribute support from H5private.h */ -#ifdef __cplusplus -# define H5_ATTR_CONST /*void*/ -#else /* __cplusplus */ -#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C) -# define H5_ATTR_CONST __attribute__((const)) -#else -# define H5_ATTR_CONST /*void*/ -#endif -#endif /* __cplusplus */ - - static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ const H5Z_class2_t H5Z_DYNLIB1[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB1, /* Filter id number */ + H5Z_FILTER_DYNLIB1, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ - "dynlib1", /* Filter name for debugging */ + "dynlib1", /* Filter name for debugging */ NULL, /* The "can apply" callback */ NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ + (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ }}; -H5_ATTR_CONST H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -H5_ATTR_CONST const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} /*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib1 + * Function: H5Z_filter_dynlib1 * - * Purpose: A dynlib1 filter method that adds on and subtract from - * the original value with another value. It will be built - * as a shared library. plugin.c test will load and use - * this filter library. + * Purpose: A dynlib1 filter method that adds on and subtract from + * the original value with another value. It will be built + * as a shared library. plugin.c test will load and use + * this filter library. * - * Return: Success: Data chunk size + * Return: Success: Data chunk size * - * Failure: 0 + * Failure: 0 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 29 March 2013 * *------------------------------------------------------------------------- @@ -81,12 +69,12 @@ H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, /* Check for the correct number of parameters */ if(cd_nelmts == 0) - return(0); + return 0; /* Check that permanent parameters are set correctly */ if(cd_values[0] > 9) - return(0); - + return 0; + add_on = (int)cd_values[0]; if(flags & H5Z_FLAG_REVERSE) { /*read*/ diff --git a/tools/h5repack/dynlib_vrpk.c b/tools/h5repack/dynlib_vrpk.c new file mode 100644 index 0000000..8da0270 --- /dev/null +++ b/tools/h5repack/dynlib_vrpk.c @@ -0,0 +1,104 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic document set and is * + * linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access * + * to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Tests the plugin module (H5PL) + */ + +#include <stdlib.h> +#include <stdio.h> +#include "H5PLextern.h" + +#define H5Z_FILTER_DYNLIB4 260 + +#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) + +static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_DYNLIB4[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIB4, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlib4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} + +/*------------------------------------------------------------------------- + * Function: H5Z_filter_dynlib4 + * + * Purpose: A dynlib4 filter method that adds on and subtract from + * the original value with another value. It will be built + * as a shared library. plugin.c test will load and use + * this filter library. Designed to call a HDF function. + * + * Return: Success: Data chunk size + * + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int add_on = 0; + unsigned ver_info[3]; + + /* Check for the library version */ + if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { + PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion"); + return(0); + } + /* Check for the correct number of parameters */ + if(cd_nelmts == 0) + return(0); + + /* Check that permanent parameters are set correctly */ + if(cd_values[0] > 9) + return(0); + + if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { + PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match"); + return(0); + } + + add_on = (int)cd_values[0]; + + if(flags & H5Z_FLAG_REVERSE) { /*read*/ + /* Substract the "add on" value to all the data values */ + while(buf_left > 0) { + *int_ptr++ -= add_on; + buf_left -= sizeof(int); + } /* end while */ + } /* end if */ + else { /*write*/ + /* Add the "add on" value to all the data values */ + while(buf_left > 0) { + *int_ptr++ += add_on; + buf_left -= sizeof(int); + } /* end while */ + } /* end else */ + + return nbytes; +} /* end H5Z_filter_dynlib4() */ + diff --git a/tools/h5repack/h5repack_plugin.sh.in b/tools/h5repack/h5repack_plugin.sh.in index a064db6..c8d5bf7 100644 --- a/tools/h5repack/h5repack_plugin.sh.in +++ b/tools/h5repack/h5repack_plugin.sh.in @@ -1,16 +1,16 @@ #! /bin/sh # -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic document set and is -# linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access -# to either file, you may request a copy from help@hdfgroup.org. +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic document set and is +# linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access +# to either file, you may request a copy from help@hdfgroup.org. # srcdir=@srcdir@ TOP_BUILDDIR=@top_builddir@ @@ -34,6 +34,7 @@ exit_code=$EXIT_SUCCESS TEST_NAME=ud_plugin FROM_DIR=`pwd`/.libs PLUGIN_LIB="$FROM_DIR/libdynlibadd.*" +PLUGIN_LIB2="$FROM_DIR/libdynlibvers.*" PLUGIN_LIBDIR=testdir3 RM='rm -rf' @@ -65,6 +66,8 @@ LIST_HDF5_TEST_FILES=" $SRC_H5REPACK_TESTFILES/h5repack_layout.h5 $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_test.ddl $SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst +$SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_version_test.ddl +$SRC_H5REPACK_TESTFILES/plugin_version_test.h5repack_layout.h5.tst " #$SRC_H5REPACK_TESTFILES/h5repack_layout.UD.h5 #$SRC_H5REPACK_TESTFILES/h5repack_layout.UD.h5-plugin_none.ddl @@ -90,6 +93,11 @@ if [ $? != 0 ]; then echo "Failed to copy plugin library ($PLUGIN_LIB) for test." exit $EXIT_FAILURE fi +$CP $PLUGIN_LIB2 $PLUGIN_LIBDIR +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB2) for test." + exit $EXIT_FAILURE +fi # setup plugin path ENVCMD="env HDF5_PLUGIN_PATH=../${PLUGIN_LIBDIR}" @@ -113,7 +121,7 @@ COPY_TESTFILES_TO_TESTDIR() $CP -f $tstfile $TESTDIR if [ $? -ne 0 ]; then echo "Error: FAILED to copy $tstfile ." - + # Comment out this to CREATE expected file exit $EXIT_FAILURE fi @@ -168,11 +176,11 @@ STDOUT_FILTER() { # cleanup rm -f $tmp_file } - + # This runs h5repack comparing output with h5dump output # from -pH option # -TOOLTEST_DUMP() +TOOLTEST_DUMP() { echo $@ infile=$2 @@ -186,7 +194,7 @@ TOOLTEST_DUMP() shift shift - + # Run test. TESTING $H5REPACK $@ ( @@ -209,10 +217,10 @@ TOOLTEST_DUMP() nerrors="`expr $nerrors + 1`" test yes = "$verbose" && diff -c $expect1 $actual1 |sed 's/^/ /' fi - VERIFY h5dump output -pH $outfile + VERIFY h5dump output -pH $outfile ( cd $TESTDIR - $ENVCMD $H5DUMP_BIN -pH $outfile + $ENVCMD $H5DUMP_BIN -pH $outfile ) >$actual2 2>$actual2_err RET=$? cat $actual2_err >> $actual2 @@ -225,26 +233,29 @@ TOOLTEST_DUMP() nerrors="`expr $nerrors + 1`" test yes = "$verbose" && diff -c $expect2 $actual2 |sed 's/^/ /' fi - + fi - + rm -f $actual1 $actual1_err $actual2 $actual2_err rm -f $outfile } ############################################################################## -### T H E T E S T S +### T H E T E S T S ############################################################################## # prepare for test COPY_TESTFILES_TO_TESTDIR # Run the test +arg="h5repack_layout.h5 -v -f UD=260,4,9,1,9,235" +TOOLTEST_DUMP plugin_version_test $arg + arg="h5repack_layout.h5 -v -f UD=257,1,9" -TOOLTEST_DUMP plugin_test $arg +TOOLTEST_DUMP plugin_test $arg #arg="h5repack_layout.UD.h5 -v -f NONE" -#TOOLTEST_DUMP plugin_none $arg +#TOOLTEST_DUMP plugin_none $arg # print results if test $nerrors -ne 0 ; then diff --git a/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl new file mode 100644 index 0000000..3d09e14 --- /dev/null +++ b/tools/h5repack/testfiles/h5repack_layout.h5-plugin_version_test.ddl @@ -0,0 +1,158 @@ +HDF5 "out-plugin_version_test.h5repack_layout.h5" { +GROUP "/" { + DATASET "dset1" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset2" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset3" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset4" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_chunk" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 20, 10 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_compact" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } + DATASET "dset_contiguous" { + DATATYPE H5T_STD_I32LE + DATASPACE SIMPLE { ( 40, 20 ) / ( 40, 20 ) } + STORAGE_LAYOUT { + CHUNKED ( 40, 20 ) + SIZE 3200 (1.000:1 COMPRESSION) + } + FILTERS { + USER_DEFINED_FILTER { + FILTER_ID 260 + COMMENT dynlib4 + PARAMS { 9 1 9 235 } + } + } + FILLVALUE { + FILL_TIME H5D_FILL_TIME_IFSET + VALUE H5D_FILL_VALUE_DEFAULT + } + ALLOCATION_TIME { + H5D_ALLOC_TIME_INCR + } + } +} +} diff --git a/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst b/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst new file mode 100644 index 0000000..1a496c6 --- /dev/null +++ b/tools/h5repack/testfiles/plugin_version_test.h5repack_layout.h5.tst @@ -0,0 +1,14 @@ +Objects to modify layout are... +Objects to apply filter are... + User Defined 260 +----------------------------------------- + Type Filter (Compression) Name +----------------------------------------- + group / + dset UD (1.000:1) /dset1 + dset UD (1.000:1) /dset2 + dset UD (1.000:1) /dset3 + dset UD (1.000:1) /dset4 + dset UD (1.000:1) /dset_chunk + dset UD (1.000:1) /dset_compact + dset UD (1.000:1) /dset_contiguous diff --git a/tools/perform/pio_engine.c b/tools/perform/pio_engine.c index eaedcb8..ab11efd 100644 --- a/tools/perform/pio_engine.c +++ b/tools/perform/pio_engine.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * diff --git a/tools/perform/pio_perf.c b/tools/perform/pio_perf.c index 1402ec3..c1bfadb 100644 --- a/tools/perform/pio_perf.c +++ b/tools/perform/pio_perf.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -378,7 +377,7 @@ main(int argc, char **argv) } if (opts->output_file) { - if ((output = fopen(opts->output_file, "w")) == NULL) { + if ((output = HDfopen(opts->output_file, "w")) == NULL) { fprintf(stderr, "%s: cannot open output file\n", progname); perror(opts->output_file); goto finish; @@ -1228,7 +1227,7 @@ report_parameters(struct options *opts) HDfprintf(output, "Contiguous\n"); { - char *prefix = getenv("HDF5_PARAPREFIX"); + char *prefix = HDgetenv("HDF5_PARAPREFIX"); HDfprintf(output, "rank %d: Env HDF5_PARAPREFIX=%s\n", rank, (prefix ? prefix : "not set")); @@ -1293,7 +1292,7 @@ parse_command_line(int argc, char *argv[]) char buf[10]; int i; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1345,7 +1344,7 @@ parse_command_line(int argc, char *argv[]) char buf[10]; int i; - memset(buf, '\0', sizeof(buf)); + HDmemset(buf, '\0', sizeof(buf)); for (i = 0; *end != '\0' && *end != ','; ++end) if (isalnum(*end) && i < 10) @@ -1509,7 +1508,7 @@ parse_size_directive(const char *size) off_t s; char *endptr; - s = strtol(size, &endptr, 10); + s = HDstrtol(size, &endptr, 10); if (endptr && *endptr) { while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t')) diff --git a/tools/perform/pio_perf.h b/tools/perform/pio_perf.h index 0fff7a3..89cf3a8 100644 --- a/tools/perform/pio_perf.h +++ b/tools/perform/pio_perf.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -16,6 +15,7 @@ #ifndef PIO_PERF_H__ #define PIO_PERF_H__ +#include "io_timer.h" #ifndef STANDALONE #include "H5private.h" #include "h5test.h" @@ -24,7 +24,6 @@ #else #include "pio_standalone.h" #endif -#include "io_timer.h" /* setup the dataset no fill option if this is v1.5 or more */ #if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4 diff --git a/tools/perform/pio_standalone.c b/tools/perform/pio_standalone.c index e404274..475c678 100644 --- a/tools/perform/pio_standalone.c +++ b/tools/perform/pio_standalone.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * diff --git a/tools/perform/pio_standalone.h b/tools/perform/pio_standalone.h index 762a564..f088c93 100644 --- a/tools/perform/pio_standalone.h +++ b/tools/perform/pio_standalone.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * @@ -44,62 +43,437 @@ #endif /* - * And now for a couple non-Posix functions... Watch out for systems that - * define these in terms of macros. + * Redefine all the POSIX functions. We should never see a POSIX + * function (or any other non-HDF5 function) in the source! */ +#define HDabort() abort() +#define HDabs(X) abs(X) #ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) +#define HDaccess(F,M) _access(F, M) +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ #else /* H5_HAVE_WIN32_API */ - -#if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); +#define HDaccess(F,M) access(F, M) +#ifndef F_OK +#define F_OK 00 +#define W_OK 02 +#define R_OK 04 #endif - -#define HDstrdup(S) strdup(S) - #endif /* H5_HAVE_WIN32_API */ - +#define HDacos(X) acos(X) +#ifdef H5_HAVE_ALARM +#define HDalarm(N) alarm(N) +#else /* H5_HAVE_ALARM */ +#define HDalarm(N) (0) +#endif /* H5_HAVE_ALARM */ +#define HDasctime(T) asctime(T) +#define HDasin(X) asin(X) +#define HDasprintf asprintf /*varargs*/ +#define HDassert(X) assert(X) +#define HDatan(X) atan(X) +#define HDatan2(X,Y) atan2(X,Y) +#define HDatexit(F) atexit(F) +#define HDatof(S) atof(S) +#define HDatoi(S) atoi(S) +#define HDatol(S) atol(S) +#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) +#define HDcalloc(N,Z) calloc(N,Z) +#define HDceil(X) ceil(X) +#define HDcfgetispeed(T) cfgetispeed(T) +#define HDcfgetospeed(T) cfgetospeed(T) +#define HDcfsetispeed(T,S) cfsetispeed(T,S) +#define HDcfsetospeed(T,S) cfsetospeed(T,S) +#define HDchdir(S) chdir(S) +#define HDchmod(S,M) chmod(S,M) +#define HDchown(S,O,G) chown(S,O,G) +#define HDclearerr(F) clearerr(F) +#define HDclock() clock() +#define HDclose(F) close(F) +#define HDclosedir(D) closedir(D) +#define HDcos(X) cos(X) +#define HDcosh(X) cosh(X) +#define HDcreat(S,M) creat(S,M) +#define HDctermid(S) ctermid(S) +#define HDctime(T) ctime(T) +#define HDcuserid(S) cuserid(S) +#ifdef H5_HAVE_DIFFTIME +#define HDdifftime(X,Y) difftime(X,Y) +#else +#define HDdifftime(X,Y) ((double)(X)-(double)(Y)) +#endif +#define HDdiv(X,Y) div(X,Y) +#define HDdup(F) dup(F) +#define HDdup2(F,I) dup2(F,I) +/* execl() variable arguments */ +/* execle() variable arguments */ +/* execlp() variable arguments */ +#define HDexecv(S,AV) execv(S,AV) +#define HDexecve(S,AV,E) execve(S,AV,E) +#define HDexecvp(S,AV) execvp(S,AV) +#define HDexit(N) exit(N) +#define HD_exit(N) _exit(N) +#define HDexp(X) exp(X) +#define HDfabs(X) fabs(X) +/* use ABS() because fabsf() fabsl() are not common yet. */ +#define HDfabsf(X) ABS(X) +#define HDfabsl(X) ABS(X) +#define HDfclose(F) fclose(F) +/* fcntl() variable arguments */ +#define HDfdopen(N,S) fdopen(N,S) +#define HDfeof(F) feof(F) +#define HDferror(F) ferror(F) +#define HDfflush(F) fflush(F) +#define HDfgetc(F) fgetc(F) +#define HDfgetpos(F,P) fgetpos(F,P) +#define HDfgets(S,N,F) fgets(S,N,F) +#ifdef H5_HAVE_WIN32_API +#define HDfileno(F) _fileno(F) +#else /* H5_HAVE_WIN32_API */ +#define HDfileno(F) fileno(F) +#endif /* H5_HAVE_WIN32_API */ +#define HDfloor(X) floor(X) +#define HDfmod(X,Y) fmod(X,Y) +#define HDfopen(S,M) fopen(S,M) +#define HDfork() fork() +#define HDfpathconf(F,N) fpathconf(F,N) H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); -#define HDstrcmp(S,T) strcmp(S,T) -#define HDstrlen(S) strlen(S) -#define HDstrncmp(S,T,L) strncmp(S,T,L) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrchr(S,C) strchr(S,C) -#define HDfree(M) free(M) +#define HDfputc(C,F) fputc(C,F) +#define HDfputs(S,F) fputs(S,F) +#define HDfread(M,Z,N,F) fread(M,Z,N,F) +#define HDfree(M) free(M) +#define HDfreopen(S,M,F) freopen(S,M,F) +#define HDfrexp(X,N) frexp(X,N) +/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ +#ifdef H5_HAVE_FREXPF +#define HDfrexpf(X,N) frexpf(X,N) +#else /* H5_HAVE_FREXPF */ +#define HDfrexpf(X,N) frexp(X,N) +#endif /* H5_HAVE_FREXPF */ +#ifdef H5_HAVE_FREXPL +#define HDfrexpl(X,N) frexpl(X,N) +#else /* H5_HAVE_FREXPL */ +#define HDfrexpl(X,N) frexp(X,N) +#endif /* H5_HAVE_FREXPL */ +/* fscanf() variable arguments */ +#ifdef H5_HAVE_FSEEKO + #define HDfseek(F,O,W) fseeko(F,O,W) +#else + #define HDfseek(F,O,W) fseek(F,O,W) +#endif +#define HDfsetpos(F,P) fsetpos(F,P) +/* definitions related to the file stat utilities. + * Windows have its own function names. + * For Unix, if off_t is not 64bit big, try use the pseudo-standard + * xxx64 versions if available. + */ +#ifdef H5_HAVE_WIN32_API + #define HDfstat(F,B) _fstati64(F,B) + #define HDlstat(S,B) _lstati64(S,B) + #define HDstat(S,B) _stati64(S,B) + typedef struct _stati64 h5_stat_t; + typedef __int64 h5_stat_size_t; + #define HDoff_t __int64 +#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) + #define HDfstat(F,B) fstat64(F,B) + #define HDlstat(S,B) lstat64(S,B) + #define HDstat(S,B) stat64(S,B) + typedef struct stat64 h5_stat_t; + typedef off64_t h5_stat_size_t; + #define HDoff_t off64_t +#else + #define HDfstat(F,B) fstat(F,B) + #define HDlstat(S,B) lstat(S,B) + #define HDstat(S,B) stat(S,B) + typedef struct stat h5_stat_t; + typedef off_t h5_stat_size_t; + #define HDoff_t off_t +#endif +#ifndef H5_HAVE_WIN32_API +/* These definitions differ in Windows and are defined in + * H5win32defs for that platform. + */ +typedef struct stat h5_stat_t; +typedef off_t h5_stat_size_t; +#define HDoff_t off_t +#endif /* H5_HAVE_WIN32_API */ +#define HDftell(F) ftell(F) +#define HDftruncate(F,L) ftruncate(F,L) +#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) +#define HDgetc(F) getc(F) +#define HDgetchar() getchar() +#define HDgetcwd(S,Z) getcwd(S,Z) +#define HDgetegid() getegid() +#define HDgetenv(S) getenv(S) +#define HDgeteuid() geteuid() +#define HDgetgid() getgid() +#define HDgetgrgid(G) getgrgid(G) +#define HDgetgrnam(S) getgrnam(S) +#define HDgetgroups(Z,G) getgroups(Z,G) +#ifdef H5_HAVE_WIN32_API +#define HDgetlogin() Wgetlogin() +#else /* H5_HAVE_WIN32_API */ +#define HDgetlogin() getlogin() +#endif /* H5_HAVE_WIN32_API */ +#define HDgetpgrp() getpgrp() +#define HDgetpid() getpid() +#define HDgetppid() getppid() +#define HDgetpwnam(S) getpwnam(S) +#define HDgetpwuid(U) getpwuid(U) +#define HDgetrusage(X,S) getrusage(X,S) +#define HDgets(S) gets(S) +#ifdef H5_HAVE_WIN32_API + H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); +#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +#else /* H5_HAVE_WIN32_API */ +#define HDgettimeofday(S,P) gettimeofday(S,P) +#endif /* H5_HAVE_WIN32_API */ +#define HDgetuid() getuid() +#define HDgmtime(T) gmtime(T) +#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ +#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ +#define HDisatty(F) isatty(F) +#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ +#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ +#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ +#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ +#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ +#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ +#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ +#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ +#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ +#define HDkill(P,S) kill(P,S) +#define HDlabs(X) labs(X) +#define HDldexp(X,N) ldexp(X,N) +#define HDldiv(X,Y) ldiv(X,Y) +#define HDlink(OLD,NEW) link(OLD,NEW) +#define HDlocaleconv() localeconv() +#define HDlocaltime(T) localtime(T) +#define HDlog(X) log(X) +#define HDlog10(X) log10(X) +#define HDlongjmp(J,N) longjmp(J,N) +#ifdef H5_HAVE_WIN32_API + #define HDlseek(F,O,W) _lseeki64(F,O,W) +#else + #ifdef H5_HAVE_LSEEK64 + #define HDlseek(F,O,W) lseek64(F,O,W) + #else + #define HDlseek(F,O,W) lseek(F,O,W) + #endif +#endif +#define HDmalloc(Z) malloc(Z) +#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) +#define HDmblen(S,N) mblen(S,N) +#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) +#define HDmbtowc(P,S,Z) mbtowc(P,S,Z) +#define HDmemchr(S,C,Z) memchr(S,C,Z) +#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) +/* + * The (char*) casts are required for the DEC when optimizations are turned + * on and the source and/or destination are not aligned. + */ +#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) +#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) +/* + * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO + */ +#ifdef H5_HAVE_VISUAL_STUDIO +#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#else /* H5_HAVE_VISUAL_STUDIO */ +#define HDmemset(X,C,Z) memset(X,C,Z) +#endif /* H5_HAVE_VISUAL_STUDIO */ +#ifdef H5_HAVE_WIN32_API +#define HDmkdir(S,M) _mkdir(S) +#else /* H5_HAVE_WIN32_API */ +#define HDmkdir(S,M) mkdir(S,M) +#endif /* H5_HAVE_WIN32_API */ +#define HDmkfifo(S,M) mkfifo(S,M) +#define HDmktime(T) mktime(T) +#define HDmodf(X,Y) modf(X,Y) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#else +#define HDopen(S,F,M) open(S,F,M) +#endif +#define HDopendir(S) opendir(S) +#define HDpathconf(S,N) pathconf(S,N) +#define HDpause() pause() +#define HDperror(S) perror(S) +#define HDpipe(F) pipe(F) +#define HDpow(X,Y) pow(X,Y) +/* printf() variable arguments */ +#define HDputc(C,F) putc(C,F) +#define HDputchar(C) putchar(C) +#define HDputs(S) puts(S) +#define HDqsort(M,N,Z,F) qsort(M,N,Z,F) +#define HDraise(N) raise(N) + +#ifdef H5_HAVE_RAND_R +#define HDrandom() HDrand() +H5_DLL int HDrand(void); +#elif H5_HAVE_RANDOM +#define HDrand() random() +#define HDrandom() random() #else -#define HDopen(S,F,M) open(S,F,M) +#define HDrand() rand() +#define HDrandom() rand() #endif -#define HDclose(F) close(F) +#define HDread(F,M,Z) read(F,M,Z) +#define HDreaddir(D) readdir(D) +#define HDrealloc(M,Z) realloc(M,Z) +#define HDremove(S) remove(S) +#define HDrename(OLD,NEW) rename(OLD,NEW) +#define HDrewind(F) rewind(F) +#define HDrewinddir(D) rewinddir(D) +#define HDrmdir(S) rmdir(S) +/* scanf() variable arguments */ +#define HDsetbuf(F,S) setbuf(F,S) +#define HDsetgid(G) setgid(G) +#define HDsetjmp(J) setjmp(J) +#define HDsetlocale(N,S) setlocale(N,S) +#define HDsetpgid(P,PG) setpgid(P,PG) +#define HDsetsid() setsid() +#define HDsetuid(U) setuid(U) +/* Windows does not permit setting the buffer size to values + less than 2. */ +#ifndef H5_HAVE_WIN32_API +#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) +#else +#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) +#endif +#define HDsigaddset(S,N) sigaddset(S,N) +#define HDsigdelset(S,N) sigdelset(S,N) +#define HDsigemptyset(S) sigemptyset(S) +#define HDsigfillset(S) sigfillset(S) +#define HDsigismember(S,N) sigismember(S,N) +#define HDsiglongjmp(J,N) siglongjmp(J,N) +#define HDsignal(N,F) signal(N,F) +#define HDsigpending(S) sigpending(S) +#define HDsigprocmask(H,S,O) sigprocmask(H,S,O) +#define HDsigsetjmp(J,N) sigsetjmp(J,N) +#define HDsigsuspend(S) sigsuspend(S) +#define HDsin(X) sin(X) +#define HDsinh(X) sinh(X) +#define HDsleep(N) sleep(N) #ifdef H5_HAVE_WIN32_API -#define HDlseek(F,O,W) _lseeki64(F,O,W) +H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); +#define HDsnprintf c99_snprintf /*varargs*/ #else -#define HDlseek(F,O,W) lseek(F,O,W) +#define HDsnprintf snprintf /*varargs*/ #endif - -#define HDwrite(F,M,Z) write(F,M,Z) - -#define HDread(F,M,Z) read(F,M,Z) +/* sprintf() variable arguments */ +#define HDsqrt(X) sqrt(X) +#ifdef H5_HAVE_RAND_R +H5_DLL void HDsrand(unsigned int seed); +#define HDsrandom(S) HDsrand(S) +#elif H5_HAVE_RANDOM +#define HDsrand(S) srandom(S) +#define HDsrandom(S) srandom(S) +#else +#define HDsrand(S) srand(S) +#define HDsrandom(S) srand(S) +#endif +/* sscanf() variable arguments */ #ifdef H5_HAVE_WIN32_API - #define HDstat(S,B) _stati64(S,B) +#define HDstrcasecmp(A,B) _stricmp(A,B) #else -#define HDstat(S,B) stat(S,B) +#define HDstrcasecmp(X,Y) strcasecmp(X,Y) #endif - +#define HDstrcat(X,Y) strcat(X,Y) +#define HDstrchr(S,C) strchr(S,C) +#define HDstrcmp(X,Y) strcmp(X,Y) +#define HDstrcoll(X,Y) strcoll(X,Y) +#define HDstrcpy(X,Y) strcpy(X,Y) +#define HDstrcspn(X,Y) strcspn(X,Y) +#define HDstrerror(N) strerror(N) +#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) +#define HDstrlen(S) strlen(S) +#define HDstrncat(X,Y,Z) strncat(X,Y,Z) +#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) +#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) +#define HDstrpbrk(X,Y) strpbrk(X,Y) +#define HDstrrchr(S,C) strrchr(S,C) +#define HDstrspn(X,Y) strspn(X,Y) +#define HDstrstr(X,Y) strstr(X,Y) +#define HDstrtod(S,R) strtod(S,R) +#define HDstrtok(X,Y) strtok(X,Y) +#define HDstrtol(S,R,N) strtol(S,R,N) +H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); +#define HDstrtoul(S,R,N) strtoul(S,R,N) +#ifdef H5_HAVE_WIN32_API +#define HDstrtoull(S,R,N) _strtoui64(S,R,N) +#else +#define HDstrtoull(S,R,N) strtoull(S,R,N) +#endif +#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) +#define HDsysconf(N) sysconf(N) +#define HDsystem(S) system(S) +#define HDtan(X) tan(X) +#define HDtanh(X) tanh(X) +#define HDtcdrain(F) tcdrain(F) +#define HDtcflow(F,A) tcflow(F,A) +#define HDtcflush(F,N) tcflush(F,N) +#define HDtcgetattr(F,T) tcgetattr(F,T) +#define HDtcgetpgrp(F) tcgetpgrp(F) +#define HDtcsendbreak(F,N) tcsendbreak(F,N) +#define HDtcsetattr(F,O,T) tcsetattr(F,O,T) +#define HDtcsetpgrp(F,N) tcsetpgrp(F,N) +#define HDtime(T) time(T) +#define HDtimes(T) times(T) +#define HDtmpfile() tmpfile() +#define HDtmpnam(S) tmpnam(S) +#define HDtolower(C) tolower(C) +#define HDtoupper(C) toupper(C) +#define HDttyname(F) ttyname(F) +#define HDtzset() tzset() +#define HDumask(N) umask(N) +#define HDuname(S) uname(S) +#define HDungetc(C,F) ungetc(C,F) #ifdef H5_HAVE_WIN32_API -#define HDfstat(F,B) _fstati64(F,B) -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; +#define HDunlink(S) _unlink(S) #else -#define HDfstat(F,B) fstat(F,B) -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; +#define HDunlink(S) unlink(S) #endif +#define HDutime(S,T) utime(S,T) +#define HDva_arg(A,T) va_arg(A,T) +#define HDva_end(A) va_end(A) +#define HDva_start(A,P) va_start(A,P) +#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) +#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) +#define HDvprintf(FMT,A) vprintf(FMT,A) +#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) +#ifdef H5_HAVE_WIN32_API +H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); +#define HDvsnprintf c99_vsnprintf +#else +# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) +#endif +#define HDwait(W) wait(W) +#define HDwaitpid(P,W,O) waitpid(P,W,O) +#define HDwcstombs(S,P,Z) wcstombs(S,P,Z) +#define HDwctomb(S,C) wctomb(S,C) +#define HDwrite(F,M,Z) write(F,M,Z) + +/* + * And now for a couple non-Posix functions... Watch out for systems that + * define these in terms of macros. + */ +#ifdef H5_HAVE_WIN32_API +#define HDstrdup(S) _strdup(S) +#else /* H5_HAVE_WIN32_API */ + +#if !defined strdup && !defined H5_HAVE_STRDUP +extern char *strdup(const char *s); +#endif + +#define HDstrdup(S) strdup(S) + +#endif /* H5_HAVE_WIN32_API */ /* * HDF Boolean type. @@ -111,7 +485,6 @@ typedef off_t h5_stat_size_t; # define TRUE true #endif - /** From h5test.h **/ #ifdef H5_HAVE_PARALLEL diff --git a/tools/perform/sio_standalone.h b/tools/perform/sio_standalone.h index 63dc7b0..83dffa2 100644 --- a/tools/perform/sio_standalone.h +++ b/tools/perform/sio_standalone.h @@ -78,6 +78,11 @@ #define F_OK 0 /* Test for existence. */ #else /* H5_HAVE_WIN32_API */ #define HDaccess(F,M) access(F, M) +#ifndef F_OK +#define F_OK 00 +#define W_OK 02 +#define R_OK 04 +#endif #endif /* H5_HAVE_WIN32_API */ #define HDacos(X) acos(X) #ifdef H5_HAVE_ALARM |