diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rwxr-xr-x | configure | 115 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | src/H5.c | 9 | ||||
-rw-r--r-- | src/H5Tbit.c | 192 | ||||
-rw-r--r-- | src/H5Tconv.c | 10 | ||||
-rw-r--r-- | src/H5config.h.in | 6 | ||||
-rw-r--r-- | src/H5private.h | 25 | ||||
-rw-r--r-- | test/.distdep | 17 | ||||
-rw-r--r-- | test/Makefile.in | 16 | ||||
-rw-r--r-- | test/bittests.c | 524 | ||||
-rw-r--r-- | test/dtypes.c | 94 | ||||
-rw-r--r-- | test/tattr.c | 24 |
13 files changed, 937 insertions, 97 deletions
@@ -209,6 +209,7 @@ ./test/.distdep ./test/Makefile.in ./test/big.c +./test/bittests.c ./test/chunk.c ./test/cmpd_dset.c ./test/dsets.c @@ -1728,8 +1728,47 @@ cat >> confdefs.h <<EOF EOF +echo $ac_n "checking size of long double""... $ac_c" 1>&6 +echo "configure:1733: checking size of long double" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long_double'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_long_double=8 +else + cat > conftest.$ac_ext <<EOF +#line 1741 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long double)); + exit(0); +} +EOF +if { (eval echo configure:1752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long_double=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long_double=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long_double" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double +EOF + + echo $ac_n "checking size of size_t""... $ac_c" 1>&6 -echo "configure:1733: checking size of size_t" >&5 +echo "configure:1772: checking size of size_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1737,7 +1776,7 @@ else ac_cv_sizeof_size_t=4 else cat > conftest.$ac_ext <<EOF -#line 1741 "configure" +#line 1780 "configure" #include "confdefs.h" #include <stdio.h> main() @@ -1748,7 +1787,7 @@ main() exit(0); } EOF -if { (eval echo configure:1752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_size_t=`cat conftestval` else @@ -1771,7 +1810,7 @@ cat >>confdefs.h <<\EOF #include <sys/types.h> /*for off_t definition*/ EOF echo $ac_n "checking size of off_t""... $ac_c" 1>&6 -echo "configure:1775: checking size of off_t" >&5 +echo "configure:1814: checking size of off_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1779,7 +1818,7 @@ else ac_cv_sizeof_off_t=4 else cat > conftest.$ac_ext <<EOF -#line 1783 "configure" +#line 1822 "configure" #include "confdefs.h" #include <stdio.h> main() @@ -1790,7 +1829,7 @@ main() exit(0); } EOF -if { (eval echo configure:1794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1833: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_off_t=`cat conftestval` else @@ -1817,7 +1856,7 @@ if test "${enable_hsizet+set}" = set; then fi echo $ac_n "checking for sizeof hsize_t and hssize_t""... $ac_c" 1>&6 -echo "configure:1821: checking for sizeof hsize_t and hssize_t" >&5 +echo "configure:1860: checking for sizeof hsize_t and hssize_t" >&5 case $HSIZET in no|small) echo "$ac_t""small" 1>&6 @@ -1835,12 +1874,12 @@ esac for ac_func in getpwuid gethostname system getrusage do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1839: checking for $ac_func" >&5 +echo "configure:1878: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1844 "configure" +#line 1883 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -1863,7 +1902,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:1867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1889,24 +1928,24 @@ done cat > conftest.$ac_ext <<EOF -#line 1893 "configure" +#line 1932 "configure" #include "confdefs.h" #include<sys/types.h> int main() { off64_t n = 0; ; return 0; } EOF -if { (eval echo configure:1900: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1939: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* for ac_func in lseek64 fseek64 do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1905: checking for $ac_func" >&5 +echo "configure:1944: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1910 "configure" +#line 1949 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -1929,7 +1968,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:1933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1964,12 +2003,12 @@ rm -f conftest* echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1968: checking for working const" >&5 +echo "configure:2007: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1973 "configure" +#line 2012 "configure" #include "confdefs.h" int main() { @@ -2018,7 +2057,7 @@ ccp = (char const *const *) p; ; return 0; } EOF -if { (eval echo configure:2022: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2039,21 +2078,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:2043: checking for inline" >&5 +echo "configure:2082: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <<EOF -#line 2050 "configure" +#line 2089 "configure" #include "confdefs.h" int main() { } $ac_kw foo() { ; return 0; } EOF -if { (eval echo configure:2057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2080,16 +2119,16 @@ esac echo $ac_n "checking for __attribute__ extension""... $ac_c" 1>&6 -echo "configure:2084: checking for __attribute__ extension" >&5 +echo "configure:2123: checking for __attribute__ extension" >&5 cat > conftest.$ac_ext <<EOF -#line 2086 "configure" +#line 2125 "configure" #include "confdefs.h" int main() { int __attribute__((unused)) f(void){return 1;} ; return 0; } EOF -if { (eval echo configure:2093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2132: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_ATTRIBUTE 1 @@ -2105,16 +2144,16 @@ fi rm -f conftest* echo $ac_n "checking for __FUNCTION__ extension""... $ac_c" 1>&6 -echo "configure:2109: checking for __FUNCTION__ extension" >&5 +echo "configure:2148: checking for __FUNCTION__ extension" >&5 cat > conftest.$ac_ext <<EOF -#line 2111 "configure" +#line 2150 "configure" #include "confdefs.h" int main() { int f(void){return __FUNCTION__;} ; return 0; } EOF -if { (eval echo configure:2118: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_FUNCTION 1 @@ -2130,7 +2169,7 @@ fi rm -f conftest* echo $ac_n "checking how to print long long""... $ac_c" 1>&6 -echo "configure:2134: checking how to print long long" >&5; +echo "configure:2173: checking how to print long long" >&5; if eval "test \"`echo '$''{'hdf5_cv_printf_ll'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2139,7 +2178,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <<EOF -#line 2143 "configure" +#line 2182 "configure" #include "confdefs.h" #include <stdio.h> @@ -2150,7 +2189,7 @@ else sprintf(s,"%${hdf5_cv_printf_ll}d",x); exit (strcmp(s,"1099511627776"));} EOF -if { (eval echo configure:2154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then break else @@ -2171,7 +2210,7 @@ EOF echo $ac_n "checking for debug flags""... $ac_c" 1>&6 -echo "configure:2175: checking for debug flags" >&5; +echo "configure:2214: checking for debug flags" >&5; # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" @@ -2209,7 +2248,7 @@ if test "${enable_parallel+set}" = set; then fi echo $ac_n "checking for parallel support""... $ac_c" 1>&6 -echo "configure:2213: checking for parallel support" >&5; +echo "configure:2252: checking for parallel support" >&5; case "X-$PARALLEL" in @@ -2234,7 +2273,7 @@ EOF CFLAGS="$CFLAGS $MPI_LIB" RUNTEST="$RUNTEST" echo $ac_n "checking for main in -lmpi""... $ac_c" 1>&6 -echo "configure:2238: checking for main in -lmpi" >&5 +echo "configure:2277: checking for main in -lmpi" >&5 ac_lib_var=`echo mpi'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2242,14 +2281,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lmpi $LIBS" cat > conftest.$ac_ext <<EOF -#line 2246 "configure" +#line 2285 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:2253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2276,7 +2315,7 @@ else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking for main in -lmpio""... $ac_c" 1>&6 -echo "configure:2280: checking for main in -lmpio" >&5 +echo "configure:2319: checking for main in -lmpio" >&5 ac_lib_var=`echo mpio'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2284,14 +2323,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lmpio $LIBS" cat > conftest.$ac_ext <<EOF -#line 2288 "configure" +#line 2327 "configure" #include "confdefs.h" int main() { main() ; return 0; } EOF -if { (eval echo configure:2295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in index 598c377..1a096c0 100644 --- a/configure.in +++ b/configure.in @@ -148,6 +148,7 @@ AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(long long, 8) AC_CHECK_SIZEOF(float, 4) AC_CHECK_SIZEOF(double, 8) +AC_CHECK_SIZEOF(long double, 8) AC_CHECK_SIZEOF(size_t, 4) cat >>confdefs.h <<\EOF #include <sys/types.h> /*for off_t definition*/ @@ -631,8 +631,17 @@ HDfprintf (FILE *stream, const char *fmt, ...) double x = va_arg (ap, double); n = fprintf (stream, template, x); } else { + /* + * Some compilers complain when `long double' and + * `double' are the same thing. + */ +#if SIZEOF_LONG_DOUBLE != SIZEOF_DOUBLE long double x = va_arg (ap, long double); n = fprintf (stream, template, x); +#else + double x = va_arg (ap, double); + n = fprintf (stream, template, x); +#endif } break; diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 0524dcc..b9a830d 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -32,25 +32,22 @@ void H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src, size_t src_offset, size_t size) { - uintn shift; + intn shift; uintn mask_lo, mask_hi; intn s_idx, d_idx; - + /* - * Calculate shifts and masks. See diagrams below. MASK_LO in this - * example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three - * bits). SHIFT is three since the source must be shifted right three bits - * to line up with the destination. + * Normalize the offset to be a byte number and a bit offset within that + * byte. */ - shift = (dst_offset%8)-(src_offset%8); - mask_lo = (1<<(8-shift))-1; - mask_hi = ((1<<shift)-1) << (8-shift); s_idx = src_offset / 8; d_idx = dst_offset / 8; + src_offset %= 8; + dst_offset %= 8; /* * Get things rolling. This means copying bits until we're aligned on a - * source byte. This the following example, four bits are copied to the + * source byte. This the following example, five bits are copied to the * destination. * * src[s_idx] @@ -64,11 +61,26 @@ H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src, * ...+---------------+---------------+ * dst[d_idx+1] dst[d_idx] */ - if (src_offset%8 && size>0) { + while (src_offset && size>0) { + unsigned nbits = MIN3 (size, 8-dst_offset, 8-src_offset); + unsigned mask = (1<<nbits) - 1; + + dst[d_idx] &= ~(mask<<dst_offset); + dst[d_idx] |= ((src[s_idx]>>src_offset)&mask) << dst_offset; + + src_offset += nbits; + if (src_offset>=8) { + s_idx++; + src_offset %= 8; + } + dst_offset += nbits; + if (dst_offset>=8) { + d_idx++; + dst_offset %= 8; + } + size -= nbits; } - - /* * The middle bits. We are aligned on a source byte which needs to be * copied to two (or one in the degenerate case) destination bytes. @@ -84,24 +96,47 @@ H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src, * +---------------+---------------+ * dst[d_idx+1] dst[d_idx] * + * + * Calculate shifts and masks. See diagrams below. MASK_LO in this + * example is 0x1f (the low five bits) and MASK_HI is 0xe0 (the high three + * bits). SHIFT is three since the source must be shifted right three bits + * to line up with the destination. */ + shift = dst_offset; + mask_lo = (1<<(8-shift))-1; + mask_hi = ~mask_lo; + for (/*void*/; size>8; size-=8, d_idx++, s_idx++) { if (shift) { - dst[d_idx+0] &= mask_lo; - dst[d_idx+0] |= (src[s_idx] << shift) & mask_hi; - dst[d_idx+1] &= mask_hi; - dst[d_idx+1] |= (src[s_idx] >> (8-shift)) & mask_lo; + dst[d_idx+0] &= ~(mask_lo<<shift); + dst[d_idx+0] |= (src[s_idx] & mask_lo) << shift; + dst[d_idx+1] &= ~(mask_hi>>(8-shift)); + dst[d_idx+1] |= (src[s_idx] & mask_hi) >> (8-shift); } else { dst[d_idx] = src[s_idx]; } } - - - /* Finish up */ - - + while (size>0) { + unsigned nbits = MIN3 (size, 8-dst_offset, 8-src_offset); + unsigned mask = (1<<nbits) - 1; + + dst[d_idx] &= ~(mask<<dst_offset); + dst[d_idx] |= ((src[s_idx]>>src_offset)&mask) << dst_offset; + + src_offset += nbits; + if (src_offset>=8) { + s_idx++; + src_offset %= 8; + } + dst_offset += nbits; + if (dst_offset>=8) { + d_idx++; + dst_offset %= 8; + } + size -= nbits; + } } @@ -123,6 +158,38 @@ H5T_bit_copy (uint8 *dst, size_t dst_offset, const uint8 *src, void H5T_bit_set (uint8 *buf, size_t offset, size_t size, hbool_t value) { + intn idx; + + /* Normalize */ + idx = offset / 8; + offset %= 8; + + /* The first partial byte */ + if (size && offset%8) { + size_t nbits = MIN (size, 8-offset); + unsigned mask = (1<<nbits)-1; + if (value) { + buf[idx++] |= mask << offset; + } else { + buf[idx++] &= ~(mask << offset); + } + size -= nbits; + } + + /* The middle bytes */ + while (size>=8) { + buf[idx++] = value ? 0xff : 0x00; + size -= 8; + } + + /* The last partial byte */ + if (size) { + if (value) { + buf[idx] |= (1<<size)-1; + } else { + buf[idx] &= ~((1<<size)-1); + } + } } @@ -150,5 +217,86 @@ ssize_t H5T_bit_find (uint8 *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value) { + size_t base=offset; + ssize_t idx, i; + + /* Some functions call this with value=TRUE */ + assert (TRUE==1); + + + switch (direction) { + case H5T_BIT_LSB: + /* Calculate index */ + idx = offset / 8; + offset %= 8; + + /* Beginning */ + if (offset) { + for (i=offset; i<8 && size>0; i++, size--) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + offset = 0; + idx++; + } + /* Middle */ + while (size>=8) { + if ((value?0x00:0xff)!=buf[idx]) { + for (i=0; i<8; i++) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + } + size -= 8; + idx++; + } + /* End */ + for (i=0; i<(ssize_t)size; i++) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + break; + + case H5T_BIT_MSB: + /* Calculate index */ + idx = (offset+size-1) / 8; + offset %= 8; + + /* Beginning */ + if (size>8-offset && (offset+size)%8) { + for (i=(offset+size)%8-1; i>=0; --i, --size) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + --idx; + } + /* Middle */ + while (size>=8) { + if ((value?0x00:0xff)!=buf[idx]) { + for (i=7; i>=0; --i) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + } + size -= 8; + --idx; + } + /* End */ + if (size>0) { + for (i=offset+size-1; i>=(ssize_t)offset; --i) { + if (value==((buf[idx]>>i) & 0x01)) { + return 8*idx+i - base; + } + } + } + break; + } + + return -1; } diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 1f2a2a5..f32c310 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -657,7 +657,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ sfirst = H5T_bit_find (s, src->u.atomic.offset, src->u.atomic.prec, H5T_BIT_MSB, TRUE); - first = (size_t)first; + first = (size_t)sfirst; if (sfirst<0) { /* @@ -759,7 +759,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FALSE); size_t fz = (size_t)sfz; - if (sfz>=0 && fz+2>=dst->u.atomic.prec) { + if (sfz>=0 && fz+1>=dst->u.atomic.prec) { /*underflow*/ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, FALSE); @@ -784,7 +784,7 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * case the destination is set to the largest possible * positive value. */ - if (first+2>=dst->u.atomic.prec) { + if (first+1>=dst->u.atomic.prec) { /*overflow*/ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE); @@ -796,6 +796,10 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, src->u.atomic.prec); H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else { + H5T_bit_copy (d, dst->u.atomic.offset, + s, src->u.atomic.offset, + dst->u.atomic.prec); } } diff --git a/src/H5config.h.in b/src/H5config.h.in index fbe2c73..ee4672c 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -46,6 +46,9 @@ /* The number of bytes in a long. */ #undef SIZEOF_LONG +/* The number of bytes in a long double. */ +#undef SIZEOF_LONG_DOUBLE + /* The number of bytes in a long long. */ #undef SIZEOF_LONG_LONG @@ -85,6 +88,9 @@ /* Define if you have the coug library (-lcoug). */ #undef HAVE_LIBCOUG +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM + /* Define if you have the mpi library (-lmpi). */ #undef HAVE_LIBMPI diff --git a/src/H5private.h b/src/H5private.h index 3d3ca3d..db7ca1e 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -64,32 +64,33 @@ /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +# define NELMTS(X) (sizeof(X)/sizeof(X[0])) #endif -/* minimum of two values */ +/* minimum of two, three, or four values */ #ifndef MIN -# define MIN(a,b) (((a)<(b)) ? (a) : (b)) +# define MIN(a,b) (((a)<(b)) ? (a) : (b)) +# define MIN2(a,b) MIN(a,b) +# define MIN3(a,b,c) MIN(a,MIN(b,c)) +# define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) #endif -/* maximum of two values */ +/* maximum of two, three, or four values */ #ifndef MAX -# define MAX(a,b) (((a)>(b)) ? (a) : (b)) +# define MAX(a,b) (((a)>(b)) ? (a) : (b)) +# define MAX2(a,b) MAX(a,b) +# define MAX3(a,b,c) MAX(a,MAX(b,c)) +# define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) #endif /* absolute value */ #ifndef ABS -# define ABS(a) (((a)>=0) ? (a) : -(a)) +# define ABS(a) (((a)>=0) ? (a) : -(a)) #endif /* sign of argument */ #ifndef SIGN -# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) -#endif - -/* maximum of three values */ -#ifndef MAX3 -# define MAX3(a,b,c) MAX(MAX(a,b),c) +# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) #endif /* maximum value of various types */ diff --git a/test/.distdep b/test/.distdep index 991f255..b2dc049 100644 --- a/test/.distdep +++ b/test/.distdep @@ -423,3 +423,20 @@ chunk.o: \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ ../src/H5Tpublic.h +bittests.o: \ + bittests.c \ + ../src/H5Tpkg.h \ + ../src/H5HGprivate.h \ + ../src/H5HGpublic.h \ + ../src/H5public.h \ + ../src/H5config.h \ + ../src/H5Fprivate.h \ + ../src/H5Fpublic.h \ + ../src/H5Ipublic.h \ + ../src/H5private.h \ + ../src/H5Dpublic.h \ + ../src/H5Tprivate.h \ + ../src/H5Tpublic.h \ + ../src/H5Gprivate.h \ + ../src/H5Gpublic.h \ + ../src/H5Bprivate.h diff --git a/test/Makefile.in b/test/Makefile.in index 37a01ac..3a68a67 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -11,10 +11,10 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@ # These are our main targets. They should be listed in the order to be # executed, generally most specific tests to least specific tests. -PROGS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \ - shtype iopipe big links chunk -TESTS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \ - shtype links +PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \ + external shtype iopipe big links chunk +TESTS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \ + external shtype links TIMINGS=iopipe chunk # Temporary files @@ -32,7 +32,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ # overlap with other tests. PROG_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c \ dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c \ - iopipe.c gheap.c shtype.c big.c links.c chunk.c + iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c PROG_OBJ=$(PROG_SRC:.c=.o) TESTHDF5_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c @@ -44,6 +44,9 @@ GHEAP_OBJ=$(GHEAP_SRC:.c=.o) DSETS_SRC=dsets.c DSETS_OBJ=$(DSETS_SRC:.c=.o) +BITTESTS_SRC=bittests.c +BITTESTS_OBJ=$(BITTESTS_SRC:.c=.o) + DTYPES_SRC=dtypes.c DTYPES_OBJ=$(DTYPES_SRC:.c=.o) @@ -103,6 +106,9 @@ gheap: $(GHEAP_OBJ) ../src/libhdf5.a dsets: $(DSETS_OBJ) ../src/libhdf5.a $(CC) $(CFLAGS) -o $@ $(DSETS_OBJ) ../src/libhdf5.a $(LIBS) +bittests: $(BITTESTS_OBJ) ../src/libhdf5.a + $(CC) $(CFLAGS) -o $@ $(BITTESTS_OBJ) ../src/libhdf5.a $(LIBS) + dtypes: $(DTYPES_OBJ) ../src/libhdf5.a $(CC) $(CFLAGS) -o $@ $(DTYPES_OBJ) ../src/libhdf5.a $(LIBS) diff --git a/test/bittests.c b/test/bittests.c new file mode 100644 index 0000000..88c48dc --- /dev/null +++ b/test/bittests.c @@ -0,0 +1,524 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke <matzke@llnl.gov> + * Tuesday, June 16, 1998 + * + * Purpose: Tests functions in H5Tbit.c + */ +#define H5T_PACKAGE +#include <H5Tpkg.h> + +#define NTESTS 100000 + + +/*------------------------------------------------------------------------- + * Function: test_find + * + * Purpose: Test bit find operations. This is just the basic stuff; more + * rigorous testing will be performed by the other test + * functions. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Tuesday, June 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_find (void) +{ + uint8 v1[8]; + intn i; + ssize_t n; + + printf ("%-70s", "Testing bit search operations"); + fflush (stdout); + + /* The zero length buffer */ + memset (v1, 0xaa, sizeof v1); + n = H5T_bit_find (v1, 0, 0, H5T_BIT_LSB, TRUE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" Zero length test failed (lsb)!"); + goto failed; + } + n = H5T_bit_find (v1, 0, 0, H5T_BIT_MSB, TRUE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" Zero length test failed (msb)!"); + goto failed; + } + + + /* The zero buffer */ + memset (v1, 0, sizeof v1); + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" Zero buffer test failed (lsb)!"); + goto failed; + } + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" Zero buffer test failed (msb)!"); + goto failed; + } + + /* Try all combinations of one byte */ + for (i=0; i<8*(int)sizeof(v1); i++) { + memset (v1, 0, sizeof v1); + v1[i/8] = 1<<(i%8); + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE); + if ((ssize_t)i!=n) { + puts ("*FAILED*"); + printf (" Test for set bit %d failed (lsb)!\n", i); + goto failed; + } + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE); + if ((ssize_t)i!=n) { + puts ("*FAILED*"); + printf (" Test for set bit %d failed (msb)!\n", i); + goto failed; + } + } + + /* The one buffer */ + memset (v1, 0xff, sizeof v1); + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" One buffer test failed (lsb)!"); + goto failed; + } + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE); + if (-1!=n) { + puts ("*FAILED*"); + puts (" One buffer test failed (msb)!"); + goto failed; + } + + /* Try all combinations of one byte */ + for (i=0; i<8*(int)sizeof(v1); i++) { + memset (v1, 0xff, sizeof v1); + v1[i/8] &= ~(1<<(i%8)); + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); + if ((ssize_t)i!=n) { + puts ("*FAILED*"); + printf (" Test for clear bit %d failed (lsb)!\n", i); + goto failed; + } + n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE); + if ((ssize_t)i!=n) { + puts ("*FAILED*"); + printf (" Test for clear bit %d failed (lsb)!\n", i); + goto failed; + } + } + + + puts (" PASSED"); + return 0; + + failed: + printf (" v = 0x"); + for (i=0; i<(int)sizeof(v1); i++) printf ("%02x", v1[i]); + printf ("\n"); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_copy + * + * Purpose: Test bit copy operations. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Tuesday, June 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy (void) +{ + uint8 v1[8], v2[8]; + size_t s_offset, d_offset, size; + intn i, j; + ssize_t n; + + printf ("%-70s", "Testing bit copy operations"); + fflush (stdout); + + for (i=0; i<NTESTS; i++) { + s_offset = rand() % (8*sizeof v1); + d_offset = rand() % (8*sizeof v2); + size = (unsigned)rand() % MIN (8*sizeof(v1), 8*sizeof(v2)); + size = MIN3 (size, 8*sizeof(v1)-s_offset, 8*sizeof(v2)-d_offset); + memset (v1, 0xff, sizeof v1); + memset (v2, 0x00, sizeof v2); + + /* Copy some bits to v2 and make sure something was copied */ + H5T_bit_copy (v2, d_offset, v1, s_offset, size); + for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break; + if (size>0 && j>=(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Unabled to find copied region in destination"); + goto failed; + } + if (0==size && j<(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Found copied bits when we shouldn't have"); + goto failed; + } + + + /* Look for the zeros and ones */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1); + if (size>0 && n!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find first copied bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found copied bits and shouldn't have!"); + goto failed; + } + n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); + if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { + puts ("*FAILED*"); + printf (" Unable to find last copied bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (d_offset+size==8*sizeof(v2) && n>=0) { + puts ("*FAILED*"); + puts (" High-order zeros are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1); + if (size>0 && (size_t)(n+1)!=d_offset+size) { + puts ("*FAILED*"); + printf (" Unable to find last copied bit in destination " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found copied bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0); + if (d_offset>0 && n+1!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find beginning of copied data " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==d_offset && n>=0) { + puts ("*FAILED*"); + puts (" Found leading original data but shouldn't have!"); + goto failed; + } + + } + + puts (" PASSED"); + return 0; + + failed: + printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n", + i, (unsigned long)s_offset, (unsigned long)d_offset, + (unsigned long)size); + printf (" s = 0x"); + for (j=sizeof(v1)-1; j>=0; --j) printf ("%02x", v1[j]); + printf ("\n d = 0x"); + for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]); + printf ("\n"); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_set + * + * Purpose: Test bit set operations + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Tuesday, June 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_set (void) +{ + uint8 v2[8]; + size_t d_offset, size; + intn i, j; + ssize_t n; + + printf ("%-70s", "Testing bit set operations"); + fflush (stdout); + + for (i=0; i<NTESTS; i++) { + d_offset = rand() % (8*sizeof v2); + size = (unsigned)rand() % (8*sizeof(v2)); + size = MIN (size, 8*sizeof(v2)-d_offset); + memset (v2, 0x00, sizeof v2); + + /* Set some bits in v2 */ + H5T_bit_set (v2, d_offset, size, TRUE); + for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break; + if (size>0 && j>=(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Unabled to find set region in buffer"); + goto failed; + } + if (0==size && j<(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Found set bits when we shouldn't have"); + goto failed; + } + + + /* Look for the zeros and ones */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1); + if (size>0 && n!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find first set bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found set bits and shouldn't have!"); + goto failed; + } + n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0); + if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { + puts ("*FAILED*"); + printf (" Unable to find last set bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (d_offset+size==8*sizeof(v2) && n>=0) { + puts ("*FAILED*"); + puts (" High-order zeros are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1); + if (size>0 && (size_t)(n+1)!=d_offset+size) { + puts ("*FAILED*"); + printf (" Unable to find last set bit in destination " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found set bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0); + if (d_offset>0 && n+1!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find beginning of set bit region " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==d_offset && n>=0) { + puts ("*FAILED*"); + puts (" Found leading zeros but shouldn't have!"); + goto failed; + } + + } + + puts (" PASSED"); + return 0; + + failed: + printf (" i=%d, d_offset=%lu, size=%lu\n", + i, (unsigned long)d_offset, (unsigned long)size); + printf (" d = 0x"); + for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]); + printf ("\n"); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: test_clear + * + * Purpose: Test bit clear operations + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Tuesday, June 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_clear (void) +{ + uint8 v2[8]; + size_t d_offset, size; + intn i, j; + ssize_t n; + + printf ("%-70s", "Testing bit clear operations"); + fflush (stdout); + + for (i=0; i<NTESTS; i++) { + d_offset = rand() % (8*sizeof v2); + size = (unsigned)rand() % (8*sizeof(v2)); + size = MIN (size, 8*sizeof(v2)-d_offset); + memset (v2, 0xff, sizeof v2); + + /* Clear some bits in v2 */ + H5T_bit_set (v2, d_offset, size, FALSE); + for (j=0; j<(intn)sizeof(v2); j++) if (0xff!=v2[j]) break; + if (size>0 && j>=(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Unabled to find cleared region in buffer"); + goto failed; + } + if (0==size && j<(intn)sizeof(v2)) { + puts ("*FAILED*"); + puts (" Found cleared bits when we shouldn't have"); + goto failed; + } + + + /* Look for the zeros and ones */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 0); + if (size>0 && n!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find first cleared bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found cleared bits and shouldn't have!"); + goto failed; + } + n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1); + if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) { + puts ("*FAILED*"); + printf (" Unable to find last cleared bit in destination " + "(n=%d)\n", (int)n); + goto failed; + } + if (d_offset+size==8*sizeof(v2) && n>=0) { + puts ("*FAILED*"); + puts (" High-order ones are present and shouldn't be!"); + goto failed; + } + + /* + * Look for zeros and ones in reverse order. This is only to test + * that reverse searches work as expected. + */ + n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 0); + if (size>0 && (size_t)(n+1)!=d_offset+size) { + puts ("*FAILED*"); + printf (" Unable to find last cleared bit in destination " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==size && n>=0) { + puts ("*FAILED*"); + puts (" Found cleared bits but shouldn't have (reverse)!"); + goto failed; + } + n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 1); + if (d_offset>0 && n+1!=(ssize_t)d_offset) { + puts ("*FAILED*"); + printf (" Unable to find beginning of cleared bit region " + "(reverse, n=%d)\n", (int)n); + goto failed; + } + if (0==d_offset && n>=0) { + puts ("*FAILED*"); + puts (" Found leading ones but shouldn't have!"); + goto failed; + } + + } + + puts (" PASSED"); + return 0; + + failed: + printf (" i=%d, d_offset=%lu, size=%lu\n", + i, (unsigned long)d_offset, (unsigned long)size); + printf (" d = 0x"); + for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]); + printf ("\n"); + return -1; +} + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: + * + * Return: Success: + * + * Failure: + * + * Programmer: Robb Matzke + * Tuesday, June 16, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main (void) +{ + intn nerrors=0; + + nerrors += test_find ()<0?1:0; + nerrors += test_set ()<0?1:0; + nerrors += test_clear()<0?1:0; + nerrors += test_copy ()<0?1:0; + + return nerrors?1:0; +} diff --git a/test/dtypes.c b/test/dtypes.c index e3d300f..a2f9a76 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -517,14 +517,100 @@ test_named (void) static herr_t test_conv_num (void) { - const size_t ntests=1; - const size_t nelmts=1; + const size_t ntests=100; + const size_t nelmts=2000; size_t i, j; void *buf=NULL, *saved=NULL; + unsigned char byte[4]; - printf ("%-70s", "Testing atomic number conversions"); + /*--------------------------------------------------------------------- + * Test some specific overflow/underflow cases. + *--------------------------------------------------------------------- + */ + printf ("%-70s", "Testing atomic number overflow conversions"); + fflush (stdout); + + /* (unsigned)0x80000000 -> (unsigned)0xffff */ + byte[0] = byte[1] = byte[2] = 0; + byte[3] = 0x80; + if (H5Tconvert (H5T_NATIVE_UINT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0xff || byte[1]!=0xff) { + puts ("*FAILED*"); + puts (" (unsigned)0x80000000 -> (unsigned)0xffff"); + goto error; + } + + /* (unsigned)0xffffffff -> (signed)0x7fff */ + byte[0] = byte[1] = byte[2] = byte[3] = 0xff; + if (H5Tconvert (H5T_NATIVE_UINT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0xff || byte[1]!=0x7f) { + puts ("*FAILED*"); + puts (" (unsigned)0xffffffff -> (signed)0x7f"); + goto error; + } + /* (signed)0xffffffff -> (unsigned)0x0000 */ + byte[0] = byte[1] = byte[2] = byte[3] = 0xff; + if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0x00 || byte[1]!=0x00) { + puts ("*FAILED*"); + puts (" (signed)0xffffffff -> (unsigned)0x00"); + goto error; + } + + /* (signed)0x7fffffff -> (unsigned)0xffff */ + byte[0] = byte[1] = byte[2] = 0xff; + byte[3] = 0x7f; + if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0xff || byte[1]!=0xff) { + puts ("*FAILED*"); + puts (" (signed)0x7fffffff -> (unsigned)0xffff"); + goto error; + } + + /* (signed)0x7fffffff -> (signed)0x7fff */ + byte[0] = byte[1] = byte[2] = 0xff; + byte[3] = 0x7f; + if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0xff || byte[1]!=0x7f) { + puts ("*FAILED*"); + puts (" (signed)0x7fffffff -> (signed)0x7fff"); + goto error; + } + + /* (signed)0xbfffffff -> (signed)0x8000 */ + byte[0] = byte[1] = byte[2] = 0xff; + byte[3] = 0xbf; + if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) { + goto error; + } + if (byte[0]!=0x00 || byte[1]!=0x80) { + puts ("*FAILED*"); + puts (" (signed)0xbfffffff -> (signed)0x8000"); + goto error; + } + + puts (" PASSED"); + + + /*----------------------------------------------------------------------- + * Test random cases. + *----------------------------------------------------------------------- + */ + printf ("%-70s", "Testing atomic number random conversions"); + fflush (stdout); + /* Allocate buffers */ buf = malloc (nelmts*8); saved = malloc (nelmts*8); @@ -597,9 +683,7 @@ main(void) nerrors += test_compound()<0 ? 1 : 0; nerrors += test_transient ()<0 ? 1 : 0; nerrors += test_named ()<0 ? 1 : 0; -#if 0 nerrors += test_conv_num ()<0 ? 1 : 0; -#endif if (nerrors) { printf("***** %d DATA TYPE TEST%s FAILED! *****\n", diff --git a/test/tattr.c b/test/tattr.c index 16cfdf3..1eae9b5 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -134,7 +134,7 @@ test_attr_basic_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write attribute information */ - ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data1); + ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data1); CHECK(ret, FAIL, "H5Awrite"); /* Close attribute */ @@ -167,7 +167,7 @@ test_attr_basic_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write attribute information */ - ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data2); + ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data2); CHECK(ret, FAIL, "H5Awrite"); /* Close attribute */ @@ -224,7 +224,7 @@ test_attr_basic_read(void) CHECK(attr, FAIL, "H5Aopen_name"); /* Read attribute information */ - ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data1); + ret=H5Aread(attr,H5T_NATIVE_INT32,read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ @@ -253,7 +253,7 @@ test_attr_basic_read(void) CHECK(attr, FAIL, "H5Aopen_name"); /* Read attribute information */ - ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data2); + ret=H5Aread(attr,H5T_NATIVE_INT32,read_data2); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ @@ -339,7 +339,7 @@ test_attr_compound_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write complex attribute data */ - ret=H5Awrite(attr,tid1,&attr_data4); + ret=H5Awrite(attr,tid1,attr_data4); CHECK(ret, FAIL, "H5Awrite"); /* Close attribute */ @@ -480,7 +480,7 @@ test_attr_compound_read(void) H5Tclose(field); /* Read attribute information */ - ret=H5Aread(attr,type,&read_data4); + ret=H5Aread(attr,type,read_data4); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ @@ -681,7 +681,7 @@ test_attr_mult_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write 1st attribute data */ - ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data1); + ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data1); CHECK(ret, FAIL, "H5Awrite"); /* Close 1st attribute */ @@ -705,7 +705,7 @@ test_attr_mult_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write 2nd attribute information */ - ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data2); + ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data2); CHECK(ret, FAIL, "H5Awrite"); /* Close 2nd attribute */ @@ -729,7 +729,7 @@ test_attr_mult_write(void) VERIFY(ret, FAIL, "H5Acreate"); /* Write 3rd attribute information */ - ret=H5Awrite(attr,H5T_NATIVE_DOUBLE,&attr_data3); + ret=H5Awrite(attr,H5T_NATIVE_DOUBLE,attr_data3); CHECK(ret, FAIL, "H5Awrite"); /* Close 3rd attribute */ @@ -819,7 +819,7 @@ test_attr_mult_read(void) H5Tclose(type); /* Read attribute information */ - ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data1); + ret=H5Aread(attr,H5T_NATIVE_INT32,read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ @@ -884,7 +884,7 @@ test_attr_mult_read(void) H5Tclose(type); /* Read attribute information */ - ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data2); + ret=H5Aread(attr,H5T_NATIVE_INT32,read_data2); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ @@ -954,7 +954,7 @@ test_attr_mult_read(void) H5Tclose(type); /* Read attribute information */ - ret=H5Aread(attr,H5T_NATIVE_DOUBLE,&read_data3); + ret=H5Aread(attr,H5T_NATIVE_DOUBLE,read_data3); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ |