2
0
mirror of https://github.com/HDFGroup/hdf5.git synced 2025-04-24 17:51:25 +08:00

[svn-r16847] Description:

Bring r16846 from revise_chunks branch back to trunk:

	Fix broken (for how long?) H5_ASSIGN_OVERFLOW macro to actually detect
overflows during assignments, along with several errors it [now] detected.

	Cleaned up a fix minor warnings and/or pieces of code also.

Tested on:
	FreeBSD/32 6.3 (duty) in debug mode
	(h5committest not needed - multi-platform test performed on branch)
This commit is contained in:
Quincey Koziol 2009-04-23 13:25:16 -05:00
parent b1f8b21130
commit f098d20ab9
24 changed files with 2321 additions and 109 deletions

@ -57,6 +57,7 @@
./bin/locate_sw
./bin/ltmain.sh
./bin/make_err
./bin/make_overflow
./bin/make_vers
./bin/makehelp
./bin/missing
@ -427,6 +428,8 @@
./src/H5err.txt
./src/H5config.h.in
./src/H5detect.c
./src/H5overflow.txt
./src/H5overflow.h
./src/H5private.h
./src/H5public.h
./src/H5system.c

219
bin/make_overflow Executable file

@ -0,0 +1,219 @@
#!/usr/bin/perl -w
require 5.003;
use strict;
# Global settings
# List of supported C types to generate overflow assignment code for
my @ctypes = ( () );
#
# 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
# 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 HDF5 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.
#
# Create assignment overflow #ifdefs
#
# Programmer: Quincey Koziol
# Creation Date: 2009/04/09
##############################################################################
# Parse a meaningful line (not a comment or blank line) into the appropriate
# data structure
#
sub parse_line ($) {
my $line = shift; # Get the line to parse
# Parse get the type name and whether it's signed or unsigned
#print "line=$line\n";
if($line =~ /.*SIGNED\s*;\s*$/ || $line =~ /.*UNSIGNED\s*;\s*$/) {
my $name; # The name of the type
my $signed; # Whether the type is signed or not
# Get the type's name & signed status
($name, $signed) = ($line =~ /^\s*(\w*)\s*,\s*(\w*)\s*;\s*$/);
#print "name = '$name', signed = '$signed'\n";
# Append the type to the list of C types already parsed
push @ctypes, [$name, $signed];
}
# Unknown keyword
else {
die "unknown keyword: $line";
}
}
##############################################################################
# Print the copyright into an open file
#
sub print_copyright ($) {
my $fh = shift;
print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n";
print $fh " * Copyright by The HDF Group. *\n";
print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n";
print $fh " * All rights reserved. *\n";
print $fh " * *\n";
print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n";
print $fh " * terms governing use, modification, and redistribution, is contained in *\n";
print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n";
print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n";
print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n";
print $fh " * is linked from the top-level documents page. It can also be found at *\n";
print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n";
print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n";
print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n";
}
##############################################################################
# Print the "do not change this file" warning
#
sub print_warning ($) {
my $fh = shift;
print $fh "\n/* Generated automatically by bin/make_overflow -- do not edit */\n";
print $fh "/* Add new types to H5overflow.txt file */\n\n";
}
##############################################################################
# Print start of ifdef's to prevent a file from being re-included
#
sub print_startprotect ($$) {
my ($fh, $file) = @_;
# Clip off the ".h" part of the name
$file =~ s/(\w*)\.h/$1/;
# Print the ifdef info
print $fh "\n#ifndef _${file}_H\n";
print $fh "#define _${file}_H\n";
}
##############################################################################
# Print assignment overflow macros for each type
#
sub print_typemacros ($) {
my $fh = shift; # File handle for output file
my ($src_aref, $dst_aref); # References for each type's information
# Print the descriptive comment
print $fh "\n\n/* Each type in this file is tested for assignment to the other types,\n";
print $fh " * and range checks are defined for bad assignments at run-time.\n";
print $fh " */\n";
for $src_aref (@ctypes) {
# Print a descriptive comment
print $fh "\n/* Assignment checks for @$src_aref[0] */\n\n";
for $dst_aref (@ctypes) {
if (@$src_aref[0] ne @$dst_aref[0]) {
# Print a descriptive comment
print $fh "/* src: @$src_aref[0], dst: @$dst_aref[0] */\n";
# Print actual type size checks & macro definitions
print $fh "#if H5_SIZEOF_", uc @$src_aref[0], " < H5_SIZEOF_", uc @$dst_aref[0], "\n";
print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n";
if ( @$src_aref[1] eq @$dst_aref[1]) {
print $fh " ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n";
} elsif ( @$src_aref[1] eq "SIGNED") {
print $fh " ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n";
} else {
print $fh " ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n";
}
print $fh "#elif H5_SIZEOF_", uc @$src_aref[0], " > H5_SIZEOF_", uc @$dst_aref[0], "\n";
print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n";
print $fh " ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype)\n";
print $fh "#else /* H5_SIZEOF_", uc @$src_aref[0], " == H5_SIZEOF_", uc @$dst_aref[0], " */\n";
print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n";
if ( @$src_aref[1] eq @$dst_aref[1]) {
print $fh " ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n";
} elsif ( @$src_aref[1] eq "SIGNED") {
print $fh " ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n";
} else {
print $fh " ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n";
}
print $fh "#endif /* src: @$src_aref[0] dst: @$dst_aref[0] */\n\n";
}
}
}
}
##############################################################################
# Print end of ifdef's to prevent a file from being re-included
#
sub print_endprotect ($$) {
my ($fh, $file) = @_;
# Clip off the ".h" part of the name
$file =~ s/(\w*)\.h/$1/;
# Print the endif info
print $fh "#endif /* ${file}_H */\n\n";
}
##############################################################################
# Create the generated portion of the public header file
#
sub create_public ($) {
my $prefix = shift; # Get the prefix for the generated file
my $file = "H5overflow.h"; # Name of file to generate
my $name; # Name of function
# Rename previous file
# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup";
# Open new header file
open HEADER, ">${prefix}${file}" or die "unable to modify source";
# Create file contents
print_copyright(*HEADER);
print_warning(*HEADER);
print_startprotect(*HEADER, $file);
print_typemacros(*HEADER);
print_endprotect(*HEADER, $file);
# Close header file
close HEADER;
}
##############################################################################
# Read symbol version file (given as command-line argument) in and process it
# into internal data structures, then create header files.
#
my $file; # Filename of input file
for $file (@ARGV) {
my $prefix; # Local prefix for generated files
my $line; # Line from input file
#print "file = '$file'\n";
($prefix) = ($file =~ /(^.*\/)/);
#print "prefix = '$prefix'\n";
# Read in the entire file
open SOURCE, $file or die "$file: $!\n";
while ( defined ($line=<SOURCE>) ) {
# Skip blank lines and those lines whose first character is a '#'
if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) {
# Construct data structures for later printing
parse_line($line);
}
}
close SOURCE;
# Create header files
print "Generating 'H5overflow.h'\n";
create_public($prefix);
}

461
configure vendored

@ -25861,6 +25861,467 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
{ echo "$as_me:$LINENO: checking for unsigned" >&5
echo $ECHO_N "checking for unsigned... $ECHO_C" >&6; }
if test "${ac_cv_type_unsigned+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_new_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
if ((ac__type_new_ *) 0)
return 0;
if (sizeof (ac__type_new_))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_type_unsigned=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_unsigned=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_unsigned" >&5
echo "${ECHO_T}$ac_cv_type_unsigned" >&6; }
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ echo "$as_me:$LINENO: checking size of unsigned" >&5
echo $ECHO_N "checking size of unsigned... $ECHO_C" >&6; }
if test "${ac_cv_sizeof_unsigned+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_lo=0 ac_mid=0
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr $ac_mid + 1`
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid + 1`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=-1 ac_mid=-1
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_lo=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_hi=`expr '(' $ac_mid ')' - 1`
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=$ac_mid
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr '(' $ac_mid ')' + 1`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in
?*) ac_cv_sizeof_unsigned=$ac_lo;;
'') if test "$ac_cv_type_unsigned" = yes; then
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned)
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (unsigned)
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
else
ac_cv_sizeof_unsigned=0
fi ;;
esac
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef unsigned ac__type_sizeof_;
static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
#include <stdio.h>
#include <stdlib.h>
#ifdef FC_DUMMY_MAIN
#ifndef FC_DUMMY_MAIN_EQ_F77
# ifdef __cplusplus
extern "C"
# endif
int FC_DUMMY_MAIN() { return 1; }
#endif
#endif
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
return 1;
if (((long int) (sizeof (ac__type_sizeof_))) < 0)
{
long int i = longval ();
if (i != ((long int) (sizeof (ac__type_sizeof_))))
return 1;
fprintf (f, "%ld\n", i);
}
else
{
unsigned long int i = ulongval ();
if (i != ((long int) (sizeof (ac__type_sizeof_))))
return 1;
fprintf (f, "%lu\n", i);
}
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sizeof_unsigned=`cat conftest.val`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
if test "$ac_cv_type_unsigned" = yes; then
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (unsigned)
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (unsigned)
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
else
ac_cv_sizeof_unsigned=0
fi
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.val
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_unsigned" >&5
echo "${ECHO_T}$ac_cv_sizeof_unsigned" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_UNSIGNED $ac_cv_sizeof_unsigned
_ACEOF
{ echo "$as_me:$LINENO: checking for long" >&5
echo $ECHO_N "checking for long... $ECHO_C" >&6; }
if test "${ac_cv_type_long+set}" = set; then

@ -1306,6 +1306,7 @@ AC_C_BIGENDIAN
AC_CHECK_SIZEOF([char], [1])
AC_CHECK_SIZEOF([short], [2])
AC_CHECK_SIZEOF([int], [4])
AC_CHECK_SIZEOF([unsigned], [4])
AC_CHECK_SIZEOF([long], [4])
AC_CHECK_SIZEOF([long long], [8])
AC_CHECK_SIZEOF([__int64], [8])

@ -33,7 +33,7 @@ TEST_PROG=test_lite test_image test_table test_ds test_packet
check_PROGRAMS=$(TEST_PROG)
# Temporary files. These files are the ones created by running `make test'.
CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-6].h5 test_image[1-3].h5 \
CHECK_CLEANFILES+=combine_tables[1-2].h5 test_ds[1-7].h5 test_image[1-3].h5 \
test_lite[1-2].h5 test_table.h5 test_packet_table.h5 \
test_packet_compress.h5

@ -207,7 +207,7 @@ HDmemset(shared->page, 0, shared->node_size);
/* Compute size to store # of records in each node */
/* (uses leaf # of records because its the largest) */
u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[0].max_nrec);
H5_ASSIGN_OVERFLOW(/* To: */ shared->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char)
H5_ASSIGN_OVERFLOW(/* To: */ shared->max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
HDassert(shared->max_nrec_size <= H5B2_SIZEOF_RECORDS_PER_NODE);
/* Initialize internal node info */
@ -223,7 +223,7 @@ HDmemset(shared->page, 0, shared->node_size);
shared->node_info[u].cum_max_nrec = ((shared->node_info[u].max_nrec + 1) *
shared->node_info[u - 1].cum_max_nrec) + shared->node_info[u].max_nrec;
u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[u].cum_max_nrec);
H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char)
H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[u].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
if((shared->node_info[u].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[u].max_nrec)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
@ -586,7 +586,7 @@ H5B2_split_root(H5F_t *f, hid_t dxpl_id, H5B2_t *bt2, unsigned *bt2_flags_ptr)
shared->node_info[shared->depth].cum_max_nrec = ((shared->node_info[shared->depth].max_nrec + 1) *
shared->node_info[shared->depth - 1].cum_max_nrec) + shared->node_info[shared->depth].max_nrec;
u_max_nrec_size = H5V_limit_enc_size((uint64_t)shared->node_info[shared->depth].cum_max_nrec);
H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[shared->depth].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ unsigned char)
H5_ASSIGN_OVERFLOW(/* To: */ shared->node_info[shared->depth].cum_max_nrec_size, /* From: */ u_max_nrec_size, /* From: */ unsigned, /* To: */ uint8_t)
if((shared->node_info[shared->depth].nat_rec_fac = H5FL_fac_init(shared->type->nrec_size * shared->node_info[shared->depth].max_nrec)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create node native key block factory")
if((shared->node_info[shared->depth].node_ptr_fac = H5FL_fac_init(sizeof(H5B2_node_ptr_t) * (shared->node_info[shared->depth].max_nrec + 1))) == NULL)

@ -124,7 +124,7 @@ typedef struct {
unsigned split_nrec; /* Number of records to split node at */
unsigned merge_nrec; /* Number of records to merge node at */
hsize_t cum_max_nrec; /* Cumulative max. # of records below this node's depth */
unsigned char cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */
uint8_t cum_max_nrec_size; /* Size to store cumulative max. # of records for this node (in bytes) */
H5FL_fac_head_t *nat_rec_fac; /* Factory for native record blocks */
H5FL_fac_head_t *node_ptr_fac; /* Factory for node pointer blocks */
} H5B2_node_info_t;
@ -149,7 +149,7 @@ typedef struct H5B2_shared_t {
unsigned depth; /* B-tree's overall depth */
/* Derived information from user's information */
unsigned char max_nrec_size; /* Size to store max. # of records in any node (in bytes) */
uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */
} H5B2_shared_t;
/* The B-tree information */

@ -2798,7 +2798,7 @@ static herr_t H5C_epoch_marker_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
unsigned *flags_ptr);
static herr_t H5C_epoch_marker_dest(H5F_t *f, void *thing);
static herr_t H5C_epoch_marker_clear(H5F_t *f, void *thing, hbool_t dest);
static herr_t H5C_epoch_marker_notify(H5C_notify_action_t action, void *thing, void *udata);
static herr_t H5C_epoch_marker_notify(H5C_notify_action_t action, void *thing);
static herr_t H5C_epoch_marker_size(const H5F_t *f, const void *thing, size_t *size_ptr);
const H5C_class_t epoch_marker_class =
@ -2891,8 +2891,7 @@ done:
static herr_t
H5C_epoch_marker_notify(H5C_notify_action_t UNUSED action,
void UNUSED * thing,
void UNUSED * udata)
void UNUSED * thing)
{
herr_t ret_value = FAIL; /* Return value */

@ -376,7 +376,10 @@ static herr_t
H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset,
const H5P_genplist_t UNUSED *dc_plist)
{
hssize_t tmp_size; /* Temporary holder for raw data size */
hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
hsize_t nelmts; /* Number of elements in dataspace */
size_t dt_size; /* Size of datatype */
hsize_t tmp_size; /* Temporary holder for raw data size */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */
hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */
int ndims; /* Rank of dataspace */
@ -402,9 +405,24 @@ H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset
if(max_dim[i] > dim[i])
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "extendible contiguous non-external dataset")
/* Compute the total size of dataset */
tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(dset->shared->type);
H5_ASSIGN_OVERFLOW(dset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t);
/* Retrieve the number of elements in the dataspace */
if((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the datatype's size */
if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the size of the dataset's contiguous storage */
tmp_size = nelmts * dt_size;
/* Check for overflow during multiplication */
if(nelmts != (tmp_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Assign the dataset's contiguous storage size */
dset->shared->layout.u.contig.size = tmp_size;
/* Get the sieve buffer size for this dataset */
dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f);

@ -457,8 +457,9 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id)
{
H5S_t *space; /* Dataset's dataspace */
hsize_t space_allocated; /* The number of bytes allocated for chunks */
hssize_t total_elem; /* The total number of elements in dataspace */
size_t type_size; /* The size of the datatype for the dataset */
hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
hsize_t nelmts; /* Number of elements in dataspace */
size_t dt_size; /* Size of datatype */
hsize_t full_size; /* The number of bytes in the dataset when fully populated */
herr_t ret_value = SUCCEED;
@ -471,16 +472,20 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id)
HDassert(space);
/* Get the total number of elements in dataset's dataspace */
if((total_elem=H5S_GET_EXTENT_NPOINTS(space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements")
if((snelmts = H5S_GET_EXTENT_NPOINTS(space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the size of the dataset's datatype */
if((type_size = H5T_get_size(dset->shared->type)) == 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype")
if(0 == (dt_size = H5T_GET_SIZE(dset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the maximum size of the dataset in bytes */
H5_CHECK_OVERFLOW(total_elem,hssize_t,hsize_t);
full_size=((hsize_t)total_elem)*type_size;
full_size = nelmts * dt_size;
/* Check for overflow during multiplication */
if(nelmts != (full_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */
space_allocated = H5D_get_storage_size(dset, dxpl_id);
@ -1392,10 +1397,29 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id)
* truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
*/
if(dataset->shared->layout.version < 3) {
hssize_t tmp_size; /* Temporary holder for raw data size */
hssize_t snelmts; /* Temporary holder for number of elements in dataspace */
hsize_t nelmts; /* Number of elements in dataspace */
size_t dt_size; /* Size of datatype */
hsize_t tmp_size; /* Temporary holder for raw data size */
tmp_size = H5S_GET_EXTENT_NPOINTS(dataset->shared->space) * H5T_get_size(dataset->shared->type);
H5_ASSIGN_OVERFLOW(dataset->shared->layout.u.contig.size, tmp_size, hssize_t, hsize_t);
/* Retrieve the number of elements in the dataspace */
if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace")
nelmts = (hsize_t)snelmts;
/* Get the datatype's size */
if(0 == (dt_size = H5T_GET_SIZE(dataset->shared->type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype")
/* Compute the size of the dataset's contiguous storage */
tmp_size = nelmts * dt_size;
/* Check for overflow during multiplication */
if(nelmts != (tmp_size / dt_size))
HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed")
/* Assign the dataset's contiguous storage size */
dataset->shared->layout.u.contig.size = tmp_size;
} /* end if */
/* Get the sieve buffer size for this dataset */

@ -956,7 +956,10 @@ if(H5DEBUG(D))
/* Chunk address relative to the first chunk */
chunk_addr_info_array[u].chunk_addr -= ctg_store.contig.dset_addr;
H5_ASSIGN_OVERFLOW(chunk_disp_array[u], chunk_addr_info_array[u].chunk_addr, haddr_t, MPI_Aint);
/* Assign chunk address to MPI displacement */
/* (assume MPI_Aint big enough to hold it) */
chunk_disp_array[u] = (MPI_Aint)chunk_addr_info_array[u].chunk_addr;
} /* end for */
/* Initialize the buffer with the constant value 1 */

@ -39,7 +39,6 @@
/* Revisions to FUNC_ENTER/LEAVE & Error Macros */
/************************************************/
#ifndef NDEBUG
/* `S' is the name of a function which is being tested to check if it's */
/* a public API function */
#define H5_IS_PUB(S) (((HDisdigit(S[1]) || HDisupper(S[1])) && HDislower(S[2])) || \
@ -58,6 +57,7 @@
((HDisdigit(S[2]) || HDisupper(S[2])) && '_' == S[3] && '_' == S[4] && HDislower(S[5])) || \
((HDisdigit(S[3]) || HDisupper(S[3])) && '_' == S[4] && '_' == S[5] && HDislower(S[6])))
#ifndef NDEBUG
#define FUNC_ENTER_NAME_CHECK(asrt) \
{ \
static hbool_t func_check = FALSE; \
@ -72,13 +72,11 @@
} /* end scope */
#else /* NDEBUG */
#define FUNC_ENTER_NAME_CHECK(asrt)
#define H5_IS_PUB(S)
#define H5_IS_PRIV(S)
#define H5_IS_PKG(S)
#endif /* NDEBUG */
/* Macro for referencing package initialization variables */
/* Macros for referencing package initialization symbols */
#define H5_PACKAGE_INIT_VAR(x) H5_GLUE3(H5_, x, _init_g)
#define H5_PACKAGE_INIT_FUNC(x) H5_GLUE(x, __pkg_init)
/* Macros to check if a package is initialized */
#define H5_CHECK_PACKAGE_INIT_REG_YES(asrt) HDassert(H5_PACKAGE_INIT_VAR(pkg));
@ -98,14 +96,18 @@
} /* end if */
#define H5_PKG_NO_INIT(pkg)
/* Macros to declare package initialization variable, if a package initialization routine is defined */
/* Macros to declare package initialization symbols, if a package initialization routine is defined */
#define H5_PKG_YES_INIT_VAR(pkg) extern hbool_t H5_PACKAGE_INIT_VAR(H5_MY_PKG);
#define H5_PKG_NO_INIT_VAR(pkg)
#define H5_PKG_YES_INIT_FUNC(pkg) extern herr_t H5_PACKAGE_INIT_FUNC(pkg)(void);
#define H5_PKG_NO_INIT_FUNC(pkg)
/* Declare package initialization variable (if in a package) */
/* Declare package initialization symbols (if in a package) */
#define H5_DECLARE_PKG_VAR(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_VAR)(pkg)
#define H5_DECLARE_PKG_FUNC(pkg_init, pkg) H5_GLUE3(H5_PKG_, pkg_init, _INIT_FUNC)(pkg)
#ifdef H5_MY_PKG
H5_DECLARE_PKG_VAR(H5_MY_PKG_INIT, H5_MY_PKG)
H5_DECLARE_PKG_FUNC(H5_MY_PKG_INIT, H5_MY_PKG)
#endif /* H5_MY_PKG */
/* API re-entrance variable */
@ -226,6 +228,13 @@ func \
#define H5_PRIV_FUNC_INIT_FAILED(pkg_init) H5_GLUE3(H5_PRIV_, pkg_init, _FUNC_INIT_FAILED)
/* Macros for leaving different scopes of routines */
#define FUNC_LEAVE_PKGINIT \
/* Leave scope for this type of function */ \
} \
\
/* Pop the name of this function off the function stack */ \
H5_POP_FUNC
#define FUNC_LEAVE_STATIC \
/* Leave scope for this type of function */ \
} \

@ -422,9 +422,6 @@ H5FD_sec2_close(H5FD_t *_file)
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_close, FAIL)
#ifdef QAK
HDfprintf(stderr, "%s: file->eof = %a, file->eoa = %a\n", FUNC, file->eof, file->eoa);
#endif /* QAK */
/* Sanity check */
HDassert(file);
@ -863,9 +860,6 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing)
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_truncate, FAIL)
#ifdef QAK
HDfprintf(stderr, "%s: file->eof = %a, file->eoa = %a\n", FUNC, file->eof, file->eoa);
#endif /* QAK */
HDassert(file);

@ -101,10 +101,10 @@ typedef struct H5FL_blk_gc_list_t {
static H5FL_blk_gc_list_t H5FL_blk_gc_head={0,NULL};
/* A garbage collection node for factory free lists */
typedef struct H5FL_fac_gc_node_t {
struct H5FL_fac_gc_node_t {
H5FL_fac_head_t *list; /* Pointer to the head of the list to garbage collect */
struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */
} H5FL_fac_gc_node_t;
};
/* The garbage collection head for factory free lists */
typedef struct H5FL_fac_gc_list_t {
@ -113,18 +113,8 @@ typedef struct H5FL_fac_gc_list_t {
} H5FL_fac_gc_list_t;
/* Data structure to store each block in factory free list */
typedef struct H5FL_fac_node_t {
struct H5FL_fac_node_t {
struct H5FL_fac_node_t *next; /* Pointer to next block in free list */
} H5FL_fac_node_t;
/* Data structure for free list block factory */
struct H5FL_fac_head_t {
unsigned init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
unsigned onlist; /* Number of blocks on free list */
size_t size; /* Size of the blocks in the list */
H5FL_fac_node_t *list; /* List of free blocks */
H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */
};
/* The head of the list of factory things to garbage collect */

@ -348,8 +348,20 @@ typedef struct H5FL_seq_head_t {
#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5MM_realloc(obj,(new_elem)*sizeof(t))
#endif /* H5_NO_SEQ_FREE_LISTS */
/* Forward declaration of the data structure for free list block factory */
typedef struct H5FL_fac_head_t H5FL_fac_head_t;
/* Forward declarations of the data structures for free list block factory */
typedef struct H5FL_fac_gc_node_t H5FL_fac_gc_node_t;
typedef struct H5FL_fac_node_t H5FL_fac_node_t;
/* Data structure for free list block factory */
typedef struct H5FL_fac_head_t {
unsigned init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
unsigned onlist; /* Number of blocks on free list */
size_t size; /* Size of the blocks in the list */
H5FL_fac_node_t *list; /* List of free blocks */
H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */
} H5FL_fac_head_t;
/*
* Macros for defining & using free list factories

@ -94,9 +94,9 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Set the uncompression parameters */
HDmemset(&z_strm, 0, sizeof(z_strm));
z_strm.next_in = *buf;
H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,uInt);
H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,unsigned);
z_strm.next_out = outbuf;
H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,uInt);
H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,unsigned);
/* Initialize the uncompression routines */
if (Z_OK!=inflateInit(&z_strm))

@ -584,6 +584,9 @@
/* The size of `uint_least8_t', as computed by sizeof. */
#undef SIZEOF_UINT_LEAST8_T
/* The size of `unsigned', as computed by sizeof. */
#undef SIZEOF_UNSIGNED
/* The size of `__int64', as computed by sizeof. */
#undef SIZEOF___INT64

1381
src/H5overflow.h Normal file

File diff suppressed because it is too large Load Diff

43
src/H5overflow.txt Normal file

@ -0,0 +1,43 @@
# 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
# 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 HDF5 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.
#
# This file is used to generate the headers that is needed for detecting
# overflows between types at run-time
#
# The bin/make_overflow script reads in this file and creates the appropriate
# file in the src/ directory when the generated header is out of date with
# respect to this file.
#
# Blank lines and lines beginning with '#' are ignored
#
# The format of this file is as follows:
# <type>, <SIGNED|UNSIGNED>;
#
# Where <type> is a valid C type (like 'int8_t', 'hssize_t', etc. and whether
# the type is signed or unsigned follows.
#
# Programmer: Quincey Koziol
# Creation Date: 2009/04/09
unsigned, UNSIGNED;
int, SIGNED;
uint8_t, UNSIGNED;
uint32_t, UNSIGNED;
uint64_t, UNSIGNED;
size_t, UNSIGNED;
ssize_t, SIGNED;
haddr_t, UNSIGNED;
hsize_t, UNSIGNED;
hssize_t, SIGNED;
h5_stat_size_t, UNSIGNED;

@ -438,35 +438,6 @@
# define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1))
#endif
/*
* A macro for detecting over/under-flow when casting between types
*/
#ifndef NDEBUG
#define H5_CHECK_OVERFLOW(var, vartype, casttype) \
{ \
casttype _tmp_overflow = (casttype)(var); \
assert((var) == (vartype)_tmp_overflow); \
}
#else /* NDEBUG */
#define H5_CHECK_OVERFLOW(var, vartype, casttype)
#endif /* NDEBUG */
/*
* A macro for detecting over/under-flow when assigning between types
*/
#ifndef NDEBUG
#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
{ \
srctype _tmp_overflow = (srctype)(src); \
dsttype _tmp_overflow2 = (dsttype)(_tmp_overflow); \
assert((dsttype)_tmp_overflow == _tmp_overflow2); \
(dst) = _tmp_overflow2; \
}
#else /* NDEBUG */
#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
(dst) = (dsttype)(src);
#endif /* NDEBUG */
/*
* Data types and functions for timing certain parts of the library.
*/
@ -764,6 +735,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#endif /* HDstat */
typedef struct stat64 h5_stat_t;
typedef off64_t h5_stat_size_t;
#define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF64_T
#else /* H5_SIZEOF_OFF_T!=8 && ... */
#ifndef HDfstat
#define HDfstat(F,B) fstat(F,B)
@ -773,6 +745,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
#endif /* HDstat */
typedef struct stat h5_stat_t;
typedef off_t h5_stat_size_t;
#define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T
#endif /* H5_SIZEOF_OFF_T!=8 && ... */
#endif /* !defined(HDfstat) || !defined(HDstat) */
@ -1237,6 +1210,9 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
#ifndef HDstrtoul
#define HDstrtoul(S,R,N) strtoul(S,R,N)
#endif /* HDstrtoul */
#ifndef HDstrtoull
#define HDstrtoull(S,R,N) strtoull(S,R,N)
#endif /* HDstrtoul */
#ifndef HDstrxfrm
#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
#endif /* HDstrxfrm */
@ -1376,6 +1352,78 @@ extern char *strdup(const char *s);
#define HDpthread_self_ulong() ((unsigned long)pthread_self())
#endif /* HDpthread_self_ulong */
/*
* A macro for detecting over/under-flow when casting between types
*/
#ifndef NDEBUG
#define H5_CHECK_OVERFLOW(var, vartype, casttype) \
{ \
casttype _tmp_overflow = (casttype)(var); \
assert((var) == (vartype)_tmp_overflow); \
}
#else /* NDEBUG */
#define H5_CHECK_OVERFLOW(var, vartype, casttype)
#endif /* NDEBUG */
/*
* A macro for detecting over/under-flow when assigning between types
*/
#ifndef NDEBUG
#define ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype) \
{ \
srctype _tmp_src = (srctype)(src); \
dsttype _tmp_dst = (dsttype)(_tmp_src); \
assert(_tmp_src == (srctype)_tmp_dst); \
(dst) = _tmp_dst; \
}
#define ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \
(dst) = (dsttype)(src);
#define ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \
{ \
srctype _tmp_src = (srctype)(src); \
dsttype _tmp_dst = (dsttype)(_tmp_src); \
assert(_tmp_src >= 0); \
assert(_tmp_src == _tmp_dst); \
(dst) = _tmp_dst; \
}
#define ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \
(dst) = (dsttype)(src);
#define ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype) \
{ \
srctype _tmp_src = (srctype)(src); \
dsttype _tmp_dst = (dsttype)(_tmp_src); \
assert(_tmp_dst >= 0); \
assert(_tmp_src == (srctype)_tmp_dst); \
(dst) = _tmp_dst; \
}
#define ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype) \
{ \
srctype _tmp_src = (srctype)(src); \
dsttype _tmp_dst = (dsttype)(_tmp_src); \
assert(_tmp_src >= 0); \
assert(_tmp_src == (srctype)_tmp_dst); \
(dst) = _tmp_dst; \
}
#define ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype) \
(dst) = (dsttype)(src);
/* Include the generated overflow header file */
#include "H5overflow.h"
#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\
#else /* NDEBUG */
#define H5_ASSIGN_OVERFLOW(dst, src, srctype, dsttype) \
(dst) = (dsttype)(src);
#endif /* NDEBUG */
#if defined(H5_HAVE_WINDOW_PATH)
/* directory delimiter for Windows: slash and backslash are acceptable on Windows */

@ -103,7 +103,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
# Public headers
include_HEADERS = hdf5.h H5api_adpt.h H5pubconf.h H5public.h H5version.h \
include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \
H5Apublic.h H5ACpublic.h \
H5Cpublic.h H5Dpublic.h \
H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \
@ -141,6 +141,10 @@ $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt
$(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt
perl $(top_srcdir)/bin/make_vers $?
# Assignment overflow macro generation
$(top_srcdir)/src/H5overflow.h: $(top_srcdir)/src/H5overflow.txt
perl $(top_srcdir)/bin/make_overflow $?
# Add TRACE macros to library source files. This is done via the trace script
# in the hdf5/bin directory. If the file contains HDF5 API macros, a "clean"
# version of the source file is saved with a tilde (~) after its name and

@ -487,7 +487,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
# Public headers
include_HEADERS = hdf5.h H5api_adpt.h H5pubconf.h H5public.h H5version.h \
include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \
H5Apublic.h H5ACpublic.h \
H5Cpublic.h H5Dpublic.h \
H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \
@ -1168,6 +1168,10 @@ $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt
$(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt
perl $(top_srcdir)/bin/make_vers $?
# Assignment overflow macro generation
$(top_srcdir)/src/H5overflow.h: $(top_srcdir)/src/H5overflow.txt
perl $(top_srcdir)/bin/make_overflow $?
# Add TRACE macros to library source files. This is done via the trace script
# in the hdf5/bin directory. If the file contains HDF5 API macros, a "clean"
# version of the source file is saved with a tilde (~) after its name and

@ -505,7 +505,6 @@ main (int ac, char **av)
hid_t fapl=-1;
hsize_t family_size;
hsize_t family_size_def; /* default family file size */
double family_size_def_dbl; /* default family file size */
unsigned long seed = 0; /* Random # seed */
int cflag=1; /* check file system before test */
char filename[1024];
@ -518,11 +517,8 @@ main (int ac, char **av)
if (strcmp("-fsize", *av)==0){
/* specify a different family file size */
ac--; av++;
if (ac > 0){
family_size_def_dbl = atof(*av);
H5_ASSIGN_OVERFLOW(family_size_def,family_size_def_dbl,double,hsize_t);
if (family_size_def <= 0)
family_size_def = (hsize_t)FAMILY_SIZE;
if (ac > 0) {
family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0);
}
else{
printf("***Missing fsize value***\n");

@ -106,8 +106,9 @@ const char *FILENAME[] = {
/* Temporary filter IDs used for testing */
#define H5Z_FILTER_BOGUS 305
#define H5Z_FILTER_CORRUPT 306
#define H5Z_FILTER_BOGUS2 307
#define H5Z_FILTER_DEPREC 308
#define H5Z_FILTER_CAN_APPLY_TEST 307
#define H5Z_FILTER_SET_LOCAL_TEST 308
#define H5Z_FILTER_DEPREC 309
/* Flags for testing filters */
#define DISABLE_FLETCHER32 0
@ -1116,7 +1117,7 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
add_on=(unsigned)H5Tget_size(type_id);
/* Get the filter's current parameters */
if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_BOGUS2, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0)
if(H5Pget_filter_by_id2(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, &flags, &cd_nelmts, cd_values, (size_t)0, NULL, NULL) < 0)
return(FAIL);
/* Check that the parameter values were passed along correctly */
@ -1130,7 +1131,7 @@ set_local_bogus2(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
cd_values[3]=add_on; /* Amount the data was modified by */
/* Modify the filter's parameters for this dataset */
if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_BOGUS2, flags, (size_t)BOGUS2_ALL_NPARMS,
if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SET_LOCAL_TEST, flags, (size_t)BOGUS2_ALL_NPARMS,
cd_values) < 0)
return(FAIL);
@ -4796,10 +4797,10 @@ test_types(hid_t file)
/* This message derives from H5Z */
const H5Z_class2_t H5Z_CAN_APPLY_TEST[1] = {{
H5Z_CLASS_T_VERS,
H5Z_FILTER_BOGUS, /* Filter id number */
1, 1,
"bogus", /* Filter name for debugging */
H5Z_CLASS_T_VERS,
H5Z_FILTER_CAN_APPLY_TEST, /* Filter id number */
1, 1,
"can_apply_test", /* Filter name for debugging */
can_apply_bogus, /* The "can apply" callback */
NULL, /* The "set local" callback */
filter_bogus, /* The actual filter function */
@ -4849,7 +4850,7 @@ test_can_apply(hid_t file)
printf(" Line %d: Can't register 'can apply' filter\n",__LINE__);
goto error;
}
if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) {
if(H5Pset_filter(dcpl, H5Z_FILTER_CAN_APPLY_TEST, 0, (size_t)0, NULL) < 0) {
H5_FAILED();
printf(" Line %d: Can't set bogus filter\n",__LINE__);
goto error;
@ -5156,10 +5157,10 @@ error:
/* This message derives from H5Z */
const H5Z_class2_t H5Z_SET_LOCAL_TEST[1] = {{
H5Z_CLASS_T_VERS,
H5Z_FILTER_BOGUS2, /* Filter id number */
1, 1,
"bogus2", /* Filter name for debugging */
H5Z_CLASS_T_VERS,
H5Z_FILTER_SET_LOCAL_TEST, /* Filter id number */
1, 1,
"set_local_test", /* Filter name for debugging */
NULL, /* The "can apply" callback */
set_local_bogus2, /* The "set local" callback */
filter_bogus2, /* The actual filter function */
@ -5229,7 +5230,7 @@ test_set_local(hid_t fapl)
printf(" Line %d: Can't register 'set local' filter\n",__LINE__);
goto error;
}
if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS2, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) {
if(H5Pset_filter(dcpl, H5Z_FILTER_SET_LOCAL_TEST, 0, (size_t)BOGUS2_PERM_NPARMS, cd_values) < 0) {
H5_FAILED();
printf(" Line %d: Can't set bogus2 filter\n",__LINE__);
goto error;
@ -5740,7 +5741,6 @@ test_filters_endianess(void)
hid_t dsid=-1; /* dataset ID */
hid_t sid=-1; /* dataspace ID */
hid_t dcpl=-1; /* dataset creation property list ID */
int i;
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing file */
@ -6384,11 +6384,11 @@ test_deprec(hid_t file)
if(H5Zregister(H5Z_DEPREC) < 0) goto error;
if(H5Pset_filter(dcpl, H5Z_FILTER_DEPREC, 0, (size_t)0, NULL) < 0) goto error;
puts("");
if(test_filter_internal(file,DSET_DEPREC_NAME_FILTER,dcpl,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&deprec_size) < 0) goto error;
if(H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
error:
@ -6762,7 +6762,7 @@ test_big_chunks_bypass_cache(hid_t fapl)
/* Define cache size to be smaller than chunk size */
rdcc_nelmts = BYPASS_CHUNK_DIM/5;
rdcc_nbytes = sizeof(int)*BYPASS_CHUNK_DIM/5;
if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, 0) < 0) FAIL_STACK_ERROR
if(H5Pset_cache(fapl_local, 0, rdcc_nelmts, rdcc_nbytes, (double)0.0) < 0) FAIL_STACK_ERROR
/* Create file */
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 0) FAIL_STACK_ERROR