mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-19 16:50:46 +08:00
[svn-r290] Changes since 19980206
---------------------- ./configure.in ./src/H5Fprivate.h ./src/H5Fsec2.c We now detect and use lseek64() on systems that have it (e.g., Irix64) and are able to generate >2GB files on Irix XFS file systems (and anything else that supports large files). This change also removed some warning messages from the Irix `-64' compiler. > $ ls -l istore.h5 > -rw-r--r-- 1 matzke meshtv 8605436856 Feb 17 14:03 istore.h5 ./configure.in ./src/H5Fprivate.h ./src/H5Fstdio.h We now detect and use fseek64() on systems that have it (e.g., Irix64) and are able to generate >2GB files on Irix XFS file systems (and anything else that supports large files). This change also removed some warning messages from the Iris `-64' compiler. ./src/H5E.c ./src/H5Epublic.h Added the H5E_OVERFLOW error to signal file address overflow. ./src/H5Fpublic.h ./examples/h5_chunk_read.c ./examples/h5_compound.c ./examples/h5_extend_write.c ./examples/h5_group.c ./examples/h5_read.c ./examples/h5_write.c ./html/Datasets.html ./html/Files.html ./html/H5.api.html ./html/H5.intro.html ./html/H5.sample_code.html ./html/ph5example.c ./html/review1.html ./test/cmpd_dset.c ./test/dsets.c ./test/extend.c ./test/tfile.c ./test/th5p.c ./test/theap.c ./test/tohdr.c ./test/tstab.c ./testpar/phdf5.c Renamed file access constants to follow the naming scheme. Also changed the base names a little to be more accurate as to what they do. The old names H5ACC_WRITE and H5ACC_OVERWRITE will temporarily work. H5ACC_DEFAULT --> H5F_ACC_RDONLY for H5Fopen() H5ACC_DEFAULT --> H5F_ACC_EXCL for H5Fcreate() H5ACC_WRITE --> H5F_ACC_RDWR H5ACC_OVERWRITE --> H5F_ACC_TRUNC Albert or Kim: The H5ACC_INDEPENDENT and H5ACC_COLLECTIVE macros in H5Fpublic.h should be an enum typedef and have names more like H5F_MPIO_INDEPENDENT and H5F_MPIO_COLLECTIVE. Also change the access_mode argument of H5Cset_mpio(). H5Fcreate() and H5Fopen() are more strict now about which flags are acceptable for the operation. ./src/H5Fprivate.h ./src/H5F.c ./src/H5C.c Changed the file access template to make it more general. A union contains a struct for each type of low-level driver and the default template is initialized at run-time. ./src/H5Fpublic.h ./src/H5F.c Added H5Fget_access_template() and cleaned up H5Fget_create_template(). ./src/H5C.c The H5Cset_mpi() no longer trashes the file access template when an error is detected. We check for errors and *then* update the file access template. Added H5C_close() so Albert and Kim have a place to release the MPI communicator and info from the file access property list. Kim or Albert: I notice in H5Cset_mpi() you copy the MPI communicator. Do you need to do something similar in H5C_copy()? ./src/H5F.c Added more error checking for the file creation and access property lists because it used to be possible to make the library dump core by swapping the creation and access property list ID numbers of H5Fcreate(). ./test/istore.c ./test/tfile.c ./test/th5p.c ./test/theap.c ./test/tohdr.c ./test/tstab.c ./testpar/testphdf5.c One must pass H5C_DEFAULT as the file creation or access property list in order to get the default property list. It is no longer possible to pass zero or any other arbitrary bad object ID. ./src/H5Fcore.c ./src/H5Ffamly.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fsplit.c ./src/H5Fstdio.c ./src/H5MF.c The file access property list is passed to all H5F_low_...() functions and to the drivers. ./src/H5Fcore.c The block size can be set at run time on a per-file basis instead of at compile time across all files. The "5000 items in a group test" now takes 1.6 seconds. ./src/H5private.h Removed inclusion of mpi.h and mpio.h since they're included from H5public.h. ./src/H5Cpublic.h ./src/H5C.c Added H5Cset_stdio(), H5Cset_sec2(), H5Cset_core(), H5Cset_split(), and H5Cset_family() in addition to the H5Cset_mpio() that Kim and Albert already wrote. We still need the H5Cget_driver() and an H5Cget...() counterpart for each of those functions. The split and family drivers still need a little work but I'm checking this in anyway.
This commit is contained in:
parent
5b8d25d3c6
commit
b24130dcf0
17
bin/release
17
bin/release
@ -79,7 +79,7 @@ sub manifest () {
|
||||
# Read files from CVS/Entries
|
||||
open FIND, "find . -name Entries -print | sort |" or
|
||||
die "unable to find CVS entries";
|
||||
while ($fname=<FIND>) {
|
||||
while (defined($fname=<FIND>)) {
|
||||
chomp $fname;
|
||||
my ($dir) = $fname =~ m%(.*)/CVS/Entries%;
|
||||
open ENTRIES, $fname or die "unable to open $fname";
|
||||
@ -208,12 +208,15 @@ EOF
|
||||
(setver ($ver=$_) or die "cannot set version") if /\S/;
|
||||
|
||||
if (-d "CVS") {
|
||||
print <<EOF;
|
||||
# If we're running under CVS then check in changes and tag all files
|
||||
# with the release number. Quincey, do you want to add this to the
|
||||
# bottom of the perl script? Otherwise just give me the commands
|
||||
# and I'll add them.
|
||||
EOF
|
||||
my $tag = $ver;
|
||||
$tag =~ s/\./-/g;
|
||||
print "Tag CVS sources with \"$tag\"? [y] ";
|
||||
chomp ($_ = <STDIN>);
|
||||
if (!$_ || $_ eq 'y') {
|
||||
print "Tagging CVS sources...\n";
|
||||
my $status = system "cvs tag -R $tag";
|
||||
die "cvs tag failed" if $status >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
32
config/linux
32
config/linux
@ -37,18 +37,26 @@
|
||||
# only apply to that compiler.
|
||||
CC=gcc
|
||||
|
||||
warn="-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
|
||||
|
||||
profile="-pg"
|
||||
|
||||
debug="-g -DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -UH5O_DEBUG -DH5T_DEBUG -DH5F_OPT_SEEK=0 -fverbose-asm"
|
||||
|
||||
production="-O3 -DNDEBUG -finline-functions -funroll-loops -malign-double -fomit-frame-pointer"
|
||||
|
||||
default_mode='-ansi $debug $warn -pipe -DH5F_LOW_DFLT=H5F_LOW_SEC2'
|
||||
|
||||
# Don't set CFLAGS if the user already did.
|
||||
if test -z "$CFLAGS"; then
|
||||
CFLAGS="`eval echo ${HDF5_MODE:-$default_mode}`"
|
||||
export CFLAGS
|
||||
# First set up the CFLAGS arguments.
|
||||
if test "X" = "X$CFLAGS"; then
|
||||
warn="-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
|
||||
profile="-pg"
|
||||
debug="-g -fverbose-asm"
|
||||
production="-O3 -finline-functions -funroll-loops -malign-double -fomit-frame-pointer"
|
||||
parallel=""
|
||||
default_mode='-ansi $debug $warn $parallel'
|
||||
CFLAGS="`eval echo ${HDF5_MODE:-$default_mode}`"
|
||||
fi
|
||||
|
||||
# Then set up the CPPFLAGS arguments.
|
||||
if test "X" = "X$CPPFLAGS"; then
|
||||
warn=
|
||||
profile=
|
||||
debug="-DH5AC_DEBUG -DH5B_DEBUG -DH5F_DEBUG -DH5G_DEBUG -UH5O_DEBUG -DH5T_DEBUG -DH5F_OPT_SEEK=0 -DH5F_LOW_DFLT=H5F_LOW_SEC2"
|
||||
production="-DNDEBUG"
|
||||
parallel=""
|
||||
default_mode='$debug $warn $parallel'
|
||||
CPPFLAGS="`eval echo ${HDF5_MODE:-$default_mode}`"
|
||||
fi
|
||||
|
211
configure
vendored
211
configure
vendored
@ -570,9 +570,8 @@ echo "$ac_t""$host" 1>&6
|
||||
|
||||
|
||||
|
||||
|
||||
echo $ac_n "checking for cached host""... $ac_c" 1>&6
|
||||
echo "configure:576: checking for cached host" >&5
|
||||
echo "configure:575: checking for cached host" >&5
|
||||
if eval "test \"`echo '$''{'hdf5_cv_host'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -591,7 +590,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for site config file""... $ac_c" 1>&6
|
||||
echo "configure:595: checking for site config file" >&5
|
||||
echo "configure:594: checking for site config file" >&5
|
||||
site_config="none"
|
||||
for f in $host \
|
||||
$host_vendor-$host_os \
|
||||
@ -611,11 +610,10 @@ if test $site_config != "none"; then
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Extract the first word of "gcc", so it can be a program name with args.
|
||||
set dummy gcc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:619: checking for $ac_word" >&5
|
||||
echo "configure:617: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -644,7 +642,7 @@ if test -z "$CC"; then
|
||||
# Extract the first word of "cc", so it can be a program name with args.
|
||||
set dummy cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:648: checking for $ac_word" >&5
|
||||
echo "configure:646: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -692,7 +690,7 @@ fi
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
|
||||
echo "configure:696: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
echo "configure:694: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
|
||||
ac_ext=c
|
||||
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
|
||||
@ -702,11 +700,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 706 "configure"
|
||||
#line 704 "configure"
|
||||
#include "confdefs.h"
|
||||
main(){return(0);}
|
||||
EOF
|
||||
if { (eval echo configure:710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
ac_cv_prog_cc_works=yes
|
||||
# If we can't run a trivial program, we are probably using a cross compiler.
|
||||
if (./conftest; exit) 2>/dev/null; then
|
||||
@ -726,12 +724,12 @@ if test $ac_cv_prog_cc_works = no; then
|
||||
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
|
||||
fi
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
|
||||
echo "configure:730: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "configure:728: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
|
||||
echo "configure:735: checking whether we are using GNU C" >&5
|
||||
echo "configure:733: checking whether we are using GNU C" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -740,7 +738,7 @@ else
|
||||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:744: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
@ -755,7 +753,7 @@ if test $ac_cv_prog_gcc = yes; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:759: checking whether ${CC-cc} accepts -g" >&5
|
||||
echo "configure:757: checking whether ${CC-cc} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -783,7 +781,7 @@ else
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
|
||||
echo "configure:787: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
echo "configure:785: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -820,7 +818,7 @@ fi
|
||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:824: checking for a BSD compatible install" >&5
|
||||
echo "configure:822: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@ -872,7 +870,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:876: checking for $ac_word" >&5
|
||||
echo "configure:874: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -900,7 +898,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for GNU Make""... $ac_c" 1>&6
|
||||
echo "configure:904: checking for GNU Make" >&5
|
||||
echo "configure:902: checking for GNU Make" >&5
|
||||
if test "`${MAKE-make} --version -f /dev/null 2>/dev/null |\
|
||||
sed -n 1p|cut -c1-8`" = "GNU Make"; then
|
||||
echo "$ac_t""yes" 1>&6
|
||||
@ -915,7 +913,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:919: checking how to run the C preprocessor" >&5
|
||||
echo "configure:917: checking how to run the C preprocessor" >&5
|
||||
# On Suns, sometimes $CPP names a directory.
|
||||
if test -n "$CPP" && test -d "$CPP"; then
|
||||
CPP=
|
||||
@ -930,13 +928,13 @@ else
|
||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||
# not just through cpp.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 934 "configure"
|
||||
#line 932 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -947,13 +945,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 951 "configure"
|
||||
#line 949 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:955: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -976,12 +974,12 @@ fi
|
||||
echo "$ac_t""$CPP" 1>&6
|
||||
|
||||
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
|
||||
echo "configure:980: checking for ANSI C header files" >&5
|
||||
echo "configure:978: checking for ANSI C header files" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 985 "configure"
|
||||
#line 983 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@ -989,7 +987,7 @@ else
|
||||
#include <float.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -1006,7 +1004,7 @@ rm -f conftest*
|
||||
if test $ac_cv_header_stdc = yes; then
|
||||
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1010 "configure"
|
||||
#line 1008 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <string.h>
|
||||
EOF
|
||||
@ -1024,7 +1022,7 @@ fi
|
||||
if test $ac_cv_header_stdc = yes; then
|
||||
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1028 "configure"
|
||||
#line 1026 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
EOF
|
||||
@ -1045,7 +1043,7 @@ if test "$cross_compiling" = yes; then
|
||||
:
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1049 "configure"
|
||||
#line 1047 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <ctype.h>
|
||||
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
|
||||
@ -1056,7 +1054,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
|
||||
exit (0); }
|
||||
|
||||
EOF
|
||||
if { (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
@ -1083,12 +1081,12 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for off_t""... $ac_c" 1>&6
|
||||
echo "configure:1087: checking for off_t" >&5
|
||||
echo "configure:1085: checking for off_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1092 "configure"
|
||||
#line 1090 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@ -1116,12 +1114,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for size_t""... $ac_c" 1>&6
|
||||
echo "configure:1120: checking for size_t" >&5
|
||||
echo "configure:1118: checking for size_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1125 "configure"
|
||||
#line 1123 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@ -1151,15 +1149,72 @@ fi
|
||||
|
||||
|
||||
|
||||
for ac_func in lseek64 fseek64
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:1156: 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 1161 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
#include <assert.h>
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char $ac_func();
|
||||
|
||||
int main() {
|
||||
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||
choke me
|
||||
#else
|
||||
$ac_func();
|
||||
#endif
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=no"
|
||||
fi
|
||||
rm -f conftest*
|
||||
fi
|
||||
|
||||
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
|
||||
echo "$ac_t""yes" 1>&6
|
||||
ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||
cat >> confdefs.h <<EOF
|
||||
#define $ac_tr_func 1
|
||||
EOF
|
||||
|
||||
else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
|
||||
echo "configure:1156: checking whether byte ordering is bigendian" >&5
|
||||
echo "configure:1211: checking whether byte ordering is bigendian" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_cv_c_bigendian=unknown
|
||||
# See if sys/param.h defines the BYTE_ORDER macro.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1163 "configure"
|
||||
#line 1218 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -1170,11 +1225,11 @@ int main() {
|
||||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1174: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
# It does; now see whether it defined to BIG_ENDIAN or not.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1178 "configure"
|
||||
#line 1233 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -1185,7 +1240,7 @@ int main() {
|
||||
#endif
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1244: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_bigendian=yes
|
||||
else
|
||||
@ -1205,7 +1260,7 @@ if test "$cross_compiling" = yes; then
|
||||
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1209 "configure"
|
||||
#line 1264 "configure"
|
||||
#include "confdefs.h"
|
||||
main () {
|
||||
/* Are we little or big endian? From Harbison&Steele. */
|
||||
@ -1218,7 +1273,7 @@ main () {
|
||||
exit (u.c[sizeof (long) - 1] == 1);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_c_bigendian=no
|
||||
else
|
||||
@ -1242,7 +1297,7 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking size of short""... $ac_c" 1>&6
|
||||
echo "configure:1246: checking size of short" >&5
|
||||
echo "configure:1301: checking size of short" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1250,7 +1305,7 @@ else
|
||||
ac_cv_sizeof_short=2
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1254 "configure"
|
||||
#line 1309 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1261,7 +1316,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_short=`cat conftestval`
|
||||
else
|
||||
@ -1281,7 +1336,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of int""... $ac_c" 1>&6
|
||||
echo "configure:1285: checking size of int" >&5
|
||||
echo "configure:1340: checking size of int" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1289,7 +1344,7 @@ else
|
||||
ac_cv_sizeof_int=4
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1293 "configure"
|
||||
#line 1348 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1300,7 +1355,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_int=`cat conftestval`
|
||||
else
|
||||
@ -1320,7 +1375,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of long""... $ac_c" 1>&6
|
||||
echo "configure:1324: checking size of long" >&5
|
||||
echo "configure:1379: checking size of long" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1328,7 +1383,7 @@ else
|
||||
ac_cv_sizeof_long=4
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1332 "configure"
|
||||
#line 1387 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1339,7 +1394,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_long=`cat conftestval`
|
||||
else
|
||||
@ -1359,7 +1414,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of long long""... $ac_c" 1>&6
|
||||
echo "configure:1363: checking size of long long" >&5
|
||||
echo "configure:1418: checking size of long long" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1367,7 +1422,7 @@ else
|
||||
ac_cv_sizeof_long_long=8
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1371 "configure"
|
||||
#line 1426 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1378,7 +1433,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_long_long=`cat conftestval`
|
||||
else
|
||||
@ -1398,7 +1453,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of float""... $ac_c" 1>&6
|
||||
echo "configure:1402: checking size of float" >&5
|
||||
echo "configure:1457: checking size of float" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1406,7 +1461,7 @@ else
|
||||
ac_cv_sizeof_float=4
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1410 "configure"
|
||||
#line 1465 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1417,7 +1472,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_float=`cat conftestval`
|
||||
else
|
||||
@ -1437,7 +1492,7 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking size of double""... $ac_c" 1>&6
|
||||
echo "configure:1441: checking size of double" >&5
|
||||
echo "configure:1496: checking size of double" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -1445,7 +1500,7 @@ else
|
||||
ac_cv_sizeof_double=8
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1449 "configure"
|
||||
#line 1504 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
main()
|
||||
@ -1456,7 +1511,7 @@ main()
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:1460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
ac_cv_sizeof_double=`cat conftestval`
|
||||
else
|
||||
@ -1480,12 +1535,12 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking for working const""... $ac_c" 1>&6
|
||||
echo "configure:1484: checking for working const" >&5
|
||||
echo "configure:1539: 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 1489 "configure"
|
||||
#line 1544 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
@ -1534,7 +1589,7 @@ ccp = (char const *const *) p;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1538: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_const=yes
|
||||
else
|
||||
@ -1555,21 +1610,21 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for inline""... $ac_c" 1>&6
|
||||
echo "configure:1559: checking for inline" >&5
|
||||
echo "configure:1614: 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 1566 "configure"
|
||||
#line 1621 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
} $ac_kw foo() {
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1628: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_inline=$ac_kw; break
|
||||
else
|
||||
@ -1596,16 +1651,16 @@ esac
|
||||
|
||||
|
||||
echo $ac_n "checking for __attribute__ extension""... $ac_c" 1>&6
|
||||
echo "configure:1600: checking for __attribute__ extension" >&5
|
||||
echo "configure:1655: checking for __attribute__ extension" >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1602 "configure"
|
||||
#line 1657 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
int __attribute__((unused)) f(void){return 1;}
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1609: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1664: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define HAVE_ATTRIBUTE 1
|
||||
@ -1621,16 +1676,16 @@ fi
|
||||
rm -f conftest*
|
||||
|
||||
echo $ac_n "checking for __FUNCTION__ extension""... $ac_c" 1>&6
|
||||
echo "configure:1625: checking for __FUNCTION__ extension" >&5
|
||||
echo "configure:1680: checking for __FUNCTION__ extension" >&5
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1627 "configure"
|
||||
#line 1682 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
int f(void){return __FUNCTION__;}
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define HAVE_FUNCTION 1
|
||||
@ -1653,7 +1708,7 @@ if test "${enable_parallel+set}" = set; then
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for parallel support""... $ac_c" 1>&6
|
||||
echo "configure:1657: checking for parallel support" >&5;
|
||||
echo "configure:1712: checking for parallel support" >&5;
|
||||
|
||||
RUNTEST=""
|
||||
|
||||
@ -1679,10 +1734,10 @@ EOF
|
||||
EOF
|
||||
|
||||
PARALLEL_SRC='$(PARALLEL_SRC)'
|
||||
CFLAGS="$CFLAGS $MPI_INC"
|
||||
CPPFLAGS="$CPPFLAGS $MPI_INC"
|
||||
CFLAGS="$CFLAGS $MPI_LIB"
|
||||
echo $ac_n "checking for main in -lmpi""... $ac_c" 1>&6
|
||||
echo "configure:1686: checking for main in -lmpi" >&5
|
||||
echo "configure:1741: 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
|
||||
@ -1690,14 +1745,14 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lmpi $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1694 "configure"
|
||||
#line 1749 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
main()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:1756: \"$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
|
||||
@ -1724,7 +1779,7 @@ else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
echo $ac_n "checking for main in -lmpio""... $ac_c" 1>&6
|
||||
echo "configure:1728: checking for main in -lmpio" >&5
|
||||
echo "configure:1783: 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
|
||||
@ -1732,14 +1787,14 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lmpio $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1736 "configure"
|
||||
#line 1791 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
main()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:1798: \"$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
|
||||
|
12
configure.in
12
configure.in
@ -13,8 +13,7 @@ AC_INIT(src/H5.c)
|
||||
AC_CONFIG_HEADER(src/H5config.h)
|
||||
AC_CONFIG_AUX_DIR(bin)
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
|
||||
AC_SUBST(CPPFLAGS)
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl Check that the cache file was build on the same host as what we're
|
||||
@ -65,7 +64,6 @@ if test $site_config != "none"; then
|
||||
fi
|
||||
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl Check for programs.
|
||||
dnl
|
||||
@ -106,6 +104,12 @@ AC_TYPE_SIZE_T
|
||||
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl Check for functions.
|
||||
dnl
|
||||
AC_CHECK_FUNCS(lseek64 fseek64)
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl Check sizes of various integral data types.
|
||||
dnl
|
||||
@ -166,7 +170,7 @@ case "X-$PARALLEL" in
|
||||
AC_DEFINE(PHDF5) dnl THIS WILL GO AWAY SHORTLY!!!
|
||||
AC_DEFINE(HAVE_PARALLEL)
|
||||
PARALLEL_SRC='$(PARALLEL_SRC)'
|
||||
CFLAGS="$CFLAGS $MPI_INC"
|
||||
CPPFLAGS="$CPPFLAGS $MPI_INC"
|
||||
CFLAGS="$CFLAGS $MPI_LIB"
|
||||
AC_CHECK_LIB(mpi,main) dnl Replace `main' with some function
|
||||
AC_CHECK_LIB(mpio,main) dnl Replace `main' with some function
|
||||
|
@ -40,7 +40,7 @@ main ()
|
||||
/*
|
||||
* Open the file and the dataset.
|
||||
*/
|
||||
file = H5Fopen(FILE, H5ACC_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT);
|
||||
dataset = H5Dopen(file, DATASETNAME);
|
||||
|
||||
/*
|
||||
|
@ -62,7 +62,7 @@ space = H5Pcreate_simple(RANK, dim, NULL);
|
||||
/*
|
||||
* Create the file.
|
||||
*/
|
||||
file = H5Fcreate(FILE, H5ACC_OVERWRITE, H5C_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT);
|
||||
|
||||
/*
|
||||
* Create the memory data type.
|
||||
@ -93,7 +93,7 @@ H5Fclose(file);
|
||||
/*
|
||||
* Open the file and the dataset.
|
||||
*/
|
||||
file = H5Fopen(FILE, H5ACC_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT);
|
||||
|
||||
dataset = H5Dopen(file, DATASETNAME);
|
||||
|
||||
|
@ -49,7 +49,7 @@ dataspace = H5Pcreate_simple(RANK, dims, maxdims);
|
||||
/*
|
||||
* Create a new file. If file exists its contents will be overwritten.
|
||||
*/
|
||||
file = H5Fcreate(FILE, H5ACC_OVERWRITE, H5C_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT);
|
||||
|
||||
/*
|
||||
* Modify dataset creation properties, i.e. enable chunking.
|
||||
|
@ -23,7 +23,7 @@ main()
|
||||
/*
|
||||
* Create a file.
|
||||
*/
|
||||
file = H5Fcreate(FILE, H5ACC_OVERWRITE, H5C_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT);
|
||||
|
||||
/*
|
||||
* Create two groups in a file.
|
||||
|
@ -48,7 +48,7 @@ for (j = 0; j < NX; j++) {
|
||||
/*
|
||||
* Open the file and the dataset.
|
||||
*/
|
||||
file = H5Fopen(FILE, H5ACC_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT);
|
||||
dataset = H5Dopen(file, DATASETNAME);
|
||||
|
||||
/*
|
||||
|
@ -35,11 +35,11 @@ for (j = 0; j < NX; j++) {
|
||||
4 5 6 7 8 9 */
|
||||
|
||||
/*
|
||||
* Create a new file using H5ACC_OVERWRITE access,
|
||||
* Create a new file using H5F_ACC_TRUNC access,
|
||||
* default file creation properties, and default file
|
||||
* access properties.
|
||||
*/
|
||||
file = H5Fcreate(FILE, H5ACC_OVERWRITE, H5C_DEFAULT, H5C_DEFAULT);
|
||||
file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT);
|
||||
|
||||
/*
|
||||
* Describe the size of the array and create the data space for fixed
|
||||
|
380
src/H5C.c
380
src/H5C.c
@ -58,6 +58,16 @@ H5C_init_interface(void)
|
||||
|
||||
FUNC_ENTER(H5C_init_interface, FAIL);
|
||||
|
||||
/*
|
||||
* Make sure the file creation and file access default templates are
|
||||
* initialized since this might be done at run-time instead of compile
|
||||
* time.
|
||||
*/
|
||||
if (H5F_init_interface ()<0) {
|
||||
HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
|
||||
"unable to initialize H5F and H5C interfaces");
|
||||
}
|
||||
|
||||
assert(H5C_NCLASSES <= H5_TEMPLATE_MAX - H5_TEMPLATE_0);
|
||||
|
||||
/*
|
||||
@ -66,14 +76,15 @@ H5C_init_interface(void)
|
||||
* atom groups aren't.
|
||||
*/
|
||||
for (i = 0; i < H5C_NCLASSES; i++) {
|
||||
status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), H5A_TEMPID_HASHSIZE, 0, NULL);
|
||||
if (status < 0)
|
||||
ret_value = FAIL;
|
||||
status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i),
|
||||
H5A_TEMPID_HASHSIZE, 0, NULL);
|
||||
if (status < 0) ret_value = FAIL;
|
||||
}
|
||||
if (ret_value < 0) {
|
||||
HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
|
||||
"unable to initialize atom group");
|
||||
}
|
||||
|
||||
/*
|
||||
* Register cleanup function.
|
||||
*/
|
||||
@ -81,6 +92,7 @@ H5C_init_interface(void)
|
||||
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
|
||||
"unable to install atexit function");
|
||||
}
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -194,7 +206,7 @@ H5Ccreate(H5C_class_t type)
|
||||
hid_t
|
||||
H5C_create(H5C_class_t type, void *tmpl)
|
||||
{
|
||||
hid_t ret_value = FAIL;
|
||||
hid_t ret_value = FAIL;
|
||||
|
||||
FUNC_ENTER(H5C_create, FAIL);
|
||||
|
||||
@ -203,10 +215,11 @@ H5C_create(H5C_class_t type, void *tmpl)
|
||||
assert(tmpl);
|
||||
|
||||
/* Atomize the new template */
|
||||
if ((ret_value = H5A_register((group_t)(H5_TEMPLATE_0 + type), tmpl)) < 0) {
|
||||
if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) {
|
||||
HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
|
||||
"can't register template");
|
||||
}
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
@ -226,21 +239,79 @@ H5C_create(H5C_class_t type, void *tmpl)
|
||||
herr_t
|
||||
H5Cclose(hid_t tid)
|
||||
{
|
||||
void *tmpl = NULL;
|
||||
H5C_class_t type;
|
||||
void *tmpl = NULL;
|
||||
|
||||
FUNC_ENTER(H5Cclose, FAIL);
|
||||
|
||||
/* Chuck the object! :-) */
|
||||
if (NULL == (tmpl = H5A_remove(tid))) {
|
||||
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to remove atom");
|
||||
/* Check arguments */
|
||||
if ((type=H5Cget_class (tid))<0 ||
|
||||
NULL==(tmpl=H5A_object (tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
|
||||
}
|
||||
|
||||
/*
|
||||
* Chuck the object! This will fail when the reference count reaches zero
|
||||
* since there is no free func registered for the property list groups.
|
||||
*/
|
||||
if (H5A_dec_ref (tid)<0) {
|
||||
H5ECLEAR;
|
||||
H5C_close (type, tmpl);
|
||||
}
|
||||
#ifdef LATER
|
||||
/* this is for file access template too. Need to free the COMM and INFO objects too. */
|
||||
#endif
|
||||
H5MM_xfree(tmpl);
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5C_close
|
||||
*
|
||||
* Purpose: Closes a template and frees the memory associated with the
|
||||
* template.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, February 18, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5C_close (H5C_class_t type, void *tmpl)
|
||||
{
|
||||
FUNC_ENTER (H5C_close, FAIL);
|
||||
|
||||
/* Check args */
|
||||
assert (tmpl);
|
||||
|
||||
/* Some templates may need to do special things */
|
||||
switch (type) {
|
||||
case H5C_FILE_ACCESS:
|
||||
#ifdef LATER
|
||||
/* Need to free the COMM and INFO objects too. */
|
||||
#endif
|
||||
break;
|
||||
|
||||
case H5C_FILE_CREATE:
|
||||
case H5C_DATASET_CREATE:
|
||||
case H5C_DATASET_XFER:
|
||||
/*nothing to do*/
|
||||
break;
|
||||
|
||||
default:
|
||||
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"unknown property list class");
|
||||
}
|
||||
|
||||
/* Free the template struct and return */
|
||||
H5MM_xfree(tmpl);
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cget_class
|
||||
@ -857,6 +928,235 @@ H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
|
||||
|
||||
FUNC_LEAVE(tmpl->chunk_ndims);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cset_stdio
|
||||
*
|
||||
* Purpose: Set the low level file driver to use the functions declared
|
||||
* in the stdio.h file: fopen(), fseek() or fseek64(), fread(),
|
||||
* fwrite(), and fclose().
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, February 19, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_stdio (hid_t tid)
|
||||
{
|
||||
H5F_access_t *tmpl = NULL;
|
||||
|
||||
FUNC_ENTER (H5Cset_stdio, FAIL);
|
||||
|
||||
/* Check arguments */
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
|
||||
/* Set driver */
|
||||
tmpl->driver = H5F_LOW_STDIO;
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cset_sec2
|
||||
*
|
||||
* Purpose: Set the low-level file driver to use the functions declared
|
||||
* in the unistd.h file: open(), lseek() or lseek64(), read(),
|
||||
* write(), and close().
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, February 19, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_sec2 (hid_t tid)
|
||||
{
|
||||
H5F_access_t *tmpl = NULL;
|
||||
|
||||
FUNC_ENTER (H5Cset_sec2, FAIL);
|
||||
|
||||
/* Check arguments */
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
|
||||
/* Set driver */
|
||||
tmpl->driver = H5F_LOW_SEC2;
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cset_core
|
||||
*
|
||||
* Purpose: Set the low-level file driver to use malloc() and free().
|
||||
* This driver is restricted to temporary files which are not
|
||||
* larger than the amount of virtual memory available. The
|
||||
* INCREMENT argument determines the file block size and memory
|
||||
* will be allocated in multiples of INCREMENT bytes. A liberal
|
||||
* INCREMENT results in fewer calls to realloc() and probably
|
||||
* less memory fragmentation.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, February 19, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_core (hid_t tid, size_t increment)
|
||||
{
|
||||
H5F_access_t *tmpl = NULL;
|
||||
|
||||
FUNC_ENTER (H5Cset_core, FAIL);
|
||||
|
||||
/* Check arguments */
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
if (increment<1) {
|
||||
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"increment must be positive");
|
||||
}
|
||||
|
||||
/* Set driver */
|
||||
tmpl->driver = H5F_LOW_CORE;
|
||||
tmpl->u.core.increment = increment;
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cset_split
|
||||
*
|
||||
* Purpose: Set the low-level driver to split meta data from raw data,
|
||||
* storing meta data in one file and raw data in another file.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, February 19, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid)
|
||||
{
|
||||
H5F_access_t *tmpl = NULL;
|
||||
H5F_access_t *meta_tmpl = NULL;
|
||||
H5F_access_t *raw_tmpl = NULL;
|
||||
|
||||
FUNC_ENTER (H5Cset_split, FAIL);
|
||||
|
||||
/* Check arguments */
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
if (H5C_DEFAULT!=meta_tid &&
|
||||
(H5C_FILE_ACCESS != H5Cget_class(meta_tid) ||
|
||||
NULL == (tmpl = H5A_object(meta_tid)))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
if (H5C_DEFAULT!=raw_tid &&
|
||||
(H5C_FILE_ACCESS != H5Cget_class(raw_tid) ||
|
||||
NULL == (tmpl = H5A_object(raw_tid)))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
|
||||
/* Set driver */
|
||||
tmpl->driver = H5F_LOW_SPLIT;
|
||||
tmpl->u.split.meta_access = H5C_copy (H5C_FILE_ACCESS, meta_tmpl);
|
||||
tmpl->u.split.raw_access = H5C_copy (H5C_FILE_ACCESS, raw_tmpl);
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5Cset_family
|
||||
*
|
||||
* Purpose: Sets the low-level driver to stripe the hdf5 address space
|
||||
* across a family of files.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Thursday, February 19, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_family (hid_t tid, hid_t memb_tid)
|
||||
{
|
||||
|
||||
H5F_access_t *tmpl = NULL;
|
||||
H5F_access_t *memb_tmpl = NULL;
|
||||
|
||||
FUNC_ENTER (H5Cset_family, FAIL);
|
||||
|
||||
/* Check arguments */
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
if (H5C_DEFAULT!=memb_tid &&
|
||||
(H5C_FILE_ACCESS != H5Cget_class(memb_tid) ||
|
||||
NULL == (tmpl = H5A_object(memb_tid)))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
}
|
||||
|
||||
/* Set driver */
|
||||
tmpl->driver = H5F_LOW_FAMILY;
|
||||
tmpl->u.fam.memb_access = H5C_copy (H5C_FILE_ACCESS, memb_tmpl);
|
||||
|
||||
FUNC_LEAVE (SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_PARALLEL
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -903,12 +1203,18 @@ H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ )
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Check all arguments before the template is updated so we don't leave
|
||||
* the template in a bad state if something goes wrong. Also, the
|
||||
* template data type changed to allow more generality so all the
|
||||
* mpi-related stuff is in the `u.mpi' member. The `access_mode' will
|
||||
* contain only mpi-related flags defined in H5Fpublic.h.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
|
||||
{
|
||||
int i;
|
||||
H5F_access_t *tmpl = NULL;
|
||||
MPI_Comm lcomm;
|
||||
int mrc; /* MPI return code */
|
||||
@ -919,31 +1225,47 @@ H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode)
|
||||
if (H5C_FILE_ACCESS != H5Cget_class(tid) ||
|
||||
NULL == (tmpl = H5A_object(tid))) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
|
||||
"not a file access template");
|
||||
"not a file access template");
|
||||
}
|
||||
|
||||
switch (access_mode){
|
||||
case H5ACC_INDEPENDENT:
|
||||
/* fall through to next case */
|
||||
case H5ACC_COLLECTIVE:
|
||||
tmpl->access_mode = access_mode;
|
||||
break;
|
||||
/* okay */
|
||||
break;
|
||||
|
||||
default:
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"unknown access_mode");
|
||||
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"invalid mpio access mode");
|
||||
}
|
||||
|
||||
/* store a duplicate copy of comm so that user may freely modify comm after this */
|
||||
/* call. */
|
||||
#ifdef LATER
|
||||
/* need to verify comm and info contain sensible information */
|
||||
/* need to duplicate info too but don't know a quick way to do it now. */
|
||||
/*
|
||||
* Need to verify comm and info contain sensible information.
|
||||
*/
|
||||
#endif
|
||||
if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS)
|
||||
|
||||
|
||||
/*
|
||||
* Everything looks good. Now go ahead and modify the access template.
|
||||
*/
|
||||
tmpl->driver = H5F_LOW_MPIO;
|
||||
tmpl->u.mpio.access_mode = access_mode;
|
||||
|
||||
/*
|
||||
* Store a duplicate copy of comm so that user may freely modify comm
|
||||
* after this call.
|
||||
*/
|
||||
if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) {
|
||||
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
|
||||
"failure to duplicate communicator");
|
||||
tmpl->comm = comm;
|
||||
tmpl->info = info;
|
||||
}
|
||||
tmpl->u.mpio.comm = comm;
|
||||
|
||||
#ifdef LATER
|
||||
/* Need to duplicate info too but don't know a quick way to do it now */
|
||||
#endif
|
||||
tmpl->u.mpio.info = info;
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
@ -1038,8 +1360,8 @@ H5C_copy (H5C_class_t type, const void *src)
|
||||
break;
|
||||
|
||||
case H5C_FILE_ACCESS:
|
||||
HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
|
||||
"file access properties are not implemented yet");
|
||||
size = sizeof(H5F_access_t);
|
||||
break;
|
||||
|
||||
case H5C_DATASET_CREATE:
|
||||
size = sizeof(H5D_create_t);
|
||||
|
@ -24,5 +24,6 @@
|
||||
|
||||
hid_t H5C_create (H5C_class_t type, void *tmpl);
|
||||
void *H5C_copy (H5C_class_t type, const void *src);
|
||||
herr_t H5C_close (H5C_class_t type, void *tmpl);
|
||||
|
||||
#endif
|
||||
|
@ -61,6 +61,11 @@ herr_t H5Cset_layout (hid_t tid, H5D_layout_t layout);
|
||||
H5D_layout_t H5Cget_layout (hid_t tid);
|
||||
herr_t H5Cset_chunk (hid_t tid, int ndims, const size_t dim[]);
|
||||
int H5Cget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/);
|
||||
herr_t H5Cset_stdio (hid_t tid);
|
||||
herr_t H5Cset_sec2 (hid_t tid);
|
||||
herr_t H5Cset_core (hid_t tid, size_t increment);
|
||||
herr_t H5Cset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid);
|
||||
herr_t H5Cset_family (hid_t tid, hid_t memb_tid);
|
||||
#ifdef HAVE_PARALLEL
|
||||
herr_t H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode);
|
||||
/* herr_t H5Cget_mpi (hid_t tid, int *ik); */ /* not defined yet */
|
||||
|
@ -77,6 +77,7 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] =
|
||||
{H5E_READERROR, "Read failed"},
|
||||
{H5E_WRITEERROR, "Write failed"},
|
||||
{H5E_CLOSEERROR, "Close failed"},
|
||||
{H5E_OVERFLOW, "Address overflowed"},
|
||||
{H5E_CANTINIT, "Can't initialize interface"},
|
||||
{H5E_ALREADYINIT, "Object already initialized"},
|
||||
{H5E_BADATOM, "Can't find atom information"},
|
||||
|
@ -76,6 +76,7 @@ typedef enum H5E_minor_t {
|
||||
H5E_READERROR, /*read failed */
|
||||
H5E_WRITEERROR, /*write failed */
|
||||
H5E_CLOSEERROR, /*close failed */
|
||||
H5E_OVERFLOW, /*address overflowed */
|
||||
|
||||
/* Function entry/exit interface errors */
|
||||
H5E_CANTINIT, /*Can't initialize interface */
|
||||
|
@ -19,32 +19,35 @@
|
||||
#include <H5Fprivate.h>
|
||||
#include <H5MMprivate.h>
|
||||
|
||||
#define H5F_CORE_INC 10240 /*amount by which to grow file */
|
||||
#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things */
|
||||
|
||||
#define PABLO_MASK H5F_core
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
|
||||
static hbool_t H5F_core_access(const char *name, int mode, H5F_search_t *key);
|
||||
static H5F_low_t *H5F_core_open(const char *name, uintn flags, H5F_search_t *);
|
||||
static herr_t H5F_core_close(H5F_low_t *lf);
|
||||
static herr_t H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf);
|
||||
static herr_t H5F_core_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static hbool_t H5F_core_access(const char *name,
|
||||
const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key/*out*/);
|
||||
static H5F_low_t *H5F_core_open(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
static herr_t H5F_core_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_core_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf);
|
||||
static herr_t H5F_core_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
|
||||
const H5F_low_class_t H5F_LOW_CORE_g[1] = {{
|
||||
H5F_core_access, /* access method */
|
||||
H5F_core_open, /* open method */
|
||||
H5F_core_close, /* close method */
|
||||
H5F_core_read, /* read method */
|
||||
H5F_core_write, /* write method */
|
||||
NULL, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
const H5F_low_class_t H5F_LOW_CORE[1] =
|
||||
{
|
||||
{
|
||||
H5F_core_access, /* access method */
|
||||
H5F_core_open, /* open method */
|
||||
H5F_core_close, /* close method */
|
||||
H5F_core_read, /* read method */
|
||||
H5F_core_write, /* write method */
|
||||
NULL, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_core_access
|
||||
@ -66,11 +69,13 @@ const H5F_low_class_t H5F_LOW_CORE[1] =
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static hbool_t
|
||||
H5F_core_access(const char *name, int mode, H5F_search_t *key /*out */ )
|
||||
H5F_core_access(const char *name, const H5F_access_t *access_parms,
|
||||
int mode, H5F_search_t *key/*out*/)
|
||||
{
|
||||
FUNC_ENTER(H5F_core_access, FAIL);
|
||||
FUNC_LEAVE(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_core_open
|
||||
@ -93,21 +98,23 @@ H5F_core_access(const char *name, int mode, H5F_search_t *key /*out */ )
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5F_low_t *
|
||||
H5F_core_open(const char *name, uintn flags, H5F_search_t *key)
|
||||
static H5F_low_t *
|
||||
H5F_core_open(const char *name, const H5F_access_t *access_parms,
|
||||
uintn flags, H5F_search_t *key/*out*/)
|
||||
{
|
||||
H5F_low_t *lf = NULL;
|
||||
static ino_t ino = 0;
|
||||
|
||||
FUNC_ENTER(H5F_core_open, NULL);
|
||||
|
||||
if (0 == (flags & H5F_ACC_WRITE) || 0 == (flags & H5F_ACC_CREAT)) {
|
||||
if (0 == (flags & H5F_ACC_RDWR) || 0 == (flags & H5F_ACC_CREAT)) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
|
||||
"must creat file with write access");
|
||||
}
|
||||
|
||||
lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
|
||||
lf->u.core.mem = H5MM_xmalloc(H5F_CORE_INC);
|
||||
lf->u.core.alloc = H5F_CORE_INC;
|
||||
lf->u.core.mem = NULL;
|
||||
lf->u.core.alloc = 0;
|
||||
lf->u.core.size = 0;
|
||||
H5F_addr_reset(&(lf->eof));
|
||||
|
||||
@ -115,8 +122,10 @@ H5F_core_open(const char *name, uintn flags, H5F_search_t *key)
|
||||
key->dev = H5F_CORE_DEV;
|
||||
key->ino = ino++;
|
||||
}
|
||||
|
||||
FUNC_LEAVE(lf);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_core_close
|
||||
@ -137,7 +146,7 @@ H5F_core_open(const char *name, uintn flags, H5F_search_t *key)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_core_close(H5F_low_t *lf)
|
||||
H5F_core_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
FUNC_ENTER(H5F_core_close, FAIL);
|
||||
|
||||
@ -147,6 +156,7 @@ H5F_core_close(H5F_low_t *lf)
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_core_read
|
||||
@ -169,7 +179,8 @@ H5F_core_close(H5F_low_t *lf)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
H5F_core_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf)
|
||||
{
|
||||
size_t n;
|
||||
size_t eof;
|
||||
@ -192,6 +203,7 @@ H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_core_write
|
||||
@ -214,27 +226,39 @@ H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_core_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_core_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf)
|
||||
{
|
||||
size_t inc_amount;
|
||||
size_t need_more;
|
||||
size_t increment = 1;
|
||||
|
||||
|
||||
FUNC_ENTER(H5F_core_write, FAIL);
|
||||
|
||||
assert(lf);
|
||||
assert(addr && H5F_addr_defined(addr));
|
||||
assert(buf);
|
||||
assert (!access_parms || H5F_LOW_CORE==access_parms->driver);
|
||||
|
||||
/* Allocate more space */
|
||||
/*
|
||||
* Allocate more space. We always allocate a multiple of the increment
|
||||
* size, which is either defined in the file access property list or
|
||||
* which defaults to one.
|
||||
*/
|
||||
if (addr->offset + size > lf->u.core.alloc) {
|
||||
inc_amount = MAX(addr->offset + size - lf->u.core.alloc, H5F_CORE_INC);
|
||||
lf->u.core.alloc = lf->u.core.alloc + inc_amount;
|
||||
if (access_parms) increment = access_parms->u.core.increment;
|
||||
need_more = addr->offset+size - lf->u.core.alloc;
|
||||
need_more = increment*((need_more+increment-1)/increment);
|
||||
|
||||
lf->u.core.alloc = lf->u.core.alloc + need_more;
|
||||
lf->u.core.mem = H5MM_xrealloc(lf->u.core.mem, lf->u.core.alloc);
|
||||
}
|
||||
|
||||
/* Move the physical EOF marker */
|
||||
if (addr->offset + size > lf->u.core.size) {
|
||||
lf->u.core.size = addr->offset + size;
|
||||
}
|
||||
|
||||
/* Copy data */
|
||||
HDmemcpy(lf->u.core.mem + addr->offset, buf, size);
|
||||
|
||||
|
660
src/H5Ffamily.c
660
src/H5Ffamily.c
@ -1,25 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 1997 Spizella Software
|
||||
* All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Programmer: Robb Matzke <matzke@llnl.gov>
|
||||
* Monday, November 10, 1997
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Purpose: Implements a family of files that acts as a single hdf5
|
||||
* file. The purpose is to be able to split a huge file on a
|
||||
* 64-bit platform, transfer all the <2GB members to a 32-bit
|
||||
* platform, and then access the entire huge file on the 32-bit
|
||||
* platform.
|
||||
* Purpose: Implements a family of files that acts as a single hdf5
|
||||
* file. The purpose is to be able to split a huge file on a
|
||||
* 64-bit platform, transfer all the <2GB members to a 32-bit
|
||||
* platform, and then access the entire huge file on the 32-bit
|
||||
* platform.
|
||||
*
|
||||
* All family members are logically the same size although their
|
||||
* physical sizes may vary. The logical member size is
|
||||
* determined by looking at the physical size of the first
|
||||
* member and rounding that up to the next power of two. When
|
||||
* creating a file family, the first member is created with a
|
||||
* predefined physical size (actually, this happens when the
|
||||
* file family is flushed, and can be quite time consuming on
|
||||
* file systems that don't implement holes, like nfs).
|
||||
*
|
||||
* All family members are logically the same size although their
|
||||
* physical sizes may vary. The logical member size is
|
||||
* determined by looking at the physical size of the first
|
||||
* member and rounding that up to the next power of two. When
|
||||
* creating a file family, the first member is created with a
|
||||
* predefined physical size (actually, this happens when the
|
||||
* file family is flushed, and can be quite time consuming on
|
||||
* file systems that don't implement holes, like nfs).
|
||||
*
|
||||
*/
|
||||
#include <H5private.h>
|
||||
#include <H5Eprivate.h>
|
||||
@ -27,7 +27,7 @@
|
||||
#include <H5MMprivate.h>
|
||||
|
||||
#define PABLO_MASK H5F_family
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
|
||||
/*
|
||||
@ -38,81 +38,104 @@ static hbool_t interface_initialize_g = FALSE;
|
||||
* Smaller values result in files of a more manageable size (from a human
|
||||
* perspective) but also limit the total logical size of the hdf5 file.
|
||||
*/
|
||||
#define H5F_FAM_DFLT_NBITS 26u /*64MB */
|
||||
#define H5F_FAM_DFLT_NBITS 26u /*64MB */
|
||||
|
||||
#define H5F_FAM_MASK(N) (((uint64)1<<(N))-1)
|
||||
#define H5F_FAM_OFFSET(ADDR,N) ((off_t)((ADDR)->offset & H5F_FAM_MASK(N)))
|
||||
#define H5F_FAM_MEMBNO(ADDR,N) ((intn)((ADDR)->offset >> N))
|
||||
#define H5F_FAM_MASK(N) (((uint64)1<<(N))-1)
|
||||
#define H5F_FAM_OFFSET(ADDR,N) ((off_t)((ADDR)->offset & H5F_FAM_MASK(N)))
|
||||
#define H5F_FAM_MEMBNO(ADDR,N) ((intn)((ADDR)->offset >> N))
|
||||
|
||||
static hbool_t H5F_fam_access(const char *name, int mode, H5F_search_t *key);
|
||||
static H5F_low_t *H5F_fam_open(const char *name, uintn flags, H5F_search_t *);
|
||||
static herr_t H5F_fam_close(H5F_low_t *lf);
|
||||
static herr_t H5F_fam_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf);
|
||||
static herr_t H5F_fam_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
static hbool_t H5F_fam_access(const char *name,
|
||||
const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key/*out*/);
|
||||
static H5F_low_t *H5F_fam_open(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
static herr_t H5F_fam_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_fam_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf);
|
||||
static herr_t H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static herr_t H5F_fam_flush(H5F_low_t *lf);
|
||||
static herr_t H5F_fam_flush(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
|
||||
const H5F_low_class_t H5F_LOW_FAM[1] = {{
|
||||
H5F_fam_access, /* access method */
|
||||
H5F_fam_open, /* open method */
|
||||
H5F_fam_close, /* close method */
|
||||
H5F_fam_read, /* read method */
|
||||
H5F_fam_write, /* write method */
|
||||
H5F_fam_flush, /* flush method */
|
||||
NULL, /* extend method */
|
||||
const H5F_low_class_t H5F_LOW_FAMILY_g[1] = {{
|
||||
H5F_fam_access, /* access method */
|
||||
H5F_fam_open, /* open method */
|
||||
H5F_fam_close, /* close method */
|
||||
H5F_fam_read, /* read method */
|
||||
H5F_fam_write, /* write method */
|
||||
H5F_fam_flush, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_open
|
||||
* Function: H5F_fam_open
|
||||
*
|
||||
* Purpose: Opens a file family with the specified base name. The name
|
||||
* should contain a printf-style "%d" field which will be
|
||||
* expanded with a zero-origin family member number.
|
||||
* Purpose: Opens a file family with the specified base name. The name
|
||||
* should contain a printf-style "%d" field which will be
|
||||
* expanded with a zero-origin family member number.
|
||||
*
|
||||
* Bugs: We don't check for overflow on the name, so keep it under
|
||||
* 4kb, please. Also, we don't actually check for the `%d'
|
||||
* field because we assume that the caller already did. Who
|
||||
* knows what happens when all the family member names are the
|
||||
* same!
|
||||
* Bugs: We don't check for overflow on the name, so keep it under
|
||||
* 4kb, please. Also, we don't actually check for the `%d'
|
||||
* field because we assume that the caller already did. Who
|
||||
* knows what happens when all the family member names are the
|
||||
* same!
|
||||
*
|
||||
* Return: Success: Low-level file pointer
|
||||
* Return: Success: Low-level file pointer
|
||||
*
|
||||
* Failure: NULL
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5F_low_t *
|
||||
H5F_fam_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
static H5F_low_t *
|
||||
H5F_fam_open(const char *name, const H5F_access_t *access_parms,
|
||||
uintn flags, H5F_search_t *key/*out*/)
|
||||
{
|
||||
H5F_low_t *ret_value = NULL, *lf = NULL;
|
||||
H5F_low_t *member = NULL; /*a family member */
|
||||
char member_name[4096]; /*name of family member */
|
||||
intn membno; /*member number (zero-origin) */
|
||||
size_t nbits = H5F_FAM_DFLT_NBITS; /*num bits in an offset */
|
||||
haddr_t tmp_addr; /*temporary address */
|
||||
H5F_low_t *ret_value = NULL;
|
||||
H5F_low_t *lf = NULL;
|
||||
H5F_low_t *member = NULL; /*a family member */
|
||||
char member_name[4096]; /*name of family member */
|
||||
intn membno; /*member number (zero-origin) */
|
||||
size_t nbits = H5F_FAM_DFLT_NBITS; /*num bits in an offset */
|
||||
haddr_t tmp_addr; /*temporary address */
|
||||
const H5F_low_class_t *memb_type; /*type of family member */
|
||||
|
||||
FUNC_ENTER(H5F_fam_open, NULL);
|
||||
|
||||
assert (access_parms);
|
||||
assert (H5F_LOW_FAMILY==access_parms->driver);
|
||||
|
||||
/*
|
||||
* Use the default file driver or the specified driver for each of the
|
||||
* family members.
|
||||
*/
|
||||
if (access_parms->u.fam.memb_access) {
|
||||
memb_type = H5F_low_class (access_parms->u.fam.memb_access->driver);
|
||||
} else {
|
||||
memb_type = H5F_low_class (H5F_LOW_DFLT);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're truncating the file then delete all but the first family
|
||||
* member. Use the default number of bits for the offset.
|
||||
* member. Use the default number of bits for the offset.
|
||||
*/
|
||||
if ((flags & H5F_ACC_WRITE) && (flags & H5F_ACC_TRUNC)) {
|
||||
for (membno = 1; /*void */ ; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
if (!H5F_low_access(H5F_LOW_DFLT, member_name, F_OK, NULL)) {
|
||||
break;
|
||||
} else if (unlink(member_name) < 0) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "can't delete member");
|
||||
}
|
||||
}
|
||||
if ((flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) {
|
||||
for (membno = 1; /*void*/; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
if (!H5F_low_access(memb_type, member_name,
|
||||
access_parms->u.fam.memb_access,
|
||||
F_OK, NULL)) {
|
||||
break;
|
||||
} else if (unlink(member_name) < 0) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "can't delete member");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Create the file descriptor */
|
||||
lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
|
||||
@ -120,33 +143,34 @@ H5F_fam_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
lf->u.fam.flags = (flags & ~H5F_ACC_CREAT);
|
||||
|
||||
/* Open all existing members */
|
||||
for (membno = 0; /*void */ ; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
for (membno = 0; /*void*/; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
|
||||
/*
|
||||
* Open the family member. After the first member is opened or created,
|
||||
* turn off the creation flag so we don't create a zillion family
|
||||
* members.
|
||||
*/
|
||||
member = H5F_low_open(H5F_LOW_DFLT, member_name, flags,
|
||||
0 == membno ? key : NULL);
|
||||
if (!member) {
|
||||
if (0 == membno) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
|
||||
"can't open first family member");
|
||||
}
|
||||
break;
|
||||
}
|
||||
flags &= ~H5F_ACC_CREAT;
|
||||
/*
|
||||
* Open the family member. After the first member is opened or
|
||||
* created, turn off the creation flag so we don't create a zillion
|
||||
* family members.
|
||||
*/
|
||||
member = H5F_low_open(memb_type, member_name,
|
||||
access_parms->u.fam.memb_access, flags,
|
||||
0 == membno ? key : NULL);
|
||||
if (!member) {
|
||||
if (0 == membno) {
|
||||
HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
|
||||
"can't open first family member");
|
||||
}
|
||||
break;
|
||||
}
|
||||
flags &= ~H5F_ACC_CREAT;
|
||||
|
||||
/* Add the member to the family */
|
||||
if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
|
||||
lf->u.fam.nalloc = MAX(100, 2 * lf->u.fam.nalloc);
|
||||
lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
|
||||
lf->u.fam.nalloc * sizeof(H5F_low_t *));
|
||||
}
|
||||
lf->u.fam.memb[lf->u.fam.nmemb++] = member;
|
||||
member = NULL;
|
||||
/* Add the member to the family */
|
||||
if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
|
||||
lf->u.fam.nalloc = MAX(100, 2 * lf->u.fam.nalloc);
|
||||
lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
|
||||
lf->u.fam.nalloc * sizeof(H5F_low_t *));
|
||||
}
|
||||
lf->u.fam.memb[lf->u.fam.nmemb++] = member;
|
||||
member = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -155,32 +179,36 @@ H5F_fam_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
* member.
|
||||
*/
|
||||
if (lf->u.fam.nmemb >= 2) {
|
||||
size_t size = H5F_low_size(lf->u.fam.memb[0], &tmp_addr);
|
||||
for (nbits = 8 * sizeof(size_t) - 1; nbits > 0; --nbits) {
|
||||
size_t mask = (size_t) 1 << nbits;
|
||||
if (size & mask) {
|
||||
if (size != mask) {
|
||||
size++;
|
||||
size_t size = H5F_low_size(lf->u.fam.memb[0], &tmp_addr);
|
||||
for (nbits=8*sizeof(size_t)-1; nbits>0; --nbits) {
|
||||
size_t mask = (size_t)1 << nbits;
|
||||
if (size & mask) {
|
||||
if (size != mask) {
|
||||
size++;
|
||||
#ifdef H5F_DEBUG
|
||||
fprintf(stderr, "HDF5-DIAG: family member size was rounded up "
|
||||
"to a power of 2");
|
||||
fprintf(stderr, "HDF5-DIAG: family member size was rounded up "
|
||||
"to a power of 2");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
lf->u.fam.offset_bits = nbits;
|
||||
|
||||
#ifdef H5F_DEBUG
|
||||
if (nbits >= 30) {
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dGB\n", 1 << (nbits - 30));
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dGB\n",
|
||||
1 << (nbits-30));
|
||||
} else if (nbits >= 20) {
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dMB\n", 1 << (nbits - 20));
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dMB\n",
|
||||
1 << (nbits-20));
|
||||
} else if (nbits >= 10) {
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dkB\n", 1 << (nbits - 10));
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %dkB\n",
|
||||
1 << (nbits-10));
|
||||
} else {
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %d bytes\n", 1 << nbits);
|
||||
fprintf(stderr, "HDF5-DIAG: family members are %d bytes\n",
|
||||
1 << nbits);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -188,50 +216,51 @@ H5F_fam_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
* Get the total family size and store it in the max_addr field.
|
||||
*/
|
||||
assert(lf->u.fam.nmemb >= 1);
|
||||
lf->eof.offset = (size_t) 1 << lf->u.fam.offset_bits;
|
||||
lf->eof.offset *= (lf->u.fam.nmemb - 1);
|
||||
lf->eof.offset += lf->u.fam.memb[lf->u.fam.nmemb - 1]->eof.offset;
|
||||
lf->eof.offset = (size_t)1 << lf->u.fam.offset_bits;
|
||||
lf->eof.offset *= (lf->u.fam.nmemb-1);
|
||||
lf->eof.offset += lf->u.fam.memb[lf->u.fam.nmemb-1]->eof.offset;
|
||||
|
||||
HRETURN(lf);
|
||||
|
||||
done:
|
||||
if (!ret_value) {
|
||||
if (lf) {
|
||||
H5F_fam_close(lf);
|
||||
H5MM_xfree(lf);
|
||||
}
|
||||
if (lf) {
|
||||
H5F_fam_close(lf, access_parms);
|
||||
H5MM_xfree(lf);
|
||||
}
|
||||
}
|
||||
FUNC_LEAVE(ret_value);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_close
|
||||
* Function: H5F_fam_close
|
||||
*
|
||||
* Purpose: Closes all members of a file family and releases resources
|
||||
* used by the file descriptor.
|
||||
* Purpose: Closes all members of a file family and releases resources
|
||||
* used by the file descriptor.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_fam_close(H5F_low_t *lf)
|
||||
H5F_fam_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
intn membno;
|
||||
intn membno;
|
||||
|
||||
FUNC_ENTER(H5F_fam_close, FAIL);
|
||||
|
||||
assert(lf);
|
||||
|
||||
for (membno = 0; membno < lf->u.fam.nmemb; membno++) {
|
||||
lf->u.fam.memb[membno] = H5F_low_close(lf->u.fam.memb[membno]);
|
||||
lf->u.fam.memb[membno] = H5F_low_close(lf->u.fam.memb[membno],
|
||||
access_parms->u.fam.memb_access);
|
||||
}
|
||||
H5MM_xfree(lf->u.fam.memb);
|
||||
H5MM_xfree(lf->u.fam.name);
|
||||
@ -240,36 +269,37 @@ H5F_fam_close(H5F_low_t *lf)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_read
|
||||
* Function: H5F_fam_read
|
||||
*
|
||||
* Purpose: Reads a chunk of contiguous data from the file family.
|
||||
* Reading past the physical end of a file returns zeros instead
|
||||
* of failing. We must insure that if the logical end of file is
|
||||
* before the physical end of file that we will read zeros there
|
||||
* also (the only time this can happen is if we create a family
|
||||
* and then close it before the first member is filled, since
|
||||
* flushing the file causes the first member to be physically
|
||||
* extended to it's maximum size).
|
||||
* Purpose: Reads a chunk of contiguous data from the file family.
|
||||
* Reading past the physical end of a file returns zeros instead
|
||||
* of failing. We must insure that if the logical end of file is
|
||||
* before the physical end of file that we will read zeros there
|
||||
* also (the only time this can happen is if we create a family
|
||||
* and then close it before the first member is filled, since
|
||||
* flushing the file causes the first member to be physically
|
||||
* extended to it's maximum size).
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_fam_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
H5F_fam_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf)
|
||||
{
|
||||
size_t nbytes;
|
||||
haddr_t cur_addr;
|
||||
uintn membno;
|
||||
off_t offset;
|
||||
size_t member_size;
|
||||
size_t nbytes;
|
||||
haddr_t cur_addr;
|
||||
uintn membno;
|
||||
off_t offset;
|
||||
size_t member_size;
|
||||
|
||||
FUNC_ENTER(H5F_fam_read, FAIL);
|
||||
|
||||
@ -283,154 +313,168 @@ H5F_fam_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
cur_addr = *addr;
|
||||
|
||||
while (size > 0) {
|
||||
if (membno >= lf->u.fam.nmemb) {
|
||||
HDmemset(buf, 0, size);
|
||||
break;
|
||||
} else {
|
||||
nbytes = MIN(size, member_size - offset);
|
||||
cur_addr.offset = offset;
|
||||
if (H5F_low_read(lf->u.fam.memb[membno], &cur_addr,
|
||||
nbytes, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||
"can't read from family member");
|
||||
}
|
||||
buf += nbytes;
|
||||
size -= nbytes;
|
||||
membno++;
|
||||
offset = 0;
|
||||
}
|
||||
if (membno >= lf->u.fam.nmemb) {
|
||||
HDmemset(buf, 0, size);
|
||||
break;
|
||||
} else {
|
||||
nbytes = MIN(size, member_size - offset);
|
||||
cur_addr.offset = offset;
|
||||
if (H5F_low_read(lf->u.fam.memb[membno],
|
||||
access_parms->u.fam.memb_access,
|
||||
&cur_addr, nbytes, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||
"can't read from family member");
|
||||
}
|
||||
buf += nbytes;
|
||||
size -= nbytes;
|
||||
membno++;
|
||||
offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_write
|
||||
* Function: H5F_fam_write
|
||||
*
|
||||
* Purpose: Writes BUF to the family of files. The superclass has
|
||||
* already insured that we aren't writing past the logical end
|
||||
* of file, so this function will extend the physical file to
|
||||
* accommodate the new data if necessary.
|
||||
* Purpose: Writes BUF to the family of files. The superclass has
|
||||
* already insured that we aren't writing past the logical end
|
||||
* of file, so this function will extend the physical file to
|
||||
* accommodate the new data if necessary.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_fam_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf)
|
||||
{
|
||||
size_t nbytes;
|
||||
haddr_t cur_addr, max_addr;
|
||||
uintn membno;
|
||||
off_t offset;
|
||||
H5F_low_t *member = NULL;
|
||||
char member_name[4096];
|
||||
intn i;
|
||||
size_t member_size;
|
||||
|
||||
size_t nbytes;
|
||||
haddr_t cur_addr, max_addr;
|
||||
uintn membno;
|
||||
off_t offset;
|
||||
H5F_low_t *member = NULL;
|
||||
char member_name[4096];
|
||||
intn i;
|
||||
size_t member_size;
|
||||
const H5F_low_class_t *memb_type = NULL;
|
||||
|
||||
FUNC_ENTER(H5F_fam_write, FAIL);
|
||||
|
||||
/* Check args */
|
||||
assert(lf);
|
||||
assert(addr && H5F_addr_defined(addr));
|
||||
assert(buf);
|
||||
assert (access_parms);
|
||||
assert (H5F_LOW_FAMILY==access_parms->driver);
|
||||
|
||||
/* Get the member driver */
|
||||
if (access_parms->u.fam.memb_access) {
|
||||
memb_type = H5F_low_class (access_parms->u.fam.memb_access->driver);
|
||||
} else {
|
||||
memb_type = H5F_low_class (H5F_LOW_DFLT);
|
||||
}
|
||||
|
||||
member_size = (size_t) 1 << lf->u.fam.offset_bits;
|
||||
membno = H5F_FAM_MEMBNO(addr, lf->u.fam.offset_bits);
|
||||
offset = H5F_FAM_OFFSET(addr, lf->u.fam.offset_bits);
|
||||
cur_addr = *addr;
|
||||
|
||||
while (size > 0) {
|
||||
nbytes = MIN(size, member_size - offset);
|
||||
cur_addr.offset = offset;
|
||||
nbytes = MIN(size, member_size - offset);
|
||||
cur_addr.offset = offset;
|
||||
|
||||
if (membno >= lf->u.fam.nmemb) {
|
||||
/*
|
||||
* We're writing past the end of the last family member--create the
|
||||
* new family member(s)
|
||||
*/
|
||||
for (i = lf->u.fam.nmemb; i <= membno; i++) {
|
||||
sprintf(member_name, lf->u.fam.name, i);
|
||||
member = H5F_low_open(H5F_LOW_DFLT, member_name,
|
||||
lf->u.fam.flags | H5F_ACC_CREAT,
|
||||
NULL);
|
||||
if (!member) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
|
||||
"can't create a new member");
|
||||
}
|
||||
/*
|
||||
* For members in the middle, set their logical eof to the
|
||||
* maximum possible value.
|
||||
*/
|
||||
if (i < membno) {
|
||||
H5F_addr_reset(&max_addr);
|
||||
H5F_addr_inc(&max_addr, member_size);
|
||||
H5F_low_seteof(member, &max_addr);
|
||||
}
|
||||
if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
|
||||
lf->u.fam.nalloc *= 2;
|
||||
lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
|
||||
(lf->u.fam.nalloc *
|
||||
sizeof(H5F_low_t *)));
|
||||
}
|
||||
lf->u.fam.memb[lf->u.fam.nmemb++] = member;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Make sure the logical eof is large enough to handle the request.
|
||||
*/
|
||||
max_addr = cur_addr;
|
||||
H5F_addr_inc(&max_addr, nbytes);
|
||||
H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
|
||||
if (membno >= lf->u.fam.nmemb) {
|
||||
/*
|
||||
* We're writing past the end of the last family member--create the
|
||||
* new family member(s)
|
||||
*/
|
||||
for (i = lf->u.fam.nmemb; i <= membno; i++) {
|
||||
sprintf(member_name, lf->u.fam.name, i);
|
||||
member = H5F_low_open(memb_type, member_name,
|
||||
access_parms->u.fam.memb_access,
|
||||
lf->u.fam.flags | H5F_ACC_CREAT,
|
||||
NULL);
|
||||
if (!member) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
|
||||
"can't create a new member");
|
||||
}
|
||||
/*
|
||||
* For members in the middle, set their logical eof to the
|
||||
* maximum possible value.
|
||||
*/
|
||||
if (i < membno) {
|
||||
H5F_addr_reset(&max_addr);
|
||||
H5F_addr_inc(&max_addr, member_size);
|
||||
H5F_low_seteof(member, &max_addr);
|
||||
}
|
||||
if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
|
||||
lf->u.fam.nalloc *= 2;
|
||||
lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
|
||||
(lf->u.fam.nalloc *
|
||||
sizeof(H5F_low_t *)));
|
||||
}
|
||||
lf->u.fam.memb[lf->u.fam.nmemb++] = member;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Make sure the logical eof is large enough to handle the request.
|
||||
*/
|
||||
max_addr = cur_addr;
|
||||
H5F_addr_inc(&max_addr, nbytes);
|
||||
H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
|
||||
|
||||
/* Write the data to the member */
|
||||
if (H5F_low_write(lf->u.fam.memb[membno], &cur_addr,
|
||||
nbytes, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't write to family member");
|
||||
}
|
||||
buf += nbytes;
|
||||
size -= nbytes;
|
||||
membno++;
|
||||
offset = 0;
|
||||
/* Write the data to the member */
|
||||
if (H5F_low_write(lf->u.fam.memb[membno],
|
||||
access_parms->u.fam.memb_access,
|
||||
&cur_addr, nbytes, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't write to family member");
|
||||
}
|
||||
buf += nbytes;
|
||||
size -= nbytes;
|
||||
membno++;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_flush
|
||||
* Function: H5F_fam_flush
|
||||
*
|
||||
* Purpose: Flushes all data to disk and makes sure that the first member
|
||||
* is as large as a member can be so we can accurately detect
|
||||
* the member size if we open this file for read access at a
|
||||
* later date.
|
||||
* Purpose: Flushes all data to disk and makes sure that the first member
|
||||
* is as large as a member can be so we can accurately detect
|
||||
* the member size if we open this file for read access at a
|
||||
* later date.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_fam_flush(H5F_low_t *lf)
|
||||
H5F_fam_flush(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
int membno, nerrors = 0;
|
||||
uint8 buf[1];
|
||||
haddr_t addr1, addr2, addr3;
|
||||
size_t max_offset;
|
||||
int membno, nerrors = 0;
|
||||
uint8 buf[1];
|
||||
haddr_t addr1, addr2, addr3;
|
||||
size_t max_offset;
|
||||
|
||||
FUNC_ENTER(H5F_fam_flush, FAIL);
|
||||
|
||||
@ -444,98 +488,118 @@ H5F_fam_flush(H5F_low_t *lf)
|
||||
max_offset = H5F_FAM_MASK(lf->u.fam.offset_bits);
|
||||
H5F_addr_reset(&addr1);
|
||||
H5F_addr_inc(&addr1, max_offset);
|
||||
H5F_low_size(lf->u.fam.memb[0], &addr2); /*remember logical eof */
|
||||
H5F_low_size(lf->u.fam.memb[0], &addr2); /*remember logical eof */
|
||||
addr3 = addr1;
|
||||
H5F_addr_inc(&addr3, (size_t) 1);
|
||||
H5F_low_seteof(lf->u.fam.memb[0], &addr3); /*prevent a warning */
|
||||
if (H5F_low_read(lf->u.fam.memb[0], &addr1, 1, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||
"can't read from first family member");
|
||||
H5F_low_seteof(lf->u.fam.memb[0], &addr3); /*prevent a warning */
|
||||
if (H5F_low_read(lf->u.fam.memb[0], access_parms->u.fam.memb_access,
|
||||
&addr1, 1, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
|
||||
"can't read from first family member");
|
||||
}
|
||||
if (H5F_low_write(lf->u.fam.memb[0], &addr1, 1, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't write to first family member");
|
||||
if (H5F_low_write(lf->u.fam.memb[0], access_parms->u.fam.memb_access,
|
||||
&addr1, 1, buf) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't write to first family member");
|
||||
}
|
||||
H5F_low_seteof(lf->u.fam.memb[0], &addr2); /*reset old eof */
|
||||
H5F_low_seteof(lf->u.fam.memb[0], &addr2); /*reset old eof */
|
||||
|
||||
/*
|
||||
* Flush each member file. Don't return an error status until we've
|
||||
* Flush each member file. Don't return an error status until we've
|
||||
* flushed as much as possible.
|
||||
*/
|
||||
for (membno = 0; membno < lf->u.fam.nmemb; membno++) {
|
||||
if (H5F_low_flush(lf->u.fam.memb[membno]) < 0) {
|
||||
nerrors++;
|
||||
}
|
||||
if (H5F_low_flush(lf->u.fam.memb[membno],
|
||||
access_parms->u.fam.memb_access) < 0) {
|
||||
nerrors++;
|
||||
}
|
||||
}
|
||||
if (nerrors) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't flush family member");
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"can't flush family member");
|
||||
}
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_fam_access
|
||||
* Function: H5F_fam_access
|
||||
*
|
||||
* Purpose: Determines if all members of the file family can be accessed
|
||||
* and returns the key for the first member of the family.
|
||||
* Purpose: Determines if all members of the file family can be accessed
|
||||
* and returns the key for the first member of the family.
|
||||
*
|
||||
* Return: Success: TRUE or FALSE
|
||||
* Return: Success: TRUE or FALSE
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Monday, November 10, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static hbool_t
|
||||
H5F_fam_access(const char *name, int mode, H5F_search_t *key /*out */ )
|
||||
H5F_fam_access(const char *name, const H5F_access_t *access_parms,
|
||||
int mode, H5F_search_t *key/*out*/)
|
||||
{
|
||||
intn membno;
|
||||
char member_name[4096];
|
||||
hbool_t status;
|
||||
hbool_t ret_value = FALSE;
|
||||
intn membno;
|
||||
char member_name[4096];
|
||||
hbool_t status;
|
||||
hbool_t ret_value = FALSE;
|
||||
const H5F_low_class_t *memb_type = NULL;
|
||||
|
||||
FUNC_ENTER(H5F_fam_access, FAIL);
|
||||
|
||||
for (membno=0; /*void*/; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
status = H5F_low_access(H5F_LOW_DFLT, member_name, mode,
|
||||
0 == membno ? key : NULL);
|
||||
/* Check args */
|
||||
assert (name && *name);
|
||||
assert (access_parms);
|
||||
assert (H5F_LOW_FAMILY==access_parms->driver);
|
||||
|
||||
if (!status) {
|
||||
if (F_OK == mode) {
|
||||
/*
|
||||
* If we didn't find a member then we must have gotten to the end
|
||||
* of the family. As long as we found the first member(s) the
|
||||
* family exists.
|
||||
*/
|
||||
ret_value = membno > 0 ? TRUE : FALSE;
|
||||
/* Get the driver for the family members */
|
||||
if (access_parms->u.fam.memb_access) {
|
||||
memb_type = H5F_low_class (access_parms->u.fam.memb_access->driver);
|
||||
} else {
|
||||
memb_type = H5F_low_class (H5F_LOW_DFLT);
|
||||
}
|
||||
|
||||
/* Access the members */
|
||||
for (membno=0; /*void*/; membno++) {
|
||||
sprintf(member_name, name, membno);
|
||||
status = H5F_low_access(memb_type, member_name, NULL, mode,
|
||||
0 == membno ? key : NULL);
|
||||
|
||||
if (!status) {
|
||||
if (F_OK == mode) {
|
||||
/*
|
||||
* If we didn't find a member then we must have gotten to the
|
||||
* end of the family. As long as we found the first
|
||||
* member(s) the family exists.
|
||||
*/
|
||||
ret_value = membno > 0 ? TRUE : FALSE;
|
||||
break;
|
||||
|
||||
} else if (H5F_low_access(H5F_LOW_DFLT, member_name, F_OK, NULL)) {
|
||||
/*
|
||||
* The file exists but didn't have the write access permissions.
|
||||
*/
|
||||
} else if (H5F_low_access(memb_type, member_name,
|
||||
access_parms->u.fam.memb_access,
|
||||
F_OK, NULL)) {
|
||||
/*
|
||||
* The file exists but didn't have the write access permissions.
|
||||
*/
|
||||
ret_value = FALSE;
|
||||
break;
|
||||
|
||||
} else {
|
||||
/*
|
||||
* The file doesn't exist because we got to the end of the
|
||||
* family.
|
||||
*/
|
||||
} else {
|
||||
/*
|
||||
* The file doesn't exist because we got to the end of the
|
||||
* family.
|
||||
*/
|
||||
ret_value = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (status < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
|
||||
"access method failed for a member file");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
|
||||
"access method failed for a member file");
|
||||
}
|
||||
}
|
||||
|
||||
FUNC_LEAVE(ret_value);
|
||||
|
110
src/H5Flow.c
110
src/H5Flow.c
@ -23,6 +23,67 @@
|
||||
#define PABLO_MASK H5F_low
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_low_class
|
||||
*
|
||||
* Purpose: Given a driver identifier return the class pointer for that
|
||||
* low-level driver.
|
||||
*
|
||||
* Return: Success: A low-level driver class pointer.
|
||||
*
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, February 18, 1998
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
const H5F_low_class_t *
|
||||
H5F_low_class (H5F_driver_t driver)
|
||||
{
|
||||
const H5F_low_class_t *type = NULL;
|
||||
|
||||
FUNC_ENTER (H5F_low_class, NULL);
|
||||
|
||||
switch (driver) {
|
||||
case H5F_LOW_STDIO:
|
||||
type = H5F_LOW_STDIO_g;
|
||||
break;
|
||||
|
||||
case H5F_LOW_SEC2:
|
||||
type = H5F_LOW_SEC2_g;
|
||||
break;
|
||||
|
||||
case H5F_LOW_CORE:
|
||||
type = H5F_LOW_CORE_g;
|
||||
break;
|
||||
|
||||
#ifdef HAVE_PARALLEL
|
||||
case H5F_LOW_MPIO:
|
||||
type = H5F_LOW_MPIO_g;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case H5F_LOW_SPLIT:
|
||||
type = H5F_LOW_SPLIT_g;
|
||||
break;
|
||||
|
||||
case H5F_LOW_FAMILY:
|
||||
type = H5F_LOW_FAMILY_g;
|
||||
break;
|
||||
|
||||
default:
|
||||
HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, NULL,
|
||||
"unknown low-level driver");
|
||||
}
|
||||
|
||||
FUNC_LEAVE (type);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_low_open
|
||||
@ -67,9 +128,10 @@ static hbool_t interface_initialize_g = FALSE;
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5F_low_t *
|
||||
H5F_low_open(const H5F_low_class_t *type, const char *name, uintn flags,
|
||||
H5F_search_t *key /*out */ )
|
||||
H5F_low_t *
|
||||
H5F_low_open(const H5F_low_class_t *type, const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/)
|
||||
{
|
||||
H5F_low_t *lf = NULL;
|
||||
|
||||
@ -78,7 +140,7 @@ H5F_low_open(const H5F_low_class_t *type, const char *name, uintn flags,
|
||||
assert(type && type->open);
|
||||
assert(name && *name);
|
||||
|
||||
if (NULL == (lf = (type->open) (name, flags, key))) {
|
||||
if (NULL == (lf = (type->open) (name, access_parms, flags, key))) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
|
||||
}
|
||||
lf->type = type;
|
||||
@ -114,13 +176,13 @@ H5F_low_open(const H5F_low_class_t *type, const char *name, uintn flags,
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5F_low_t *
|
||||
H5F_low_close(H5F_low_t *lf)
|
||||
H5F_low_t *
|
||||
H5F_low_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
FUNC_ENTER(H5F_low_close, NULL);
|
||||
|
||||
if (lf) {
|
||||
if ((lf->type->close) (lf) < 0) {
|
||||
if ((lf->type->close) (lf, access_parms) < 0) {
|
||||
H5MM_xfree(lf);
|
||||
HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, NULL, "close failed");
|
||||
}
|
||||
@ -156,8 +218,8 @@ H5F_low_close(H5F_low_t *lf)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf /*out */ )
|
||||
H5F_low_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf/*out*/)
|
||||
{
|
||||
herr_t ret_value = FAIL;
|
||||
|
||||
@ -168,7 +230,8 @@ H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
assert(buf);
|
||||
|
||||
if (lf->type->read) {
|
||||
if ((ret_value = (lf->type->read) (lf, addr, size, buf)) < 0) {
|
||||
if ((ret_value = (lf->type->read) (lf, access_parms, addr, size,
|
||||
buf)) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, ret_value, "read failed");
|
||||
}
|
||||
} else {
|
||||
@ -204,8 +267,8 @@ H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf)
|
||||
{
|
||||
herr_t ret_value = FAIL;
|
||||
haddr_t tmp_addr;
|
||||
@ -225,7 +288,8 @@ H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
}
|
||||
/* Write the data */
|
||||
if (lf->type->write) {
|
||||
if ((ret_value = (lf->type->write) (lf, addr, size, buf)) < 0) {
|
||||
if ((ret_value = (lf->type->write) (lf, access_parms, addr, size,
|
||||
buf)) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, ret_value, "write failed");
|
||||
}
|
||||
} else {
|
||||
@ -260,7 +324,7 @@ H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5F_low_flush(H5F_low_t *lf)
|
||||
H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
haddr_t last_byte;
|
||||
uint8 buf[1];
|
||||
@ -274,13 +338,13 @@ H5F_low_flush(H5F_low_t *lf)
|
||||
if (addr_defined(&(lf->eof)) && H5F_addr_gt(&(lf->eof), &last_byte)) {
|
||||
last_byte = lf->eof;
|
||||
last_byte.offset -= 1;
|
||||
if (H5F_low_read(lf, &last_byte, 1, buf) >= 0) {
|
||||
H5F_low_write(lf, &last_byte, 1, buf);
|
||||
if (H5F_low_read(lf, access_parms, &last_byte, 1, buf) >= 0) {
|
||||
H5F_low_write(lf, access_parms, &last_byte, 1, buf);
|
||||
}
|
||||
}
|
||||
/* Invoke the subclass the flush method */
|
||||
if (lf->type->flush) {
|
||||
if ((lf->type->flush) (lf) < 0) {
|
||||
if ((lf->type->flush) (lf, access_parms) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
|
||||
"low level flush failed");
|
||||
}
|
||||
@ -372,8 +436,9 @@ H5F_low_size(H5F_low_t *lf, haddr_t *eof /*out */ )
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hbool_t
|
||||
H5F_low_access(const H5F_low_class_t *type, const char *name, int mode,
|
||||
H5F_search_t *key /*out */ )
|
||||
H5F_low_access(const H5F_low_class_t *type, const char *name,
|
||||
const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key/*out*/)
|
||||
{
|
||||
hbool_t ret_value;
|
||||
struct stat sb;
|
||||
@ -382,7 +447,7 @@ H5F_low_access(const H5F_low_class_t *type, const char *name, int mode,
|
||||
assert(type);
|
||||
|
||||
if (type->access) {
|
||||
ret_value = (type->access) (name, mode, key /*out */ );
|
||||
ret_value = (type->access) (name, access_parms, mode, key /*out*/);
|
||||
|
||||
} else {
|
||||
ret_value = (0 == access(name, mode) ? TRUE : FALSE);
|
||||
@ -418,7 +483,8 @@ H5F_low_access(const H5F_low_class_t *type, const char *name, int mode,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr /*out */ )
|
||||
H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms, intn op,
|
||||
size_t size, haddr_t *addr/*out*/)
|
||||
{
|
||||
FUNC_ENTER(H5F_low_alloc, FAIL);
|
||||
|
||||
@ -427,7 +493,7 @@ H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr /*out */ )
|
||||
assert(addr);
|
||||
|
||||
if (lf->type->extend) {
|
||||
if ((lf->type->extend) (lf, op, size, addr /*out */ ) < 0) {
|
||||
if ((lf->type->extend) (lf, access_parms, op, size, addr/*out*/) < 0) {
|
||||
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
|
||||
"unable to extend file");
|
||||
}
|
||||
|
110
src/H5Fmpio.c
110
src/H5Fmpio.c
@ -15,15 +15,16 @@
|
||||
* and to infer the access flags. If the file is opened,
|
||||
* we close it without reading or writing it.
|
||||
* - It is not possible within MPI-IO to determine whether or not
|
||||
* the names "file1" and "file2" refer to the same physical fileC
|
||||
* the names "file1" and "file2" refer to the same physical file
|
||||
* (at least not without writing one and reading the other).
|
||||
* So we do what H5F_core_open() does: return a bogus device
|
||||
* number and a unique inode number.
|
||||
* This has the side effect that calling H5Fopen() twice
|
||||
* with the same name really does open the file twice
|
||||
* and the two handles don't communicate with each other,
|
||||
* resulting in trashing the file. It also runs the (very small)
|
||||
* risk of having two unrelated names be seen as the same file.
|
||||
* resulting in trashing the file. It also runs the (very
|
||||
* small) risk of having two unrelated names be seen as the
|
||||
* same file.
|
||||
*
|
||||
* H5F_mpio_open
|
||||
* - should take MPI communicator and MPI info as parameters
|
||||
@ -57,32 +58,35 @@ static hbool_t interface_initialize_g = FALSE; /* rky??? */
|
||||
#define H5F_MPIO_DEV 0xfffe /*pseudo dev for MPI-IO until we fix things */
|
||||
/* Make sure this differs from H5F_CORE_DEV */
|
||||
|
||||
static hbool_t H5F_mpio_access(const char *name, int mode,
|
||||
H5F_search_t *key /*out */ );
|
||||
static H5F_low_t *H5F_mpio_open(const char *name, uintn flags,
|
||||
H5F_search_t *key);
|
||||
static herr_t H5F_mpio_close(H5F_low_t *lf);
|
||||
static herr_t H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr,
|
||||
size_t size, uint8 *buf);
|
||||
static herr_t H5F_mpio_write(H5F_low_t *lf, const haddr_t *addr,
|
||||
size_t size, const uint8 *buf);
|
||||
static herr_t H5F_mpio_flush(H5F_low_t *lf);
|
||||
static herr_t H5F_MPIOff_to_haddr( MPI_Offset mpi_off, haddr_t *addr);
|
||||
static herr_t H5F_haddr_to_MPIOff( haddr_t addr, MPI_Offset *mpi_off);
|
||||
static hbool_t H5F_mpio_access(const char *name,
|
||||
const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key/*out*/);
|
||||
static H5F_low_t *H5F_mpio_open(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
static herr_t H5F_mpio_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_mpio_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
uint8 *buf/*out*/);
|
||||
static herr_t H5F_mpio_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static herr_t H5F_mpio_flush(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_MPIOff_to_haddr(MPI_Offset mpi_off, haddr_t *addr);
|
||||
static herr_t H5F_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off);
|
||||
|
||||
const H5F_low_class_t H5F_LOW_MPIO[1] =
|
||||
{
|
||||
{
|
||||
H5F_mpio_access, /* access method */
|
||||
H5F_mpio_open, /* open method */
|
||||
H5F_mpio_close, /* close method */
|
||||
H5F_mpio_read, /* read method */
|
||||
H5F_mpio_write, /* write method */
|
||||
H5F_mpio_flush, /* flush method */
|
||||
NULL /* extend method */
|
||||
}};
|
||||
const H5F_low_class_t H5F_LOW_MPIO_g[1] = {{
|
||||
H5F_mpio_access, /* access method */
|
||||
H5F_mpio_open, /* open method */
|
||||
H5F_mpio_close, /* close method */
|
||||
H5F_mpio_read, /* read method */
|
||||
H5F_mpio_write, /* write method */
|
||||
H5F_mpio_flush, /* flush method */
|
||||
NULL /* extend method */
|
||||
}};
|
||||
|
||||
ino_t mpio_inode_num = 0; /* fake "inode" number */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_mpio_access
|
||||
@ -121,10 +125,14 @@ ino_t mpio_inode_num = 0; /* fake "inode" number */
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static hbool_t
|
||||
H5F_mpio_access(const char *name, int mode, H5F_search_t *key /*out */ )
|
||||
H5F_mpio_access(const char *name, const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key/*out*/)
|
||||
{
|
||||
hbool_t ret_val = FALSE;
|
||||
MPI_File fh;
|
||||
@ -209,10 +217,15 @@ H5F_mpio_access(const char *name, int mode, H5F_search_t *key /*out */ )
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument. Moved some error checking here from
|
||||
* elsewhere.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5F_low_t *
|
||||
H5F_mpio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
static H5F_low_t *
|
||||
H5F_mpio_open(const char *name, const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/)
|
||||
{
|
||||
H5F_low_t *lf = NULL;
|
||||
MPI_File fh;
|
||||
@ -226,9 +239,22 @@ H5F_mpio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
fprintf(stdout, "Entering H5F_mpio_open name=%s flags=%x\n", name, flags );
|
||||
#endif
|
||||
|
||||
switch (access_parms->u.mpio.access_mode){
|
||||
case H5ACC_INDEPENDENT:
|
||||
/*void*/
|
||||
break;
|
||||
|
||||
case H5ACC_COLLECTIVE:
|
||||
HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, NULL,
|
||||
"collective I/O is not supported yet");
|
||||
|
||||
default:
|
||||
HRETURN_ERROR(H5E_IO, H5E_BADVALUE, NULL, "invalid file access mode");
|
||||
}
|
||||
|
||||
/* convert HDF5 flags to MPI-IO flags */
|
||||
/* some combinations are illegal; let MPI-IO figure it out */
|
||||
mpi_amode = (flags&H5F_ACC_WRITE) ? MPI_MODE_RDWR : MPI_MODE_RDONLY;
|
||||
mpi_amode = (flags&H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY;
|
||||
if (flags&H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE;
|
||||
if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL;
|
||||
|
||||
@ -303,10 +329,13 @@ H5F_mpio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_mpio_close(H5F_low_t *lf)
|
||||
H5F_mpio_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
int mpierr;
|
||||
char mpierrmsg[MPI_MAX_ERROR_STRING];
|
||||
@ -351,10 +380,14 @@ H5F_mpio_close(H5F_low_t *lf)
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
H5F_mpio_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf/*out*/)
|
||||
{
|
||||
MPI_Offset mpi_off;
|
||||
int size_i, bytes_read, n;
|
||||
@ -449,11 +482,15 @@ H5F_mpio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_mpio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_mpio_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
{
|
||||
MPI_Offset mpi_off;
|
||||
MPI_Status mpi_stat;
|
||||
@ -511,10 +548,13 @@ H5F_mpio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
* Robb Matzke, 18 Feb 1998
|
||||
* Added the ACCESS_PARMS argument.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_mpio_flush(H5F_low_t *lf)
|
||||
H5F_mpio_flush(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
int mpierr;
|
||||
char mpierrmsg[MPI_MAX_ERROR_STRING];
|
||||
|
131
src/H5Fprivate.h
131
src/H5Fprivate.h
@ -53,13 +53,11 @@
|
||||
#define H5F_SIZEOF_SIZE(F) ((F)->shared->create_parms.sizeof_size)
|
||||
|
||||
/*
|
||||
* File open flags.
|
||||
* Private file open flags.
|
||||
*/
|
||||
#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */
|
||||
#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */
|
||||
#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */
|
||||
#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */
|
||||
#define H5F_ACC_DEBUG 0x00010 /* Print debug info */
|
||||
#define H5F_ACC_PUBLIC_FLAGS 0x00ff
|
||||
|
||||
#define H5F_ACC_CREAT 0x0100 /* Create non-existing files */
|
||||
|
||||
/*
|
||||
* Encode and decode macros for file meta-data.
|
||||
@ -204,8 +202,10 @@
|
||||
|
||||
#define NBYTEENCODE(d, s, n) { HDmemcpy(d,s,n); p+=n }
|
||||
|
||||
/* Note! the NBYTEDECODE macro is backwards from the memcpy() routine, */
|
||||
/* in the spirit of the other DECODE macros */
|
||||
/*
|
||||
* Note: the NBYTEDECODE macro is backwards from the memcpy() routine, in
|
||||
* the spirit of the other DECODE macros.
|
||||
*/
|
||||
#define NBYTEDECODE(s, d, n) { HDmemcpy(d,s,n); p+=n }
|
||||
|
||||
/*
|
||||
@ -228,11 +228,35 @@ typedef struct H5F_create_t {
|
||||
* File-access template.
|
||||
*/
|
||||
typedef struct H5F_access_t {
|
||||
uintn access_mode; /* file access mode */
|
||||
H5F_driver_t driver; /* Low level file driver */
|
||||
union {
|
||||
|
||||
/* Properties for in-core files */
|
||||
struct {
|
||||
size_t increment; /*amount by which to increment size*/
|
||||
} core;
|
||||
|
||||
/* Properties for file families */
|
||||
struct {
|
||||
struct H5F_access_t *memb_access; /*plist for the members*/
|
||||
} fam;
|
||||
|
||||
/* Properties for the split driver */
|
||||
struct {
|
||||
struct H5F_access_t *meta_access; /*plist for meta file */
|
||||
struct H5F_access_t *raw_access; /*plist for raw data file */
|
||||
} split;
|
||||
|
||||
#ifdef HAVE_PARALLEL
|
||||
MPI_Comm comm; /* communicator for file access */
|
||||
MPI_Info info; /* optional info for MPI-IO */
|
||||
#endif /*HAVE_PARALLEL*/
|
||||
/* Properties for parallel I/O */
|
||||
struct {
|
||||
uintn access_mode; /* independent or collective variety? */
|
||||
MPI_Comm comm; /* communicator for file access */
|
||||
MPI_Info info; /* optional info for MPI-IO */
|
||||
} mpio;
|
||||
#endif
|
||||
|
||||
} u;
|
||||
} H5F_access_t;
|
||||
|
||||
/*
|
||||
@ -255,18 +279,27 @@ typedef enum {
|
||||
* Define the low-level file interface.
|
||||
*/
|
||||
typedef struct H5F_low_class_t {
|
||||
hbool_t (*access)(const char *, int, H5F_search_t *);
|
||||
struct H5F_low_t *(*open)(const char *, uintn, H5F_search_t *);
|
||||
herr_t (*close)(struct H5F_low_t *);
|
||||
herr_t (*read)(struct H5F_low_t *, const haddr_t *, size_t, uint8 *);
|
||||
herr_t (*write)(struct H5F_low_t *, const haddr_t *, size_t,
|
||||
const uint8 *);
|
||||
herr_t (*flush)(struct H5F_low_t *);
|
||||
herr_t (*extend)(struct H5F_low_t *, intn, size_t, haddr_t *);
|
||||
hbool_t (*access)(const char *name, const H5F_access_t *access_parms,
|
||||
int mode, H5F_search_t *key/*out*/);
|
||||
struct H5F_low_t *(*open)(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
herr_t (*close)(struct H5F_low_t *lf,
|
||||
const H5F_access_t *access_parms);
|
||||
herr_t (*read)(struct H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf);
|
||||
herr_t (*write)(struct H5F_low_t *lf,
|
||||
const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf);
|
||||
herr_t (*flush)(struct H5F_low_t *lf,
|
||||
const H5F_access_t *access_parms);
|
||||
herr_t (*extend)(struct H5F_low_t *lf,
|
||||
const H5F_access_t *access_parms,
|
||||
intn op, size_t size, haddr_t *addr);
|
||||
} H5F_low_class_t;
|
||||
|
||||
typedef struct H5F_low_t {
|
||||
const H5F_low_class_t *type; /* What type of file is this? */
|
||||
const H5F_low_class_t *type;/* What type of file is this? */
|
||||
haddr_t eof; /* Address of logical end-of-file */
|
||||
union {
|
||||
|
||||
@ -292,14 +325,22 @@ typedef struct H5F_low_t {
|
||||
struct {
|
||||
int fd; /* The unix file descriptor */
|
||||
H5F_fileop_t op; /* Previous file operation */
|
||||
#ifdef HAVE_LSEEK64
|
||||
off64_t cur; /* Current file position */
|
||||
#else
|
||||
off_t cur; /* Current file position */
|
||||
#endif
|
||||
} sec2;
|
||||
|
||||
/* Posix stdio */
|
||||
struct {
|
||||
FILE *f; /* Posix stdio file */
|
||||
H5F_fileop_t op; /* Previous file operation */
|
||||
#ifdef HAVE_FSEEK64
|
||||
long long cur; /* Current file position */
|
||||
#else
|
||||
off_t cur; /* Current file position */
|
||||
#endif
|
||||
} stdio;
|
||||
|
||||
/* In-core temp file */
|
||||
@ -323,13 +364,13 @@ typedef struct H5F_low_t {
|
||||
#ifndef H5F_LOW_DFLT
|
||||
# define H5F_LOW_DFLT H5F_LOW_STDIO /* The default type */
|
||||
#endif
|
||||
extern const H5F_low_class_t H5F_LOW_SEC2[]; /* Posix section 2 */
|
||||
extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
|
||||
extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
|
||||
extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
|
||||
extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
|
||||
extern const H5F_low_class_t H5F_LOW_SEC2_g[]; /* Posix section 2 */
|
||||
extern const H5F_low_class_t H5F_LOW_STDIO_g[]; /* Posix stdio */
|
||||
extern const H5F_low_class_t H5F_LOW_CORE_g[]; /* In-core temp file */
|
||||
extern const H5F_low_class_t H5F_LOW_FAMILY_g[];/* File family */
|
||||
extern const H5F_low_class_t H5F_LOW_SPLIT_g[]; /* Split meta/raw data */
|
||||
#ifdef HAVE_PARALLEL
|
||||
extern const H5F_low_class_t H5F_LOW_MPIO[]; /* MPI-IO */
|
||||
extern const H5F_low_class_t H5F_LOW_MPIO_g[]; /* MPI-IO */
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -349,9 +390,7 @@ typedef struct H5F_file_t {
|
||||
haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data*/
|
||||
struct H5AC_t *cache; /* The object cache */
|
||||
H5F_create_t create_parms; /* File-creation template */
|
||||
#ifdef HAVE_PARALLEL
|
||||
H5F_access_t access_parms; /* File-access template */
|
||||
#endif
|
||||
struct H5G_entry_t *root_ent; /* Root symbol table entry */
|
||||
} H5F_file_t;
|
||||
|
||||
@ -411,18 +450,20 @@ struct H5O_layout_t; /*forward decl for prototype arguments */
|
||||
|
||||
/* library variables */
|
||||
extern const H5F_create_t H5F_create_dflt;
|
||||
extern const H5F_access_t H5F_access_dflt;
|
||||
extern H5F_access_t H5F_access_dflt;
|
||||
|
||||
/* Private functions, not part of the publicly documented API */
|
||||
herr_t H5F_init_interface(void);
|
||||
void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
|
||||
H5F_t *H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
|
||||
const H5F_create_t *create_parms, const H5F_access_t *access_parms);
|
||||
H5F_t *H5F_open(const char *name, uintn flags,
|
||||
const H5F_create_t *create_parms,
|
||||
const H5F_access_t *access_parms);
|
||||
herr_t H5F_close(H5F_t *f);
|
||||
herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
|
||||
intn fwidth);
|
||||
|
||||
/* Functions that operate on array storage */
|
||||
herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
|
||||
herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out*/);
|
||||
herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const size_t _hslab_size[], const size_t mem_size[],
|
||||
const size_t mem_offset[], const size_t file_offset[],
|
||||
@ -433,7 +474,7 @@ herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const void *_buf);
|
||||
|
||||
/* Functions that operate on indexed storage */
|
||||
herr_t H5F_istore_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
|
||||
herr_t H5F_istore_create(H5F_t *f, struct H5O_layout_t *layout /*in,out*/);
|
||||
herr_t H5F_istore_read(H5F_t *f, const struct H5O_layout_t *layout,
|
||||
const size_t offset[], const size_t size[],
|
||||
void *buf /*out */ );
|
||||
@ -447,19 +488,23 @@ herr_t H5F_block_write(H5F_t *f, const haddr_t *addr, size_t size,
|
||||
const void *buf);
|
||||
|
||||
/* Functions that operate directly on low-level files */
|
||||
herr_t H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr);
|
||||
const H5F_low_class_t *H5F_low_class (H5F_driver_t driver);
|
||||
herr_t H5F_low_extend(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
intn op, size_t size, haddr_t *addr);
|
||||
herr_t H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr);
|
||||
hbool_t H5F_low_access(const H5F_low_class_t *type, const char *name,
|
||||
int mode, H5F_search_t *key);
|
||||
const H5F_access_t *access_parms, int mode,
|
||||
H5F_search_t *key);
|
||||
H5F_low_t *H5F_low_open(const H5F_low_class_t *type, const char *name,
|
||||
uintn flags, H5F_search_t *key);
|
||||
H5F_low_t *H5F_low_close(H5F_low_t *lf);
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key);
|
||||
H5F_low_t *H5F_low_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
size_t H5F_low_size(H5F_low_t *lf, haddr_t *addr);
|
||||
herr_t H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf);
|
||||
herr_t H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
herr_t H5F_low_flush(H5F_low_t *lf);
|
||||
herr_t H5F_low_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf);
|
||||
herr_t H5F_low_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf);
|
||||
herr_t H5F_low_flush(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
|
||||
/* Functions that operate on addresses */
|
||||
#define H5F_addr_eq(A1,A2) (H5F_addr_cmp(A1,A2)==0)
|
||||
|
@ -20,15 +20,50 @@
|
||||
#include <H5public.h>
|
||||
#include <H5Apublic.h>
|
||||
|
||||
/* file access codes */
|
||||
#define H5ACC_DEFAULT 0x0000/*use in H5Fopen & H5Fcreate to open a file with default access*/
|
||||
#define H5ACC_WRITE 0x0001/*use in H5Fopen to open a file with write access*/
|
||||
#define H5ACC_OVERWRITE 0x0002/*use in H5Fcreate truncate an existing file*/
|
||||
#ifdef HAVE_PARALLEL
|
||||
#define H5ACC_INDEPENDENT 0x0010/*use in H5Cset_mpi for MPI independent access*/
|
||||
#define H5ACC_COLLECTIVE 0x0011/*use in H5Cset_mpi for MPI collective access*/
|
||||
/*
|
||||
* These are the bits that can be passed to the `flags' argument of
|
||||
* H5Fcreate() and H5Fopen(). Use the bit-wise OR operator (|) to combine
|
||||
* them as needed.
|
||||
*/
|
||||
#define H5F_ACC_RDONLY 0x0000 /*absence of write implies read only */
|
||||
#define H5F_ACC_RDWR 0x0001 /*open file for reading and writing */
|
||||
#define H5F_ACC_TRUNC 0x0002 /*overwrite existing files during create*/
|
||||
#define H5F_ACC_EXCL 0x0004 /*create fails if file already exists */
|
||||
#define H5F_ACC_DEBUG 0x0008 /*print debug info */
|
||||
|
||||
|
||||
#ifdef LATER
|
||||
/*
|
||||
* These are here temporarily for backward compatibility with version
|
||||
* 5.1.0.0a and should eventually be removed since they violate the naming
|
||||
* scheme.
|
||||
*/
|
||||
#define H5ACC_DEFAULT H5F_ACC_RDONLY
|
||||
#define H5ACC_WRITE H5F_ACC_RDWR
|
||||
#define H5ACC_OVERWRITE H5F_ACC_TRUNC
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Low-level file drivers. These values are returned by H5Cget_file_driver()
|
||||
* and are set by the various H5Cset_...() functions that set file driver
|
||||
* properties.
|
||||
*/
|
||||
typedef enum H5F_driver_t {
|
||||
H5F_LOW_ERROR = -1, /*error return value */
|
||||
H5F_LOW_STDIO = 0, /*use functions declared in stdio.h */
|
||||
H5F_LOW_SEC2 = 1, /*use functions declared in unistd.h */
|
||||
H5F_LOW_MPIO = 2, /*use indep or collective MPI-IO */
|
||||
H5F_LOW_CORE = 3, /*use malloc() and free() */
|
||||
H5F_LOW_SPLIT = 4, /*separate meta data from raw data */
|
||||
H5F_LOW_FAMILY = 5, /*split addr space over many files */
|
||||
} H5F_driver_t;
|
||||
|
||||
|
||||
/* Parallel styles passed to H5Cset_mpi() */
|
||||
#ifdef HAVE_PARALLEL
|
||||
# define H5ACC_INDEPENDENT 0x0010 /*MPI independent access */
|
||||
# define H5ACC_COLLECTIVE 0x0011 /*MPI collective access */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -41,6 +76,7 @@ hid_t H5Fcreate (const char *filename, uintn flags, hid_t create_template,
|
||||
hid_t H5Fopen (const char *filename, uintn flags, hid_t access_template);
|
||||
herr_t H5Fclose (hid_t fid);
|
||||
hid_t H5Fget_create_template (hid_t fid);
|
||||
hid_t H5Fget_access_template (hid_t file_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
265
src/H5Fsec2.c
265
src/H5Fsec2.c
@ -1,18 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 1997 NCSA
|
||||
* All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Programmer: Robb Matzke <matzke@llnl.gov>
|
||||
* Wednesday, October 22, 1997
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Purpose: This is the Posix section-2 I/O subclass of H5Flow.
|
||||
*
|
||||
* Notes: This driver keeps track of its own file position in order to
|
||||
* minimize the number of calls to lseek(). We assume that
|
||||
* opening a file sets the current file position to the beginning
|
||||
* and that read() and write() modify the file position as
|
||||
* expected when they return successfully (unsuccessful return
|
||||
* leaves the file position undefined).
|
||||
* minimize the number of calls to lseek(). We assume that
|
||||
* opening a file sets the current file position to the beginning
|
||||
* and that read() and write() modify the file position as
|
||||
* expected when they return successfully (unsuccessful return
|
||||
* leaves the file position undefined).
|
||||
*/
|
||||
#include <H5private.h>
|
||||
#include <H5Eprivate.h>
|
||||
@ -22,66 +22,70 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define PABLO_MASK H5F_sec2
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
#define PABLO_MASK H5F_sec2
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
|
||||
static H5F_low_t *H5F_sec2_open(const char *name, uintn flags, H5F_search_t *);
|
||||
static herr_t H5F_sec2_close(H5F_low_t *lf);
|
||||
static herr_t H5F_sec2_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf);
|
||||
static herr_t H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static H5F_low_t *H5F_sec2_open(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
static herr_t H5F_sec2_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
uint8 *buf/*out*/);
|
||||
static herr_t H5F_sec2_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
|
||||
const H5F_low_class_t H5F_LOW_SEC2_g[1] = {{
|
||||
NULL, /* access method */
|
||||
H5F_sec2_open, /* open method */
|
||||
H5F_sec2_close, /* close method */
|
||||
H5F_sec2_read, /* read method */
|
||||
H5F_sec2_write, /* write method */
|
||||
NULL, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
const H5F_low_class_t H5F_LOW_SEC2[1] =
|
||||
{
|
||||
{
|
||||
NULL, /* access method */
|
||||
H5F_sec2_open, /* open method */
|
||||
H5F_sec2_close, /* close method */
|
||||
H5F_sec2_read, /* read method */
|
||||
H5F_sec2_write, /* write method */
|
||||
NULL, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_sec2_open
|
||||
* Function: H5F_sec2_open
|
||||
*
|
||||
* Purpose: Opens a file with name NAME. The FLAGS are a bit field with
|
||||
* the possible values defined in H5F_low_open().
|
||||
* Purpose: Opens a file with name NAME. The FLAGS are a bit field with
|
||||
* the possible values defined in H5F_low_open().
|
||||
*
|
||||
* Errors:
|
||||
* IO CANTOPENFILE Open failed.
|
||||
* IO CANTOPENFILE Open failed.
|
||||
*
|
||||
* Return: Success: Low-level file pointer
|
||||
* Return: Success: Low-level file pointer
|
||||
*
|
||||
* Failure: NULL
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5F_low_t *
|
||||
H5F_sec2_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
static H5F_low_t *
|
||||
H5F_sec2_open(const char *name, const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/)
|
||||
{
|
||||
uintn oflags;
|
||||
H5F_low_t *lf = NULL;
|
||||
int fd;
|
||||
struct stat sb;
|
||||
uintn oflags;
|
||||
H5F_low_t *lf = NULL;
|
||||
int fd;
|
||||
struct stat sb;
|
||||
|
||||
FUNC_ENTER(H5F_sec2_open, NULL);
|
||||
|
||||
oflags = (flags & H5F_ACC_WRITE) ? O_RDWR : O_RDONLY;
|
||||
oflags = (flags & H5F_ACC_RDWR) ? O_RDWR : O_RDONLY;
|
||||
oflags |= (flags & H5F_ACC_CREAT) ? O_CREAT : 0;
|
||||
oflags |= (flags & H5F_ACC_EXCL) ? O_EXCL : 0;
|
||||
oflags |= (flags & H5F_ACC_TRUNC) ? O_TRUNC : 0;
|
||||
|
||||
if ((fd = open(name, oflags, 0666)) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
|
||||
}
|
||||
lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
|
||||
lf->u.sec2.fd = fd;
|
||||
@ -91,38 +95,38 @@ H5F_sec2_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
lf->eof.offset = sb.st_size;
|
||||
|
||||
if (key) {
|
||||
key->dev = sb.st_dev;
|
||||
key->ino = sb.st_ino;
|
||||
key->dev = sb.st_dev;
|
||||
key->ino = sb.st_ino;
|
||||
}
|
||||
FUNC_LEAVE(lf);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_sec2_close
|
||||
* Function: H5F_sec2_close
|
||||
*
|
||||
* Purpose: Closes a file.
|
||||
* Purpose: Closes a file.
|
||||
*
|
||||
* Errors:
|
||||
* IO CLOSEERROR Close failed.
|
||||
* IO CLOSEERROR Close failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_sec2_close(H5F_low_t *lf)
|
||||
H5F_sec2_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
FUNC_ENTER(H5F_sec2_close, FAIL);
|
||||
|
||||
if (close(lf->u.sec2.fd) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "close failed");
|
||||
HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "close failed");
|
||||
}
|
||||
lf->u.sec2.fd = -1;
|
||||
|
||||
@ -130,148 +134,181 @@ H5F_sec2_close(H5F_low_t *lf)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_sec2_read
|
||||
* Function: H5F_sec2_read
|
||||
*
|
||||
* Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
|
||||
* places them in buffer BUF. Reading past the logical or
|
||||
* physical end of file returns zeros instead of failing.
|
||||
* Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
|
||||
* places them in buffer BUF. Reading past the logical or
|
||||
* physical end of file returns zeros instead of failing.
|
||||
*
|
||||
* Errors:
|
||||
* IO READERROR Read failed.
|
||||
* IO SEEKERROR Lseek failed.
|
||||
* IO READERROR Read failed.
|
||||
* IO SEEKERROR Lseek failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_sec2_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
H5F_sec2_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf)
|
||||
{
|
||||
ssize_t n;
|
||||
off_t offset;
|
||||
ssize_t n;
|
||||
uint64 mask;
|
||||
#ifdef HAVE_LSEEK64
|
||||
off64_t offset;
|
||||
#else
|
||||
off_t offset;
|
||||
#endif
|
||||
|
||||
FUNC_ENTER(H5F_sec2_read, FAIL);
|
||||
|
||||
/* Check for overflow */
|
||||
offset = addr->offset; /*FIX_ME*/
|
||||
assert("address overflowed" && offset == addr->offset);
|
||||
assert("overflow" && offset + size >= offset);
|
||||
mask = (uint64)1 << (8*sizeof(offset)-1);
|
||||
if (addr->offset >= mask ||
|
||||
addr->offset+size < addr->offset ||
|
||||
addr->offset+size >= mask) {
|
||||
HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||
}
|
||||
#ifdef HAVE_LSEEK64
|
||||
offset = (off64_t)(addr->offset); /*checked for overflow*/
|
||||
#else
|
||||
offset = (off_t)(addr->offset); /*checked for overflow*/
|
||||
#endif
|
||||
|
||||
/* Check easy cases */
|
||||
if (0 == size)
|
||||
HRETURN(SUCCEED);
|
||||
if (0 == size) HRETURN(SUCCEED);
|
||||
if (offset >= lf->eof.offset) {
|
||||
HDmemset(buf, 0, size);
|
||||
HRETURN(SUCCEED);
|
||||
HDmemset(buf, 0, size);
|
||||
HRETURN(SUCCEED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Optimize seeking. If that optimization is disabled then always call
|
||||
* lseek().
|
||||
*/
|
||||
if (!H5F_OPT_SEEK ||
|
||||
lf->u.sec2.op == H5F_OP_UNKNOWN ||
|
||||
lf->u.sec2.cur != offset) {
|
||||
if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
|
||||
}
|
||||
lf->u.sec2.cur = offset;
|
||||
lf->u.sec2.op == H5F_OP_UNKNOWN ||
|
||||
lf->u.sec2.cur != offset) {
|
||||
if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
|
||||
}
|
||||
lf->u.sec2.cur = offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read zeros past the logical end of file (physical is handled below)
|
||||
*/
|
||||
if ((size_t) offset + size > lf->eof.offset) {
|
||||
size_t nbytes = (size_t) offset + size - lf->eof.offset;
|
||||
HDmemset(buf + size - nbytes, 0, nbytes);
|
||||
size -= nbytes;
|
||||
size_t nbytes = (size_t)offset + size - lf->eof.offset;
|
||||
HDmemset(buf + size - nbytes, 0, nbytes);
|
||||
size -= nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the data. If a read error occurs then set the last file operation
|
||||
* to UNKNOWN because the file position isn't guaranteed by Posix.
|
||||
*/
|
||||
if ((n = read(lf->u.sec2.fd, buf, size)) < 0) {
|
||||
lf->u.sec2.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
|
||||
lf->u.sec2.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
|
||||
} else if (n < size) {
|
||||
HDmemset(buf + n, 0, size - n);
|
||||
HDmemset(buf + n, 0, size - n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the file position with the number of bytes actually read. This
|
||||
* Update the file position with the number of bytes actually read. This
|
||||
* might be different than the number requested.
|
||||
*/
|
||||
lf->u.sec2.op = H5F_OP_READ;
|
||||
lf->u.sec2.cur = offset + n;
|
||||
assert("address overflowed" && lf->u.sec2.cur >= offset);
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_sec2_write
|
||||
* Function: H5F_sec2_write
|
||||
*
|
||||
* Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
|
||||
* file address ADDR.
|
||||
* Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
|
||||
* file address ADDR.
|
||||
*
|
||||
* Errors:
|
||||
* IO SEEKERROR Lseek failed.
|
||||
* IO WRITEERROR Write failed.
|
||||
* IO SEEKERROR Lseek failed.
|
||||
* IO WRITEERROR Write failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_sec2_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, const uint8 *buf)
|
||||
{
|
||||
off_t offset;
|
||||
uint64 mask;
|
||||
ssize_t n;
|
||||
#ifdef HAVE_LSEEK64
|
||||
off64_t offset;
|
||||
#else
|
||||
off_t offset;
|
||||
#endif
|
||||
|
||||
FUNC_ENTER(H5F_sec2_write, FAIL);
|
||||
|
||||
/* Check for overflow */
|
||||
offset = addr->offset; /*FIX_ME*/
|
||||
assert("address overflowed" && offset == addr->offset);
|
||||
assert("overflow" && offset + size >= offset);
|
||||
mask = (uint64)1 << (8*sizeof(offset)-1);
|
||||
if (addr->offset >= mask ||
|
||||
addr->offset+size < addr->offset ||
|
||||
addr->offset+size >= mask) {
|
||||
HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||
}
|
||||
#ifdef HAVE_LSEEK64
|
||||
offset = (off64_t)(addr->offset); /*checked for overflow*/
|
||||
n = (off64_t)size; /*checked for overflow*/
|
||||
#else
|
||||
offset = (off_t)(addr->offset); /*checked for overflow*/
|
||||
n = (off_t)size; /*checked for overflow*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Optimize seeking. If that optimization is disabled then always call
|
||||
* lseek().
|
||||
*/
|
||||
if (!H5F_OPT_SEEK ||
|
||||
lf->u.sec2.op == H5F_OP_UNKNOWN ||
|
||||
lf->u.sec2.cur != offset) {
|
||||
if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
|
||||
}
|
||||
lf->u.sec2.cur = offset;
|
||||
lf->u.sec2.op == H5F_OP_UNKNOWN ||
|
||||
lf->u.sec2.cur != offset) {
|
||||
if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
|
||||
}
|
||||
lf->u.sec2.cur = offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the data to the file. If the write failed then set the
|
||||
* operation back to UNKNOWN since Posix doesn't gurantee its value.
|
||||
*/
|
||||
if (size != write(lf->u.sec2.fd, buf, size)) {
|
||||
lf->u.sec2.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
|
||||
if (n != write(lf->u.sec2.fd, buf, size)) {
|
||||
lf->u.sec2.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the file position.
|
||||
*/
|
||||
lf->u.sec2.op = H5F_OP_WRITE;
|
||||
lf->u.sec2.cur = offset + size; /*FIX_ME*/
|
||||
assert("address overflowed" && lf->u.sec2.cur >= offset);
|
||||
lf->u.sec2.cur = offset + n;
|
||||
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
315
src/H5Fstdio.c
315
src/H5Fstdio.c
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (C) 1997 NCSA
|
||||
* All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Programmer: Robb Matzke <matzke@llnl.gov>
|
||||
* Wednesday, October 22, 1997
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Purpose: This is the Posix stdio.h I/O subclass of H5Flow.
|
||||
*/
|
||||
@ -16,89 +16,92 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define PABLO_MASK H5F_stdio
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
#define PABLO_MASK H5F_stdio
|
||||
static hbool_t interface_initialize_g = FALSE;
|
||||
#define INTERFACE_INIT NULL
|
||||
|
||||
static H5F_low_t *H5F_stdio_open(const char *name, uintn flags,
|
||||
H5F_search_t *key);
|
||||
static herr_t H5F_stdio_close(H5F_low_t *lf);
|
||||
static herr_t H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
uint8 *buf);
|
||||
static herr_t H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static herr_t H5F_stdio_flush(H5F_low_t *lf);
|
||||
static H5F_low_t *H5F_stdio_open(const char *name,
|
||||
const H5F_access_t *access_parms, uintn flags,
|
||||
H5F_search_t *key/*out*/);
|
||||
static herr_t H5F_stdio_close(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
static herr_t H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
uint8 *buf/*out*/);
|
||||
static herr_t H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf);
|
||||
static herr_t H5F_stdio_flush(H5F_low_t *lf, const H5F_access_t *access_parms);
|
||||
|
||||
const H5F_low_class_t H5F_LOW_STDIO_g[1] = {{
|
||||
NULL, /* use default access(2) func */
|
||||
H5F_stdio_open, /* open method */
|
||||
H5F_stdio_close, /* close method */
|
||||
H5F_stdio_read, /* read method */
|
||||
H5F_stdio_write, /* write method */
|
||||
H5F_stdio_flush, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
const H5F_low_class_t H5F_LOW_STDIO[1] =
|
||||
{
|
||||
{
|
||||
NULL, /* use default access(2) func */
|
||||
H5F_stdio_open, /* open method */
|
||||
H5F_stdio_close, /* close method */
|
||||
H5F_stdio_read, /* read method */
|
||||
H5F_stdio_write, /* write method */
|
||||
H5F_stdio_flush, /* flush method */
|
||||
NULL, /* extend method */
|
||||
}};
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_stdio_open
|
||||
* Function: H5F_stdio_open
|
||||
*
|
||||
* Purpose: Opens a file with name NAME. The FLAGS are a bit field with
|
||||
* the possible values defined in H5F_low_open().
|
||||
* Purpose: Opens a file with name NAME. The FLAGS are a bit field with
|
||||
* the possible values defined in H5F_low_open().
|
||||
*
|
||||
* Bugs: H5F_ACC_EXCL has a race condition.
|
||||
* Bugs: H5F_ACC_EXCL has a race condition.
|
||||
*
|
||||
* Errors:
|
||||
* IO CANTOPENFILE File doesn't exist and CREAT wasn't
|
||||
* specified.
|
||||
* IO CANTOPENFILE Fopen failed.
|
||||
* IO FILEEXISTS File exists but CREAT and EXCL were
|
||||
* specified.
|
||||
* IO CANTOPENFILE File doesn't exist and CREAT wasn't
|
||||
* specified.
|
||||
* IO CANTOPENFILE Fopen failed.
|
||||
* IO FILEEXISTS File exists but CREAT and EXCL were
|
||||
* specified.
|
||||
*
|
||||
* Return: Success: Low-level file pointer
|
||||
* Return: Success: Low-level file pointer
|
||||
*
|
||||
* Failure: NULL
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5F_low_t *
|
||||
H5F_stdio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
static H5F_low_t *
|
||||
H5F_stdio_open(const char *name, const H5F_access_t *access_parms,
|
||||
uintn flags, H5F_search_t *key/*out*/)
|
||||
{
|
||||
H5F_low_t *lf = NULL;
|
||||
FILE *f = NULL;
|
||||
struct stat sb;
|
||||
H5F_low_t *lf = NULL;
|
||||
FILE *f = NULL;
|
||||
struct stat sb;
|
||||
|
||||
FUNC_ENTER(H5F_stdio_open, NULL);
|
||||
|
||||
if (access(name, F_OK) < 0) {
|
||||
if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_WRITE)) {
|
||||
f = fopen(name, "wb+");
|
||||
} else {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
|
||||
"file doesn't exist and CREAT wasn't specified");
|
||||
}
|
||||
if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR)) {
|
||||
f = fopen(name, "wb+");
|
||||
} else {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
|
||||
"file doesn't exist and CREAT wasn't specified");
|
||||
}
|
||||
|
||||
} else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_FILEEXISTS, NULL,
|
||||
"file exists but CREAT and EXCL were specified");
|
||||
HRETURN_ERROR(H5E_IO, H5E_FILEEXISTS, NULL,
|
||||
"file exists but CREAT and EXCL were specified");
|
||||
|
||||
} else if (flags & H5F_ACC_WRITE) {
|
||||
if (flags & H5F_ACC_TRUNC)
|
||||
f = fopen(name, "wb+");
|
||||
else
|
||||
f = fopen(name, "rb+");
|
||||
} else if (flags & H5F_ACC_RDWR) {
|
||||
if (flags & H5F_ACC_TRUNC)
|
||||
f = fopen(name, "wb+");
|
||||
else
|
||||
f = fopen(name, "rb+");
|
||||
|
||||
} else {
|
||||
f = fopen(name, "rb");
|
||||
f = fopen(name, "rb");
|
||||
}
|
||||
if (!f)
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "fopen failed");
|
||||
HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "fopen failed");
|
||||
|
||||
/* Build the return value */
|
||||
lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
|
||||
@ -107,46 +110,46 @@ H5F_stdio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
|
||||
lf->u.stdio.cur = 0;
|
||||
H5F_addr_reset(&(lf->eof));
|
||||
if (fseek(lf->u.stdio.f, 0, SEEK_END) < 0) {
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
} else {
|
||||
H5F_addr_inc(&(lf->eof), ftell(lf->u.stdio.f));
|
||||
H5F_addr_inc(&(lf->eof), ftell(lf->u.stdio.f));
|
||||
}
|
||||
|
||||
/* The unique key */
|
||||
if (key) {
|
||||
fstat(fileno(f), &sb);
|
||||
key->dev = sb.st_dev;
|
||||
key->ino = sb.st_ino;
|
||||
fstat(fileno(f), &sb);
|
||||
key->dev = sb.st_dev;
|
||||
key->ino = sb.st_ino;
|
||||
}
|
||||
FUNC_LEAVE(lf);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_stdio_close
|
||||
* Function: H5F_stdio_close
|
||||
*
|
||||
* Purpose: Closes a file.
|
||||
* Purpose: Closes a file.
|
||||
*
|
||||
* Errors:
|
||||
* IO CLOSEERROR Fclose failed.
|
||||
* IO CLOSEERROR Fclose failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_stdio_close(H5F_low_t *lf)
|
||||
H5F_stdio_close(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
FUNC_ENTER(H5F_stdio_close, FAIL);
|
||||
|
||||
if (fclose(lf->u.stdio.f) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "fclose failed");
|
||||
HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "fclose failed");
|
||||
}
|
||||
lf->u.stdio.f = NULL;
|
||||
|
||||
@ -154,66 +157,82 @@ H5F_stdio_close(H5F_low_t *lf)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_stdio_read
|
||||
* Function: H5F_stdio_read
|
||||
*
|
||||
* Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
|
||||
* places them in buffer BUF. Reading past the logical or
|
||||
* physical end of file returns zeros instead of failing.
|
||||
* Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
|
||||
* places them in buffer BUF. Reading past the logical or
|
||||
* physical end of file returns zeros instead of failing.
|
||||
*
|
||||
* Errors:
|
||||
* IO READERROR Fread failed.
|
||||
* IO SEEKERROR Fseek failed.
|
||||
* IO READERROR Fread failed.
|
||||
* IO SEEKERROR Fseek failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
H5F_stdio_read(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size, uint8 *buf/*out*/)
|
||||
{
|
||||
size_t n;
|
||||
off_t offset;
|
||||
size_t n;
|
||||
uint64 mask;
|
||||
#ifdef HAVE_FSEEK64
|
||||
long long offset;
|
||||
#else
|
||||
off_t offset;
|
||||
#endif
|
||||
|
||||
FUNC_ENTER(H5F_stdio_read, FAIL);
|
||||
|
||||
/* Check for overflow */
|
||||
offset = addr->offset; /*FIX_ME*/
|
||||
assert("address overflowed" && offset == addr->offset);
|
||||
assert("overflow" && offset + size >= offset);
|
||||
mask = (uint64)1 << (8*sizeof(offset)-1);
|
||||
if (addr->offset >= mask ||
|
||||
addr->offset + size < addr->offset ||
|
||||
addr->offset+size >= mask) {
|
||||
HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||
}
|
||||
#ifdef HAVE_FSEEK64
|
||||
offset = (long long)(addr->offset); /*checked for overflow*/
|
||||
#else
|
||||
offset = (off_t)(addr->offset); /*checked for overflow*/
|
||||
#endif
|
||||
|
||||
/* Check easy cases */
|
||||
if (0 == size)
|
||||
HRETURN(SUCCEED);
|
||||
if (0 == size) HRETURN(SUCCEED);
|
||||
if (offset >= lf->eof.offset) {
|
||||
HDmemset(buf, 0, size);
|
||||
HRETURN(SUCCEED);
|
||||
HDmemset(buf, 0, size);
|
||||
HRETURN(SUCCEED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Seek to the correct file position.
|
||||
*/
|
||||
if (!H5F_OPT_SEEK ||
|
||||
lf->u.stdio.op != H5F_OP_READ ||
|
||||
lf->u.stdio.cur != offset) {
|
||||
if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
|
||||
}
|
||||
lf->u.stdio.cur = offset;
|
||||
lf->u.stdio.op != H5F_OP_READ ||
|
||||
lf->u.stdio.cur != offset) {
|
||||
if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
|
||||
}
|
||||
lf->u.stdio.cur = offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read zeros past the logical end of file (physical is handled below)
|
||||
*/
|
||||
if ((size_t) offset + size > lf->eof.offset) {
|
||||
size_t nbytes = (size_t) offset + size - lf->eof.offset;
|
||||
HDmemset(buf + size - nbytes, 0, nbytes);
|
||||
size -= nbytes;
|
||||
size_t nbytes = (size_t) offset + size - lf->eof.offset;
|
||||
HDmemset(buf + size - nbytes, 0, nbytes);
|
||||
size -= nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the data. Since we're reading single-byte values, a partial read
|
||||
* will advance the file position by N. If N is negative or an error
|
||||
@ -221,102 +240,122 @@ H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
|
||||
*/
|
||||
n = fread(buf, 1, size, lf->u.stdio.f);
|
||||
if (n <= 0 && ferror(lf->u.stdio.f)) {
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "fread failed");
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "fread failed");
|
||||
} else if (n < size) {
|
||||
HDmemset(buf + n, 0, size - n);
|
||||
HDmemset(buf + n, 0, size - n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the file position data.
|
||||
*/
|
||||
lf->u.stdio.op = H5F_OP_READ;
|
||||
lf->u.stdio.cur = offset + n; /*FIX_ME*/
|
||||
lf->u.stdio.cur = offset + n;
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_stdio_write
|
||||
* Function: H5F_stdio_write
|
||||
*
|
||||
* Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
|
||||
* file address ADDR.
|
||||
* Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
|
||||
* file address ADDR.
|
||||
*
|
||||
* Errors:
|
||||
* IO SEEKERROR Fseek failed.
|
||||
* IO WRITEERROR Fwrite failed.
|
||||
* IO SEEKERROR Fseek failed.
|
||||
* IO WRITEERROR Fwrite failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
H5F_stdio_write(H5F_low_t *lf, const H5F_access_t *access_parms,
|
||||
const haddr_t *addr, size_t size,
|
||||
const uint8 *buf)
|
||||
{
|
||||
off_t offset;
|
||||
ssize_t n;
|
||||
uint64 mask;
|
||||
#ifdef HAVE_FSEEK64
|
||||
long long offset;
|
||||
#else
|
||||
off_t offset;
|
||||
#endif
|
||||
|
||||
FUNC_ENTER(H5F_stdio_write, FAIL);
|
||||
|
||||
/* Check for overflow */
|
||||
offset = addr->offset; /*FIX_ME*/
|
||||
assert("address overflowed" && offset == addr->offset);
|
||||
assert("overflow" && offset + size >= offset);
|
||||
mask = (uint64)1 << (8*sizeof(offset)-1);
|
||||
if (addr->offset >= mask ||
|
||||
addr->offset+size < addr->offset ||
|
||||
addr->offset+size >= mask) {
|
||||
HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
|
||||
}
|
||||
#ifdef HAVE_FSEEK64
|
||||
offset = (long long)(addr->offset); /*checked for overflow*/
|
||||
n = (long long)size; /*checked for overflow*/
|
||||
#else
|
||||
offset = (long)(addr->offset); /*checked for overflow*/
|
||||
n = (off_t)size; /*checked for overflow*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Seek to the correct file position.
|
||||
*/
|
||||
if (!H5F_OPT_SEEK ||
|
||||
lf->u.stdio.op != H5F_OP_WRITE ||
|
||||
lf->u.stdio.cur != offset) {
|
||||
if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
|
||||
}
|
||||
lf->u.stdio.cur = offset;
|
||||
lf->u.stdio.op != H5F_OP_WRITE ||
|
||||
lf->u.stdio.cur != offset) {
|
||||
if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
|
||||
}
|
||||
lf->u.stdio.cur = offset;
|
||||
}
|
||||
/*
|
||||
* Write the buffer. On successful return, the file position will be
|
||||
* advanced by the number of bytes read. Otherwise nobody knows where it
|
||||
* is.
|
||||
*/
|
||||
if (size != fwrite(buf, 1, size, lf->u.stdio.f)) {
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fwrite failed");
|
||||
if (n != fwrite(buf, 1, size, lf->u.stdio.f)) {
|
||||
lf->u.stdio.op = H5F_OP_UNKNOWN;
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fwrite failed");
|
||||
}
|
||||
/*
|
||||
* Update seek optimizing data.
|
||||
*/
|
||||
lf->u.stdio.op = H5F_OP_WRITE;
|
||||
lf->u.stdio.cur = offset + size; /*FIX_ME*/
|
||||
lf->u.stdio.cur = offset + n;
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F_stdio_flush
|
||||
* Function: H5F_stdio_flush
|
||||
*
|
||||
* Purpose: Makes sure that all data is on disk.
|
||||
* Purpose: Makes sure that all data is on disk.
|
||||
*
|
||||
* Errors:
|
||||
* IO WRITEERROR Fflush failed.
|
||||
* IO WRITEERROR Fflush failed.
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
* Programmer: Robb Matzke
|
||||
* Wednesday, October 22, 1997
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F_stdio_flush(H5F_low_t *lf)
|
||||
H5F_stdio_flush(H5F_low_t *lf, const H5F_access_t *access_parms)
|
||||
{
|
||||
FUNC_ENTER(H5F_stdio_flush, FAIL);
|
||||
|
||||
@ -330,7 +369,7 @@ H5F_stdio_flush(H5F_low_t *lf)
|
||||
* Flush
|
||||
*/
|
||||
if (fflush(lf->u.stdio.f) < 0) {
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fflush failed");
|
||||
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fflush failed");
|
||||
}
|
||||
FUNC_LEAVE(SUCCEED);
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ H5MF_alloc(H5F_t *f, intn op, size_t size, haddr_t *addr /*out */ )
|
||||
* from there. But for now we just allocate more memory from the end of
|
||||
* the file.
|
||||
*/
|
||||
if (H5F_low_extend(f->shared->lf, op, size, addr /*out */ ) < 0) {
|
||||
if (H5F_low_extend(f->shared->lf, &(f->shared->access_parms), op,
|
||||
size, addr/*out*/) < 0) {
|
||||
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
|
||||
"low level mem management failed");
|
||||
}
|
||||
|
@ -49,6 +49,12 @@
|
||||
/* The number of bytes in a short. */
|
||||
#undef SIZEOF_SHORT
|
||||
|
||||
/* Define if you have the fseek64 function. */
|
||||
#undef HAVE_FSEEK64
|
||||
|
||||
/* Define if you have the lseek64 function. */
|
||||
#undef HAVE_LSEEK64
|
||||
|
||||
/* Define if you have the mpi library (-lmpi). */
|
||||
#undef HAVE_LIBMPI
|
||||
|
||||
|
@ -46,15 +46,6 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PARALLEL
|
||||
/*
|
||||
* MPIO headers
|
||||
*/
|
||||
# include <mpi.h>
|
||||
# include <mpio.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Pablo support files.
|
||||
*/
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <H5config.h> /*from configure */
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_PARALLEL
|
||||
#include <mpi.h>
|
||||
#include <mpio.h>
|
||||
# include <mpi.h>
|
||||
# include <mpio.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -129,7 +129,7 @@ main (void)
|
||||
size_t h_sample[2]; /*hyperslab sampling */
|
||||
|
||||
/* Create the file */
|
||||
file = H5Fcreate ("cmpd_dset.h5", H5ACC_OVERWRITE,
|
||||
file = H5Fcreate ("cmpd_dset.h5", H5F_ACC_TRUNC,
|
||||
H5C_DEFAULT, H5C_DEFAULT);
|
||||
assert (file>=0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user