From 9115bab9e36d72bb395820e38b6bee4c99dcd78c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 12 Sep 2011 09:02:44 -0500 Subject: [svn-r21376] JIRA-HDFFV-2748: Relplace WIN32 macros in source. New H5_HAVE_WIN32_API and H5_HAVE_VISUAL_STUDIO defines only need to be set on windows. Autotools configure is not affected. Trunk passed for a week and cmake branch has been in place > 3 weeks. Tested: local linux --- config/cmake/ConfigureChecks.cmake | 4 + config/cmake/H5pubconf.h.in | 13 +- examples/h5_elink_unix2win.c | 14 +- perform/benchpar.c | 5 + perform/iopipe.c | 306 ++++++------ perform/pio_perf.h | 2 +- perform/pio_standalone.h | 56 +-- perform/sio_standalone.h | 48 +- release_docs/RELEASE.txt | 3 + src/H5FDcore.c | 432 ++++++++--------- src/H5FDdirect.c | 780 +++++++++++++++--------------- src/H5FDlog.c | 414 ++++++++-------- src/H5FDmpiposix.c | 606 ++++++++++++------------ src/H5FDsec2.c | 368 +++++++-------- src/H5FDstdio.c | 429 +++++++++-------- src/H5FDwindows.c | 544 ++++++++++----------- src/H5TS.c | 42 +- src/H5api_adpt.h | 22 +- src/H5private.h | 942 +++++++++++++++++++------------------ src/H5system.c | 713 ++++++++++++++-------------- src/H5win32defs.h | 55 ++- test/flush2.c | 106 ++--- test/h5test.c | 646 +++++++++++++------------ test/vfd.c | 124 ++--- tools/h5import/h5import.c | 4 +- tools/h5import/h5importtest.c | 2 +- windows/src/H5pubconf.h | 6 + 27 files changed, 3367 insertions(+), 3319 deletions(-) diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 332239b..37560a5 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -129,8 +129,12 @@ ENDMACRO (CHECK_LIBRARY_EXISTS_CONCAT) SET (WINDOWS) IF (WIN32) + SET (H5_HAVE_WIN32_API 1) IF (NOT UNIX AND NOT CYGWIN AND NOT MINGW) SET (WINDOWS 1) + IF (MSVC_IDE) + SET (H5_HAVE_VISUAL_STUDIO 1) + ENDIF (MSVC_IDE) ENDIF (NOT UNIX AND NOT CYGWIN AND NOT MINGW) ENDIF (WIN32) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index ed0c15c..c685014 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -6,6 +6,12 @@ /* Define if the Windows virtual file driver should be compiled */ #cmakedefine H5_HAVE_WINDOWS @H5_HAVE_WINDOWS@ +/* Define if on the Windows platform and default WIN32 API */ +#cmakedefine H5_HAVE_WIN32_API @H5_HAVE_WIN32_API@ + +/* Define if using a Windows compiler (i.e. Visual Studio) */ +#cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ + /* Define if the Windows virtual file driver should use buffered IO functions */ /* #undef WINDOWS_USE_STDIO */ @@ -514,17 +520,10 @@ /* Define if the metadata trace file code is to be compiled in */ #cmakedefine H5_METADATA_TRACE_FILE @H5_METADATA_TRACE_FILE@ -/* Define if your system can handle complicated MPI derived datatype - correctly. */ -#cmakedefine H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS @H5_MPI_COMPLEX_DERIVED_DATATYPE_WORKS@ - /* Define if your system's `MPI_File_set_size' function works for files over 2GB. */ #cmakedefine H5_MPI_FILE_SET_SIZE_BIG @H5_MPI_FILE_SET_SIZE_BIG@ -/* Define if your system can handle special collective IO properly. */ -#cmakedefine H5_MPI_SPECIAL_COLLECTIVE_IO_WORKS @H5_MPI_SPECIAL_COLLECTIVE_IO_WORKS@ - /* Define if we can violate pointer alignment restrictions */ #cmakedefine H5_NO_ALIGNMENT_RESTRICTIONS @H5_NO_ALIGNMENT_RESTRICTIONS@ diff --git a/examples/h5_elink_unix2win.c b/examples/h5_elink_unix2win.c index bcbb65f..9c0918c 100644 --- a/examples/h5_elink_unix2win.c +++ b/examples/h5_elink_unix2win.c @@ -138,11 +138,11 @@ const H5L_class_t elink_unix2win_class[1] = {{ static int unix2win_example(void) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group ID */ + hid_t fid = (-1); /* File ID */ + hid_t gid = (-1); /* Group ID */ /* Create the target file. */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if((fid=H5Fcreate("u2w\\u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error; #else if((fid=H5Fcreate("u2w/u2w_target.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) goto error; @@ -161,7 +161,7 @@ unix2win_example(void) * that external links can be traversed. */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API /* Register the elink_unix2win class defined above to replace default * external links */ @@ -181,8 +181,8 @@ unix2win_example(void) error: printf("Error!\n"); H5E_BEGIN_TRY { - H5Gclose (gid); - H5Fclose (fid); + H5Gclose (gid); + H5Fclose (fid); } H5E_END_TRY; return -1; } @@ -195,7 +195,7 @@ unix2win_example(void) int main(void) { - int ret; + int ret; printf("Testing unix2win external links.\n"); ret = unix2win_example(); diff --git a/perform/benchpar.c b/perform/benchpar.c index bf75d77..24146e4 100644 --- a/perform/benchpar.c +++ b/perform/benchpar.c @@ -25,6 +25,11 @@ #include "hdf5.h" /* Local macros */ +#ifdef H5_HAVE_VISUAL_STUDIO +#define HDgetlogin() Wgetlogin() +#else /* H5_HAVE_VISUAL_STUDIO */ +#define HDgetlogin() getlogin() +#endif /* H5_HAVE_VISUAL_STUDIO */ /* * HDF Boolean type. diff --git a/perform/iopipe.c b/perform/iopipe.c index c72e3aa..85063fa 100644 --- a/perform/iopipe.c +++ b/perform/iopipe.c @@ -28,34 +28,34 @@ #endif -#define RAW_FILE_NAME "iopipe.raw" -#define HDF5_FILE_NAME "iopipe.h5" -#define HEADING "%-16s" -#define PROGRESS '=' +#define RAW_FILE_NAME "iopipe.raw" +#define HDF5_FILE_NAME "iopipe.h5" +#define HEADING "%-16s" +#define PROGRESS '=' #if 0 /* Normal testing */ -#define REQUEST_SIZE_X 4579 -#define REQUEST_SIZE_Y 4579 -#define NREAD_REQUESTS 45 -#define NWRITE_REQUESTS 45 +#define REQUEST_SIZE_X 4579 +#define REQUEST_SIZE_Y 4579 +#define NREAD_REQUESTS 45 +#define NWRITE_REQUESTS 45 #else /* Speedy testing */ -#define REQUEST_SIZE_X 1000 -#define REQUEST_SIZE_Y 1000 -#define NREAD_REQUESTS 45 -#define NWRITE_REQUESTS 45 +#define REQUEST_SIZE_X 1000 +#define REQUEST_SIZE_Y 1000 +#define NREAD_REQUESTS 45 +#define NWRITE_REQUESTS 45 #endif /*------------------------------------------------------------------------- - * Function: print_stats + * Function: print_stats * - * Purpose: Prints statistics + * Purpose: Prints statistics * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, March 12, 1998 * * Modifications: @@ -65,63 +65,63 @@ #ifdef H5_HAVE_GETRUSAGE static void print_stats (const char *prefix, - struct rusage *r_start, struct rusage *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) + struct rusage *r_start, struct rusage *r_stop, + struct timeval *t_start, struct timeval *t_stop, + size_t nbytes) #else /* H5_HAVE_GETRUSAGE */ static void print_stats (const char *prefix, - struct timeval *r_start, struct timeval *r_stop, - struct timeval *t_start, struct timeval *t_stop, - size_t nbytes) + struct timeval *r_start, struct timeval *r_stop, + struct timeval *t_start, struct timeval *t_stop, + size_t nbytes) #endif /* H5_HAVE_GETRUSAGE */ { - double e_time, bw; + double e_time, bw; #ifdef H5_HAVE_GETRUSAGE - double u_time, s_time; + double u_time, s_time; u_time = ((double)(r_stop->ru_utime.tv_sec)+ - (double)(r_stop->ru_utime.tv_usec)/1000000.0) - - ((double)(r_start->ru_utime.tv_sec)+ - (double)(r_start->ru_utime.tv_usec)/1000000.0); + (double)(r_stop->ru_utime.tv_usec)/1000000.0) - + ((double)(r_start->ru_utime.tv_sec)+ + (double)(r_start->ru_utime.tv_usec)/1000000.0); s_time = ((double)(r_stop->ru_stime.tv_sec)+ - (double)(r_stop->ru_stime.tv_usec)/1000000.0) - - ((double)(r_start->ru_stime.tv_sec)+ - (double)(r_start->ru_stime.tv_usec)/1000000.0); + (double)(r_stop->ru_stime.tv_usec)/1000000.0) - + ((double)(r_start->ru_stime.tv_sec)+ + (double)(r_start->ru_stime.tv_usec)/1000000.0); #endif #ifndef H5_HAVE_SYS_TIMEB e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/1000000.0) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/1000000.0); + (double)(t_stop->tv_usec)/1000000.0) - + ((double)(t_start->tv_sec)+ + (double)(t_start->tv_usec)/1000000.0); #else e_time = ((double)(t_stop->tv_sec)+ - (double)(t_stop->tv_usec)/1000.0) - - ((double)(t_start->tv_sec)+ - (double)(t_start->tv_usec)/1000.0); + (double)(t_stop->tv_usec)/1000.0) - + ((double)(t_start->tv_sec)+ + (double)(t_start->tv_usec)/1000.0); #endif bw = (double)nbytes / e_time; #ifdef H5_HAVE_GETRUSAGE printf (HEADING "%1.2fuser %1.2fsystem %1.2felapsed %1.2fMB/s\n", - prefix, u_time, s_time, e_time, bw/(1024*1024)); + prefix, u_time, s_time, e_time, bw/(1024*1024)); #else printf (HEADING "%1.2felapsed %1.2fMB/s\n", - prefix, e_time, bw/(1024*1024)); + prefix, e_time, bw/(1024*1024)); #endif } /*------------------------------------------------------------------------- - * Function: synchronize + * Function: synchronize * * Purpose: * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, March 12, 1998 * * Modifications: @@ -132,7 +132,7 @@ static void synchronize (void) { #ifdef H5_HAVE_SYSTEM -#if defined(_WIN32) && ! defined(__CYGWIN__) +#if defined(H5_HAVE_WIN32_API) && ! defined(__CYGWIN__) _flushall(); #else HDsystem("sync"); @@ -143,15 +143,15 @@ synchronize (void) /*------------------------------------------------------------------------- - * Function: main + * Function: main * * Purpose: * - * Return: Success: + * Return: Success: * - * Failure: + * Failure: * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, March 12, 1998 * * Modifications: @@ -161,29 +161,29 @@ synchronize (void) int main (void) { - static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; - static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; + static hsize_t size[2] = {REQUEST_SIZE_X, REQUEST_SIZE_Y}; + static unsigned nread = NREAD_REQUESTS, nwrite = NWRITE_REQUESTS; - unsigned char *the_data = NULL; - hid_t file, dset, file_space = -1; - herr_t status; + unsigned char *the_data = NULL; + hid_t file, dset, file_space = -1; + herr_t status; #ifdef H5_HAVE_GETRUSAGE - struct rusage r_start, r_stop; + struct rusage r_start, r_stop; #else struct timeval r_start, r_stop; #endif - struct timeval t_start, t_stop; - int fd; - unsigned u; - hssize_t n; - off_t offset; - hsize_t start[2]; - hsize_t count[2]; + struct timeval t_start, t_stop; + int fd; + unsigned u; + hssize_t n; + off_t offset; + hsize_t start[2]; + hsize_t count[2]; #ifdef H5_HAVE_SYS_TIMEB - struct _timeb *tbstart = malloc(sizeof(struct _timeb)); - struct _timeb *tbstop = malloc(sizeof(struct _timeb)); + struct _timeb *tbstart = malloc(sizeof(struct _timeb)); + struct _timeb *tbstop = malloc(sizeof(struct _timeb)); #endif /* * The extra cast in the following statement is a bug workaround for the @@ -191,7 +191,7 @@ main (void) * 1998-11-06 ptl */ printf ("I/O request size is %1.1fMB\n", - (double)(hssize_t)(size[0]*size[1])/1024.0*1024); + (double)(hssize_t)(size[0]*size[1])/1024.0*1024); /* Open the files */ file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -218,14 +218,14 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "fill raw"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); + putc (PROGRESS, stderr); + HDfflush(stderr); + HDmemset(the_data, 0xAA, (size_t)(size[0]*size[1])); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -234,17 +234,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("fill raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Fill hdf5 */ @@ -256,16 +256,16 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "fill hdf5"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + putc (PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -274,17 +274,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("fill hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Write the raw dataset */ synchronize (); @@ -295,17 +295,17 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "out raw"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - assert (0==offset); - n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); - assert (n>=0 && (size_t)n==size[0]*size[1]); + putc (PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek (fd, (off_t)0, SEEK_SET); + assert (0==offset); + n = HDwrite (fd, the_data, (size_t)(size[0]*size[1])); + assert (n>=0 && (size_t)n==size[0]*size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -314,17 +314,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("out raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Write the hdf5 dataset */ synchronize (); @@ -335,16 +335,16 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "out hdf5"); for(u = 0; u < nwrite; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, - H5P_DEFAULT, the_data); - assert (status>=0); + putc (PROGRESS, stderr); + HDfflush(stderr); + status = H5Dwrite (dset, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, + H5P_DEFAULT, the_data); + assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -353,17 +353,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("out hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Read the raw dataset */ synchronize (); @@ -374,17 +374,17 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in raw"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - offset = HDlseek (fd, (off_t)0, SEEK_SET); - assert (0==offset); - n = HDread (fd, the_data, (size_t)(size[0]*size[1])); - assert (n>=0 && (size_t)n==size[0]*size[1]); + putc (PROGRESS, stderr); + HDfflush(stderr); + offset = HDlseek (fd, (off_t)0, SEEK_SET); + assert (0==offset); + n = HDread (fd, the_data, (size_t)(size[0]*size[1])); + assert (n>=0 && (size_t)n==size[0]*size[1]); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -393,17 +393,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("in raw", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Read the hdf5 dataset */ @@ -415,16 +415,16 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in hdf5"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + putc (PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -433,17 +433,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc ('\n', stderr); print_stats ("in hdf5", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*size[0]*size[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*size[0]*size[1])); /* Read hyperslab */ assert (size[0]>20 && size[1]>20); @@ -459,16 +459,16 @@ main (void) HDgettimeofday(&t_start, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstart); + _ftime(tbstart); #endif #endif fprintf (stderr, HEADING, "in hdf5 partial"); for(u = 0; u < nread; u++) { - putc (PROGRESS, stderr); - HDfflush(stderr); - status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, - H5P_DEFAULT, the_data); - assert (status>=0); + putc (PROGRESS, stderr); + HDfflush(stderr); + status = H5Dread (dset, H5T_NATIVE_UCHAR, file_space, file_space, + H5P_DEFAULT, the_data); + assert (status>=0); } #ifdef H5_HAVE_GETRUSAGE HDgetrusage(RUSAGE_SELF, &r_stop); @@ -477,17 +477,17 @@ main (void) HDgettimeofday(&t_stop, NULL); #else #ifdef H5_HAVE_SYS_TIMEB - _ftime(tbstop); - t_start.tv_sec = tbstart->time; - t_start.tv_usec = tbstart->millitm; - t_stop.tv_sec = tbstop->time; - t_stop.tv_usec = tbstop->millitm; + _ftime(tbstop); + t_start.tv_sec = tbstart->time; + t_start.tv_usec = tbstart->millitm; + t_stop.tv_sec = tbstop->time; + t_stop.tv_usec = tbstop->millitm; #endif #endif putc('\n', stderr); print_stats("in hdf5 partial", - &r_start, &r_stop, &t_start, &t_stop, - (size_t)(nread*count[0]*count[1])); + &r_start, &r_stop, &t_start, &t_stop, + (size_t)(nread*count[0]*count[1])); diff --git a/perform/pio_perf.h b/perform/pio_perf.h index f9a8e03..6f510ca 100644 --- a/perform/pio_perf.h +++ b/perform/pio_perf.h @@ -16,7 +16,6 @@ #ifndef PIO_PERF_H__ #define PIO_PERF_H__ -#include "pio_timer.h" #ifndef STANDALONE #include "H5private.h" #include "h5test.h" @@ -24,6 +23,7 @@ #else #include "pio_standalone.h" #endif +#include "pio_timer.h" /* setup the dataset no fill option if this is v1.5 or more */ #if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4 diff --git a/perform/pio_standalone.h b/perform/pio_standalone.h index a4bc8b5..584a057 100644 --- a/perform/pio_standalone.h +++ b/perform/pio_standalone.h @@ -22,7 +22,7 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ /* @@ -47,57 +47,57 @@ * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ -#ifdef _WIN32 -#define HDstrdup(S) _strdup(S) -#else /* _WIN32 */ +#ifdef H5_HAVE_WIN32_API +#define HDstrdup(S) _strdup(S) +#else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP extern char *strdup(const char *s); #endif -#define HDstrdup(S) strdup(S) +#define HDstrdup(S) strdup(S) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); -#define HDstrcmp(S,T) strcmp(S,T) -#define HDstrlen(S) strlen(S) -#define HDstrncmp(S,T,L) strncmp(S,T,L) -#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) -#define HDstrchr(S,C) strchr(S,C) -#define HDfree(M) free(M) +#define HDstrcmp(S,T) strcmp(S,T) +#define HDstrlen(S) strlen(S) +#define HDstrncmp(S,T,L) strncmp(S,T,L) +#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) +#define HDstrchr(S,C) strchr(S,C) +#define HDfree(M) free(M) #ifdef _O_BINARY -#define HDopen(S,F,M) open(S,F|_O_BINARY,M) +#define HDopen(S,F,M) open(S,F|_O_BINARY,M) #else -#define HDopen(S,F,M) open(S,F,M) +#define HDopen(S,F,M) open(S,F,M) #endif -#define HDclose(F) close(F) +#define HDclose(F) close(F) -#ifdef _WIN32 -#define HDlseek(F,O,W) _lseeki64(F,O,W) +#ifdef H5_HAVE_WIN32_API +#define HDlseek(F,O,W) _lseeki64(F,O,W) #else -#define HDlseek(F,O,W) lseek(F,O,W) +#define HDlseek(F,O,W) lseek(F,O,W) #endif -#define HDwrite(F,M,Z) write(F,M,Z) +#define HDwrite(F,M,Z) write(F,M,Z) -#define HDread(F,M,Z) read(F,M,Z) +#define HDread(F,M,Z) read(F,M,Z) -#ifdef _WIN32 - #define HDstat(S,B) _stati64(S,B) +#ifdef H5_HAVE_WIN32_API + #define HDstat(S,B) _stati64(S,B) #else #define HDstat(S,B) stat(S,B) #endif -#ifdef _WIN32 -#define HDfstat(F,B) _fstati64(F,B) -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; +#ifdef H5_HAVE_WIN32_API +#define HDfstat(F,B) _fstati64(F,B) +typedef struct _stati64 h5_stat_t; +typedef __int64 h5_stat_size_t; #else #define HDfstat(F,B) fstat(F,B) -typedef struct stat h5_stat_t; +typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; #endif @@ -134,7 +134,7 @@ extern const char *opt_arg; /* flag argument (or value) */ enum { no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ + require_arg, /* requires an argument */ optional_arg /* argument is optional */ }; diff --git a/perform/sio_standalone.h b/perform/sio_standalone.h index 77bb7f8..677a8ae 100644 --- a/perform/sio_standalone.h +++ b/perform/sio_standalone.h @@ -21,7 +21,7 @@ /** From H5private.h **/ -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ /* @@ -129,11 +129,11 @@ #define HDfgetc(F) fgetc(F) #define HDfgetpos(F,P) fgetpos(F,P) #define HDfgets(S,N,F) fgets(S,N,F) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDfileno(F) _fileno(F) -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ #define HDfileno(F) fileno(F) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ #define HDfloor(X) floor(X) #define HDfmod(X,Y) fmod(X,Y) #define HDfopen(S,M) fopen(S,M) @@ -169,7 +169,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); * For Unix, if off_t is not 64bit big, try use the pseudo-standard * xxx64 versions if available. */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDfstat(F,B) _fstati64(F,B) #define HDlstat(S,B) _lstati64(S,B) #define HDstat(S,B) _stati64(S,B) @@ -202,7 +202,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDgetgrgid(G) getgrgid(G) #define HDgetgrnam(S) getgrnam(S) #define HDgetgroups(Z,G) getgroups(Z,G) +#ifdef H5_HAVE_VISUAL_STUDIO +#define HDgetlogin() Wgetlogin() +#else /* H5_HAVE_VISUAL_STUDIO */ #define HDgetlogin() getlogin() +#endif /* H5_HAVE_VISUAL_STUDIO */ #define HDgetpgrp() getpgrp() #define HDgetpid() getpid() #define HDgetppid() getppid() @@ -235,7 +239,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDlog(X) log(X) #define HDlog10(X) log10(X) #define HDlongjmp(J,N) longjmp(J,N) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDlseek(F,O,W) _lseeki64(F,O,W) #else #ifdef H5_HAVE_LSEEK64 @@ -258,18 +262,18 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) /* - * The (void*) cast just avoids a compiler warning in _WIN32 + * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO */ -#ifdef _WIN32 +#ifdef H5_HAVE_VISUAL_STUDIO #define HDmemset(X,C,Z) memset((void*)(X),C,Z) -#else /* _WIN32 */ +#else /* H5_HAVE_VISUAL_STUDIO */ #define HDmemset(X,C,Z) memset(X,C,Z) -#endif /* _WIN32 */ -#ifdef _WIN32 +#endif /* H5_HAVE_VISUAL_STUDIO */ +#ifdef H5_HAVE_WIN32_API #define HDmkdir(S,M) _mkdir(S) -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ #define HDmkdir(S,M) mkdir(S,M) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ #define HDmkfifo(S,M) mkfifo(S,M) #define HDmktime(T) mktime(T) #define HDmodf(X,Y) modf(X,Y) @@ -331,7 +335,7 @@ int HDremove_all(const char * fname); #define HDsetuid(U) setuid(U) /* Windows does not permit setting the buffer size to values less than 2. */ -#ifndef _WIN32 +#ifndef H5_HAVE_WIN32_API #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) #else #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) @@ -350,7 +354,7 @@ int HDremove_all(const char * fname); #define HDsin(X) sin(X) #define HDsinh(X) sinh(X) #define HDsleep(N) sleep(N) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDsnprintf _snprintf /*varargs*/ #else #define HDsnprintf snprintf /*varargs*/ @@ -369,7 +373,7 @@ H5_DLL void HDsrand(unsigned int seed); #endif /* sscanf() variable arguments */ -#define HDstrcasecmp(X,Y) strcasecmp(X,Y) +#define HDstrcasecmp(X,Y) strcasecmp(X,Y) #define HDstrcat(X,Y) strcat(X,Y) #define HDstrchr(S,C) strchr(S,C) #define HDstrcmp(X,Y) strcmp(X,Y) @@ -415,7 +419,7 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #define HDumask(N) umask(N) #define HDuname(S) uname(S) #define HDungetc(C,F) ungetc(C,F) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDunlink(S) _unlink(S) #else #define HDunlink(S) unlink(S) @@ -428,7 +432,7 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) #define HDvprintf(FMT,A) vprintf(FMT,A) #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API # define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A) #else # define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) @@ -443,9 +447,9 @@ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #define HDstrdup(S) _strdup(S) -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ #if !defined strdup && !defined H5_HAVE_STRDUP extern char *strdup(const char *s); @@ -453,7 +457,7 @@ extern char *strdup(const char *s); #define HDstrdup(S) strdup(S) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* * HDF Boolean type. @@ -487,7 +491,7 @@ extern const char *opt_arg; /* flag argument (or value) */ enum { no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ + require_arg, /* requires an argument */ optional_arg /* argument is optional */ }; diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index b8b5b87..9ea2d34 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -114,6 +114,9 @@ Bug Fixes since HDF5-1.8.7 Library ------- + - #ifdef _WIN32 instances changed to #ifdef H5_HAVE_WIN32_API and added + H5_HAVE_VISUAL_STUDIO checks where necessary. CMake only as configure + never set _WIN32. - CLANG compiler with the options -fcatch-undefined-behavior and -ftrapv discovered 3 problems in tests and tools' library (Issue 7674): 1. In dsets.c, left shifting an unsigned int for 32 bits or more diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 1851e8c..0b19e78 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -17,23 +17,23 @@ * Programmer: Robb Matzke * Tuesday, August 10, 1999 * - * Purpose: A driver which stores the HDF5 data in main memory using - * only the HDF5 public API. This driver is useful for fast - * access to small, temporary hdf5 files. + * Purpose: A driver which stores the HDF5 data in main memory using + * only the HDF5 public API. This driver is useful for fast + * access to small, temporary hdf5 files. */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_core_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDcore.h" /* Core file driver */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDcore.h" /* Core file driver */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_CORE_g = 0; @@ -44,16 +44,16 @@ static hid_t H5FD_CORE_g = 0; * of the file (the current size of the underlying memory). */ typedef struct H5FD_core_t { - H5FD_t pub; /*public stuff, must be first */ - char *name; /*for equivalence testing */ - unsigned char *mem; /*the underlying memory */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*current allocated size */ - size_t increment; /*multiples for mem allocation */ - hbool_t backing_store; /*write to file name on flush */ - int fd; /*backing store file descriptor */ + H5FD_t pub; /*public stuff, must be first */ + char *name; /*for equivalence testing */ + unsigned char *mem; /*the underlying memory */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*current allocated size */ + size_t increment; /*multiples for mem allocation */ + hbool_t backing_store; /*write to file name on flush */ + int fd; /*backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ -#ifndef _WIN32 +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. @@ -66,7 +66,7 @@ typedef struct H5FD_core_t { #endif /*H5_VMS*/ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -77,43 +77,43 @@ typedef struct H5FD_core_t { DWORD fileindexlo; DWORD fileindexhi; #endif - hbool_t dirty; /*changes not saved? */ + hbool_t dirty; /*changes not saved? */ } H5FD_core_t; /* Driver-specific file access properties */ typedef struct H5FD_core_fapl_t { - size_t increment; /*how much to grow memory */ - hbool_t backing_store; /*write to file name on flush */ + size_t increment; /*how much to grow memory */ + hbool_t backing_store; /*write to file name on flush */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_INCREMENT 8192 /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely in memory. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely in memory. */ -#define MAXADDR ((haddr_t)((~(size_t)0)-1)) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) -#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (size_t)((A)+(Z))<(size_t)(A)) +#define MAXADDR ((haddr_t)((~(size_t)0)-1)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || (A) > (haddr_t)MAXADDR) +#define SIZE_OVERFLOW(Z) ((Z) > (hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (size_t)((A)+(Z))<(size_t)(A)) /* Prototypes */ static void *H5FD_core_fapl_get(H5FD_t *_file); static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_core_close(H5FD_t *_file); static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_core_query(const H5FD_t *_f1, unsigned long *flags); @@ -122,44 +122,44 @@ static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_core_get_eof(const H5FD_t *_file); static herr_t H5FD_core_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_core_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static herr_t H5FD_core_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_core_g = { - "core", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /*fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_core_fapl_t), /*fapl_size */ - H5FD_core_fapl_get, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_core_open, /*open */ - H5FD_core_close, /*close */ - H5FD_core_cmp, /*cmp */ - H5FD_core_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_core_get_eoa, /*get_eoa */ - H5FD_core_set_eoa, /*set_eoa */ - H5FD_core_get_eof, /*get_eof */ + "core", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /*fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + sizeof(H5FD_core_fapl_t), /*fapl_size */ + H5FD_core_fapl_get, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_core_open, /*open */ + H5FD_core_close, /*close */ + H5FD_core_cmp, /*cmp */ + H5FD_core_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_core_get_eoa, /*get_eoa */ + H5FD_core_set_eoa, /*set_eoa */ + H5FD_core_get_eof, /*get_eof */ H5FD_core_get_handle, /*get_handle */ - H5FD_core_read, /*read */ - H5FD_core_write, /*write */ - H5FD_core_flush, /*flush */ - H5FD_core_truncate, /*truncate */ + H5FD_core_read, /*read */ + H5FD_core_write, /*write */ + H5FD_core_flush, /*flush */ + H5FD_core_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; @@ -186,16 +186,16 @@ H5FD_core_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_core_init + * Function: H5FD_core_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the core driver. + * Return: Success: The driver ID for the core driver. * - * Failure: Negative. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -221,11 +221,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_core_term + * Function: H5FD_core_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -247,32 +247,32 @@ H5FD_core_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_core + * Function: H5Pset_fapl_core * - * Purpose: Modify the file access property list to use the H5FD_CORE - * driver defined in this source file. The INCREMENT specifies - * how much to grow the memory each time we need more. + * Purpose: Modify the file access property list to use the H5FD_CORE + * driver defined in this source file. The INCREMENT specifies + * how much to grow the memory each time we need more. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * * Modifications: - * Robb Matzke, 1999-10-19 - * Added the BACKING_STORE argument. If set then the entire file - * contents are flushed to a file with the same name as this - * core file. + * Robb Matzke, 1999-10-19 + * Added the BACKING_STORE argument. If set then the entire file + * contents are flushed to a file with the same name as this + * core file. * - * Raymond Lu, 2001-10-25 - * Changed the file access list to the new generic list. + * Raymond Lu, 2001-10-25 + * Changed the file access list to the new generic list. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5FD_core_fapl_t fa; + H5FD_core_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; @@ -294,32 +294,32 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_core + * Function: H5Pget_fapl_core * - * Purpose: Queries properties set by the H5Pset_fapl_core() function. + * Purpose: Queries properties set by the H5Pset_fapl_core() function. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, August 10, 1999 * * Modifications: - * Robb Matzke, 1999-10-19 - * Added the BACKING_STORE argument. + * Robb Matzke, 1999-10-19 + * Added the BACKING_STORE argument. * - * Raymond Lu - * 2001-10-25 - * Changed file access list to the new generic property list. + * Raymond Lu + * 2001-10-25 + * Changed file access list to the new generic property list. * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/, - hbool_t *backing_store/*out*/) + hbool_t *backing_store/*out*/) { - H5FD_core_fapl_t *fa; + H5FD_core_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ @@ -344,15 +344,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_fapl_get + * Function: H5FD_core_fapl_get * - * Purpose: Returns a copy of the file access properties. + * Purpose: Returns a copy of the file access properties. * - * Return: Success: Ptr to new file access properties. + * Return: Success: Ptr to new file access properties. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, August 13, 1999 * * Modifications: @@ -362,8 +362,8 @@ done: static void * H5FD_core_fapl_get(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; - H5FD_core_fapl_t *fa; + H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_fapl_t *fa; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_fapl_get, NULL) @@ -383,22 +383,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_open + * Function: H5FD_core_open * - * Purpose: Create memory as an HDF5 file. + * Purpose: Create memory as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: - * Robb Matzke, 1999-10-19 - * The backing store file is created and opened if specified. + * Robb Matzke, 1999-10-19 + * The backing store file is created and opened if specified. * * Raymond Lu, 2006-11-30 * Enabled the driver to read an existing file depending on @@ -407,19 +407,19 @@ done: */ static H5FD_t * H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) + haddr_t maxaddr) { - int o_flags; - H5FD_core_t *file=NULL; - H5FD_core_fapl_t *fa=NULL; + int o_flags; + H5FD_core_t *file=NULL; + H5FD_core_fapl_t *fa=NULL; H5P_genplist_t *plist; /* Property list pointer */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - int fd=-1; - H5FD_t *ret_value; + h5_stat_t sb; + int fd=-1; + H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_core_open, NULL) @@ -470,12 +470,12 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, if(fd >= 0) { /* Retrieve information for determining uniqueness of file */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; #ifdef H5_VMS file->inode[0] = sb.st_ino[0]; @@ -485,7 +485,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, file->inode = sb.st_ino; #endif /* H5_VMS */ -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ } /* end if */ /* If an existing file is opened, load the whole file into memory. */ @@ -493,7 +493,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, size_t size; /* Retrieve file size */ - size = (size_t)sb.st_size; + size = (size_t)sb.st_size; /* Check if we should allocate the memory buffer and read in existing data */ if(size) { @@ -519,15 +519,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_close + * Function: H5FD_core_close * - * Purpose: Closes the file. + * Purpose: Closes the file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -535,7 +535,7 @@ done: static herr_t H5FD_core_close(H5FD_t *_file) { - H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_close, FAIL) @@ -560,19 +560,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_cmp + * Function: H5FD_core_cmp * - * Purpose: Compares two files belonging to this driver by name. If one - * file doesn't have a name then it is less than the other file. - * If neither file has a name then the comparison is by file - * address. + * Purpose: Compares two files belonging to this driver by name. If one + * file doesn't have a name then it is less than the other file. + * If neither file has a name then the comparison is by file + * address. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -587,15 +587,15 @@ done: static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; - const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; - int ret_value = 0; + const H5FD_core_t *f1 = (const H5FD_core_t*)_f1; + const H5FD_core_t *f2 = (const H5FD_core_t*)_f2; + int ret_value = 0; FUNC_ENTER_NOAPI(H5FD_core_cmp, FAIL) if(f1->fd >= 0 && f2->fd >= 0) { /* Compare low level file information for backing store */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -623,7 +623,7 @@ H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2) if(HDmemcmp(&(f1->inode),&(f2->inode),3*sizeof(ino_t))>0) HGOTO_DONE(1) #endif /* H5_VMS */ -#endif /*_WIN32*/ +#endif /*H5_HAVE_WIN32_API*/ } /* end if */ else { if (NULL==f1->name && NULL==f2->name) { @@ -648,15 +648,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_query + * Function: H5FD_core_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 7, 2008 * *------------------------------------------------------------------------- @@ -664,7 +664,7 @@ done: static herr_t H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_core_query) @@ -686,17 +686,17 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eoa + * Function: H5FD_core_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: Success: The end-of-address marker. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: @@ -709,7 +709,7 @@ H5FD_core_query(const H5FD_t * _file, unsigned long *flags /* out */) static haddr_t H5FD_core_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_get_eoa, HADDR_UNDEF) @@ -723,17 +723,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_set_eoa + * Function: H5FD_core_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -746,7 +746,7 @@ done: static herr_t H5FD_core_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_set_eoa, FAIL) @@ -762,19 +762,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_get_eof + * Function: H5FD_core_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the size of the underlying memory or the HDF5 - * end-of-address markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the size of the underlying memory or the HDF5 + * end-of-address markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the memory - * or the HDF5 file. + * Return: Success: End of file address, the first address past + * the end of the "file", either the memory + * or the HDF5 file. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -786,7 +786,7 @@ H5FD_core_get_eof(const H5FD_t *_file) { haddr_t ret_value; /* Return value */ - const H5FD_core_t *file = (const H5FD_core_t*)_file; + const H5FD_core_t *file = (const H5FD_core_t*)_file; FUNC_ENTER_NOAPI(H5FD_core_get_eof, HADDR_UNDEF) @@ -861,18 +861,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_read + * Function: H5FD_core_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, Contents of buffer BUF are undefined. + * Failure: -1, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -882,9 +882,9 @@ done: /* ARGSUSED */ static herr_t H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { - H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_read, FAIL) @@ -929,17 +929,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_write + * Function: H5FD_core_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -949,7 +949,7 @@ done: /* ARGSUSED */ static herr_t H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value = SUCCEED; /* Return value */ @@ -1001,16 +1001,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_flush + * Function: H5FD_core_flush * - * Purpose: Flushes the file to backing store if there is any and if the - * dirty flag is set. + * Purpose: Flushes the file to backing store if there is any and if the + * dirty flag is set. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 15, 1999 * * Modifications: @@ -1023,7 +1023,7 @@ done: static herr_t H5FD_core_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing) { - H5FD_core_t *file = (H5FD_core_t*)_file; + H5FD_core_t *file = (H5FD_core_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_core_flush, FAIL) @@ -1057,15 +1057,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_core_truncate + * Function: H5FD_core_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 7, 2008 * *------------------------------------------------------------------------- diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 29fd84f..8e7a2b7 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -17,27 +17,27 @@ * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Purpose: The Direct I/O file driver forces the data to be written to - * the file directly without being copied into system kernel - * buffer. The main system support this feature is Linux. + * Purpose: The Direct I/O file driver forces the data to be written to + * the file directly without being copied into system kernel + * buffer. The main system support this feature is Linux. */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_direct_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_direct_init_interface /* For system function posix_memalign - Commented it out because copper isn't able to compile * this file. */ /* #define _XOPEN_SOURCE 600 */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDdirect.h" /* Direct file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDdirect.h" /* Direct file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_DIRECT @@ -45,15 +45,15 @@ static hid_t H5FD_DIRECT_g = 0; /* File operations */ -#define OP_UNKNOWN 0 -#define OP_READ 1 -#define OP_WRITE 2 +#define OP_UNKNOWN 0 +#define OP_READ 1 +#define OP_WRITE 2 /* Driver-specific file access properties */ typedef struct H5FD_direct_fapl_t { - size_t mboundary; /* Memory boundary for alignment */ - size_t fbsize; /* File system block size */ - size_t cbsize; /* Maximal buffer size for copying user data */ + size_t mboundary; /* Memory boundary for alignment */ + size_t fbsize; /* File system block size */ + size_t cbsize; /* Maximal buffer size for copying user data */ hbool_t must_align; /* Decides if data alignment is required */ } H5FD_direct_fapl_t; @@ -70,27 +70,27 @@ typedef struct H5FD_direct_fapl_t { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_direct_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - int op; /*last operation */ - H5FD_direct_fapl_t fa; /*file access properties */ -#ifndef _WIN32 + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + int op; /*last operation */ + H5FD_direct_fapl_t fa; /*file access properties */ +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ + dev_t device; /*file device number */ #ifdef H5_VMS - ino_t inode[3]; /*file i-node number */ + ino_t inode[3]; /*file i-node number */ #else - ino_t inode; /*file i-node number */ + ino_t inode; /*file i-node number */ #endif /*H5_VMS*/ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -108,57 +108,57 @@ typedef struct H5FD_direct_t { * some macros here so we don't have to have conditional compilations later * throughout the code. * - * file_offset_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. + * file_offset_t: The datatype for file offsets, the second argument of + * the lseek() or lseek64() call. * - * file_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). + * file_seek: The function which adjusts the current file position, + * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ #ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -# define file_truncate ftruncate64 -#elif defined (_WIN32) +# define file_offset_t off64_t +# define file_seek lseek64 +# define file_truncate ftruncate64 +#elif defined (H5_HAVE_WIN32_API) # /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 -# define file_truncate _chsize +# define file_truncate _chsize #else -# define file_offset_t off_t -# define file_seek lseek -# define file_truncate HDftruncate +# define file_offset_t off_t +# define file_seek lseek +# define file_truncate HDftruncate #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (file_offset_t)((A)+(Z))<(file_offset_t)(A)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ + ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (file_offset_t)((A)+(Z))<(file_offset_t)(A)) /* Prototypes */ static void *H5FD_direct_fapl_get(H5FD_t *file); static void *H5FD_direct_fapl_copy(const void *_old_fa); static H5FD_t *H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_direct_close(H5FD_t *_file); static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_direct_query(const H5FD_t *_f1, unsigned long *flags); @@ -167,43 +167,43 @@ static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_direct_get_eof(const H5FD_t *_file); static herr_t H5FD_direct_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_direct_g = { - "direct", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_direct_fapl_t), /*fapl_size */ - H5FD_direct_fapl_get, /*fapl_get */ - H5FD_direct_fapl_copy, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_direct_open, /*open */ - H5FD_direct_close, /*close */ - H5FD_direct_cmp, /*cmp */ - H5FD_direct_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_direct_get_eoa, /*get_eoa */ - H5FD_direct_set_eoa, /*set_eoa */ - H5FD_direct_get_eof, /*get_eof */ + "direct", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + sizeof(H5FD_direct_fapl_t), /*fapl_size */ + H5FD_direct_fapl_get, /*fapl_get */ + H5FD_direct_fapl_copy, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_direct_open, /*open */ + H5FD_direct_close, /*close */ + H5FD_direct_cmp, /*cmp */ + H5FD_direct_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_direct_get_eoa, /*get_eoa */ + H5FD_direct_set_eoa, /*set_eoa */ + H5FD_direct_get_eof, /*get_eof */ H5FD_direct_get_handle, /*get_handle */ - H5FD_direct_read, /*read */ - H5FD_direct_write, /*write */ - NULL, /*flush */ - H5FD_direct_truncate, /*truncate */ + H5FD_direct_read, /*read */ + H5FD_direct_write, /*write */ + NULL, /*flush */ + H5FD_direct_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /* Declare a free list to manage the H5FD_direct_t struct */ @@ -233,16 +233,16 @@ H5FD_direct_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_direct_init + * Function: H5FD_direct_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the direct driver. + * Return: Success: The driver ID for the direct driver. * - * Failure: Negative. + * Failure: Negative. * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -268,11 +268,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_direct_term + * Function: H5FD_direct_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Raymond Lu * Wednesday, 20 September 2006 @@ -294,16 +294,16 @@ H5FD_direct_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_direct + * Function: H5Pset_fapl_direct * - * Purpose: Modify the file access property list to use the H5FD_DIRECT - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_DIRECT + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Raymond Lu - * Wednesday, 20 September 2006 + * Programmer: Raymond Lu + * Wednesday, 20 September 2006 * * Modifications: * @@ -312,9 +312,9 @@ H5FD_direct_term(void) herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbuf_size) { - H5P_genplist_t *plist; /* Property list pointer */ - H5FD_direct_fapl_t fa; - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_direct_fapl_t fa; + herr_t ret_value; FUNC_ENTER_API(H5Pset_fapl_direct, FAIL) H5TRACE4("e", "izzz", fapl_id, boundary, block_size, cbuf_size); @@ -323,17 +323,17 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(boundary != 0) - fa.mboundary = boundary; + fa.mboundary = boundary; else - fa.mboundary = MBOUNDARY_DEF; + fa.mboundary = MBOUNDARY_DEF; if(block_size != 0) - fa.fbsize = block_size; + fa.fbsize = block_size; else - fa.fbsize = FBSIZE_DEF; + fa.fbsize = FBSIZE_DEF; if(cbuf_size != 0) - fa.cbsize = cbuf_size; + fa.cbsize = cbuf_size; else - fa.cbsize = CBSIZE_DEF; + fa.cbsize = CBSIZE_DEF; /* Set the default to be true for data alignment */ fa.must_align = TRUE; @@ -350,16 +350,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_direct + * Function: H5Pget_fapl_direct * - * Purpose: Returns information about the direct file access property - * list though the function arguments. + * Purpose: Returns information about the direct file access property + * list though the function arguments. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, October 18, 2006 * * Modifications: @@ -368,9 +368,9 @@ done: */ herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*out*/, - size_t *cbuf_size/*out*/) + size_t *cbuf_size/*out*/) { - H5FD_direct_fapl_t *fa; + H5FD_direct_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ @@ -386,9 +386,9 @@ H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*o if (boundary) *boundary = fa->mboundary; if (block_size) - *block_size = fa->fbsize; + *block_size = fa->fbsize; if (cbuf_size) - *cbuf_size = fa->cbsize; + *cbuf_size = fa->cbsize; done: FUNC_LEAVE_API(ret_value) @@ -396,18 +396,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_get + * Function: H5FD_direct_fapl_get * - * Purpose: Returns a file access property list which indicates how the - * specified file is being accessed. The return list could be - * used to access another file the same way. + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. * - * Return: Success: Ptr to new file access property list with all - * members copied from the file struct. + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. * - * Failure: NULL + * Failure: NULL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 18 October 2006 * * Modifications: @@ -417,7 +417,7 @@ done: static void * H5FD_direct_fapl_get(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; + H5FD_direct_t *file = (H5FD_direct_t*)_file; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_fapl_get, NULL) @@ -431,15 +431,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_fapl_copy + * Function: H5FD_direct_fapl_copy * - * Purpose: Copies the direct-specific file access properties. + * Purpose: Copies the direct-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 18 October 2006 * * Modifications: @@ -469,17 +469,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_open + * Function: H5FD_direct_open * - * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file. + * Purpose: Create and/or opens a Unix file for direct I/O as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -489,18 +489,18 @@ done: static H5FD_t * H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - int o_flags; - int fd=(-1); - H5FD_direct_t *file=NULL; - H5FD_direct_fapl_t *fa; -#ifdef _WIN32 - HFILE filehandle; + int o_flags; + int fd=(-1); + H5FD_direct_t *file=NULL; + H5FD_direct_fapl_t *fa; +#ifdef H5_HAVE_WIN32_API + HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - H5P_genplist_t *plist; /* Property list */ + h5_stat_t sb; + H5P_genplist_t *plist; /* Property list */ int *buf1, *buf2; - H5FD_t *ret_value; + H5FD_t *ret_value; FUNC_ENTER_NOAPI(H5FD_direct_open, NULL) @@ -544,7 +544,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd H5_ASSIGN_OVERFLOW(file->eof,sb.st_size,h5_stat_size_t,haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; @@ -558,7 +558,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd #else file->inode = sb.st_ino; #endif /*H5_VMS*/ -#endif /*_WIN32*/ +#endif /*H5_HAVE_WIN32_API*/ file->fa.mboundary = fa->mboundary; file->fa.fbsize = fa->fbsize; file->fa.cbsize = fa->cbsize; @@ -569,7 +569,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd */ buf1 = (int*)HDmalloc(sizeof(int)); if (HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed") if(o_flags & O_CREAT) { if(write(file->fd, (void*)buf1, sizeof(int))<0) { @@ -619,15 +619,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_close + * Function: H5FD_direct_close * - * Purpose: Closes the file. + * Purpose: Closes the file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, file not closed. + * Failure: -1, file not closed. * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -637,8 +637,8 @@ done: static herr_t H5FD_direct_close(H5FD_t *_file) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t*)_file; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_close, FAIL) @@ -653,17 +653,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_cmp + * Function: H5FD_direct_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Thursday, 21 September 2006 * * Modifications: @@ -673,13 +673,13 @@ done: static int H5FD_direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1; - const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2; + const H5FD_direct_t *f1 = (const H5FD_direct_t*)_f1; + const H5FD_direct_t *f2 = (const H5FD_direct_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_direct_cmp, H5FD_VFD_DEFAULT) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -715,16 +715,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_query + * Function: H5FD_direct_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Thursday, 21 September 2006 * * Modifications: @@ -753,17 +753,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eoa + * Function: H5FD_direct_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: Success: The end-of-address marker. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -776,7 +776,7 @@ done: static haddr_t H5FD_direct_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_get_eoa, HADDR_UNDEF) @@ -790,17 +790,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_set_eoa + * Function: H5FD_direct_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -813,7 +813,7 @@ done: static herr_t H5FD_direct_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; + H5FD_direct_t *file = (H5FD_direct_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_set_eoa, FAIL) @@ -826,19 +826,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_get_eof + * Function: H5FD_direct_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Unix end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Unix end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, 20 September 2006 * * Modifications: @@ -848,7 +848,7 @@ done: static haddr_t H5FD_direct_get_eof(const H5FD_t *_file) { - const H5FD_direct_t *file = (const H5FD_direct_t*)_file; + const H5FD_direct_t *file = (const H5FD_direct_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_get_eof, HADDR_UNDEF) @@ -893,18 +893,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_read + * Function: H5FD_direct_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, Contents of buffer BUF are undefined. + * Failure: -1, Contents of buffer BUF are undefined. * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Thursday, 21 September 2006 * * Modifications: @@ -913,19 +913,19 @@ done: */ static herr_t H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p2; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; - haddr_t read_size; /* Size to read into copy buffer */ - size_t copy_size = size; /* Size remaining to read when using copy buffer */ + H5FD_direct_t *file = (H5FD_direct_t*)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value=SUCCEED; /* Return value */ + size_t alloc_size; + void *copy_buf = NULL, *p2; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; + haddr_t read_size; /* Size to read into copy buffer */ + size_t copy_size = size; /* Size remaining to read when using copy buffer */ size_t copy_offset; /* Offset into copy buffer of the requested data */ FUNC_ENTER_NOAPI(H5FD_direct_read, FAIL) @@ -958,44 +958,44 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha * and aligned data first, then copy the data into memory buffer. */ if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_READ!=file->op) && - file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* Read the aligned data in file first, being careful of interrupted - * system calls and partial results. */ - while (size>0) { - do { - nbytes = HDread(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - if (0==nbytes) { - /* end of file but not end of format address space */ - HDmemset(buf, 0, size); - break; - } - assert(nbytes>=0); - assert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (char*)buf + nbytes; - } + /* Seek to the correct location */ + if ((addr!=file->pos || OP_READ!=file->op) && + file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + /* Read the aligned data in file first, being careful of interrupted + * system calls and partial results. */ + while (size>0) { + do { + nbytes = HDread(file->fd, buf, size); + } while (-1==nbytes && EINTR==errno); + if (-1==nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if (0==nbytes) { + /* end of file but not end of format address space */ + HDmemset(buf, 0, size); + break; + } + assert(nbytes>=0); + assert((size_t)nbytes<=size); + H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); + addr += (haddr_t)nbytes; + buf = (char*)buf + nbytes; + } } else { /* Calculate where we will begin copying from the copy buffer */ copy_offset = (size_t)(addr % _fbsize); - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; - if(alloc_size > _cbsize) - alloc_size = _cbsize; - HDassert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. */ + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + if(alloc_size > _cbsize) + alloc_size = _cbsize; + HDassert(!(alloc_size % _fbsize)); + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") /* look for the aligned position for reading the data */ HDassert(!(((addr / _fbsize) * _fbsize) % _fbsize)); @@ -1003,18 +1003,18 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - /* - * Read the aligned data in file into aligned buffer first, then copy the data - * into the final buffer. If the data size is bigger than maximal copy buffer - * size, do the reading by segment (the outer while loop). If not, do one step - * reading. - */ - do { - /* Read the aligned data in file first. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's expecially true when the data in - * file is smaller than ALLOC_SIZE. */ - HDmemset(copy_buf, 0, alloc_size); + /* + * Read the aligned data in file into aligned buffer first, then copy the data + * into the final buffer. If the data size is bigger than maximal copy buffer + * size, do the reading by segment (the outer while loop). If not, do one step + * reading. + */ + do { + /* Read the aligned data in file first. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's expecially true when the data in + * file is smaller than ALLOC_SIZE. */ + HDmemset(copy_buf, 0, alloc_size); /* Calculate how much data we have to read in this iteration * (including unused parts of blocks) */ @@ -1025,23 +1025,23 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha read_size = alloc_size; HDassert(!(read_size % _fbsize)); - do { - nbytes = HDread(file->fd, copy_buf, read_size); - } while(-1==nbytes && EINTR==errno); + do { + nbytes = HDread(file->fd, copy_buf, read_size); + } while(-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") + if (-1==nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - /* Copy the needed data from the copy buffer to the output - * buffer, and update copy_size. If the copy buffer does not + /* Copy the needed data from the copy buffer to the output + * buffer, and update copy_size. If the copy buffer does not * contain the rest of the data, just copy what's in the copy * buffer and also update read_addr and copy_offset to read the * next section of data. */ - p2 = (unsigned char*)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { - HDmemcpy(buf, p2, copy_size); - buf = (unsigned char *)buf + copy_size; - copy_size = 0; + p2 = (unsigned char*)copy_buf + copy_offset; + if((copy_size + copy_offset) <= alloc_size) { + HDmemcpy(buf, p2, copy_size); + buf = (unsigned char *)buf + copy_size; + copy_size = 0; } /* end if */ else { HDmemcpy(buf, p2, alloc_size - copy_offset); @@ -1049,12 +1049,12 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ha copy_size -= alloc_size - copy_offset; copy_offset = 0; } /* end else */ - } while (copy_size > 0); + } while (copy_size > 0); - /*Final step: update address*/ - addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); + /*Final step: update address*/ + addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize); - if(copy_buf) { + if(copy_buf) { HDfree(copy_buf); copy_buf = NULL; } /* end if */ @@ -1079,17 +1079,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_write + * Function: H5FD_direct_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Thursday, 21 September 2006 * * Modifications: @@ -1098,18 +1098,18 @@ done: */ static herr_t H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - ssize_t nbytes; - hbool_t _must_align = TRUE; - herr_t ret_value=SUCCEED; /* Return value */ - size_t alloc_size; - void *copy_buf = NULL, *p1; - const void *p3; - size_t _boundary; - size_t _fbsize; - size_t _cbsize; + H5FD_direct_t *file = (H5FD_direct_t*)_file; + ssize_t nbytes; + hbool_t _must_align = TRUE; + herr_t ret_value=SUCCEED; /* Return value */ + size_t alloc_size; + void *copy_buf = NULL, *p1; + const void *p3; + size_t _boundary; + size_t _fbsize; + size_t _cbsize; haddr_t write_addr; /* Address to write copy buffer */ haddr_t write_size; /* Size to write from copy buffer */ haddr_t read_size; /* Size to read into copy buffer */ @@ -1146,49 +1146,49 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h * first, update buffer with user data, then write the data out. */ if(!_must_align || ((addr%_fbsize==0) && (size%_fbsize==0) && ((size_t)buf%_boundary==0))) { - /* Seek to the correct location */ - if ((addr!=file->pos || OP_WRITE!=file->op) && - file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - while (size>0) { - do { - nbytes = HDwrite(file->fd, buf, size); - } while (-1==nbytes && EINTR==errno); - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - assert(nbytes>0); - assert((size_t)nbytes<=size); - H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); - size -= (size_t)nbytes; - H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); - addr += (haddr_t)nbytes; - buf = (const char*)buf + nbytes; - } + /* Seek to the correct location */ + if ((addr!=file->pos || OP_WRITE!=file->op) && + file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + while (size>0) { + do { + nbytes = HDwrite(file->fd, buf, size); + } while (-1==nbytes && EINTR==errno); + if (-1==nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + assert(nbytes>0); + assert((size_t)nbytes<=size); + H5_CHECK_OVERFLOW(nbytes,ssize_t,size_t); + size -= (size_t)nbytes; + H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); + addr += (haddr_t)nbytes; + buf = (const char*)buf + nbytes; + } } else { /* Calculate where we will begin reading from (on disk) and where we * will begin copying from the copy buffer */ write_addr = (addr / _fbsize) * _fbsize; copy_offset = (size_t)(addr % _fbsize); - /* allocate memory needed for the Direct IO option up to the maximal - * copy buffer size. Make a bigger buffer for aligned I/O if size is - * smaller than maximal copy buffer. - */ - alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; + /* allocate memory needed for the Direct IO option up to the maximal + * copy buffer size. Make a bigger buffer for aligned I/O if size is + * smaller than maximal copy buffer. + */ + alloc_size = ((copy_offset + size - 1) / _fbsize + 1) * _fbsize; if(alloc_size > _cbsize) alloc_size = _cbsize; HDassert(!(alloc_size % _fbsize)); - if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") + if (HDposix_memalign(©_buf, _boundary, alloc_size) != 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "HDposix_memalign failed") /* look for the right position for reading or writing the data */ if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - p3 = buf; - do { + p3 = buf; + do { /* Calculate how much data we have to write in this iteration * (including unused parts of blocks) */ if((copy_size + copy_offset) < alloc_size) @@ -1197,16 +1197,16 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h else write_size = alloc_size; - /* - * Read the aligned data first if the aligned region doesn't fall - * entirely in the range to be writen. Not able to handle interrupted - * system calls and partial results like sec2 driver does because the - * data may no longer be aligned. It's expecially true when the data in - * file is smaller than ALLOC_SIZE. Only read the entire section if + /* + * Read the aligned data first if the aligned region doesn't fall + * entirely in the range to be writen. Not able to handle interrupted + * system calls and partial results like sec2 driver does because the + * data may no longer be aligned. It's expecially true when the data in + * file is smaller than ALLOC_SIZE. Only read the entire section if * both ends are misaligned, otherwise only read the block on the * misaligned end. - */ - HDmemset(copy_buf, 0, _fbsize); + */ + HDmemset(copy_buf, 0, _fbsize); if(copy_offset > 0) { if((write_addr + write_size) > (addr + size)) { @@ -1244,14 +1244,14 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") } /* end if */ - /* look for the right position and append or copy the data to be written to - * the aligned buffer. - * Consider all possible situations here: file address is not aligned on - * file block size; the end of data address is not aligned; the end of data - * address is aligned; data size is smaller or bigger than maximal copy size. - */ - p1 = (unsigned char *)copy_buf + copy_offset; - if((copy_size + copy_offset) <= alloc_size) { + /* look for the right position and append or copy the data to be written to + * the aligned buffer. + * Consider all possible situations here: file address is not aligned on + * file block size; the end of data address is not aligned; the end of data + * address is aligned; data size is smaller or bigger than maximal copy size. + */ + p1 = (unsigned char *)copy_buf + copy_offset; + if((copy_size + copy_offset) <= alloc_size) { HDmemcpy(p1, p3, copy_size); copy_size = 0; } /* end if */ @@ -1262,34 +1262,34 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h copy_offset = 0; } /* end else */ - /*look for the aligned position for writing the data*/ - HDassert(!(write_addr % _fbsize)); - if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0) - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - - /* - * Write the data. It doesn't truncate the extra data introduced by - * alignment because that step is done in H5FD_direct_flush. - */ - HDassert(!(write_size % _fbsize)); - do { - nbytes = HDwrite(file->fd, copy_buf, write_size); - } while (-1==nbytes && EINTR==errno); - - if (-1==nbytes) /* error */ - HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") - - /* update the write address */ - write_addr += write_size; - } while (copy_size > 0); - - /*Update the address and size*/ - addr = write_addr; - buf = (const char*)buf + size; - - if(copy_buf) { - HDfree(copy_buf); - copy_buf = NULL; + /*look for the aligned position for writing the data*/ + HDassert(!(write_addr % _fbsize)); + if(file_seek(file->fd, (file_offset_t)write_addr, SEEK_SET) < 0) + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + + /* + * Write the data. It doesn't truncate the extra data introduced by + * alignment because that step is done in H5FD_direct_flush. + */ + HDassert(!(write_size % _fbsize)); + do { + nbytes = HDwrite(file->fd, copy_buf, write_size); + } while (-1==nbytes && EINTR==errno); + + if (-1==nbytes) /* error */ + HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") + + /* update the write address */ + write_addr += write_size; + } while (copy_size > 0); + + /*Update the address and size*/ + addr = write_addr; + buf = (const char*)buf + size; + + if(copy_buf) { + HDfree(copy_buf); + copy_buf = NULL; } /* end if */ } @@ -1314,16 +1314,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_truncate + * Function: H5FD_direct_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative + * Return: Success: Non-negative * - * Failure: Negative + * Failure: Negative * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Thursday, 21 September 2006 * *------------------------------------------------------------------------- @@ -1331,8 +1331,8 @@ done: static herr_t H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_direct_t *file = (H5FD_direct_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_direct_t *file = (H5FD_direct_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_direct_truncate, FAIL) @@ -1340,7 +1340,7 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing /* Extend the file to make sure it's large enough */ if (file->eoa!=file->eof) { -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ @@ -1353,10 +1353,10 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing (void)SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ if (-1==file_truncate(file->fd, (file_offset_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Update the eof value */ file->eof = file->eoa; @@ -1366,9 +1366,9 @@ H5FD_direct_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing file->op = OP_UNKNOWN; } else if (file->fa.must_align){ - /*Even though eof is equal to eoa, file is still truncated because Direct I/O - *write introduces some extra data for alignment. - */ + /*Even though eof is equal to eoa, file is still truncated because Direct I/O + *write introduces some extra data for alignment. + */ if (-1==file_truncate(file->fd, (file_offset_t)file->eof)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") } diff --git a/src/H5FDlog.c b/src/H5FDlog.c index da19e46..0e3c562 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -17,17 +17,17 @@ * Programmer: Quincey Koziol * Monday, April 17, 2000 * - * Purpose: The POSIX unbuffered file driver using only the HDF5 public - * API and with a few optimizations: the lseek() call is made - * only when the current file position is unknown or needs to be - * changed based on previous I/O through this driver (don't mix - * I/O from this driver with I/O from other parts of the - * application to the same file). + * Purpose: The POSIX unbuffered file driver using only the HDF5 public + * API and with a few optimizations: the lseek() call is made + * only when the current file position is unknown or needs to be + * changed based on previous I/O through this driver (don't mix + * I/O from this driver with I/O from other parts of the + * application to the same file). * With custom modifications... */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_log_init_interface #include "H5private.h" /* Generic Functions */ @@ -45,7 +45,7 @@ static hid_t H5FD_LOG_g = 0; /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { - char *logfile; /* Allocated log file name */ + char *logfile; /* Allocated log file name */ unsigned long long flags; /* Flags for logging behavior */ size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; @@ -78,27 +78,27 @@ static const char *flavors[]={ * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_log_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - H5FD_file_op_t op; /*last operation */ - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ -#ifndef _WIN32 + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + H5FD_file_op_t op; /*last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ + dev_t device; /*file device number */ #ifdef H5_VMS - ino_t inode[3]; /*file i-node number */ + ino_t inode[3]; /*file i-node number */ #else - ino_t inode; /*file i-node number */ + ino_t inode; /*file i-node number */ #endif /*H5_VMS*/ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -127,7 +127,7 @@ typedef struct H5FD_log_t { double total_seek_time; /* Total time spent in seek operations */ size_t iosize; /* Size of I/O information buffers */ FILE *logfp; /* Log file pointer */ - H5FD_log_fapl_t fa; /* Driver-specific file access properties*/ + H5FD_log_fapl_t fa; /* Driver-specific file access properties*/ } H5FD_log_t; @@ -136,8 +136,8 @@ typedef struct H5FD_log_t { * some macros here so we don't have to have conditional compilations later * throughout the code. * - * HDoff_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. + * HDoff_t: The datatype for file offsets, the second argument of + * the lseek() or lseek64() call. * */ @@ -145,31 +145,31 @@ typedef struct H5FD_log_t { * These macros check for overflow of various quantities. These macros * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ + ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static void *H5FD_log_fapl_get(H5FD_t *file); static void *H5FD_log_fapl_copy(const void *_old_fa); static herr_t H5FD_log_fapl_free(void *_fa); static H5FD_t *H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_log_close(H5FD_t *_file); static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_log_query(const H5FD_t *_f1, unsigned long *flags); @@ -179,43 +179,43 @@ static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_log_get_eof(const H5FD_t *_file); static herr_t H5FD_log_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_log_g = { - "log", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - sizeof(H5FD_log_fapl_t), /*fapl_size */ - H5FD_log_fapl_get, /*fapl_get */ - H5FD_log_fapl_copy, /*fapl_copy */ - H5FD_log_fapl_free, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_log_open, /*open */ - H5FD_log_close, /*close */ - H5FD_log_cmp, /*cmp */ - H5FD_log_query, /*query */ - NULL, /*get_type_map */ - H5FD_log_alloc, /*alloc */ - NULL, /*free */ - H5FD_log_get_eoa, /*get_eoa */ - H5FD_log_set_eoa, /*set_eoa */ - H5FD_log_get_eof, /*get_eof */ + "log", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + sizeof(H5FD_log_fapl_t), /*fapl_size */ + H5FD_log_fapl_get, /*fapl_get */ + H5FD_log_fapl_copy, /*fapl_copy */ + H5FD_log_fapl_free, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_log_open, /*open */ + H5FD_log_close, /*close */ + H5FD_log_cmp, /*cmp */ + H5FD_log_query, /*query */ + NULL, /*get_type_map */ + H5FD_log_alloc, /*alloc */ + NULL, /*free */ + H5FD_log_get_eoa, /*get_eoa */ + H5FD_log_set_eoa, /*set_eoa */ + H5FD_log_get_eof, /*get_eof */ H5FD_log_get_handle, /*get_handle */ - H5FD_log_read, /*read */ - H5FD_log_write, /*write */ - NULL, /*flush */ - H5FD_log_truncate, /*truncate */ + H5FD_log_read, /*read */ + H5FD_log_write, /*write */ + NULL, /*flush */ + H5FD_log_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /* Declare a free list to manage the H5FD_log_t struct */ @@ -245,15 +245,15 @@ H5FD_log_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_log_init + * Function: H5FD_log_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the log driver. - * Failure: Negative. + * Return: Success: The driver ID for the log driver. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -277,11 +277,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_log_term + * Function: H5FD_log_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -301,23 +301,23 @@ H5FD_log_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_log + * Function: H5Pset_fapl_log * - * Purpose: Modify the file access property list to use the H5FD_LOG - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_LOG + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, size_t buf_size) { - H5FD_log_fapl_t fa; /* File access property list information */ + H5FD_log_fapl_t fa; /* File access property list information */ H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; @@ -338,17 +338,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_get + * Function: H5FD_log_fapl_get * - * Purpose: Returns a file access property list which indicates how the - * specified file is being accessed. The return list could be - * used to access another file the same way. + * Purpose: Returns a file access property list which indicates how the + * specified file is being accessed. The return list could be + * used to access another file the same way. * - * Return: Success: Ptr to new file access property list with all - * members copied from the file struct. - * Failure: NULL + * Return: Success: Ptr to new file access property list with all + * members copied from the file struct. + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -356,7 +356,7 @@ done: static void * H5FD_log_fapl_get(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_fapl_get) @@ -369,14 +369,14 @@ H5FD_log_fapl_get(H5FD_t *_file) /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_copy + * Function: H5FD_log_fapl_copy * - * Purpose: Copies the log-specific file access properties. + * Purpose: Copies the log-specific file access properties. * - * Return: Success: Ptr to a new property list - * Failure: NULL + * Return: Success: Ptr to a new property list + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -420,14 +420,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_fapl_free + * Function: H5FD_log_fapl_free * - * Purpose: Frees the log-specific file access properties. + * Purpose: Frees the log-specific file access properties. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, April 20, 2000 * *------------------------------------------------------------------------- @@ -435,7 +435,7 @@ done: static herr_t H5FD_log_fapl_free(void *_fa) { - H5FD_log_fapl_t *fa = (H5FD_log_fapl_t*)_fa; + H5FD_log_fapl_t *fa = (H5FD_log_fapl_t*)_fa; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_fapl_free) @@ -449,16 +449,16 @@ H5FD_log_fapl_free(void *_fa) /*------------------------------------------------------------------------- - * Function: H5FD_log_open + * Function: H5FD_log_open * - * Purpose: Create and/or opens a Unix file as an HDF5 file. + * Purpose: Create and/or opens a Unix file as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). - * Failure: NULL + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -466,12 +466,12 @@ H5FD_log_fapl_free(void *_fa) static H5FD_t * H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_log_t *file = NULL; + H5FD_log_t *file = NULL; H5P_genplist_t *plist; /* Property list */ - H5FD_log_fapl_t *fa; /* File access property list information */ - int fd = (-1); /* File descriptor */ - int o_flags; /* Flags for open() call */ -#ifdef _WIN32 + H5FD_log_fapl_t *fa; /* File access property list information */ + int fd = (-1); /* File descriptor */ + int o_flags; /* Flags for open() call */ +#ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif @@ -480,8 +480,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) struct timeval open_timeval_diff; struct timeval stat_timeval_diff; #endif /* H5_HAVE_GETTIMEOFDAY */ - h5_stat_t sb; - H5FD_t *ret_value; /* Return value */ + h5_stat_t sb; + H5FD_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_log_open) @@ -568,12 +568,12 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_ASSIGN_OVERFLOW(file->eof, sb.st_size, h5_stat_size_t, haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; #ifdef H5_VMS file->inode[0] = sb.st_ino[0]; @@ -583,7 +583,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->inode = sb.st_ino; #endif /*H5_VMS*/ -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Retain a copy of the name used to open the file, for possible error reporting */ HDstrncpy(file->filename, name, sizeof(file->filename)); @@ -652,14 +652,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_close + * Function: H5FD_log_close * - * Purpose: Closes a Unix file. + * Purpose: Closes a Unix file. * - * Return: Success: 0 - * Failure: -1, file not closed. + * Return: Success: 0 + * Failure: -1, file not closed. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -667,7 +667,7 @@ done: static herr_t H5FD_log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; #ifdef H5_HAVE_GETTIMEOFDAY struct timeval timeval_start, timeval_stop; #endif /* H5_HAVE_GETTIMEOFDAY */ @@ -800,16 +800,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_cmp + * Function: H5FD_log_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() - * Failure: never fails (arguments were checked by the - * caller). + * Return: Success: A value like strcmp() + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -817,13 +817,13 @@ done: static int H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; - const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; + const H5FD_log_t *f1 = (const H5FD_log_t *)_f1; + const H5FD_log_t *f2 = (const H5FD_log_t *)_f2; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_cmp) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if(f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if(f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -859,15 +859,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_query + * Function: H5FD_log_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- @@ -875,7 +875,7 @@ done: static herr_t H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_query) @@ -898,14 +898,14 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_log_alloc + * Function: H5FD_log_alloc * - * Purpose: Allocate file memory. + * Purpose: Allocate file memory. * - * Return: Success: Address of new memory - * Failure: HADDR_UNDEF + * Return: Success: Address of new memory + * Failure: HADDR_UNDEF * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, April 17, 2000 * *------------------------------------------------------------------------- @@ -914,7 +914,7 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t size) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; haddr_t addr; haddr_t ret_value; /* Return value */ @@ -952,16 +952,16 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eoa + * Function: H5FD_log_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: Success: The end-of-address marker. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * *------------------------------------------------------------------------- @@ -969,7 +969,7 @@ H5FD_log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, hsize_t siz static haddr_t H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_get_eoa) @@ -978,16 +978,16 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) /*------------------------------------------------------------------------- - * Function: H5FD_log_set_eoa + * Function: H5FD_log_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -995,7 +995,7 @@ H5FD_log_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) static herr_t H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_set_eoa) @@ -1006,18 +1006,18 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_log_get_eof + * Function: H5FD_log_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Unix end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Unix end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. - * Failure: HADDR_UNDEF + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -1025,7 +1025,7 @@ H5FD_log_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) static haddr_t H5FD_log_get_eof(const H5FD_t *_file) { - const H5FD_log_t *file = (const H5FD_log_t *)_file; + const H5FD_log_t *file = (const H5FD_log_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_log_get_eof) @@ -1065,17 +1065,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_read + * Function: H5FD_log_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. - * Failure: -1, Contents of buffer BUF are undefined. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. + * Failure: -1, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -1083,10 +1083,10 @@ done: /* ARGSUSED */ static herr_t H5FD_log_read(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { - H5FD_log_t *file = (H5FD_log_t *)_file; - ssize_t nbytes; + H5FD_log_t *file = (H5FD_log_t *)_file; + ssize_t nbytes; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; #ifdef H5_HAVE_GETTIMEOFDAY @@ -1253,16 +1253,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_write + * Function: H5FD_log_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero - * Failure: -1 + * Return: Success: Zero + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -1270,10 +1270,10 @@ done: /* ARGSUSED */ static herr_t H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_log_t *file = (H5FD_log_t *)_file; - ssize_t nbytes; + H5FD_log_t *file = (H5FD_log_t *)_file; + ssize_t nbytes; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; #ifdef H5_HAVE_GETTIMEOFDAY @@ -1446,15 +1446,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_log_truncate + * Function: H5FD_log_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -1463,7 +1463,7 @@ done: static herr_t H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_log_t *file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_log_truncate) @@ -1472,7 +1472,7 @@ H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) /* Extend the file to make sure it's large enough */ if(!H5F_addr_eq(file->eoa, file->eof)) { -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ @@ -1485,7 +1485,7 @@ H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle) == 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ #ifdef H5_VMS /* Reset seek offset to the beginning of the file, so that the file isn't * re-extended later. This may happen on Open VMS. */ @@ -1495,7 +1495,7 @@ H5FD_log_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Log information about the truncate */ if(file->fa.flags & H5FD_LOG_NUM_TRUNCATE) diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index 7ca38cc..558c709 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -17,7 +17,7 @@ * Programmer: Quincey Koziol * Thursday, July 11, 2002 * - * Purpose: This is a "combination" MPI-2 and posix I/O driver. + * Purpose: This is a "combination" MPI-2 and posix I/O driver. * It uses MPI for coordinating the actions of several processes * and posix I/O calls to do the actual I/O to the disk. * @@ -34,17 +34,17 @@ */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_mpiposix_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_mpiposix_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ /* Features: @@ -72,9 +72,9 @@ static hid_t H5FD_MPIPOSIX_g = 0; /* File operations */ -#define OP_UNKNOWN 0 -#define OP_READ 1 -#define OP_WRITE 2 +#define OP_UNKNOWN 0 +#define OP_READ 1 +#define OP_WRITE 2 /* * The description of a file belonging to this driver. @@ -84,31 +84,31 @@ static hid_t H5FD_MPIPOSIX_g = 0; * doesn't bother to keep it updated since it's an expensive operation. */ typedef struct H5FD_mpiposix_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file handle */ - MPI_Comm comm; /*communicator */ + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file handle */ + MPI_Comm comm; /*communicator */ int mpi_rank; /* This process's rank */ int mpi_size; /* Total number of processes */ - haddr_t eof; /*end-of-file marker */ - haddr_t eoa; /*end-of-address marker */ - haddr_t last_eoa; /* Last known end-of-address marker */ - haddr_t pos; /* Current file I/O position */ - int op; /* Last file I/O operation */ - hsize_t naccess; /* Number of (write) accesses to file */ + haddr_t eof; /*end-of-file marker */ + haddr_t eoa; /*end-of-address marker */ + haddr_t last_eoa; /* Last known end-of-address marker */ + haddr_t pos; /* Current file I/O position */ + int op; /* Last file I/O operation */ + hsize_t naccess; /* Number of (write) accesses to file */ #ifdef H5_HAVE_GPFS size_t blksize; /* Block size of file system */ #endif hbool_t use_gpfs; /* Use GPFS to write things */ -#ifndef _WIN32 +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -126,59 +126,59 @@ typedef struct H5FD_mpiposix_t { * some macros here so we don't have to have conditional compilations later * throughout the code. * - * file_offset_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. + * file_offset_t: The datatype for file offsets, the second argument of + * the lseek() or lseek64() call. * - * file_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). + * file_seek: The function which adjusts the current file position, + * either lseek() or lseek64(). */ /* adding for windows NT file system support. */ #ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -# define file_truncate ftruncate64 -#elif defined (_WIN32) +# define file_offset_t off64_t +# define file_seek lseek64 +# define file_truncate ftruncate64 +#elif defined (H5_HAVE_WIN32_API) # /*MSVC*/ # define file_offset_t __int64 # define file_seek _lseeki64 -# define file_truncate _ftruncatei64 +# define file_truncate _ftruncatei64 #else -# define file_offset_t off_t -# define file_seek HDlseek -# define file_truncate HDftruncate +# define file_offset_t off_t +# define file_seek HDlseek +# define file_truncate HDftruncate #endif /* * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - sizeof(file_offset_t) + * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -326,43 +326,43 @@ H5FD_mpiposix_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_mpiposix + * Function: H5Pset_fapl_mpiposix * - * Purpose: Store the user supplied MPI communicator COMM in - * the file access property list FAPL_ID which can then be used - * to create and/or open the file. This function is available - * only in the parallel HDF5 library and is not collective. + * Purpose: Store the user supplied MPI communicator COMM in + * the file access property list FAPL_ID which can then be used + * to create and/or open the file. This function is available + * only in the parallel HDF5 library and is not collective. * - * comm is the MPI communicator to be used for file open as - * defined in MPI_FILE_OPEN of MPI-2. This function makes a - * duplicate of comm. Any modification to comm after this function - * call returns has no effect on the access property list. + * comm is the MPI communicator to be used for file open as + * defined in MPI_FILE_OPEN of MPI-2. This function makes a + * duplicate of comm. Any modification to comm after this function + * call returns has no effect on the access property list. * * If fapl_id has previously set comm value, it will be replaced * and the old communicator is freed. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol - * Thursday, July 11, 2002 + * Programmer: Quincey Koziol + * Thursday, July 11, 2002 * * Modifications: - * Albert Cheng, 2003-04-24 - * Modified the description of the function that it now stores - * a duplicate of the communicator. Free the old duplicate if - * previously set. (Work is actually done by H5P_set_driver.) + * Albert Cheng, 2003-04-24 + * Modified the description of the function that it now stores + * a duplicate of the communicator. Free the old duplicate if + * previously set. (Work is actually done by H5P_set_driver.) * - * Bill Wendling, 2003-05-01 - * Modified to take an extra flag indicating that we should - * use the GPFS hints (if available) for this file. + * Bill Wendling, 2003-05-01 + * Modified to take an extra flag indicating that we should + * use the GPFS hints (if available) for this file. * *------------------------------------------------------------------------- */ herr_t H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs) { - H5FD_mpiposix_fapl_t fa; + H5FD_mpiposix_fapl_t fa; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; @@ -373,7 +373,7 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs) if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; @@ -388,29 +388,29 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_fapl_mpiposix + * Function: H5Pget_fapl_mpiposix * - * Purpose: If the file access property list is set to the H5FD_MPIPOSIX - * driver then this function returns a duplicate of the MPI - * communicator through the comm pointer. It is the responsibility - * of the application to free the returned communicator. + * Purpose: If the file access property list is set to the H5FD_MPIPOSIX + * driver then this function returns a duplicate of the MPI + * communicator through the comm pointer. It is the responsibility + * of the application to free the returned communicator. * - * Return: Success: Non-negative with the communicator and - * information returned through the COMM - * argument if non-null. Since it is a duplicate - * of the stored object, future modifications to - * the access property list do not affect it and - * it is the responsibility of the application to - * free it. + * Return: Success: Non-negative with the communicator and + * information returned through the COMM + * argument if non-null. Since it is a duplicate + * of the stored object, future modifications to + * the access property list do not affect it and + * it is the responsibility of the application to + * free it. * - * Failure: Negative + * Failure: Negative * - * Programmer: Quincey Koziol - * Thursday, July 11, 2002 + * Programmer: Quincey Koziol + * Thursday, July 11, 2002 * * Modifications: - * Albert Cheng, 2003-04-24 - * Return duplicate of the stored communicator. + * Albert Cheng, 2003-04-24 + * Return duplicate of the stored communicator. * * Bill Wendling, 2003-05-01 * Return the USE_GPFS flag. @@ -420,9 +420,9 @@ done: herr_t H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/, hbool_t *use_gpfs/*out*/) { - H5FD_mpiposix_fapl_t *fa; + H5FD_mpiposix_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ - int mpi_code; /* mpi return code */ + int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL) @@ -437,8 +437,8 @@ H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/, hbool_t *use_gpfs/*ou /* Get MPI Communicator */ if (comm){ - if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) + if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } if (use_gpfs) @@ -450,32 +450,32 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_fapl_get + * Function: H5FD_mpiposix_fapl_get * - * Purpose: Returns a file access property list which could be used to - * create another file the same as this one. + * Purpose: Returns a file access property list which could be used to + * create another file the same as this one. * - * Return: Success: Ptr to new file access property list with all - * fields copied from the file pointer. + * Return: Success: Ptr to new file access property list with all + * fields copied from the file pointer. * - * Failure: NULL + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: - * Albert Cheng, 2003-04-24 - * Duplicate the communicator object so that the new - * property list is insulated from the old one. + * Albert Cheng, 2003-04-24 + * Duplicate the communicator object so that the new + * property list is insulated from the old one. * *------------------------------------------------------------------------- */ static void * H5FD_mpiposix_fapl_get(H5FD_t *_file) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; H5FD_mpiposix_fapl_t *fa = NULL; - int mpi_code; /* MPI return code */ + int mpi_code; /* MPI return code */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_get, NULL) @@ -488,7 +488,7 @@ H5FD_mpiposix_fapl_get(H5FD_t *_file) /* Duplicate the communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(file->comm, &fa->comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) fa->use_gpfs = file->use_gpfs; @@ -501,15 +501,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_fapl_copy + * Function: H5FD_mpiposix_fapl_copy * - * Purpose: Copies the mpiposix-specific file access properties. + * Purpose: Copies the mpiposix-specific file access properties. * - * Return: Success: Ptr to a new property list + * Return: Success: Ptr to a new property list * - * Failure: NULL + * Failure: NULL * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * Apr 24, 2003 * * Modifications: @@ -519,10 +519,10 @@ done: static void * H5FD_mpiposix_fapl_copy(const void *_old_fa) { - void *ret_value = NULL; + void *ret_value = NULL; const H5FD_mpiposix_fapl_t *old_fa = (const H5FD_mpiposix_fapl_t*)_old_fa; - H5FD_mpiposix_fapl_t *new_fa = NULL; - int mpi_code; /* MPI return code */ + H5FD_mpiposix_fapl_t *new_fa = NULL; + int mpi_code; /* MPI return code */ FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_copy, NULL) @@ -534,16 +534,16 @@ H5FD_mpiposix_fapl_copy(const void *_old_fa) /* Duplicate communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(old_fa->comm, &new_fa->comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) new_fa->use_gpfs = old_fa->use_gpfs; ret_value = new_fa; done: if (NULL == ret_value){ - /* cleanup */ - if (new_fa) - H5MM_xfree(new_fa); + /* cleanup */ + if (new_fa) + H5MM_xfree(new_fa); } FUNC_LEAVE_NOAPI(ret_value) @@ -551,15 +551,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_fapl_free + * Function: H5FD_mpiposix_fapl_free * - * Purpose: Frees the mpiposix-specific file access properties. + * Purpose: Frees the mpiposix-specific file access properties. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * Apr 24, 2003 * * Modifications: @@ -569,8 +569,8 @@ done: static herr_t H5FD_mpiposix_fapl_free(void *_fa) { - herr_t ret_value = SUCCEED; - H5FD_mpiposix_fapl_t *fa = (H5FD_mpiposix_fapl_t*)_fa; + herr_t ret_value = SUCCEED; + H5FD_mpiposix_fapl_t *fa = (H5FD_mpiposix_fapl_t*)_fa; FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_free, FAIL) assert(fa); @@ -589,11 +589,11 @@ done: * Function: H5FD_mpiposix_open * * Purpose: Opens a file with name NAME. The FLAGS are a bit field with - * purpose similar to the second argument of open(2) and which - * are defined in H5Fpublic.h. The file access property list - * FAPL_ID contains the properties driver properties and MAXADDR - * is the largest address which this file will be expected to - * access. This is collective. + * purpose similar to the second argument of open(2) and which + * are defined in H5Fpublic.h. The file access property list + * FAPL_ID contains the properties driver properties and MAXADDR + * is the largest address which this file will be expected to + * access. This is collective. * * Return: Success: A new file pointer. * Failure: NULL @@ -602,27 +602,27 @@ done: * Thursday, July 11, 2002 * * Modifications: - * Albert Cheng, 2003-04-24 - * Duplicate the communicator so that file is insulated from the - * old one. + * Albert Cheng, 2003-04-24 + * Duplicate the communicator so that file is insulated from the + * old one. * *------------------------------------------------------------------------- */ static H5FD_t * H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr) + haddr_t maxaddr) { - H5FD_mpiposix_t *file=NULL; /* New MPIPOSIX file struct */ + H5FD_mpiposix_t *file=NULL; /* New MPIPOSIX file struct */ int o_flags; /* Flags for file open call */ - int fd=(-1); /* File handle for file opened */ - int mpi_rank; /* MPI rank of this process */ - int mpi_size; /* Total number of MPI processes */ - int mpi_code; /* mpi return code */ - const H5FD_mpiposix_fapl_t *fa=NULL; /* MPIPOSIX file access property list information */ - H5FD_mpiposix_fapl_t _fa; /* Private copy of default file access property list information */ + int fd=(-1); /* File handle for file opened */ + int mpi_rank; /* MPI rank of this process */ + int mpi_size; /* Total number of MPI processes */ + int mpi_code; /* mpi return code */ + const H5FD_mpiposix_fapl_t *fa=NULL; /* MPIPOSIX file access property list information */ + H5FD_mpiposix_fapl_t _fa; /* Private copy of default file access property list information */ H5P_genplist_t *plist; /* Property list pointer */ h5_stat_t sb; /* Portable 'stat' struct */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; int results; @@ -644,18 +644,18 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MPIPOSIX!=H5P_get_driver(plist)) { - _fa.comm = MPI_COMM_SELF; /*default*/ + _fa.comm = MPI_COMM_SELF; /*default*/ _fa.use_gpfs = FALSE; - fa = &_fa; + fa = &_fa; } /* end if */ else { - fa = H5P_get_driver_info(plist); - assert(fa); + fa = H5P_get_driver_info(plist); + assert(fa); } /* end else */ /* Duplicate the communicator for use by this file. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_dup))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) /* Get the MPI rank of this process and the total number of processes */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (comm_dup, &mpi_rank))) @@ -756,7 +756,7 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, file->fd = fd; file->eof = sb.st_size; - /* for _WIN32 support. _WIN32 'stat' does not have st_blksize and st_blksize + /* for H5_HAVE_WIN32_API support. H5_HAVE_WIN32_API 'stat' does not have st_blksize and st_blksize is only used for the H5_HAVE_GPFS case */ #ifdef H5_HAVE_GPFS file->blksize = sb.st_blksize; @@ -775,7 +775,7 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, file->op = OP_UNKNOWN; /* Set the information for the file's device and inode */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); results = GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; @@ -794,8 +794,8 @@ done: /* Close the file if it was left open */ if(fd!=(-1)) HDclose(fd); - if (MPI_COMM_NULL != comm_dup) - MPI_Comm_free(&comm_dup); + if (MPI_COMM_NULL != comm_dup) + MPI_Comm_free(&comm_dup); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -807,21 +807,21 @@ done: * * Purpose: Closes a file. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: - * Albert Cheng, 2003-04-24 - * Free the communicator stored. + * Albert Cheng, 2003-04-24 + * Free the communicator stored. *------------------------------------------------------------------------- */ static herr_t H5FD_mpiposix_close(H5FD_t *_file) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_close, FAIL) @@ -845,16 +845,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_cmp + * Function: H5FD_mpiposix_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() - * Failure: never fails (arguments were checked by the - * caller). + * Return: Success: A value like strcmp() + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -864,13 +864,13 @@ done: static int H5FD_mpiposix_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_mpiposix_t *f1 = (const H5FD_mpiposix_t*)_f1; - const H5FD_mpiposix_t *f2 = (const H5FD_mpiposix_t*)_f2; + const H5FD_mpiposix_t *f1 = (const H5FD_mpiposix_t*)_f1; + const H5FD_mpiposix_t *f2 = (const H5FD_mpiposix_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_mpiposix_cmp, H5FD_VFD_DEFAULT) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -900,15 +900,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_query + * Function: H5FD_mpiposix_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -916,8 +916,8 @@ done: * John Mainzer -- 9/21/05 * Modified code to turn off the * H5FD_FEAT_ACCUMULATE_METADATA_WRITE flag. - * With the movement of all cache writes to process 0, - * this flag has become problematic in PHDF5. + * With the movement of all cache writes to process 0, + * this flag has become problematic in PHDF5. * *------------------------------------------------------------------------- */ @@ -941,16 +941,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_get_eoa + * Function: H5FD_mpiposix_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: Success: The end-of-address marker. + * Failure: HADDR_UNDEF * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -980,16 +980,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_set_eoa + * Function: H5FD_mpiposix_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1002,7 +1002,7 @@ done: static herr_t H5FD_mpiposix_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_set_eoa, FAIL) @@ -1018,21 +1018,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_get_eof + * Function: H5FD_mpiposix_get_eof * - * Purpose: Gets the end-of-file marker for the file. The EOF marker - * is the real size of the file. + * Purpose: Gets the end-of-file marker for the file. The EOF marker + * is the real size of the file. * - * The MPIPOSIX driver doesn't bother keeping this field updated - * since that's a relatively expensive operation. Fortunately - * the library only needs the EOF just after the file is opened - * in order to determine whether the file is empty, truncated, - * or okay. + * The MPIPOSIX driver doesn't bother keeping this field updated + * since that's a relatively expensive operation. Fortunately + * the library only needs the EOF just after the file is opened + * in order to determine whether the file is empty, truncated, + * or okay. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: Success: The end-of-address marker. + * Failure: HADDR_UNDEF * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1042,7 +1042,7 @@ done: static haddr_t H5FD_mpiposix_get_eof(const H5FD_t *_file) { - const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; + const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eof, HADDR_UNDEF) @@ -1091,21 +1091,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_read + * Function: H5FD_mpiposix_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID using potentially complex file and buffer types to - * effect the transfer. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID using potentially complex file and buffer types to + * effect the transfer. * - * Reading past the end of the file returns zeros instead of - * failing. + * Reading past the end of the file returns zeros instead of + * failing. * - * Return: Success: Non-negative. Result is stored in caller-supplied - * buffer BUF. - * Failure: Negative, Contents of buffer BUF are undefined. + * Return: Success: Non-negative. Result is stored in caller-supplied + * buffer BUF. + * Failure: Negative, Contents of buffer BUF are undefined. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1114,11 +1114,11 @@ done: */ static herr_t H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, - void *buf/*out*/) + void *buf/*out*/) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; - ssize_t nbytes; /* Number of bytes read each I/O call */ - herr_t ret_value=SUCCEED; + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; + ssize_t nbytes; /* Number of bytes read each I/O call */ + herr_t ret_value=SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_read, FAIL) @@ -1187,17 +1187,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_write + * Function: H5FD_mpiposix_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID using potentially complex file and buffer types to - * effect the transfer. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID using potentially complex file and buffer types to + * effect the transfer. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1212,15 +1212,15 @@ done: */ static herr_t H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; #if 0 /* JRM */ - int mpi_code; /* MPI return code */ + int mpi_code; /* MPI return code */ #endif /* JRM */ - ssize_t nbytes; /* Number of bytes written each I/O call */ + ssize_t nbytes; /* Number of bytes written each I/O call */ H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_mpiposix_write, FAIL) @@ -1249,10 +1249,10 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, * writes between processes, but we should really just flag an error * whenever any process other than process 0 attempts to write * metadata. - * -- JRM 9/1/05 + * -- JRM 9/1/05 */ if(type!=H5FD_MEM_DRAW) { - unsigned block_before_meta_write=0; /* Whether to block before a metadata write */ + unsigned block_before_meta_write=0; /* Whether to block before a metadata write */ /* Check if we need to syncronize all processes before attempting metadata write * (Prevents race condition where the process writing the metadata goes ahead @@ -1350,11 +1350,11 @@ done: } /* end if */ #if 0 /* JRM */ /* Since metadata writes are now done by process 0 only, this broadcast - * is no longer needed. I leave it in and commented out to remind us - * that we need to re-work this function to reflect this reallity. - * - * -- JRM 9/1/05 - */ + * is no longer needed. I leave it in and commented out to remind us + * that we need to re-work this function to reflect this reallity. + * + * -- JRM 9/1/05 + */ /* Guard against getting into metadata broadcast in failure cases */ else { @@ -1373,11 +1373,11 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol * Thursday, July 11, 2002 @@ -1387,12 +1387,12 @@ done: static herr_t H5FD_mpiposix_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; -#ifdef _WIN32 + H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ -#endif /* _WIN32 */ - int mpi_code; /* MPI return code */ +#endif /* H5_HAVE_WIN32_API */ + int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5FD_mpiposix_truncate, FAIL) @@ -1404,7 +1404,7 @@ H5FD_mpiposix_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closi if(file->eoa > file->last_eoa) { /* Use the round-robin process to truncate (extend) the file */ if(file->mpi_rank == H5_PAR_META_WRITE) { -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API /* Map the posix file handle to a Windows file handle */ filehandle = _get_osfhandle(file->fd); @@ -1414,10 +1414,10 @@ H5FD_mpiposix_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closi SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle) == 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ if(-1==file_truncate(file->fd, (file_offset_t)file->eoa)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ } /* end if */ /* Don't let any proc return until all have extended the file. @@ -1444,14 +1444,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_mpi_rank + * Function: H5FD_mpiposix_mpi_rank * - * Purpose: Returns the MPI rank for a process + * Purpose: Returns the MPI rank for a process * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1478,14 +1478,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_mpi_size + * Function: H5FD_mpiposix_mpi_size * - * Purpose: Returns the number of MPI processes + * Purpose: Returns the number of MPI processes * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: @@ -1512,15 +1512,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_communicator + * Function: H5FD_mpiposix_communicator * - * Purpose: Returns the MPI communicator for the file. + * Purpose: Returns the MPI communicator for the file. * - * Return: Success: The communicator + * Return: Success: The communicator * - * Failure: NULL + * Failure: NULL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, July 11, 2002 * * Modifications: diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 5b9b22b..14598d2 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -17,27 +17,27 @@ * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Purpose: The POSIX unbuffered file driver using only the HDF5 public - * API and with a few optimizations: the lseek() call is made - * only when the current file position is unknown or needs to be - * changed based on previous I/O through this driver (don't mix - * I/O from this driver with I/O from other parts of the - * application to the same file). + * Purpose: The POSIX unbuffered file driver using only the HDF5 public + * API and with a few optimizations: the lseek() call is made + * only when the current file position is unknown or needs to be + * changed based on previous I/O through this driver (don't mix + * I/O from this driver with I/O from other parts of the + * application to the same file). */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_sec2_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDsec2.h" /* Sec2 file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDsec2.h" /* Sec2 file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* The driver identification number, initialized at runtime */ static hid_t H5FD_SEC2_g = 0; @@ -55,27 +55,27 @@ static hid_t H5FD_SEC2_g = 0; * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_sec2_t { - H5FD_t pub; /*public stuff, must be first */ - int fd; /*the unix file */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - H5FD_file_op_t op; /*last operation */ - char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ -#ifndef _WIN32 + H5FD_t pub; /*public stuff, must be first */ + int fd; /*the unix file */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + H5FD_file_op_t op; /*last operation */ + char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ + dev_t device; /*file device number */ #ifdef H5_VMS - ino_t inode[3]; /*file i-node number */ + ino_t inode[3]; /*file i-node number */ #else - ino_t inode; /*file i-node number */ + ino_t inode; /*file i-node number */ #endif /*H5_VMS*/ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -98,8 +98,8 @@ typedef struct H5FD_sec2_t { * some macros here so we don't have to have conditional compilations later * throughout the code. * - * HDoff_t: The datatype for file offsets, the second argument of - * the lseek() or lseek64() call. + * HDoff_t: The datatype for file offsets, the second argument of + * the lseek() or lseek64() call. * */ @@ -107,28 +107,28 @@ typedef struct H5FD_sec2_t { * These macros check for overflow of various quantities. These macros * assume that HDoff_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(HDoff_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (HDoff_t)((A)+(Z))<(HDoff_t)(A)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ + ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (HDoff_t)((A)+(Z))<(HDoff_t)(A)) /* Prototypes */ static H5FD_t *H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_sec2_close(H5FD_t *_file); static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_sec2_query(const H5FD_t *_f1, unsigned long *flags); @@ -137,43 +137,43 @@ static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file); static herr_t H5FD_sec2_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_sec2_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_sec2_g = { - "sec2", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_sec2_open, /*open */ - H5FD_sec2_close, /*close */ - H5FD_sec2_cmp, /*cmp */ - H5FD_sec2_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_sec2_get_eoa, /*get_eoa */ - H5FD_sec2_set_eoa, /*set_eoa */ - H5FD_sec2_get_eof, /*get_eof */ + "sec2", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_sec2_open, /*open */ + H5FD_sec2_close, /*close */ + H5FD_sec2_cmp, /*cmp */ + H5FD_sec2_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_sec2_get_eoa, /*get_eoa */ + H5FD_sec2_set_eoa, /*set_eoa */ + H5FD_sec2_get_eof, /*get_eof */ H5FD_sec2_get_handle, /*get_handle */ - H5FD_sec2_read, /*read */ - H5FD_sec2_write, /*write */ - NULL, /*flush */ - H5FD_sec2_truncate, /*truncate */ + H5FD_sec2_read, /*read */ + H5FD_sec2_write, /*write */ + NULL, /*flush */ + H5FD_sec2_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /* Declare a free list to manage the H5FD_sec2_t struct */ @@ -203,15 +203,15 @@ H5FD_sec2_init_interface(void) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_init + * Function: H5FD_sec2_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the sec2 driver. - * Failure: Negative. + * Return: Success: The driver ID for the sec2 driver. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -235,11 +235,11 @@ done: /*--------------------------------------------------------------------------- - * Function: H5FD_sec2_term + * Function: H5FD_sec2_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -259,16 +259,16 @@ H5FD_sec2_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_sec2 + * Function: H5Pset_fapl_sec2 * - * Purpose: Modify the file access property list to use the H5FD_SEC2 - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_SEC2 + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * *------------------------------------------------------------------------- */ @@ -292,16 +292,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_open + * Function: H5FD_sec2_open * - * Purpose: Create and/or opens a Unix file as an HDF5 file. + * Purpose: Create and/or opens a Unix file as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). - * Failure: NULL + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -309,15 +309,15 @@ done: static H5FD_t * H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_sec2_t *file = NULL; /* sec2 VFD info */ - int fd = (-1); /* File descriptor */ - int o_flags; /* Flags for open() call */ -#ifdef _WIN32 + H5FD_sec2_t *file = NULL; /* sec2 VFD info */ + int fd = (-1); /* File descriptor */ + int o_flags; /* Flags for open() call */ +#ifdef H5_HAVE_WIN32_API HFILE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - h5_stat_t sb; - H5FD_t *ret_value; /* Return value */ + h5_stat_t sb; + H5FD_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_open) @@ -358,12 +358,12 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_ASSIGN_OVERFLOW(file->eof, sb.st_size, h5_stat_size_t, haddr_t); file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API filehandle = _get_osfhandle(fd); (void)GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ file->device = sb.st_dev; #ifdef H5_VMS file->inode[0] = sb.st_ino[0]; @@ -373,7 +373,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->inode = sb.st_ino; #endif /*H5_VMS*/ -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Retain a copy of the name used to open the file, for possible error reporting */ HDstrncpy(file->filename, name, sizeof(file->filename)); @@ -413,14 +413,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_close + * Function: H5FD_sec2_close * - * Purpose: Closes a Unix file. + * Purpose: Closes a Unix file. * - * Return: Success: 0 - * Failure: -1, file not closed. + * Return: Success: 0 + * Failure: -1, file not closed. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -428,7 +428,7 @@ done: static herr_t H5FD_sec2_close(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_close) @@ -449,16 +449,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_cmp + * Function: H5FD_sec2_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() - * Failure: never fails (arguments were checked by the - * caller). + * Return: Success: A value like strcmp() + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -466,13 +466,13 @@ done: static int H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; - const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; + const H5FD_sec2_t *f1 = (const H5FD_sec2_t *)_f1; + const H5FD_sec2_t *f2 = (const H5FD_sec2_t *)_f2; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_cmp) -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if(f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if(f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -508,15 +508,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_query + * Function: H5FD_sec2_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * *------------------------------------------------------------------------- @@ -524,7 +524,7 @@ done: static herr_t H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; /* sec2 VFD info */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_query) @@ -547,16 +547,16 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eoa + * Function: H5FD_sec2_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. - * Failure: HADDR_UNDEF + * Return: Success: The end-of-address marker. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * *------------------------------------------------------------------------- @@ -564,7 +564,7 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) static haddr_t H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_get_eoa) @@ -573,16 +573,16 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_set_eoa + * Function: H5FD_sec2_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -590,7 +590,7 @@ H5FD_sec2_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) static herr_t H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_set_eoa) @@ -601,18 +601,18 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_sec2_get_eof + * Function: H5FD_sec2_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Unix end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Unix end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. - * Failure: HADDR_UNDEF + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -620,7 +620,7 @@ H5FD_sec2_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) static haddr_t H5FD_sec2_get_eof(const H5FD_t *_file) { - const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; + const H5FD_sec2_t *file = (const H5FD_sec2_t *)_file; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_sec2_get_eof) @@ -660,17 +660,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_read + * Function: H5FD_sec2_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. - * Failure: -1, Contents of buffer BUF are undefined. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. + * Failure: -1, Contents of buffer BUF are undefined. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -680,8 +680,8 @@ static herr_t H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - ssize_t nbytes; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + ssize_t nbytes; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_read) @@ -749,16 +749,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_write + * Function: H5FD_sec2_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero - * Failure: -1 + * Return: Success: Zero + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * *------------------------------------------------------------------------- @@ -766,10 +766,10 @@ done: /* ARGSUSED */ static herr_t H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; - ssize_t nbytes; + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; + ssize_t nbytes; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FD_sec2_write) @@ -833,15 +833,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_sec2_truncate + * Function: H5FD_sec2_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -859,7 +859,7 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) /* Extend the file to make sure it's large enough */ if(!H5F_addr_eq(file->eoa, file->eof)) { -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ @@ -872,7 +872,7 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle) == 0) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ #ifdef H5_VMS /* Reset seek offset to the beginning of the file, so that the file isn't * re-extended later. This may happen on Open VMS. */ @@ -882,7 +882,7 @@ H5FD_sec2_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) if(-1 == HDftruncate(file->fd, (HDoff_t)file->eoa)) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Update the eof value */ file->eof = file->eoa; diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 9bc4161..8e970c6 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -14,12 +14,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * - * Purpose: This is the Posix stdio.h I/O subclass of H5Flow. - * It also serves as an example of coding a simple file driver, - * therefore, it should not use any non-public definitions. + * Purpose: This is the Posix stdio.h I/O subclass of H5Flow. + * It also serves as an example of coding a simple file driver, + * therefore, it should not use any non-public definitions. * * Notes: Ported to the new H5FD architecture on 10/18/99 - QAK * @@ -43,7 +43,7 @@ #include #endif -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #include #include @@ -58,7 +58,7 @@ #ifdef MAX #undef MAX #endif /* MAX */ -#define MAX(X,Y) ((X)>(Y)?(X):(Y)) +#define MAX(X,Y) ((X)>(Y)?(X):(Y)) /* The driver identification number, initialized at runtime */ static hid_t H5FD_STDIO_g = 0; @@ -84,23 +84,23 @@ typedef enum { * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_stdio_t { - H5FD_t pub; /*public stuff, must be first */ - FILE * fp; /*the file handle */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - H5FD_stdio_file_op op; /*last operation */ + H5FD_t pub; /*public stuff, must be first */ + FILE * fp; /*the file handle */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + H5FD_stdio_file_op op; /*last operation */ unsigned write_access; /* Flag to indicate the file was opened with write access */ -#ifndef _WIN32 +#ifndef H5_HAVE_WIN32_API /* * On most systems the combination of device and i-node number uniquely * identify a file. */ - dev_t device; /*file device number */ - ino_t inode; /*file i-node number */ + dev_t device; /*file device number */ + ino_t inode; /*file i-node number */ #else /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * (which, both? -rpm) may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -114,18 +114,11 @@ typedef struct H5FD_stdio_t { } H5FD_stdio_t; /* Use similar structure as in H5private.h by defining Windows stuff first. */ -#ifdef _WIN32 - #if _MSC_VER > 1310 /* Newer than VS.NET 2003 */ - # define file_fseek _fseeki64 - # define file_offset_t __int64 - # define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ - # define file_ftell _ftelli64 - #else - # define file_fseek fseek - # define file_offset_t long - # define file_ftruncate _chsize - # define file_ftell ftell - #endif +#ifdef H5_HAVE_WIN32_API + # define file_fseek _fseeki64 + # define file_offset_t __int64 + # define file_ftruncate _chsize_s /* Supported in VS 2005 or newer */ + # define file_ftell _ftelli64 #endif /* Use file_xxx to indicate these are local macros, avoiding confusing @@ -135,15 +128,15 @@ typedef struct H5FD_stdio_t { */ #ifndef file_fseek #ifdef H5_HAVE_FSEEKO64 - # define file_fseek fseeko64 - # define file_offset_t off64_t - # define file_ftruncate ftruncate64 - # define file_ftell ftello64 + # define file_fseek fseeko64 + # define file_offset_t off64_t + # define file_ftruncate ftruncate64 + # define file_ftell ftello64 #else - # define file_fseek fseeko - # define file_offset_t off_t - # define file_ftruncate ftruncate - # define file_ftell ftello + # define file_fseek fseeko + # define file_offset_t off_t + # define file_ftruncate ftruncate + # define file_ftell ftello #endif #endif @@ -151,22 +144,22 @@ typedef struct H5FD_stdio_t { * These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ /* adding for windows NT filesystem support. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A)) /* Prototypes */ @@ -188,51 +181,51 @@ static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_stdio_g = { - "stdio", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_stdio_open, /*open */ - H5FD_stdio_close, /*close */ - H5FD_stdio_cmp, /*cmp */ - H5FD_stdio_query, /*query */ - NULL, /*get_type_map */ - H5FD_stdio_alloc, /*alloc */ - NULL, /*free */ - H5FD_stdio_get_eoa, /*get_eoa */ - H5FD_stdio_set_eoa, /*set_eoa */ - H5FD_stdio_get_eof, /*get_eof */ + "stdio", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_stdio_open, /*open */ + H5FD_stdio_close, /*close */ + H5FD_stdio_cmp, /*cmp */ + H5FD_stdio_query, /*query */ + NULL, /*get_type_map */ + H5FD_stdio_alloc, /*alloc */ + NULL, /*free */ + H5FD_stdio_get_eoa, /*get_eoa */ + H5FD_stdio_set_eoa, /*set_eoa */ + H5FD_stdio_get_eof, /*get_eof */ H5FD_stdio_get_handle, /*get_handle */ - H5FD_stdio_read, /*read */ - H5FD_stdio_write, /*write */ - H5FD_stdio_flush, /*flush */ - H5FD_stdio_truncate, /*truncate */ + H5FD_stdio_read, /*read */ + H5FD_stdio_write, /*write */ + H5FD_stdio_flush, /*flush */ + H5FD_stdio_truncate, /*truncate */ NULL, /*lock */ NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /*------------------------------------------------------------------------- - * Function: H5FD_stdio_init + * Function: H5FD_stdio_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the stdio driver. + * Return: Success: The driver ID for the stdio driver. * - * Failure: Negative. + * Failure: Negative. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -253,11 +246,11 @@ H5FD_stdio_init(void) /*--------------------------------------------------------------------------- - * Function: H5FD_stdio_term + * Function: H5FD_stdio_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Quincey Koziol * Friday, Jan 30, 2004 @@ -276,16 +269,16 @@ H5FD_stdio_term(void) /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_stdio + * Function: H5Pset_fapl_stdio * - * Purpose: Modify the file access property list to use the H5FD_STDIO - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_STDIO + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 + * Programmer: Robb Matzke + * Thursday, February 19, 1998 * * Modifications: * Stolen from the sec2 driver - QAK, 10/18/99 @@ -310,27 +303,27 @@ H5Pset_fapl_stdio(hid_t fapl_id) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_open + * Function: H5FD_stdio_open * - * Purpose: Create and/or opens a Standard C file as an HDF5 file. + * Purpose: Create and/or opens a Standard C file as an HDF5 file. * - * Bugs: H5F_ACC_EXCL has a race condition. (? -QAK) + * Bugs: H5F_ACC_EXCL has a race condition. (? -QAK) * * 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: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 @@ -341,17 +334,17 @@ static H5FD_t * H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - FILE *f = NULL; + FILE *f = NULL; unsigned write_access=0; /* File opened with write access? */ - H5FD_stdio_t *file=NULL; + H5FD_stdio_t *file=NULL; static const char *func="H5FD_stdio_open"; /* Function Name for error reporting */ -#ifdef _WIN32 - HFILE filehandle; - struct _BY_HANDLE_FILE_INFORMATION fileinfo; +#ifdef H5_HAVE_WIN32_API + HFILE filehandle; + struct _BY_HANDLE_FILE_INFORMATION fileinfo; int fd; -#else /* _WIN32 */ - struct stat sb; -#endif /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ + struct stat sb; +#endif /* H5_HAVE_WIN32_API */ /* Sanity check on file offsets */ assert(sizeof(file_offset_t)>=sizeof(size_t)); @@ -409,7 +402,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, } /* The unique key */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API /*#error "Needs correct fileindexhi & fileindexlo, code below is from sec2 driver"*/ fd = _fileno(f); filehandle = _get_osfhandle(fd); @@ -426,17 +419,17 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, /*------------------------------------------------------------------------- - * 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: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: * Ported to VFL/H5FD layer - QAK, 10/18/99 @@ -446,7 +439,7 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id, static herr_t H5FD_stdio_close(H5FD_t *_file) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ @@ -462,17 +455,17 @@ H5FD_stdio_close(H5FD_t *_file) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_cmp + * Function: H5FD_stdio_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -483,13 +476,13 @@ H5FD_stdio_close(H5FD_t *_file) static int H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; - const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; + const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1; + const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API if (f1->fileindexhi < f2->fileindexhi) return -1; if (f1->fileindexhi > f2->fileindexhi) return 1; @@ -517,16 +510,16 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_query + * Function: H5FD_stdio_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, August 25, 2000 * * Modifications: @@ -553,18 +546,18 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long *flags /* out */) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_alloc + * Function: H5FD_stdio_alloc * - * Purpose: Allocates file memory. If fseeko isn't available, makes + * Purpose: Allocates file memory. If fseeko isn't available, makes * sure the file size isn't bigger than 2GB because the * parameter OFFSET of fseek is of the type LONG INT, limiting * the file size to 2GB. * - * Return: Success: Address of new memory + * Return: Success: Address of new memory * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * 30 March 2007 * * Modifications: @@ -574,8 +567,8 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long *flags /* out */) static haddr_t H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, hsize_t size) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; - haddr_t addr; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + haddr_t addr; haddr_t ret_value; /* Return value */ /* Shut compiler up */ @@ -605,17 +598,17 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp /*------------------------------------------------------------------------- - * Function: H5FD_stdio_get_eoa + * Function: H5FD_stdio_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: Success: The end-of-address marker. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, August 2, 1999 * * Modifications: @@ -630,7 +623,7 @@ H5FD_stdio_alloc(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp static haddr_t H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -643,17 +636,17 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_set_eoa + * Function: H5FD_stdio_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -667,7 +660,7 @@ H5FD_stdio_get_eoa(const H5FD_t *_file, H5FD_mem_t /*unused*/ type) static herr_t H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -682,19 +675,19 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5FD_stdio_get_eof + * Function: H5FD_stdio_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Unix end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Unix end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -705,7 +698,7 @@ H5FD_stdio_set_eoa(H5FD_t *_file, H5FD_mem_t /*unused*/ type, haddr_t addr) static haddr_t H5FD_stdio_get_eof(const H5FD_t *_file) { - const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; + const H5FD_stdio_t *file = (const H5FD_stdio_t *)_file; /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -748,24 +741,24 @@ H5FD_stdio_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle) /*------------------------------------------------------------------------- - * 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: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * June 2, 1998 Albert Cheng + * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * @@ -775,8 +768,8 @@ static herr_t H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/) { - size_t n; - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + size_t n; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_read"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -848,23 +841,23 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz /*------------------------------------------------------------------------- - * 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: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * * Modifications: - * June 2, 1998 Albert Cheng - * Added xfer_mode argument + * June 2, 1998 Albert Cheng + * Added xfer_mode argument * * Ported to VFL/H5FD layer - QAK, 10/18/99 * @@ -872,9 +865,9 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, siz */ static herr_t H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func="H5FD_stdio_write"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -931,25 +924,25 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /*------------------------------------------------------------------------- - * 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 SEEKERROR fseek failed. - * IO WRITEERROR fflush or fwrite failed. + * IO SEEKERROR fseek failed. + * IO WRITEERROR fflush or fwrite failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Wednesday, October 22, 1997 + * Programmer: Robb Matzke + * Wednesday, October 22, 1997 * *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -976,29 +969,29 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing) /*------------------------------------------------------------------------- - * Function: H5F_stdio_truncate + * Function: H5F_stdio_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * * Errors: - * IO SEEKERROR fseek failed. - * IO WRITEERROR fflush or fwrite failed. + * IO SEEKERROR fseek failed. + * IO WRITEERROR fflush or fwrite failed. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, January 31, 2008 + * Programmer: Quincey Koziol + * Thursday, January 31, 2008 * * Modifications: - * Vailin Choi; June 2010 - * Fix for window failures manifested from tests in mf.c. + * Vailin Choi; June 2010 + * Fix for window failures manifested from tests in mf.c. *------------------------------------------------------------------------- */ static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_stdio_t *file = (H5FD_stdio_t*)_file; + H5FD_stdio_t *file = (H5FD_stdio_t*)_file; static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Shut compiler up */ @@ -1014,11 +1007,11 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) if(file->eoa != file->eof) { int fd = fileno(file->fp); /* File descriptor for HDF5 file */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API HFILE filehandle; /* Windows file handle */ LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */ - /* Reset seek offset to beginning of file, so that file isn't re-extended later */ + /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Map the posix file handle to a Windows file handle */ @@ -1030,14 +1023,14 @@ H5FD_stdio_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) (void)SetFilePointer((HANDLE)filehandle, li.LowPart, &li.HighPart, FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle) == 0) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#else /* _WIN32 */ +#else /* H5_HAVE_WIN32_API */ /* Reset seek offset to beginning of file, so that file isn't re-extended later */ rewind(file->fp); /* Truncate file to proper length */ if(-1 == file_ftruncate(fd, (file_offset_t)file->eoa)) H5Epush_ret(func, H5E_ERR_CLS, H5E_IO, H5E_SEEKERROR, "unable to truncate/extend file properly", -1) -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* Update the eof value */ file->eof = file->eoa; diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 47c7f2d..ba5bd9b 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -15,32 +15,32 @@ /* * Programmer: Scott Wegner - * Based on code by Robb Matzke - * May 24, 2007 - * - * Purpose: We would like to create a driver specifically for Windows - * to utilize the Win32 API, and reduce the maintenence demands - * for the other file drivers. Our other motivation is that - * the Windows system calls of the existing sec2 driver differ - * from those on other platforms, and are not 64-bit compatible. - * From the start, this will have the structure very similar - * to our sec2 driver, but make system calls more similar to - * our stdio driver. + * Based on code by Robb Matzke + * May 24, 2007 + * + * Purpose: We would like to create a driver specifically for Windows + * to utilize the Win32 API, and reduce the maintenence demands + * for the other file drivers. Our other motivation is that + * the Windows system calls of the existing sec2 driver differ + * from those on other platforms, and are not 64-bit compatible. + * From the start, this will have the structure very similar + * to our sec2 driver, but make system calls more similar to + * our stdio driver. */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5FD_windows_init_interface +#define H5_INTERFACE_INIT_FUNC H5FD_windows_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FDwindows.h" /* Windows file driver */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDwindows.h" /* Windows file driver */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #ifdef H5_HAVE_WINDOWS @@ -48,9 +48,9 @@ static hid_t H5FD_WINDOWS_g = 0; /* File operations */ -#define OP_UNKNOWN 0 -#define OP_READ 1 -#define OP_WRITE 2 +#define OP_UNKNOWN 0 +#define OP_READ 1 +#define OP_WRITE 2 /* * The description of a file belonging to this driver. The `eoa' and `eof' @@ -65,23 +65,23 @@ static hid_t H5FD_WINDOWS_g = 0; * occurs), and `op' will be set to H5F_OP_UNKNOWN. */ typedef struct H5FD_windows_t { - H5FD_t pub; /*public stuff, must be first */ - /* - * .NET doesn't support our 64-bit safe stdio functions, - * so we will use io.h functions instead. + H5FD_t pub; /*public stuff, must be first */ + /* + * .NET doesn't support our 64-bit safe stdio functions, + * so we will use io.h functions instead. */ #ifndef WINDOWS_USE_STDIO - int fd; /*the file descriptor */ + int fd; /*the file descriptor */ #else - FILE *fp; /*the file handle */ + FILE *fp; /*the file handle */ #endif /*MSC_VER */ - haddr_t eoa; /*end of allocated region */ - haddr_t eof; /*end of file; current file size*/ - haddr_t pos; /*current file I/O position */ - int op; /*last operation */ - unsigned write_access; /*flag to indicate the file was opened with write access */ + haddr_t eoa; /*end of allocated region */ + haddr_t eof; /*end of file; current file size*/ + haddr_t pos; /*current file I/O position */ + int op; /*last operation */ + unsigned write_access; /*flag to indicate the file was opened with write access */ /* - * On _WIN32 the low-order word of a unique identifier associated with the + * On H5_HAVE_WIN32_API the low-order word of a unique identifier associated with the * file and the volume serial number uniquely identify a file. This number * may change when the system is restarted or when the * file is opened. After a process opens a file, the identifier is @@ -100,83 +100,83 @@ typedef struct H5FD_windows_t { /* These are used by the macros below */ -#define file_offset_t __int64 -#define fseek_offset_t __int64 +#define file_offset_t __int64 +#define fseek_offset_t __int64 /* * These macros check for overflow of various quantities. These macros * assume that fseek_offset_t is signed and haddr_t and size_t are unsigned. * - * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' - * is too large to be represented by the second argument - * of the file seek function. + * ADDR_OVERFLOW: Checks whether a file address of type `haddr_t' + * is too large to be represented by the second argument + * of the file seek function. * - * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too - * large to be represented by the `size_t' type. + * SIZE_OVERFLOW: Checks whether a buffer size of type `hsize_t' is too + * large to be represented by the `size_t' type. * - * REGION_OVERFLOW: Checks whether an address and size pair describe data - * which can be addressed entirely by the second - * argument of the file seek function. + * REGION_OVERFLOW: Checks whether an address and size pair describe data + * which can be addressed entirely by the second + * argument of the file seek function. */ #define MAXADDR (((haddr_t)1<<(8*sizeof(file_offset_t)-1))-1) -#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ - ((A) & ~(haddr_t)MAXADDR)) -#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) -#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ - HADDR_UNDEF==(A)+(Z) || \ - (fseek_offset_t)((A)+(Z))<(fseek_offset_t)(A)) +#define ADDR_OVERFLOW(A) (HADDR_UNDEF==(A) || \ + ((A) & ~(haddr_t)MAXADDR)) +#define SIZE_OVERFLOW(Z) ((Z) & ~(hsize_t)MAXADDR) +#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \ + HADDR_UNDEF==(A)+(Z) || \ + (fseek_offset_t)((A)+(Z))<(fseek_offset_t)(A)) /* Prototypes */ static H5FD_t *H5FD_windows_open(const char *name, unsigned flags, hid_t fapl_id, - haddr_t maxaddr); + haddr_t maxaddr); static herr_t H5FD_windows_close(H5FD_t *_file); static int H5FD_windows_cmp(const H5FD_t *_f1, const H5FD_t *_f2); static herr_t H5FD_windows_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD_windows_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, - hsize_t size); + hsize_t size); static haddr_t H5FD_windows_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD_windows_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); static haddr_t H5FD_windows_get_eof(const H5FD_t *_file); static herr_t H5FD_windows_get_handle(H5FD_t *_file, hid_t fapl, void** file_handle); static herr_t H5FD_windows_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, void *buf); + size_t size, void *buf); static herr_t H5FD_windows_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, - size_t size, const void *buf); + size_t size, const void *buf); static herr_t H5FD_windows_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); static herr_t H5FD_windows_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing); static const H5FD_class_t H5FD_windows_g = { - "windows", /*name */ - MAXADDR, /*maxaddr */ - H5F_CLOSE_WEAK, /* fc_degree */ - NULL, /*sb_size */ - NULL, /*sb_encode */ - NULL, /*sb_decode */ - 0, /*fapl_size */ - NULL, /*fapl_get */ - NULL, /*fapl_copy */ - NULL, /*fapl_free */ - 0, /*dxpl_size */ - NULL, /*dxpl_copy */ - NULL, /*dxpl_free */ - H5FD_windows_open, /*open */ - H5FD_windows_close, /*close */ - H5FD_windows_cmp, /*cmp */ - H5FD_windows_query, /*query */ - NULL, /*get_type_map */ - NULL, /*alloc */ - NULL, /*free */ - H5FD_windows_get_eoa, /*get_eoa */ - H5FD_windows_set_eoa, /*set_eoa */ - H5FD_windows_get_eof, /*get_eof */ - H5FD_windows_get_handle, /*get_handle */ - H5FD_windows_read, /*read */ - H5FD_windows_write, /*write */ - H5FD_windows_flush, /*flush */ - H5FD_windows_truncate, /*truncate */ - NULL, /*lock */ - NULL, /*unlock */ - H5FD_FLMAP_SINGLE /*fl_map */ + "windows", /*name */ + MAXADDR, /*maxaddr */ + H5F_CLOSE_WEAK, /* fc_degree */ + NULL, /*sb_size */ + NULL, /*sb_encode */ + NULL, /*sb_decode */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + 0, /*dxpl_size */ + NULL, /*dxpl_copy */ + NULL, /*dxpl_free */ + H5FD_windows_open, /*open */ + H5FD_windows_close, /*close */ + H5FD_windows_cmp, /*cmp */ + H5FD_windows_query, /*query */ + NULL, /*get_type_map */ + NULL, /*alloc */ + NULL, /*free */ + H5FD_windows_get_eoa, /*get_eoa */ + H5FD_windows_set_eoa, /*set_eoa */ + H5FD_windows_get_eof, /*get_eof */ + H5FD_windows_get_handle, /*get_handle */ + H5FD_windows_read, /*read */ + H5FD_windows_write, /*write */ + H5FD_windows_flush, /*flush */ + H5FD_windows_truncate, /*truncate */ + NULL, /*lock */ + NULL, /*unlock */ + H5FD_FLMAP_SINGLE /*fl_map */ }; /* Declare a free list to manage the H5FD_windows_t struct */ @@ -204,16 +204,16 @@ H5FD_windows_init_interface(void) } /* H5FD_windows_init_interface() */ /*------------------------------------------------------------------------- - * Function: H5FD_windows_init + * Function: H5FD_windows_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the windows driver. - * Failure: Negative. + * Return: Success: The driver ID for the windows driver. + * Failure: Negative. * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24, 2007 * *------------------------------------------------------------------------- @@ -236,14 +236,14 @@ done: } /* end H5FD_windows_init() */ /*--------------------------------------------------------------------------- - * Function: H5FD_windows_term + * Function: H5FD_windows_term * - * Purpose: Shut down the VFD + * Purpose: Shut down the VFD * - * Return: + * Return: * * Programmer: Scott Wegner - * Based on code by Quincey Koziol + * Based on code by Quincey Koziol * Thursday, May 24 2007 * * Modification: @@ -262,17 +262,17 @@ H5FD_windows_term(void) } /* end H5FD_windows_term() */ /*------------------------------------------------------------------------- - * Function: H5Pset_fapl_windows + * Function: H5Pset_fapl_windows * - * Purpose: Modify the file access property list to use the H5FD_WINDOWS - * driver defined in this source file. There are no driver - * specific properties. + * Purpose: Modify the file access property list to use the H5FD_WINDOWS + * driver defined in this source file. There are no driver + * specific properties. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Scott Wegner - * Based on code by Robb Matzke - * Thursday, May 24 2007 + * Programmer: Scott Wegner + * Based on code by Robb Matzke + * Thursday, May 24 2007 * * Modifications: * @@ -297,18 +297,18 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_open + * Function: H5FD_windows_open * - * Purpose: Create and/or opens a Windows file as an HDF5 file. + * Purpose: Create and/or opens a Windows file as an HDF5 file. * - * Return: Success: A pointer to a new file data structure. The - * public fields will be initialized by the - * caller, which is always H5FD_open(). + * Return: Success: A pointer to a new file data structure. The + * public fields will be initialized by the + * caller, which is always H5FD_open(). * - * Failure: NULL + * Failure: NULL * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -318,19 +318,19 @@ done: /* ARGSUSED */ static H5FD_t * H5FD_windows_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, - haddr_t maxaddr) + haddr_t maxaddr) { int fd = -1; - FILE *f = NULL; - H5FD_windows_t *file = NULL; - HANDLE filehandle; + FILE *f = NULL; + H5FD_windows_t *file = NULL; + HANDLE filehandle; struct _BY_HANDLE_FILE_INFORMATION fileinfo; - H5FD_t *ret_value; + H5FD_t *ret_value; struct _stati64 sb; #ifndef WINDOWS_USE_STDIO int o_flags; #else - unsigned write_access = 0; + unsigned write_access = 0; #endif /* WINDOWS_USE_STDIO */ FUNC_ENTER_NOAPI(H5FD_windows_open, NULL) @@ -352,8 +352,8 @@ H5FD_windows_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC; if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT; if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL; - /* Windows needs O_BINARY to correctly handle eol characters */ - o_flags |= O_BINARY; + /* Windows needs O_BINARY to correctly handle eol characters */ + o_flags |= O_BINARY; /* Open the file */ if ((fd=_open(name, o_flags, 0666))<0) @@ -362,33 +362,33 @@ H5FD_windows_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") #else /* WINDOWS_USE_STDIO */ - /* Translate our flags into a mode, and open the file */ + /* Translate our flags into a mode, and open the file */ if (_access_s(name, F_OK)) { if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR)) { f = fopen(name, "wb+"); write_access=1; /* Note the write access */ } else - HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file doesn't exist and CREAT wasn't specified") + HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file doesn't exist and CREAT wasn't specified") } else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) { - HSYS_GOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file exists but CREAT and EXCL were specified") + HSYS_GOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file exists but CREAT and EXCL were specified") } else if (flags & H5F_ACC_RDWR) { - if (flags & H5F_ACC_TRUNC) + if (flags & H5F_ACC_TRUNC) f = fopen(name, "wb+"); - else + else f = fopen(name, "rb+"); write_access=1; /* Note the write access */ } else f = fopen(name, "rb"); if (!f) - HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "fsopen failed") + HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "fsopen failed") if (_stati64(name, &sb) == -1) HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to stat file") #endif /* WINDOWS_USE_STDIO */ - /* Create the new file struct */ + /* Create the new file struct */ if (NULL==(file=H5FL_CALLOC(H5FD_windows_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") @@ -400,8 +400,8 @@ H5FD_windows_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, file->fd = fd; #else file->fp = f; - if((fd = _fileno(f)) == -1) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get file descriptor for file") + if((fd = _fileno(f)) == -1) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to get file descriptor for file") file->write_access=write_access; /* Note the write_access for later */ #endif /* WINDOWS_USE_STDIO */ @@ -441,7 +441,7 @@ done: _close(fd); #else if(f) - fclose(file->fp); + fclose(file->fp); #endif /* WINDOWS_USE_STDIO */ } /* end if */ @@ -449,16 +449,16 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_close + * Function: H5FD_windows_close * - * Purpose: Closes a Windows file. + * Purpose: Closes a Windows file. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1, file not closed. + * Failure: -1, file not closed. * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -468,8 +468,8 @@ done: static herr_t H5FD_windows_close(H5FD_t *_file) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_windows_t *file = (H5FD_windows_t*)_file; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_close, FAIL) @@ -487,18 +487,18 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_cmp + * Function: H5FD_windows_cmp * - * Purpose: Compares two files belonging to this driver using an - * arbitrary (but consistent) ordering. + * Purpose: Compares two files belonging to this driver using an + * arbitrary (but consistent) ordering. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: never fails (arguments were checked by the - * caller). + * Failure: never fails (arguments were checked by the + * caller). * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -508,14 +508,14 @@ done: static int H5FD_windows_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_windows_t *f1 = (const H5FD_windows_t*)_f1; - const H5FD_windows_t *f2 = (const H5FD_windows_t*)_f2; + const H5FD_windows_t *f1 = (const H5FD_windows_t*)_f1; + const H5FD_windows_t *f2 = (const H5FD_windows_t*)_f2; int ret_value=0; FUNC_ENTER_NOAPI(H5FD_windows_cmp, H5FD_VFD_DEFAULT) - if (f1->volumeserialnumber < f2->volumeserialnumber) HGOTO_DONE(-1) - if (f1->volumeserialnumber > f2->volumeserialnumber) HGOTO_DONE(1) + if (f1->volumeserialnumber < f2->volumeserialnumber) HGOTO_DONE(-1) + if (f1->volumeserialnumber > f2->volumeserialnumber) HGOTO_DONE(1) if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) @@ -529,17 +529,17 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_query + * Function: H5FD_windows_query * - * Purpose: Set the flags that this VFL driver is capable of supporting. + * Purpose: Set the flags that this VFL driver is capable of supporting. * (listed in H5FDpublic.h) * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * - * Programmer: Scott Wegner - Based on code by Quincey Koziol + * Programmer: Scott Wegner + Based on code by Quincey Koziol * Thursday, May 24 2007 * *------------------------------------------------------------------------- @@ -554,10 +554,10 @@ H5FD_windows_query(const H5FD_t *_file, unsigned long *flags /* out */) /* Set the VFL feature flags that this driver supports */ if(flags) { *flags = 0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ /* Check for flags that are set by h5repart */ if(file->fam_to_sec2) @@ -569,18 +569,18 @@ done: } /* end H5FD_windows_query() */ /*------------------------------------------------------------------------- - * Function: H5FD_windows_get_eoa + * Function: H5FD_windows_get_eoa * - * Purpose: Gets the end-of-address marker for the file. The EOA marker - * is the first address past the last byte allocated in the - * format address space. + * Purpose: Gets the end-of-address marker for the file. The EOA marker + * is the first address past the last byte allocated in the + * format address space. * - * Return: Success: The end-of-address marker. + * Return: Success: The end-of-address marker. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -590,7 +590,7 @@ done: static haddr_t H5FD_windows_get_eoa(const H5FD_t *_file, H5FD_mem_t UNUSED type) { - const H5FD_windows_t *file = (const H5FD_windows_t*)_file; + const H5FD_windows_t *file = (const H5FD_windows_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_get_eoa, HADDR_UNDEF) @@ -604,18 +604,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_set_eoa + * Function: H5FD_windows_set_eoa * - * Purpose: Set the end-of-address marker for the file. This function is - * called shortly after an existing HDF5 file is opened in order - * to tell the driver where the end of the HDF5 data is located. + * Purpose: Set the end-of-address marker for the file. This function is + * called shortly after an existing HDF5 file is opened in order + * to tell the driver where the end of the HDF5 data is located. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, July 29, 1999 * * Modifications: @@ -625,7 +625,7 @@ done: static herr_t H5FD_windows_set_eoa(H5FD_t *_file, H5FD_mem_t UNUSED type, haddr_t addr) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; + H5FD_windows_t *file = (H5FD_windows_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_set_eoa, FAIL) @@ -637,20 +637,20 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_get_eof + * Function: H5FD_windows_get_eof * - * Purpose: Returns the end-of-file marker, which is the greater of - * either the Windows end-of-file or the HDF5 end-of-address - * markers. + * Purpose: Returns the end-of-file marker, which is the greater of + * either the Windows end-of-file or the HDF5 end-of-address + * markers. * - * Return: Success: End of file address, the first address past - * the end of the "file", either the Unix file - * or the HDF5 file. + * Return: Success: End of file address, the first address past + * the end of the "file", either the Unix file + * or the HDF5 file. * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -660,7 +660,7 @@ done: static haddr_t H5FD_windows_get_eof(const H5FD_t *_file) { - const H5FD_windows_t *file = (const H5FD_windows_t*)_file; + const H5FD_windows_t *file = (const H5FD_windows_t*)_file; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_get_eof, HADDR_UNDEF) @@ -674,15 +674,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_get_handle + * Function: H5FD_windows_get_handle * - * Purpose: Returns the file handle of windows file driver. + * Purpose: Returns the file handle of windows file driver. * - * Returns: Non-negative if succeed or negative if fails. + * Returns: Non-negative if succeed or negative if fails. * - * Programmer: Scott Wegner - Based on code by Raymond Lu - * Thursday, May 24 2007 + * Programmer: Scott Wegner + Based on code by Raymond Lu + * Thursday, May 24 2007 * * Modifications: * @@ -704,7 +704,7 @@ H5FD_windows_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) #else *file_handle = &(file->fp); #endif /* WINDOWS_USE_STDIO */ - if(*file_handle==NULL) + if(*file_handle==NULL) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "get handle failed") @@ -713,16 +713,16 @@ done: } /*------------------------------------------------------------------------- - * Function: H5FD_windows_alloc + * Function: H5FD_windows_alloc * - * Purpose: Allocates file memory. + * Purpose: Allocates file memory. * - * Return: Success: Address of new memory + * Return: Success: Address of new memory * - * Failure: HADDR_UNDEF + * Failure: HADDR_UNDEF * - * Programmer: Scott Wegner - Based on code by Raymond Lu + * Programmer: Scott Wegner + Based on code by Raymond Lu * Thursday, May 24 2007 * * Modifications: @@ -732,8 +732,8 @@ done: static haddr_t H5FD_windows_alloc(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hsize_t size) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; - haddr_t addr; + H5FD_windows_t *file = (H5FD_windows_t*)_file; + haddr_t addr; haddr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_alloc, HADDR_UNDEF) @@ -761,19 +761,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_read + * Function: H5FD_windows_read * - * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR - * into buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Reads SIZE bytes of data from FILE beginning at address ADDR + * into buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero. Result is stored in caller-supplied - * buffer BUF. + * Return: Success: Zero. Result is stored in caller-supplied + * buffer BUF. * - * Failure: -1, Contents of buffer BUF are undefined. + * Failure: -1, Contents of buffer BUF are undefined. * - * Programmer: Scott Wegner - Based on code by Robb Matzke + * Programmer: Scott Wegner + Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -783,11 +783,11 @@ done: /* ARGSUSED */ static herr_t H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, void *buf/*out*/) + size_t size, void *buf/*out*/) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; - int nbytes; - herr_t ret_value=SUCCEED; /* Return value */ + H5FD_windows_t *file = (H5FD_windows_t*)_file; + int nbytes; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_read, FAIL) @@ -805,14 +805,14 @@ H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op)) #ifndef WINDOWS_USE_STDIO - if (_lseeki64(file->fd, addr, SEEK_SET) == -1) { + if (_lseeki64(file->fd, addr, SEEK_SET) == -1) { #else if (_fseeki64(file->fp, addr, SEEK_SET) == -1) { #endif /* WINDOWS_USE_STDIO */ file->op = OP_UNKNOWN; file->pos = HADDR_UNDEF; - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + } /* * Read data, being careful of interrupted system calls, partial results, @@ -821,7 +821,7 @@ H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h while (size>0) { #ifndef WINDOWS_USE_STDIO do { - nbytes = _read(file->fd, buf, (unsigned)(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF)); + nbytes = _read(file->fd, buf, (unsigned)(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF)); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) /* error */ HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") @@ -834,15 +834,15 @@ H5FD_windows_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, h do { nbytes = fread(buf,(size_t)1,(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF),file->fp); } while (!nbytes && EINTR==errno); - if(!nbytes) { + if(!nbytes) { if (ferror(file->fp)) /* error */ HSYS_GOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") - if (feof(file->fp)) { - /* end of file but not end of format address space */ - HDmemset(buf, 0, size); - break; - } - } + if (feof(file->fp)) { + /* end of file but not end of format address space */ + HDmemset(buf, 0, size); + break; + } + } #endif /* WINDOWS_USE_STDIO */ assert(nbytes>=0); assert((size_t)nbytes<=size); @@ -869,18 +869,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_write + * Function: H5FD_windows_write * - * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR - * from buffer BUF according to data transfer properties in - * DXPL_ID. + * Purpose: Writes SIZE bytes of data to FILE beginning at address ADDR + * from buffer BUF according to data transfer properties in + * DXPL_ID. * - * Return: Success: Zero + * Return: Success: Zero * - * Failure: -1 + * Failure: -1 * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * * Modifications: @@ -890,10 +890,10 @@ done: /* ARGSUSED */ static herr_t H5FD_windows_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, - size_t size, const void *buf) + size_t size, const void *buf) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; - ssize_t nbytes; + H5FD_windows_t *file = (H5FD_windows_t*)_file; + ssize_t nbytes; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_write, FAIL) @@ -911,23 +911,23 @@ H5FD_windows_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op)) - { + { #ifndef WINDOWS_USE_STDIO - if (_lseeki64(file->fd, addr, SEEK_SET) == -1) { + if (_lseeki64(file->fd, addr, SEEK_SET) == -1) { #else if (_fseeki64(file->fp, addr, SEEK_SET) == -1) { #endif /* WINDOWS_USE_STDIO */ file->op = OP_UNKNOWN; file->pos = HADDR_UNDEF; - HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") - } - } + HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") + } + } /* * Write the data, being careful of interrupted system calls and partial * results */ - while (size>0) { + while (size>0) { do { #ifndef WINDOWS_USE_STDIO nbytes = _write(file->fd, buf, (unsigned)(size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF)); @@ -936,9 +936,9 @@ H5FD_windows_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, #else - /* Write 1GB or less at a time */ - nbytes = fwrite(buf, 1, (size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF),file->fp); - } while (!nbytes && EINTR==errno); + /* Write 1GB or less at a time */ + nbytes = fwrite(buf, 1, (size <= WINDOWS_MAX_BUF ? size: WINDOWS_MAX_BUF),file->fp); + } while (!nbytes && EINTR==errno); if (!nbytes) /* error */ #endif /* WINDOWS_USE_STDIO */ HSYS_GOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") @@ -949,7 +949,7 @@ H5FD_windows_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, H5_CHECK_OVERFLOW(nbytes,ssize_t,haddr_t); addr += (haddr_t)nbytes; buf = (const char*)buf + nbytes; - } + } /* Update current position and eof */ file->pos = addr; @@ -969,16 +969,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_flush + * Function: H5FD_windows_flush * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * *------------------------------------------------------------------------- @@ -987,8 +987,8 @@ done: static herr_t H5FD_windows_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_windows_t *file = (H5FD_windows_t*)_file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_flush, FAIL) @@ -1015,16 +1015,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_windows_truncate + * Function: H5FD_windows_truncate * - * Purpose: Makes sure that the true file size is the same (or larger) - * than the end-of-address. + * Purpose: Makes sure that the true file size is the same (or larger) + * than the end-of-address. * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Scott Wegner - * Based on code by Robb Matzke + * Programmer: Scott Wegner + * Based on code by Robb Matzke * Thursday, May 24 2007 * *------------------------------------------------------------------------- @@ -1033,14 +1033,14 @@ done: static herr_t H5FD_windows_truncate(H5FD_t *_file, hid_t UNUSED dxpl_id, hbool_t UNUSED closing) { - H5FD_windows_t *file = (H5FD_windows_t*)_file; + H5FD_windows_t *file = (H5FD_windows_t*)_file; #ifndef WINDOWS_USE_STDIO - LARGE_INTEGER li; - HANDLE filehandle; + LARGE_INTEGER li; + HANDLE filehandle; #else - int fd; + int fd; #endif /* WINDOWS_USE_STDIO */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_windows_truncate, FAIL) diff --git a/src/H5TS.c b/src/H5TS.c index 480bc2d..97a743f 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -14,9 +14,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* private headers */ -#include "H5private.h" /*library */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /*memory management functions */ +#include "H5private.h" /*library */ +#include "H5Eprivate.h" /*error handling */ +#include "H5MMprivate.h" /*memory management functions */ #ifdef H5_HAVE_THREADSAFE @@ -126,6 +126,12 @@ void H5TS_pthread_first_thread_init(void) { H5_g.H5_libinit_g = FALSE; + +#ifdef H5_HAVE_WIN32_API +# ifdef PTW32_STATIC_LIB + pthread_win32_process_attach_np(); +# endif +#endif /* initialize global API mutex lock */ pthread_mutex_init(&H5_g.init_lock.atomic_lock, NULL); @@ -171,7 +177,7 @@ H5TS_pthread_first_thread_init(void) herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS EnterCriticalSection( &mutex->CriticalSection); return 0; #else /* H5_HAVE_WIN_THREADS */ @@ -226,7 +232,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* Releases ownership of the specified critical section object. */ LeaveCriticalSection(&mutex->CriticalSection); return 0; @@ -285,7 +291,7 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) herr_t H5TS_cancel_count_inc(void) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* unsupported; just return 0 */ return SUCCEED; #else /* H5_HAVE_WIN_THREADS */ @@ -296,25 +302,25 @@ H5TS_cancel_count_inc(void) if (!cancel_counter) { /* - * First time thread calls library - create new counter and associate + * First time thread calls library - create new counter and associate * with key */ - cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); - if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", - __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); - return FAIL; - } + if (!cancel_counter) { + H5E_push_stack(NULL, "H5TS_cancel_count_inc", + __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); + return FAIL; + } ret_value = pthread_setspecific(H5TS_cancel_key_g, - (void *)cancel_counter); + (void *)cancel_counter); } if (cancel_counter->cancel_count == 0) /* thread entering library */ ret_value = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, - &cancel_counter->previous_state); + &cancel_counter->previous_state); ++cancel_counter->cancel_count; @@ -352,7 +358,7 @@ H5TS_cancel_count_inc(void) herr_t H5TS_cancel_count_dec(void) { -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS /* unsupported; will just return 0 */ return SUCCEED; #else /* H5_HAVE_WIN_THREADS */ @@ -391,7 +397,7 @@ H5TS_create_thread(void * func, H5TS_attr_t * attr, void*udata) { H5TS_thread_t ret_value; -#ifdef H5_HAVE_WIN_THREADS +#ifdef H5_HAVE_WIN_THREADS ret_value = CreateThread(NULL, 0, func, udata, 0, NULL); @@ -405,4 +411,4 @@ H5TS_create_thread(void * func, H5TS_attr_t * attr, void*udata) } /* H5TS_create_thread */ -#endif /* H5_HAVE_THREADSAFE */ +#endif /* H5_HAVE_THREADSAFE */ diff --git a/src/H5api_adpt.h b/src/H5api_adpt.h index fc0b467..845a9a0 100644 --- a/src/H5api_adpt.h +++ b/src/H5api_adpt.h @@ -303,10 +303,10 @@ * The Visual Studio project files will not be supported in the next major release of 1.10. */ -#if defined(_WIN32) +#if defined(H5_HAVE_WIN32_API) #if defined(_HDF5DLL_) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_DLL __declspec(dllexport) #define H5_DLLVAR extern __declspec(dllexport) #elif defined(_HDF5USEDLL_) @@ -318,7 +318,7 @@ #endif /* _HDF5DLL_ */ #if defined(_HDF5TESTDLL_) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5TEST_DLL __declspec(dllexport) #define H5TEST_DLLVAR extern __declspec(dllexport) #elif defined(_HDF5TESTUSEDLL_) @@ -330,7 +330,7 @@ #endif /* _HDF5TESTDLL_ */ #if defined(_HDF5TOOLSDLL_) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5TOOLS_DLL __declspec(dllexport) #define H5TOOLS_DLLVAR extern __declspec(dllexport) #elif defined(_HDF5TOOLSUSEDLL_) @@ -342,7 +342,7 @@ #endif /* _HDF5TOOLSDLL_ */ #if defined(_HDF5_HLDLL_EXPORTS_) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_HLDLL __declspec(dllexport) #elif defined(_HDF5USEHLDLL_) #define H5_HLDLL __declspec(dllimport) @@ -351,7 +351,7 @@ #endif /* _HDF5_HLDLL_EXPORTS */ #if defined(HDF5_HL_CPPDLL_EXPORTS) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_HLCPPDLL __declspec(dllexport) #elif defined(HDF5USE_HLCPPDLL) #define H5_HLCPPDLL __declspec(dllimport) @@ -360,7 +360,7 @@ #endif /*HDF5_HL_CPPDLL_EXPORTS*/ #if defined(HDF5_HL_F90CSTUBDLL_EXPORTS) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define HDF5_HL_F90CSTUBDLL __declspec(dllexport) #elif defined(HDF5USE_HLF90CSTUBDLL) #define HDF5_HL_F90CSTUBDLL __declspec(dllimport) @@ -370,7 +370,7 @@ #if defined(HDF5FORT_CSTUB_DLL_EXPORTS) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_FCDLL __declspec(dllexport) #define H5_FCDLLVAR extern __declspec(dllexport) #elif defined(HDF5FORT_CSTUB_USEDLL) @@ -382,7 +382,7 @@ #endif /* _HDF5_FORTRANDLL_EXPORTS_ */ #if defined(HDF5FORTTEST_CSTUB_DLL_EXPORTS) -#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ +#pragma warning(disable: 4273) /* Disable the dll linkage warnings */ #define H5_FCTESTDLL __declspec(dllexport) #define H5_FCTESTDLLVAR extern __declspec(dllexport) #elif defined(HDF5FORTTEST_CSTUB_USEDLL) @@ -402,7 +402,7 @@ #define H5_DLLCPP #endif /* HDF5_CPPDLL_EXPORTS */ -#else /*_WIN32*/ +#else /*H5_HAVE_WIN32_API*/ #define H5_DLL #define H5_HLDLL #define H5_HLCPPDLL @@ -417,7 +417,7 @@ #define H5_FCDLLVAR extern #define H5_FCTESTDLL #define H5_FCTESTDLLVAR extern -#endif +#endif /*H5_HAVE_WIN32_API*/ #endif /* H5API_ADPT_H */ diff --git a/src/H5private.h b/src/H5private.h index 09df6ac..7129f72 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -13,28 +13,34 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke - * Friday, October 30, 1998 +/* Programmer: Robb Matzke + * Friday, October 30, 1998 * - * Purpose: This file is included by all HDF5 library source files to - * define common things which are not defined in the HDF5 API. - * The configuration constants like H5_HAVE_UNISTD_H etc. are - * defined in H5config.h which is included by H5public.h. + * Purpose: This file is included by all HDF5 library source files to + * define common things which are not defined in the HDF5 API. + * The configuration constants like H5_HAVE_UNISTD_H etc. are + * defined in H5config.h which is included by H5public.h. * */ #ifndef _H5private_H #define _H5private_H -#include "H5public.h" /* Include Public Definitions */ +#include "H5public.h" /* Include Public Definitions */ /* include the pthread header */ #ifdef H5_HAVE_THREADSAFE -#ifdef H5_HAVE_PTHREAD_H -#include -#else /* H5_HAVE_PTHREAD_H */ -#define H5_HAVE_WIN_THREADS -#endif /* H5_HAVE_PTHREAD_H */ + #ifdef H5_HAVE_WIN32_API + #ifndef H5_HAVE_WIN_THREADS + #ifdef H5_HAVE_PTHREAD_H + #include + #endif /* H5_HAVE_PTHREAD_H */ + #endif /* H5_HAVE_WIN_THREADS */ + #else /* H5_HAVE_WIN32_API */ + #ifdef H5_HAVE_PTHREAD_H + #include + #endif /* H5_HAVE_PTHREAD_H */ + #endif /* H5_HAVE_WIN32_API */ #endif /* H5_HAVE_THREADSAFE */ /* @@ -79,7 +85,7 @@ /* * The `struct stat' data type for stat() and fstat(). This is a Posix file - * but often apears on non-Posix systems also. The `struct stat' is required + * but often apears on non-Posix systems also. The `struct stat' is required * for hdf5 to compile, although only a few fields are actually used. */ #ifdef H5_HAVE_SYS_STAT_H @@ -121,7 +127,7 @@ #endif /* - * Unix ioctls. These are used by h5ls (and perhaps others) to determine a + * Unix ioctls. These are used by h5ls (and perhaps others) to determine a * resonable output width. */ #ifdef H5_HAVE_SYS_IOCTL_H @@ -144,8 +150,8 @@ #endif -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN /*Exclude rarely-used stuff from Windows headers */ +#ifdef H5_HAVE_WIN32_API +#define WIN32_LEAN_AND_MEAN /*Exclude rarely-used stuff from Windows headers */ #ifdef H5_HAVE_WINSOCK_H #include @@ -154,7 +160,7 @@ #include #include /* For _getcwd() */ -#endif /*_WIN32*/ +#endif /*H5_HAVE_WIN32_API*/ /* H5_inline */ #ifndef H5_inline @@ -163,7 +169,7 @@ #ifndef F_OK -# define F_OK 00 +# define F_OK 00 # define W_OK 02 # define R_OK 04 #endif @@ -201,14 +207,14 @@ * BEGIN_MPE_LOG_COLOR variant). -QAK */ #define BEGIN_MPE_LOG(func_name) \ - if (H5_MPEinit_g){ \ - if (eventa(func_name) == -1 && eventb(func_name) == -1) { \ - const char* p_color = "red"; \ + if (H5_MPEinit_g){ \ + if (eventa(func_name) == -1 && eventb(func_name) == -1) { \ + const char* p_color = "red"; \ eventa(func_name)=MPE_Log_get_event_number(); \ eventb(func_name)=MPE_Log_get_event_number(); \ MPE_Describe_state(eventa(func_name), eventb(func_name), (char *)p_end_funcname, (char *)p_color); \ } \ - MPE_Log_event(eventa(func_name), 0, (char *)p_event_start); \ + MPE_Log_event(eventa(func_name), 0, (char *)p_event_start); \ } @@ -244,23 +250,23 @@ * never be raised by the hdf5 library). */ #ifndef SIGBUS -# define SIGBUS SIGILL +# define SIGBUS SIGILL #endif /* * Does the compiler support the __attribute__(()) syntax? This is how gcc - * suppresses warnings about unused function arguments. It's no big deal if + * suppresses warnings about unused function arguments. It's no big deal if * we don't. */ #ifdef __cplusplus -# define __attribute__(X) /*void*/ -# define UNUSED /*void*/ +# define __attribute__(X) /*void*/ +# define UNUSED /*void*/ #else /* __cplusplus */ #ifdef H5_HAVE_ATTRIBUTE -# define UNUSED __attribute__((unused)) +# define UNUSED __attribute__((unused)) #else -# define __attribute__(X) /*void*/ -# define UNUSED /*void*/ +# define __attribute__(X) /*void*/ +# define UNUSED /*void*/ #endif #endif /* __cplusplus */ @@ -270,7 +276,7 @@ * string. */ #ifndef H5_HAVE_FUNCTION -# define __FUNCTION__ "NoFunctionName" +# define __FUNCTION__ "NoFunctionName" #endif /* @@ -282,45 +288,45 @@ * function, remember to compare against zero and not one of these two * values. */ -#define SUCCEED 0 -#define FAIL (-1) -#define UFAIL (unsigned)(-1) +#define SUCCEED 0 +#define FAIL (-1) +#define UFAIL (unsigned)(-1) /* number of members in an array */ #ifndef NELMTS -# define NELMTS(X) (sizeof(X)/sizeof(X[0])) +# define NELMTS(X) (sizeof(X)/sizeof(X[0])) #endif /* minimum of two, three, or four values */ #undef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#define MIN2(a,b) MIN(a,b) -#define MIN3(a,b,c) MIN(a,MIN(b,c)) -#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) +#define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN2(a,b) MIN(a,b) +#define MIN3(a,b,c) MIN(a,MIN(b,c)) +#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d)) /* maximum of two, three, or four values */ #undef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) -#define MAX2(a,b) MAX(a,b) -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) +#define MAX(a,b) (((a)>(b)) ? (a) : (b)) +#define MAX2(a,b) MAX(a,b) +#define MAX3(a,b,c) MAX(a,MAX(b,c)) +#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) /* limit the middle value to be within a range (inclusive) */ -#define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) +#define RANGE(LO,X,HI) MAX(LO,MIN(X,HI)) /* absolute value */ #ifndef ABS -# define ABS(a) (((a)>=0) ? (a) : -(a)) +# define ABS(a) (((a)>=0) ? (a) : -(a)) #endif /* sign of argument */ #ifndef SIGN -# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) +# define SIGN(a) ((a)>0 ? 1 : (a)<0 ? -1 : 0) #endif /* test for number that is a power of 2 */ /* (from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2) */ -# define POWER_OF_TWO(n) (!(n & (n - 1)) && n) +# define POWER_OF_TWO(n) (!(n & (n - 1)) && n) /* * HDF Boolean type. @@ -333,7 +339,7 @@ #endif /* - * Numeric data types. Some of these might be defined in Posix.1g, otherwise + * Numeric data types. Some of these might be defined in Posix.1g, otherwise * we define them with the closest available type which is at least as large * as the number of bits indicated in the type name. The `int8' types *must* * be exactly one byte wide because we use it for pointer calculations to @@ -401,28 +407,28 @@ #endif /* - * Maximum and minimum values. These should be defined in for the + * Maximum and minimum values. These should be defined in for the * most part. */ #ifndef LLONG_MAX -# define LLONG_MAX ((long long)(((unsigned long long)1 \ - <<(8*sizeof(long long)-1))-1)) +# define LLONG_MAX ((long long)(((unsigned long long)1 \ + <<(8*sizeof(long long)-1))-1)) # define LLONG_MIN ((long long)(-LLONG_MAX)-1) #endif #ifndef ULLONG_MAX -# define ULLONG_MAX ((unsigned long long)((long long)(-1))) +# define ULLONG_MAX ((unsigned long long)((long long)(-1))) #endif #ifndef SIZET_MAX -# define SIZET_MAX ((size_t)(ssize_t)(-1)) -# define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) +# define SIZET_MAX ((size_t)(ssize_t)(-1)) +# define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1)) #endif /* * Maximum & minimum values for our typedefs. */ -#define HSIZET_MAX ((hsize_t)ULLONG_MAX) -#define HSSIZET_MAX ((hssize_t)LLONG_MAX) -#define HSSIZET_MIN (~(HSSIZET_MAX)) +#define HSIZET_MAX ((hsize_t)ULLONG_MAX) +#define HSSIZET_MAX ((hssize_t)LLONG_MAX) +#define HSSIZET_MIN (~(HSSIZET_MAX)) /* * A macro to portably increment enumerated types. @@ -442,15 +448,15 @@ * Data types and functions for timing certain parts of the library. */ typedef struct { - double utime; /*user time */ - double stime; /*system time */ - double etime; /*elapsed wall-clock time */ + double utime; /*user time */ + double stime; /*system time */ + double etime; /*elapsed wall-clock time */ } H5_timer_t; H5_DLL void H5_timer_reset (H5_timer_t *timer); H5_DLL void H5_timer_begin (H5_timer_t *timer); H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/, - H5_timer_t *timer/*in,out*/); + H5_timer_t *timer/*in,out*/); H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); H5_DLL time_t H5_now(void); @@ -478,19 +484,19 @@ typedef struct { /* Put all platform-specific definitions in the following file */ /* so that the following definitions are platform free. */ -#include "H5win32defs.h" /* For Windows-specific definitions */ +#include "H5win32defs.h" /* For Windows-specific definitions */ #ifndef HDabort - #define HDabort() abort() + #define HDabort() abort() #endif /* HDabort */ #ifndef HDabs - #define HDabs(X) abs(X) + #define HDabs(X) abs(X) #endif /* HDabs */ #ifndef HDaccess - #define HDaccess(F,M) access(F, M) + #define HDaccess(F,M) access(F, M) #endif /* HDaccess */ #ifndef HDacos - #define HDacos(X) acos(X) + #define HDacos(X) acos(X) #endif /* HDacos */ #ifndef HDalarm #ifdef H5_HAVE_ALARM @@ -500,229 +506,229 @@ typedef struct { #endif /* H5_HAVE_ALARM */ #endif /* HDalarm */ #ifndef HDasctime - #define HDasctime(T) asctime(T) + #define HDasctime(T) asctime(T) #endif /* HDasctime */ #ifndef HDasin - #define HDasin(X) asin(X) + #define HDasin(X) asin(X) #endif /* HDasin */ #ifndef HDassert - #define HDassert(X) assert(X) + #define HDassert(X) assert(X) #endif /* HDassert */ #ifndef HDatan - #define HDatan(X) atan(X) + #define HDatan(X) atan(X) #endif /* HDatan */ #ifndef HDatan2 - #define HDatan2(X,Y) atan2(X,Y) + #define HDatan2(X,Y) atan2(X,Y) #endif /* HDatan2 */ #ifndef HDatexit - #define HDatexit(F) atexit(F) + #define HDatexit(F) atexit(F) #endif /* HDatexit */ #ifndef HDatof - #define HDatof(S) atof(S) + #define HDatof(S) atof(S) #endif /* HDatof */ #ifndef HDatoi - #define HDatoi(S) atoi(S) + #define HDatoi(S) atoi(S) #endif /* HDatoi */ #ifndef HDatol - #define HDatol(S) atol(S) + #define HDatol(S) atol(S) #endif /* HDatol */ #ifndef HDBSDgettimeofday - #define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P) + #define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P) #endif /* HDBSDgettimeofday */ #ifndef HDbsearch - #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) + #define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F) #endif /* HDbsearch */ #ifndef HDcalloc - #define HDcalloc(N,Z) calloc(N,Z) + #define HDcalloc(N,Z) calloc(N,Z) #endif /* HDcalloc */ #ifndef HDceil - #define HDceil(X) ceil(X) + #define HDceil(X) ceil(X) #endif /* HDceil */ #ifndef HDcfgetispeed - #define HDcfgetispeed(T) cfgetispeed(T) + #define HDcfgetispeed(T) cfgetispeed(T) #endif /* HDcfgetispeed */ #ifndef HDcfgetospeed - #define HDcfgetospeed(T) cfgetospeed(T) + #define HDcfgetospeed(T) cfgetospeed(T) #endif /* HDcfgetospeed */ #ifndef HDcfsetispeed - #define HDcfsetispeed(T,S) cfsetispeed(T,S) + #define HDcfsetispeed(T,S) cfsetispeed(T,S) #endif /* HDcfsetispeed */ #ifndef HDcfsetospeed - #define HDcfsetospeed(T,S) cfsetospeed(T,S) + #define HDcfsetospeed(T,S) cfsetospeed(T,S) #endif /* HDcfsetospeed */ #ifndef HDchdir - #define HDchdir(S) chdir(S) + #define HDchdir(S) chdir(S) #endif /* HDchdir */ #ifndef HDchmod - #define HDchmod(S,M) chmod(S,M) + #define HDchmod(S,M) chmod(S,M) #endif /* HDchmod */ #ifndef HDchown - #define HDchown(S,O,G) chown(S,O,G) + #define HDchown(S,O,G) chown(S,O,G) #endif /* HDchown */ #ifndef HDclearerr - #define HDclearerr(F) clearerr(F) + #define HDclearerr(F) clearerr(F) #endif /* HDclearerr */ #ifndef HDclock - #define HDclock() clock() + #define HDclock() clock() #endif /* HDclock */ #ifndef HDclose - #define HDclose(F) close(F) + #define HDclose(F) close(F) #endif /* HDclose */ #ifndef HDclosedir - #define HDclosedir(D) closedir(D) + #define HDclosedir(D) closedir(D) #endif /* HDclosedir */ #ifndef HDcos - #define HDcos(X) cos(X) + #define HDcos(X) cos(X) #endif /* HDcos */ #ifndef HDcosh - #define HDcosh(X) cosh(X) + #define HDcosh(X) cosh(X) #endif /* HDcosh */ #ifndef HDcreat - #define HDcreat(S,M) creat(S,M) + #define HDcreat(S,M) creat(S,M) #endif /* HDcreat */ #ifndef HDctermid - #define HDctermid(S) ctermid(S) + #define HDctermid(S) ctermid(S) #endif /* HDctermid */ #ifndef HDctime - #define HDctime(T) ctime(T) + #define HDctime(T) ctime(T) #endif /* HDctime */ #ifndef HDcuserid - #define HDcuserid(S) cuserid(S) + #define HDcuserid(S) cuserid(S) #endif /* HDcuserid */ #ifndef HDdifftime #ifdef H5_HAVE_DIFFTIME - #define HDdifftime(X,Y) difftime(X,Y) + #define HDdifftime(X,Y) difftime(X,Y) #else /* H5_HAVE_DIFFTIME */ - #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) + #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) #endif /* H5_HAVE_DIFFTIME */ #endif /* HDdifftime */ #ifndef HDdiv - #define HDdiv(X,Y) div(X,Y) + #define HDdiv(X,Y) div(X,Y) #endif /* HDdiv */ #ifndef HDdup - #define HDdup(F) dup(F) + #define HDdup(F) dup(F) #endif /* HDdup */ #ifndef HDdup2 - #define HDdup2(F,I) dup2(F,I) + #define HDdup2(F,I) dup2(F,I) #endif /* HDdup2 */ /* execl() variable arguments */ /* execle() variable arguments */ /* execlp() variable arguments */ #ifndef HDexecv - #define HDexecv(S,AV) execv(S,AV) + #define HDexecv(S,AV) execv(S,AV) #endif /* HDexecv */ #ifndef HDexecve - #define HDexecve(S,AV,E) execve(S,AV,E) + #define HDexecve(S,AV,E) execve(S,AV,E) #endif /* HDexecve */ #ifndef HDexecvp - #define HDexecvp(S,AV) execvp(S,AV) + #define HDexecvp(S,AV) execvp(S,AV) #endif /* HDexecvp */ #ifndef HDexit - #define HDexit(N) exit(N) + #define HDexit(N) exit(N) #endif /* HDexit */ #ifndef HD_exit - #define HD_exit(N) _exit(N) + #define HD_exit(N) _exit(N) #endif /* HD_exit */ #ifndef HDexp - #define HDexp(X) exp(X) + #define HDexp(X) exp(X) #endif /* HDexp */ #ifndef HDfabs - #define HDfabs(X) fabs(X) + #define HDfabs(X) fabs(X) #endif /* HDfabs */ /* use ABS() because fabsf() fabsl() are not common yet. */ #ifndef HDfabsf - #define HDfabsf(X) ABS(X) + #define HDfabsf(X) ABS(X) #endif /* HDfabsf */ #ifndef HDfabsl - #define HDfabsl(X) ABS(X) + #define HDfabsl(X) ABS(X) #endif /* HDfabsl */ #ifndef HDfclose - #define HDfclose(F) fclose(F) + #define HDfclose(F) fclose(F) #endif /* HDfclose */ /* fcntl() variable arguments */ #ifndef HDfdopen - #define HDfdopen(N,S) fdopen(N,S) + #define HDfdopen(N,S) fdopen(N,S) #endif /* HDfdopen */ #ifndef HDfeof - #define HDfeof(F) feof(F) + #define HDfeof(F) feof(F) #endif /* HDfeof */ #ifndef HDferror - #define HDferror(F) ferror(F) + #define HDferror(F) ferror(F) #endif /* HDferror */ #ifndef HDfflush - #define HDfflush(F) fflush(F) + #define HDfflush(F) fflush(F) #endif /* HDfflush */ #ifndef HDfgetc - #define HDfgetc(F) fgetc(F) + #define HDfgetc(F) fgetc(F) #endif /* HDfgetc */ #ifndef HDfgetpos - #define HDfgetpos(F,P) fgetpos(F,P) + #define HDfgetpos(F,P) fgetpos(F,P) #endif /* HDfgetpos */ #ifndef HDfgets - #define HDfgets(S,N,F) fgets(S,N,F) + #define HDfgets(S,N,F) fgets(S,N,F) #endif /* HDfgets */ #ifndef HDfileno - #define HDfileno(F) fileno(F) + #define HDfileno(F) fileno(F) #endif /* HDfileno */ #ifndef HDfloor - #define HDfloor(X) floor(X) + #define HDfloor(X) floor(X) #endif /* HDfloor */ #ifndef HDfmod - #define HDfmod(X,Y) fmod(X,Y) + #define HDfmod(X,Y) fmod(X,Y) #endif /* HDfmod */ #ifndef HDfopen - #define HDfopen(S,M) fopen(S,M) + #define HDfopen(S,M) fopen(S,M) #endif /* HDfopen */ #ifndef HDfork - #define HDfork() fork() + #define HDfork() fork() #endif /* HDfork */ #ifndef HDfpathconf - #define HDfpathconf(F,N) fpathconf(F,N) + #define HDfpathconf(F,N) fpathconf(F,N) #endif /* HDfpathconf */ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #ifndef HDfputc - #define HDfputc(C,F) fputc(C,F) + #define HDfputc(C,F) fputc(C,F) #endif /* HDfputc */ #ifndef HDfputs - #define HDfputs(S,F) fputs(S,F) + #define HDfputs(S,F) fputs(S,F) #endif /* HDfputs */ #ifndef HDfread - #define HDfread(M,Z,N,F) fread(M,Z,N,F) + #define HDfread(M,Z,N,F) fread(M,Z,N,F) #endif /* HDfread */ #ifndef HDfree - #define HDfree(M) free(M) + #define HDfree(M) free(M) #endif /* HDfree */ #ifndef HDfreopen - #define HDfreopen(S,M,F) freopen(S,M,F) + #define HDfreopen(S,M,F) freopen(S,M,F) #endif /* HDfreopen */ #ifndef HDfrexp - #define HDfrexp(X,N) frexp(X,N) + #define HDfrexp(X,N) frexp(X,N) #endif /* HDfrexp */ /* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */ #ifndef HDfrexpf #ifdef H5_HAVE_FREXPF - #define HDfrexpf(X,N) frexpf(X,N) + #define HDfrexpf(X,N) frexpf(X,N) #else /* H5_HAVE_FREXPF */ - #define HDfrexpf(X,N) frexp(X,N) + #define HDfrexpf(X,N) frexp(X,N) #endif /* H5_HAVE_FREXPF */ #endif /* HDfrexpf */ #ifndef HDfrexpl #ifdef H5_HAVE_FREXPL - #define HDfrexpl(X,N) frexpl(X,N) + #define HDfrexpl(X,N) frexpl(X,N) #else /* H5_HAVE_FREXPL */ - #define HDfrexpl(X,N) frexp(X,N) + #define HDfrexpl(X,N) frexp(X,N) #endif /* H5_HAVE_FREXPL */ #endif /* HDfrexpl */ /* fscanf() variable arguments */ #ifndef HDfseek #ifdef H5_HAVE_FSEEKO - #define HDfseek(F,O,W) fseeko(F,O,W) + #define HDfseek(F,O,W) fseeko(F,O,W) #else /* H5_HAVE_FSEEKO */ - #define HDfseek(F,O,W) fseek(F,O,W) + #define HDfseek(F,O,W) fseek(F,O,W) #endif /* H5_HAVE_FSEEKO */ #endif /* HDfseek */ #ifndef HDfsetpos - #define HDfsetpos(F,P) fsetpos(F,P) + #define HDfsetpos(F,P) fsetpos(F,P) #endif /* HDfsetpos */ /* definitions related to the file stat utilities. * For Unix, if off_t is not 64bit big, try use the pseudo-standard @@ -734,10 +740,10 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfstat(F,B) fstat64(F,B) #endif /* HDfstat */ #ifndef HDlstat - #define HDlstat(S,B) lstat64(S,B) + #define HDlstat(S,B) lstat64(S,B) #endif /* HDlstat */ #ifndef HDstat - #define HDstat(S,B) stat64(S,B) + #define HDstat(S,B) stat64(S,B) #endif /* HDstat */ typedef struct stat64 h5_stat_t; typedef off64_t h5_stat_size_t; @@ -747,10 +753,10 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #define HDfstat(F,B) fstat(F,B) #endif /* HDfstat */ #ifndef HDlstat - #define HDlstat(S,B) lstat(S,B) + #define HDlstat(S,B) lstat(S,B) #endif /* HDlstat */ #ifndef HDstat - #define HDstat(S,B) stat(S,B) + #define HDstat(S,B) stat(S,B) #endif /* HDstat */ typedef struct stat h5_stat_t; typedef off_t h5_stat_size_t; @@ -759,7 +765,7 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif /* !defined(HDfstat) || !defined(HDstat) */ #ifndef HDftell - #define HDftell(F) ftell(F) + #define HDftell(F) ftell(F) #endif /* HDftell */ #ifndef HDftruncate #ifdef H5_HAVE_FTRUNCATE64 @@ -769,273 +775,273 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); #endif #endif /* HDftruncate */ #ifndef HDfwrite - #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) + #define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F) #endif /* HDfwrite */ #ifndef HDgetc - #define HDgetc(F) getc(F) + #define HDgetc(F) getc(F) #endif /* HDgetc */ #ifndef HDgetchar - #define HDgetchar() getchar() + #define HDgetchar() getchar() #endif /* HDgetchar */ #ifndef HDgetcwd - #define HDgetcwd(S,Z) getcwd(S,Z) + #define HDgetcwd(S,Z) getcwd(S,Z) #endif /* HDgetcwd */ #ifndef HDgetdcwd - #define HDgetdcwd(D,S,Z) getcwd(S,Z) + #define HDgetdcwd(D,S,Z) getcwd(S,Z) #endif /* HDgetdcwd */ #ifndef HDgetdrive - #define HDgetdrive() 0 + #define HDgetdrive() 0 #endif /* HDgetdrive */ #ifndef HDgetegid - #define HDgetegid() getegid() + #define HDgetegid() getegid() #endif /* HDgetegid() */ #ifndef HDgetenv - #define HDgetenv(S) getenv(S) + #define HDgetenv(S) getenv(S) #endif /* HDgetenv */ #ifndef HDgeteuid - #define HDgeteuid() geteuid() + #define HDgeteuid() geteuid() #endif /* HDgeteuid */ #ifndef HDgetgid - #define HDgetgid() getgid() + #define HDgetgid() getgid() #endif /* HDgetgid */ #ifndef HDgetgrgid - #define HDgetgrgid(G) getgrgid(G) + #define HDgetgrgid(G) getgrgid(G) #endif /* HDgetgrgid */ #ifndef HDgetgrnam - #define HDgetgrnam(S) getgrnam(S) + #define HDgetgrnam(S) getgrnam(S) #endif /* HDgetgrnam */ #ifndef HDgetgroups - #define HDgetgroups(Z,G) getgroups(Z,G) + #define HDgetgroups(Z,G) getgroups(Z,G) #endif /* HDgetgroups */ #ifndef HDgetlogin - #define HDgetlogin() getlogin() + #define HDgetlogin() getlogin() #endif /* HDgetlogin */ #ifndef HDgetpgrp - #define HDgetpgrp() getpgrp() + #define HDgetpgrp() getpgrp() #endif /* HDgetpgrp */ #ifndef HDgetpid - #define HDgetpid() getpid() + #define HDgetpid() getpid() #endif /* HDgetpid */ #ifndef HDgetppid - #define HDgetppid() getppid() + #define HDgetppid() getppid() #endif /* HDgetppid */ #ifndef HDgetpwnam - #define HDgetpwnam(S) getpwnam(S) + #define HDgetpwnam(S) getpwnam(S) #endif /* HDgetpwnam */ #ifndef HDgetpwuid - #define HDgetpwuid(U) getpwuid(U) + #define HDgetpwuid(U) getpwuid(U) #endif /* HDgetpwuid */ #ifndef HDgetrusage - #define HDgetrusage(X,S) getrusage(X,S) + #define HDgetrusage(X,S) getrusage(X,S) #endif /* HDgetrusage */ #ifndef HDgets - #define HDgets(S) gets(S) + #define HDgets(S) gets(S) #endif /* HDgets */ #ifndef HDgettimeofday - #define HDgettimeofday(S,P) gettimeofday(S,P) + #define HDgettimeofday(S,P) gettimeofday(S,P) #endif /* HDgettimeofday */ #ifndef HDgetuid - #define HDgetuid() getuid() + #define HDgetuid() getuid() #endif /* HDgetuid */ #ifndef HDgmtime - #define HDgmtime(T) gmtime(T) + #define HDgmtime(T) gmtime(T) #endif /* HDgmtime */ #ifndef HDisalnum - #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ + #define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/ #endif /* HDisalnum */ #ifndef HDisalpha - #define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ + #define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/ #endif /* HDisalpha */ #ifndef HDisatty - #define HDisatty(F) isatty(F) + #define HDisatty(F) isatty(F) #endif /* HDisatty */ #ifndef HDiscntrl - #define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ + #define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/ #endif /* HDiscntrl */ #ifndef HDisdigit - #define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ + #define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/ #endif /* HDisdigit */ #ifndef HDisgraph - #define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ + #define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/ #endif /* HDisgraph */ #ifndef HDislower - #define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ + #define HDislower(C) islower((int)(C)) /*cast for solaris warning*/ #endif /* HDislower */ #ifndef HDisprint - #define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ + #define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/ #endif /* HDisprint */ #ifndef HDispunct - #define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ + #define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/ #endif /* HDispunct */ #ifndef HDisspace - #define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ + #define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/ #endif /* HDisspace */ #ifndef HDisupper - #define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ + #define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/ #endif /* HDisupper */ #ifndef HDisxdigit - #define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ + #define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/ #endif /* HDisxdigit */ #ifndef HDkill - #define HDkill(P,S) kill(P,S) + #define HDkill(P,S) kill(P,S) #endif /* HDkill */ #ifndef HDlabs - #define HDlabs(X) labs(X) + #define HDlabs(X) labs(X) #endif /* HDlabs */ #ifndef HDldexp - #define HDldexp(X,N) ldexp(X,N) + #define HDldexp(X,N) ldexp(X,N) #endif /* HDldexp */ #ifndef HDldiv - #define HDldiv(X,Y) ldiv(X,Y) + #define HDldiv(X,Y) ldiv(X,Y) #endif /* HDldiv */ #ifndef HDlink - #define HDlink(OLD,NEW) link(OLD,NEW) + #define HDlink(OLD,NEW) link(OLD,NEW) #endif /* HDlink */ #ifndef HDlocaleconv - #define HDlocaleconv() localeconv() + #define HDlocaleconv() localeconv() #endif /* HDlocaleconv */ #ifndef HDlocaltime - #define HDlocaltime(T) localtime(T) + #define HDlocaltime(T) localtime(T) #endif /* HDlocaltime */ #ifndef HDlog - #define HDlog(X) log(X) + #define HDlog(X) log(X) #endif /* HDlog */ #ifndef HDlog10 - #define HDlog10(X) log10(X) + #define HDlog10(X) log10(X) #endif /* HDlog10 */ #ifndef HDlongjmp - #define HDlongjmp(J,N) longjmp(J,N) + #define HDlongjmp(J,N) longjmp(J,N) #endif /* HDlongjmp */ /* HDlseek and HDoff_t must be defined together for consistency. */ #ifndef HDlseek #ifdef H5_HAVE_LSEEK64 - #define HDlseek(F,O,W) lseek64(F,O,W) - #define HDoff_t off64_t + #define HDlseek(F,O,W) lseek64(F,O,W) + #define HDoff_t off64_t #else - #define HDlseek(F,O,W) lseek(F,O,W) - #define HDoff_t off_t + #define HDlseek(F,O,W) lseek(F,O,W) + #define HDoff_t off_t #endif #endif /* HDlseek */ #ifndef HDmalloc - #define HDmalloc(Z) malloc(Z) + #define HDmalloc(Z) malloc(Z) #endif /* HDmalloc */ #ifndef HDposix_memalign #define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z) #endif /* HDposix_memalign */ #ifndef HDmblen - #define HDmblen(S,N) mblen(S,N) + #define HDmblen(S,N) mblen(S,N) #endif /* HDmblen */ #ifndef HDmbstowcs - #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) + #define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z) #endif /* HDmbstowcs */ #ifndef HDmbtowc - #define HDmbtowc(P,S,Z) mbtowc(P,S,Z) + #define HDmbtowc(P,S,Z) mbtowc(P,S,Z) #endif /* HDmbtowc */ #ifndef HDmemchr - #define HDmemchr(S,C,Z) memchr(S,C,Z) + #define HDmemchr(S,C,Z) memchr(S,C,Z) #endif /* HDmemchr */ #ifndef HDmemcmp - #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) + #define HDmemcmp(X,Y,Z) memcmp(X,Y,Z) #endif /* HDmemcmp */ /* * The (char*) casts are required for the DEC when optimizations are turned * on and the source and/or destination are not aligned. */ #ifndef HDmemcpy - #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) + #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z) #endif /* HDmemcpy */ #ifndef HDmemmove - #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) + #define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z) #endif /* HDmemmove */ #ifndef HDmemset - #define HDmemset(X,C,Z) memset(X,C,Z) + #define HDmemset(X,C,Z) memset(X,C,Z) #endif /* HDmemset */ #ifndef HDmkdir - #define HDmkdir(S,M) mkdir(S,M) + #define HDmkdir(S,M) mkdir(S,M) #endif /* HDmkdir */ #ifndef HDmkfifo - #define HDmkfifo(S,M) mkfifo(S,M) + #define HDmkfifo(S,M) mkfifo(S,M) #endif /* HDmkfifo */ #ifndef HDmktime - #define HDmktime(T) mktime(T) + #define HDmktime(T) mktime(T) #endif /* HDmktime */ #ifndef HDmodf - #define HDmodf(X,Y) modf(X,Y) + #define HDmodf(X,Y) modf(X,Y) #endif /* HDmodf */ #ifndef HDopen #ifdef _O_BINARY - #define HDopen(S,F,M) open(S,F|_O_BINARY,M) + #define HDopen(S,F,M) open(S,F|_O_BINARY,M) #else - #define HDopen(S,F,M) open(S,F,M) + #define HDopen(S,F,M) open(S,F,M) #endif #endif /* HDopen */ #ifndef HDopendir - #define HDopendir(S) opendir(S) + #define HDopendir(S) opendir(S) #endif /* HDopendir */ #ifndef HDpathconf - #define HDpathconf(S,N) pathconf(S,N) + #define HDpathconf(S,N) pathconf(S,N) #endif /* HDpathconf */ #ifndef HDpause - #define HDpause() pause() + #define HDpause() pause() #endif /* HDpause */ #ifndef HDperror - #define HDperror(S) perror(S) + #define HDperror(S) perror(S) #endif /* HDperror */ #ifndef HDpipe - #define HDpipe(F) pipe(F) + #define HDpipe(F) pipe(F) #endif /* HDpipe */ #ifndef HDpow - #define HDpow(X,Y) pow(X,Y) + #define HDpow(X,Y) pow(X,Y) #endif /* HDpow */ /* printf() variable arguments */ #ifndef HDputc - #define HDputc(C,F) putc(C,F) + #define HDputc(C,F) putc(C,F) #endif /* HDputc*/ #ifndef HDputchar - #define HDputchar(C) putchar(C) + #define HDputchar(C) putchar(C) #endif /* HDputchar */ #ifndef HDputs - #define HDputs(S) puts(S) + #define HDputs(S) puts(S) #endif /* HDputs */ #ifndef HDqsort - #define HDqsort(M,N,Z,F) qsort(M,N,Z,F) + #define HDqsort(M,N,Z,F) qsort(M,N,Z,F) #endif /* HDqsort*/ #ifndef HDraise - #define HDraise(N) raise(N) + #define HDraise(N) raise(N) #endif /* HDraise */ #ifdef H5_HAVE_RAND_R #ifndef HDrandom - #define HDrandom() HDrand() + #define HDrandom() HDrand() #endif /* HDrandom */ H5_DLL int HDrand(void); #elif H5_HAVE_RANDOM #ifndef HDrand - #define HDrand() random() + #define HDrand() random() #endif /* HDrand */ #ifndef HDrandom - #define HDrandom() random() + #define HDrandom() random() #endif /* HDrandom */ #else /* H5_HAVE_RANDOM */ #ifndef HDrand - #define HDrand() rand() + #define HDrand() rand() #endif /* HDrand */ #ifndef HDrandom - #define HDrandom() rand() + #define HDrandom() rand() #endif /* HDrandom */ #endif /* H5_HAVE_RANDOM */ #ifndef HDread - #define HDread(F,M,Z) read(F,M,Z) + #define HDread(F,M,Z) read(F,M,Z) #endif /* HDread */ #ifndef HDreaddir - #define HDreaddir(D) readdir(D) + #define HDreaddir(D) readdir(D) #endif /* HDreaddir */ #ifndef HDrealloc - #define HDrealloc(M,Z) realloc(M,Z) + #define HDrealloc(M,Z) realloc(M,Z) #endif /* HDrealloc */ #ifndef HDrealpath - #define HDrealpath(F1,F2) realpath(F1,F2) + #define HDrealpath(F1,F2) realpath(F1,F2) #endif /* HDrealloc */ #ifdef H5_VMS #ifdef __cplusplus @@ -1046,309 +1052,309 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); } #endif /* __cplusplus */ #ifndef HDremove - #define HDremove(S) HDremove_all(S) + #define HDremove(S) HDremove_all(S) #endif /* HDremove */ #else /* H5_VMS */ #ifndef HDremove - #define HDremove(S) remove(S) + #define HDremove(S) remove(S) #endif /* HDremove */ #endif /*H5_VMS*/ #ifndef HDrename - #define HDrename(OLD,NEW) rename(OLD,NEW) + #define HDrename(OLD,NEW) rename(OLD,NEW) #endif /* HDrename */ #ifndef HDrewind - #define HDrewind(F) rewind(F) + #define HDrewind(F) rewind(F) #endif /* HDrewind */ #ifndef HDrewinddir - #define HDrewinddir(D) rewinddir(D) + #define HDrewinddir(D) rewinddir(D) #endif /* HDrewinddir */ #ifndef HDrmdir - #define HDrmdir(S) rmdir(S) + #define HDrmdir(S) rmdir(S) #endif /* HDrmdir */ /* scanf() variable arguments */ #ifndef HDsetbuf - #define HDsetbuf(F,S) setbuf(F,S) + #define HDsetbuf(F,S) setbuf(F,S) #endif /* HDsetbuf */ #ifndef HDsetgid - #define HDsetgid(G) setgid(G) + #define HDsetgid(G) setgid(G) #endif /* HDsetgid */ #ifndef HDsetjmp - #define HDsetjmp(J) setjmp(J) + #define HDsetjmp(J) setjmp(J) #endif /* HDsetjmp */ #ifndef HDsetlocale - #define HDsetlocale(N,S) setlocale(N,S) + #define HDsetlocale(N,S) setlocale(N,S) #endif /* HDsetlocale */ #ifndef HDsetpgid - #define HDsetpgid(P,PG) setpgid(P,PG) + #define HDsetpgid(P,PG) setpgid(P,PG) #endif /* HDsetpgid */ #ifndef HDsetsid - #define HDsetsid() setsid() + #define HDsetsid() setsid() #endif /* HDsetsid */ #ifndef HDsetuid - #define HDsetuid(U) setuid(U) + #define HDsetuid(U) setuid(U) #endif /* HDsetuid */ #ifndef HDsetvbuf - #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) + #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z) #endif /* HDsetvbuf */ #ifndef HDsigaddset - #define HDsigaddset(S,N) sigaddset(S,N) + #define HDsigaddset(S,N) sigaddset(S,N) #endif /* HDsigaddset */ #ifndef HDsigdelset - #define HDsigdelset(S,N) sigdelset(S,N) + #define HDsigdelset(S,N) sigdelset(S,N) #endif /* HDsigdelset */ #ifndef HDsigemptyset - #define HDsigemptyset(S) sigemptyset(S) + #define HDsigemptyset(S) sigemptyset(S) #endif /* HDsigemptyset */ #ifndef HDsigfillset - #define HDsigfillset(S) sigfillset(S) + #define HDsigfillset(S) sigfillset(S) #endif /* HDsigfillset */ #ifndef HDsigismember - #define HDsigismember(S,N) sigismember(S,N) + #define HDsigismember(S,N) sigismember(S,N) #endif /* HDsigismember */ #ifndef HDsiglongjmp - #define HDsiglongjmp(J,N) siglongjmp(J,N) + #define HDsiglongjmp(J,N) siglongjmp(J,N) #endif /* HDsiglongjmp */ #ifndef HDsignal - #define HDsignal(N,F) signal(N,F) + #define HDsignal(N,F) signal(N,F) #endif /* HDsignal */ #ifndef HDsigpending - #define HDsigpending(S) sigpending(S) + #define HDsigpending(S) sigpending(S) #endif /* HDsigpending */ #ifndef HDsigprocmask - #define HDsigprocmask(H,S,O) sigprocmask(H,S,O) + #define HDsigprocmask(H,S,O) sigprocmask(H,S,O) #endif /* HDsigprocmask */ #ifndef HDsigsetjmp - #define HDsigsetjmp(J,N) sigsetjmp(J,N) + #define HDsigsetjmp(J,N) sigsetjmp(J,N) #endif /* HDsigsetjmp */ #ifndef HDsigsuspend - #define HDsigsuspend(S) sigsuspend(S) + #define HDsigsuspend(S) sigsuspend(S) #endif /* HDsigsuspend */ #ifndef HDsin - #define HDsin(X) sin(X) + #define HDsin(X) sin(X) #endif /* HDsin */ #ifndef HDsinh - #define HDsinh(X) sinh(X) + #define HDsinh(X) sinh(X) #endif /* HDsinh */ #ifndef HDsleep - #define HDsleep(N) sleep(N) + #define HDsleep(N) sleep(N) #endif /* HDsleep */ #ifndef HDsnprintf - #define HDsnprintf snprintf /*varargs*/ + #define HDsnprintf snprintf /*varargs*/ #endif /* HDsnprintf */ /* sprintf() variable arguments */ #ifndef HDsqrt - #define HDsqrt(X) sqrt(X) + #define HDsqrt(X) sqrt(X) #endif /* HDsqrt */ #ifdef H5_HAVE_RAND_R H5_DLL void HDsrand(unsigned int seed); #ifndef HDsrandom - #define HDsrandom(S) HDsrand(S) + #define HDsrandom(S) HDsrand(S) #endif /* HDsrandom */ #elif H5_HAVE_RANDOM #ifndef HDsrand - #define HDsrand(S) srandom(S) + #define HDsrand(S) srandom(S) #endif /* HDsrand */ #ifndef HDsrandom - #define HDsrandom(S) srandom(S) + #define HDsrandom(S) srandom(S) #endif /* HDsrandom */ #else /* H5_HAVE_RAND_R */ #ifndef HDsrand - #define HDsrand(S) srand(S) + #define HDsrand(S) srand(S) #endif /* HDsrand */ #ifndef HDsrandom - #define HDsrandom(S) srand(S) + #define HDsrandom(S) srand(S) #endif /* HDsrandom */ #endif /* H5_HAVE_RAND_R */ /* sscanf() variable arguments */ #ifndef HDstrcat - #define HDstrcat(X,Y) strcat(X,Y) + #define HDstrcat(X,Y) strcat(X,Y) #endif /* HDstrcat */ #ifndef HDstrchr - #define HDstrchr(S,C) strchr(S,C) + #define HDstrchr(S,C) strchr(S,C) #endif /* HDstrchr */ #ifndef HDstrcmp - #define HDstrcmp(X,Y) strcmp(X,Y) + #define HDstrcmp(X,Y) strcmp(X,Y) #endif /* HDstrcmp */ #ifndef HDstrcasecmp #define HDstrcasecmp(X,Y) strcasecmp(X,Y) #endif /* HDstrcasecmp */ #ifndef HDstrcoll - #define HDstrcoll(X,Y) strcoll(X,Y) + #define HDstrcoll(X,Y) strcoll(X,Y) #endif /* HDstrcoll */ #ifndef HDstrcpy - #define HDstrcpy(X,Y) strcpy(X,Y) + #define HDstrcpy(X,Y) strcpy(X,Y) #endif /* HDstrcpy */ #ifndef HDstrcspn - #define HDstrcspn(X,Y) strcspn(X,Y) + #define HDstrcspn(X,Y) strcspn(X,Y) #endif /* HDstrcspn */ #ifndef HDstrerror - #define HDstrerror(N) strerror(N) + #define HDstrerror(N) strerror(N) #endif /* HDstrerror */ #ifndef HDstrftime - #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) + #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) #endif /* HDstrftime */ #ifndef HDstrlen - #define HDstrlen(S) strlen(S) + #define HDstrlen(S) strlen(S) #endif /* HDstrlen */ #ifndef HDstrncat - #define HDstrncat(X,Y,Z) strncat(X,Y,Z) + #define HDstrncat(X,Y,Z) strncat(X,Y,Z) #endif /* HDstrncat */ #ifndef HDstrncmp - #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) + #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) #endif /* HDstrncmp */ #ifndef HDstrncpy - #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) + #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) #endif /* HDstrncpy */ #ifndef HDstrpbrk - #define HDstrpbrk(X,Y) strpbrk(X,Y) + #define HDstrpbrk(X,Y) strpbrk(X,Y) #endif /* HDstrpbrk */ #ifndef HDstrrchr - #define HDstrrchr(S,C) strrchr(S,C) + #define HDstrrchr(S,C) strrchr(S,C) #endif /* HDstrrchr */ #ifndef HDstrspn - #define HDstrspn(X,Y) strspn(X,Y) + #define HDstrspn(X,Y) strspn(X,Y) #endif /* HDstrspn */ #ifndef HDstrstr - #define HDstrstr(X,Y) strstr(X,Y) + #define HDstrstr(X,Y) strstr(X,Y) #endif /* HDstrstr */ #ifndef HDstrtod - #define HDstrtod(S,R) strtod(S,R) + #define HDstrtod(S,R) strtod(S,R) #endif /* HDstrtod */ #ifndef HDstrtok - #define HDstrtok(X,Y) strtok(X,Y) + #define HDstrtok(X,Y) strtok(X,Y) #endif /* HDstrtok */ #ifndef HDstrtol - #define HDstrtol(S,R,N) strtol(S,R,N) + #define HDstrtol(S,R,N) strtol(S,R,N) #endif /* HDstrtol */ H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base); #ifndef HDstrtoul - #define HDstrtoul(S,R,N) strtoul(S,R,N) + #define HDstrtoul(S,R,N) strtoul(S,R,N) #endif /* HDstrtoul */ #ifndef HDstrtoull - #define HDstrtoull(S,R,N) strtoull(S,R,N) + #define HDstrtoull(S,R,N) strtoull(S,R,N) #endif /* HDstrtoul */ #ifndef HDstrxfrm - #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) + #define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z) #endif /* HDstrxfrm */ #ifdef H5_HAVE_SYMLINK #ifndef HDsymlink - #define HDsymlink(F1,F2) symlink(F1,F2) + #define HDsymlink(F1,F2) symlink(F1,F2) #endif /* HDsymlink */ #endif /* H5_HAVE_SYMLINK */ #ifndef HDsysconf - #define HDsysconf(N) sysconf(N) + #define HDsysconf(N) sysconf(N) #endif /* HDsysconf */ #ifndef HDsystem - #define HDsystem(S) system(S) + #define HDsystem(S) system(S) #endif /* HDsystem */ #ifndef HDtan - #define HDtan(X) tan(X) + #define HDtan(X) tan(X) #endif /* HDtan */ #ifndef HDtanh - #define HDtanh(X) tanh(X) + #define HDtanh(X) tanh(X) #endif /* HDtanh */ #ifndef HDtcdrain - #define HDtcdrain(F) tcdrain(F) + #define HDtcdrain(F) tcdrain(F) #endif /* HDtcdrain */ #ifndef HDtcflow - #define HDtcflow(F,A) tcflow(F,A) + #define HDtcflow(F,A) tcflow(F,A) #endif /* HDtcflow */ #ifndef HDtcflush - #define HDtcflush(F,N) tcflush(F,N) + #define HDtcflush(F,N) tcflush(F,N) #endif /* HDtcflush */ #ifndef HDtcgetattr - #define HDtcgetattr(F,T) tcgetattr(F,T) + #define HDtcgetattr(F,T) tcgetattr(F,T) #endif /* HDtcgetattr */ #ifndef HDtcgetpgrp - #define HDtcgetpgrp(F) tcgetpgrp(F) + #define HDtcgetpgrp(F) tcgetpgrp(F) #endif /* HDtcgetpgrp */ #ifndef HDtcsendbreak - #define HDtcsendbreak(F,N) tcsendbreak(F,N) + #define HDtcsendbreak(F,N) tcsendbreak(F,N) #endif /* HDtcsendbreak */ #ifndef HDtcsetattr - #define HDtcsetattr(F,O,T) tcsetattr(F,O,T) + #define HDtcsetattr(F,O,T) tcsetattr(F,O,T) #endif /* HDtcsetattr */ #ifndef HDtcsetpgrp - #define HDtcsetpgrp(F,N) tcsetpgrp(F,N) + #define HDtcsetpgrp(F,N) tcsetpgrp(F,N) #endif /* HDtcsetpgrp */ #ifndef HDtime - #define HDtime(T) time(T) + #define HDtime(T) time(T) #endif /* HDtime */ #ifndef HDtimes - #define HDtimes(T) times(T) + #define HDtimes(T) times(T) #endif /* HDtimes*/ #ifndef HDtmpfile - #define HDtmpfile() tmpfile() + #define HDtmpfile() tmpfile() #endif /* HDtmpfile */ #ifndef HDtmpnam - #define HDtmpnam(S) tmpnam(S) + #define HDtmpnam(S) tmpnam(S) #endif /* HDtmpnam */ #ifndef HDtolower - #define HDtolower(C) tolower(C) + #define HDtolower(C) tolower(C) #endif /* HDtolower */ #ifndef HDtoupper - #define HDtoupper(C) toupper(C) + #define HDtoupper(C) toupper(C) #endif /* HDtoupper */ #ifndef HDttyname - #define HDttyname(F) ttyname(F) + #define HDttyname(F) ttyname(F) #endif /* HDttyname */ #ifndef HDtzset - #define HDtzset() tzset() + #define HDtzset() tzset() #endif /* HDtzset */ #ifndef HDumask - #define HDumask(N) umask(N) + #define HDumask(N) umask(N) #endif /* HDumask */ #ifndef HDuname - #define HDuname(S) uname(S) + #define HDuname(S) uname(S) #endif /* HDuname */ #ifndef HDungetc - #define HDungetc(C,F) ungetc(C,F) + #define HDungetc(C,F) ungetc(C,F) #endif /* HDungetc */ #ifndef HDunlink - #define HDunlink(S) unlink(S) + #define HDunlink(S) unlink(S) #endif /* HDunlink */ #ifndef HDutime - #define HDutime(S,T) utime(S,T) + #define HDutime(S,T) utime(S,T) #endif /* HDutime */ #ifndef HDva_arg - #define HDva_arg(A,T) va_arg(A,T) + #define HDva_arg(A,T) va_arg(A,T) #endif /* HDva_arg */ #ifndef HDva_end - #define HDva_end(A) va_end(A) + #define HDva_end(A) va_end(A) #endif /* HDva_end */ #ifndef HDva_start - #define HDva_start(A,P) va_start(A,P) + #define HDva_start(A,P) va_start(A,P) #endif /* HDva_start */ #ifndef HDvasprintf #define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A) #endif /* HDvasprintf */ #ifndef HDvfprintf - #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) + #define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A) #endif /* HDvfprintf */ #ifndef HDvprintf - #define HDvprintf(FMT,A) vprintf(FMT,A) + #define HDvprintf(FMT,A) vprintf(FMT,A) #endif /* HDvprintf */ #ifndef HDvsprintf - #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) + #define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A) #endif /* HDvsprintf */ #ifndef HDvsnprintf #define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A) #endif /* HDvsnprintf */ #ifndef HDwait - #define HDwait(W) wait(W) + #define HDwait(W) wait(W) #endif /* HDwait */ #ifndef HDwaitpid - #define HDwaitpid(P,W,O) waitpid(P,W,O) + #define HDwaitpid(P,W,O) waitpid(P,W,O) #endif /* HDwaitpid */ #ifndef HDwcstombs - #define HDwcstombs(S,P,Z) wcstombs(S,P,Z) + #define HDwcstombs(S,P,Z) wcstombs(S,P,Z) #endif /* HDwcstombs */ #ifndef HDwctomb - #define HDwctomb(S,C) wctomb(S,C) + #define HDwctomb(S,C) wctomb(S,C) #endif /* HDwctomb */ #ifndef HDwrite - #define HDwrite(F,M,Z) write(F,M,Z) + #define HDwrite(F,M,Z) write(F,M,Z) #endif /* HDwrite */ /* @@ -1447,9 +1453,9 @@ extern char *strdup(const char *s); #if defined(H5_HAVE_WINDOW_PATH) /* directory delimiter for Windows: slash and backslash are acceptable on Windows */ -#define DIR_SLASH_SEPC '/' -#define DIR_SEPC '\\' -#define DIR_SEPS "\\" +#define DIR_SLASH_SEPC '/' +#define DIR_SEPC '\\' +#define DIR_SEPS "\\" #define CHECK_DELIMITER(SS) ((SS == DIR_SEPC)||(SS == DIR_SLASH_SEPC)) #define CHECK_ABSOLUTE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':') && (CHECK_DELIMITER(NAME[2]))) #define CHECK_ABS_DRIVE(NAME) ((isalpha(NAME[0])) && (NAME[1] == ':')) @@ -1469,59 +1475,59 @@ extern char *strdup(const char *s); /* OpenVMS pathname: $:[path] * i.g. SYS$SYSUSERS:[LU.HDF5.SRC]H5system.c */ -#define DIR_SEPC ']' -#define DIR_SEPS "]" +#define DIR_SEPC ']' +#define DIR_SEPS "]" #define CHECK_DELIMITER(SS) (SS == DIR_SEPC) #define CHECK_ABSOLUTE(NAME) (strrchr(NAME, ':') && strrchr(NAME, '[')) -#define CHECK_ABS_DRIVE(NAME) (0) -#define CHECK_ABS_PATH(NAME) (0) +#define CHECK_ABS_DRIVE(NAME) (0) +#define CHECK_ABS_PATH(NAME) (0) #define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, DIR_SEPC); #else -#define DIR_SEPC '/' -#define DIR_SEPS "/" +#define DIR_SEPC '/' +#define DIR_SEPS "/" #define CHECK_DELIMITER(SS) (SS == DIR_SEPC) #define CHECK_ABSOLUTE(NAME) (CHECK_DELIMITER(*NAME)) -#define CHECK_ABS_DRIVE(NAME) (0) -#define CHECK_ABS_PATH(NAME) (0) +#define CHECK_ABS_DRIVE(NAME) (0) +#define CHECK_ABS_PATH(NAME) (0) #define GET_LAST_DELIMITER(NAME, ptr) ptr = strrchr(NAME, DIR_SEPC); #endif -#define COLON_SEPC ':' +#define COLON_SEPC ':' /* * These macros check whether debugging has been requested for a certain - * package at run-time. Code for debugging is conditionally compiled by - * defining constants like `H5X_DEBUG'. In order to see the output though + * package at run-time. Code for debugging is conditionally compiled by + * defining constants like `H5X_DEBUG'. In order to see the output though * the code must be enabled at run-time with an environment variable * HDF5_DEBUG which is a list of packages to debug. * * Note: If you add/remove items from this enum then be sure to update the - * information about the package in H5_init_library(). + * information about the package in H5_init_library(). */ typedef enum { - H5_PKG_A, /*Attributes */ - H5_PKG_AC, /*Meta data cache */ - H5_PKG_B, /*B-trees */ - H5_PKG_D, /*Datasets */ - H5_PKG_E, /*Error handling */ - H5_PKG_F, /*Files */ - H5_PKG_G, /*Groups */ - H5_PKG_HG, /*Global heap */ - H5_PKG_HL, /*Local heap */ - H5_PKG_I, /*Interface */ - H5_PKG_MF, /*File memory management */ - H5_PKG_MM, /*Core memory management */ - H5_PKG_O, /*Object headers */ - H5_PKG_P, /*Property lists */ - H5_PKG_S, /*Data spaces */ - H5_PKG_T, /*Data types */ - H5_PKG_V, /*Vector functions */ - H5_PKG_Z, /*Raw data filters */ - H5_NPKGS /*Must be last */ + H5_PKG_A, /*Attributes */ + H5_PKG_AC, /*Meta data cache */ + H5_PKG_B, /*B-trees */ + H5_PKG_D, /*Datasets */ + H5_PKG_E, /*Error handling */ + H5_PKG_F, /*Files */ + H5_PKG_G, /*Groups */ + H5_PKG_HG, /*Global heap */ + H5_PKG_HL, /*Local heap */ + H5_PKG_I, /*Interface */ + H5_PKG_MF, /*File memory management */ + H5_PKG_MM, /*Core memory management */ + H5_PKG_O, /*Object headers */ + H5_PKG_P, /*Property lists */ + H5_PKG_S, /*Data spaces */ + H5_PKG_T, /*Data types */ + H5_PKG_V, /*Vector functions */ + H5_PKG_Z, /*Raw data filters */ + H5_NPKGS /*Must be last */ } H5_pkg_t; typedef struct H5_debug_open_stream_t { @@ -1530,58 +1536,58 @@ typedef struct H5_debug_open_stream_t { } H5_debug_open_stream_t; typedef struct H5_debug_t { - FILE *trace; /*API trace output stream */ + FILE *trace; /*API trace output stream */ hbool_t ttop; /*Show only top-level calls? */ hbool_t ttimes; /*Show trace event times? */ struct { - const char *name; /*package name */ - FILE *stream; /*output stream or NULL */ + const char *name; /*package name */ + FILE *stream; /*output stream or NULL */ } pkg[H5_NPKGS]; H5_debug_open_stream_t *open_stream; /* Stack of open output streams */ } H5_debug_t; -extern H5_debug_t H5_debug_g; -#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) +extern H5_debug_t H5_debug_g; +#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream) /* Do not use const else AIX strings does not show it. */ extern char H5libhdf5_settings[]; /* embedded library information */ /*------------------------------------------------------------------------- - * Purpose: These macros are inserted automatically just after the - * FUNC_ENTER() macro of API functions and are used to trace - * application program execution. Unless H5_DEBUG_API has been - * defined they are no-ops. + * Purpose: These macros are inserted automatically just after the + * FUNC_ENTER() macro of API functions and are used to trace + * application program execution. Unless H5_DEBUG_API has been + * defined they are no-ops. * - * Arguments: R - Return type encoded as a string - * T - Argument types encoded as a string - * A0-An - Arguments. The number at the end of the macro name - * indicates the number of arguments. + * Arguments: R - Return type encoded as a string + * T - Argument types encoded as a string + * A0-An - Arguments. The number at the end of the macro name + * indicates the number of arguments. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * * Modifications: *------------------------------------------------------------------------- */ #ifdef H5_DEBUG_API -#define H5TRACE_DECL const char *RTYPE=NULL; \ +#define H5TRACE_DECL const char *RTYPE=NULL; \ double CALLTIME; -#define H5TRACE0(R,T) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T) -#define H5TRACE1(R,T,A0) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0) -#define H5TRACE2(R,T,A0,A1) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1) -#define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2) -#define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3) -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ +#define H5TRACE0(R,T) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T) +#define H5TRACE1(R,T,A0) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0) +#define H5TRACE2(R,T,A0,A1) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1) +#define H5TRACE3(R,T,A0,A1,A2) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2) +#define H5TRACE4(R,T,A0,A1,A2,A3) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3) +#define H5TRACE5(R,T,A0,A1,A2,A3,A4) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4) -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ +#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5) #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) RTYPE=R; \ - CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6) #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) RTYPE=R; \ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ @@ -1596,46 +1602,46 @@ extern char H5libhdf5_settings[]; /* embedded library information */ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \ #A10,A10) -#define H5TRACE_RETURN(V) if (RTYPE) { \ - H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V); \ - RTYPE=NULL; \ - } +#define H5TRACE_RETURN(V) if (RTYPE) { \ + H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V); \ + RTYPE=NULL; \ + } #else -#define H5TRACE_DECL /*void*/ -#define H5TRACE0(R,T) /*void*/ -#define H5TRACE1(R,T,A0) /*void*/ -#define H5TRACE2(R,T,A0,A1) /*void*/ -#define H5TRACE3(R,T,A0,A1,A2) /*void*/ -#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ -#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ -#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ +#define H5TRACE_DECL /*void*/ +#define H5TRACE0(R,T) /*void*/ +#define H5TRACE1(R,T,A0) /*void*/ +#define H5TRACE2(R,T,A0,A1) /*void*/ +#define H5TRACE3(R,T,A0,A1,A2) /*void*/ +#define H5TRACE4(R,T,A0,A1,A2,A3) /*void*/ +#define H5TRACE5(R,T,A0,A1,A2,A3,A4) /*void*/ +#define H5TRACE6(R,T,A0,A1,A2,A3,A4,A5) /*void*/ #define H5TRACE7(R,T,A0,A1,A2,A3,A4,A5,A6) /*void*/ #define H5TRACE8(R,T,A0,A1,A2,A3,A4,A5,A6,A7) /*void*/ #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) /*void*/ #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) /*void*/ #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/ -#define H5TRACE_RETURN(V) /*void*/ +#define H5TRACE_RETURN(V) /*void*/ #endif H5_DLL double H5_trace(const double *calltime, const char *func, const char *type, ...); /*------------------------------------------------------------------------- - * Purpose: Register function entry for library initialization and code - * profiling. + * Purpose: Register function entry for library initialization and code + * profiling. * - * Notes: Every file must have a file-scope variable called - * `initialize_interface_g' of type hbool_t which is initialized - * to FALSE. + * Notes: Every file must have a file-scope variable called + * `initialize_interface_g' of type hbool_t which is initialized + * to FALSE. * - * Don't use local variable initializers which contain - * calls to other library functions since the initializer - * would happen before the FUNC_ENTER() gets called. Don't - * use initializers that require special cleanup code to - * execute if FUNC_ENTER() fails since a failing FUNC_ENTER() - * returns immediately without branching to the `done' label. + * Don't use local variable initializers which contain + * calls to other library functions since the initializer + * would happen before the FUNC_ENTER() gets called. Don't + * use initializers that require special cleanup code to + * execute if FUNC_ENTER() fails since a failing FUNC_ENTER() + * returns immediately without branching to the `done' label. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * * Modifications: * @@ -1647,7 +1653,7 @@ H5_DLL double H5_trace(const double *calltime, const char *func, const char *typ #define H5_IS_API(S) ('_'!=((const char *)S)[2] && '_'!=((const char *)S)[3] && (!((const char *)S)[4] || '_'!=((const char *)S)[4])) /* global library version information string */ -extern char H5_lib_vers_info_g[]; +extern char H5_lib_vers_info_g[]; /* Lock headers */ #ifdef H5_HAVE_THREADSAFE @@ -1734,17 +1740,17 @@ extern hbool_t H5_MPEinit_g; /* Has the MPE Library been initialized? */ /* Macros for defining interface initialization routines */ #ifdef H5_INTERFACE_INIT_FUNC -static int H5_interface_initialize_g = 0; -static herr_t H5_INTERFACE_INIT_FUNC(void); -#define H5_INTERFACE_INIT(err) \ - /* Initialize this interface or bust */ \ - if (!H5_interface_initialize_g) { \ - H5_interface_initialize_g = 1; \ - if (H5_INTERFACE_INIT_FUNC()<0) { \ - H5_interface_initialize_g = 0; \ - HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \ - "interface initialization failed") \ - } \ +static int H5_interface_initialize_g = 0; +static herr_t H5_INTERFACE_INIT_FUNC(void); +#define H5_INTERFACE_INIT(err) \ + /* Initialize this interface or bust */ \ + if (!H5_interface_initialize_g) { \ + H5_interface_initialize_g = 1; \ + if (H5_INTERFACE_INIT_FUNC()<0) { \ + H5_interface_initialize_g = 0; \ + HGOTO_ERROR (H5E_FUNC, H5E_CANTINIT, err, \ + "interface initialization failed") \ + } \ } #else /* H5_INTERFACE_INIT_FUNC */ #define H5_INTERFACE_INIT(err) @@ -1753,17 +1759,17 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #ifndef NDEBUG #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) \ - static hbool_t func_check = FALSE; \ - \ - if(!func_check) { \ - /* Check API status */ \ - HDassert(asrt); \ - \ - /* Check function name */ \ - H5_CHECK_FUNCNAME(func_name); \ - \ - /* Don't check again */ \ - func_check = TRUE; \ + static hbool_t func_check = FALSE; \ + \ + if(!func_check) { \ + /* Check API status */ \ + HDassert(asrt); \ + \ + /* Check function name */ \ + H5_CHECK_FUNCNAME(func_name); \ + \ + /* Don't check again */ \ + func_check = TRUE; \ } /* end if */ #else /* NDEBUG */ #define FUNC_ENTER_COMMON_NOFUNC(func_name,asrt) @@ -1771,7 +1777,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_ENTER_COMMON(func_name, asrt) \ static const char FUNC[] = #func_name; \ - hbool_t err_occurred = FALSE; \ + hbool_t err_occurred = FALSE; \ FUNC_ENTER_COMMON_NOFUNC(func_name, asrt); #define FUNC_ENTER_COMMON_NOERR(func_name, asrt) \ @@ -1780,10 +1786,10 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); /* Threadsafety initialization code for API routines */ #define FUNC_ENTER_API_THREADSAFE \ - /* Initialize the thread-safe code */ \ + /* Initialize the thread-safe code */ \ H5_FIRST_THREAD_INIT \ - \ - /* Grab the mutex for the library */ \ + \ + /* Grab the mutex for the library */ \ H5_API_UNSET_CANCEL \ H5_API_LOCK @@ -1792,22 +1798,22 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); MPE_LOG_VARS(func_name) \ H5TRACE_DECL -#define FUNC_ENTER_API_COMMON(func_name) \ +#define FUNC_ENTER_API_COMMON(func_name) \ FUNC_ENTER_API_VARS(func_name) \ FUNC_ENTER_COMMON(func_name, H5_IS_API(#func_name)); \ FUNC_ENTER_API_THREADSAFE; -#define FUNC_ENTER_API_INIT(func_name,err) \ - /* Initialize the library */ \ +#define FUNC_ENTER_API_INIT(func_name,err) \ + /* Initialize the library */ \ if(!(H5_INIT_GLOBAL)) { \ H5_INIT_GLOBAL = TRUE; \ - if(H5_init_library() < 0) \ - HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, \ - "library initialization failed") \ - } \ + if(H5_init_library() < 0) \ + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, err, \ + "library initialization failed") \ + } \ \ - /* Initialize the interface, if appropriate */ \ - H5_INTERFACE_INIT(err) \ + /* Initialize the interface, if appropriate */ \ + H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC(#func_name) \ @@ -1817,9 +1823,9 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); /* Use this macro for all "normal" API functions */ #define FUNC_ENTER_API(func_name,err) {{ \ FUNC_ENTER_API_COMMON(func_name) \ - FUNC_ENTER_API_INIT(func_name,err); \ - /* Clear thread error stack entering public functions */ \ - H5E_clear_stack(NULL); \ + FUNC_ENTER_API_INIT(func_name,err); \ + /* Clear thread error stack entering public functions */ \ + H5E_clear_stack(NULL); \ { /* @@ -1828,7 +1834,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); */ #define FUNC_ENTER_API_NOCLEAR(func_name,err) {{ \ FUNC_ENTER_API_COMMON(func_name) \ - FUNC_ENTER_API_INIT(func_name,err); \ + FUNC_ENTER_API_INIT(func_name,err); \ { /* @@ -1853,14 +1859,14 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_ENTER_API_NOINIT_NOERR_NOFS(func_name) {{ \ FUNC_ENTER_API_VARS(func_name) \ FUNC_ENTER_COMMON_NOERR(func_name, H5_IS_API(#func_name)); \ - FUNC_ENTER_API_THREADSAFE; \ + FUNC_ENTER_API_THREADSAFE; \ BEGIN_MPE_LOG(func_name); \ { /* Note: this macro only works when there's _no_ interface initialization routine for the module */ -#define FUNC_ENTER_NOAPI_INIT(func_name,err) \ - /* Initialize the interface, if appropriate */ \ - H5_INTERFACE_INIT(err) \ +#define FUNC_ENTER_NOAPI_INIT(func_name,err) \ + /* Initialize the interface, if appropriate */ \ + H5_INTERFACE_INIT(err) \ \ /* Push the name of this function on the function stack */ \ H5_PUSH_FUNC(#func_name) @@ -1868,19 +1874,19 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); /* Use this macro for all "normal" non-API functions */ #define FUNC_ENTER_NOAPI(func_name,err) { \ FUNC_ENTER_COMMON(func_name, !H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ + FUNC_ENTER_NOAPI_INIT(func_name,err) \ { /* Use this macro for all non-API functions, which propagate errors, but don't issue them */ #define FUNC_ENTER_NOAPI_NOERR(func_name,err) { \ FUNC_ENTER_COMMON_NOERR(func_name, !H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ + FUNC_ENTER_NOAPI_INIT(func_name,err) \ { /* Use this macro for all non-API functions which don't issue errors */ #define FUNC_ENTER_NOAPI_NOFUNC(func_name) { \ FUNC_ENTER_COMMON_NOFUNC(func_name,!H5_IS_API(#func_name)); \ - FUNC_ENTER_NOAPI_INIT(func_name,err) \ + FUNC_ENTER_NOAPI_INIT(func_name,err) \ { /* @@ -1941,10 +1947,10 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); { /*------------------------------------------------------------------------- - * Purpose: Register function exit for code profiling. This should be - * the last statement executed by a function. + * Purpose: Register function exit for code profiling. This should be + * the last statement executed by a function. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * *------------------------------------------------------------------------- */ @@ -1955,33 +1961,33 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); #define FUNC_LEAVE_API(ret_value) \ FINISH_MPE_LOG; \ - H5TRACE_RETURN(ret_value); \ + H5TRACE_RETURN(ret_value); \ H5_POP_FUNC \ - if(err_occurred) \ - (void)H5E_dump_api_stack(TRUE); \ + if(err_occurred) \ + (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ + return(ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ }} /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOFS macro */ #define FUNC_LEAVE_API_NOFS(ret_value) \ FINISH_MPE_LOG; \ - H5TRACE_RETURN(ret_value); \ + H5TRACE_RETURN(ret_value); \ FUNC_LEAVE_API_THREADSAFE \ - return(ret_value); \ + return(ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ }} /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI(ret_value) \ H5_POP_FUNC \ - return(ret_value); \ + return(ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI_VOID \ H5_POP_FUNC \ - return; \ + return; \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ @@ -1991,7 +1997,7 @@ static herr_t H5_INTERFACE_INIT_FUNC(void); * (so far, just the H5CS routines themselves) */ #define FUNC_LEAVE_NOAPI_NOFS(ret_value) \ - return(ret_value); \ + return(ret_value); \ } /*end scope from end of FUNC_ENTER*/ \ } /*end scope from beginning of FUNC_ENTER*/ diff --git a/src/H5system.c b/src/H5system.c index afe07b0..1f0ad29 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -15,11 +15,11 @@ /*------------------------------------------------------------------------- * - * Created: H5system.c - * Aug 21 2006 - * Quincey Koziol + * Created: H5system.c + * Aug 21 2006 + * Quincey Koziol * - * Purpose: System call wrapper implementations. + * Purpose: System call wrapper implementations. * *------------------------------------------------------------------------- */ @@ -32,9 +32,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Fprivate.h" /* File access */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Fprivate.h" /* File access */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Eprivate.h" @@ -75,71 +75,71 @@ /*------------------------------------------------------------------------- - * Function: HDfprintf + * Function: HDfprintf * - * Purpose: Prints the optional arguments under the control of the format - * string FMT to the stream STREAM. This function takes the - * same format as fprintf(3c) with a few added features: + * Purpose: Prints the optional arguments under the control of the format + * string FMT to the stream STREAM. This function takes the + * same format as fprintf(3c) with a few added features: * - * The conversion modifier `H' refers to the size of an - * `hsize_t' or `hssize_t' type. For instance, "0x%018Hx" - * prints an `hsize_t' value as a hex number right justified and - * zero filled in an 18-character field. + * The conversion modifier `H' refers to the size of an + * `hsize_t' or `hssize_t' type. For instance, "0x%018Hx" + * prints an `hsize_t' value as a hex number right justified and + * zero filled in an 18-character field. * - * The conversion `a' refers to an `haddr_t' type. + * The conversion `a' refers to an `haddr_t' type. * - * Return: Success: Number of characters printed + * Return: Success: Number of characters printed * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, April 9, 1998 * * Modifications: - * Robb Matzke, 1999-07-27 - * The `%a' format refers to an argument of `haddr_t' type - * instead of `haddr_t*' and the return value is correct. + * Robb Matzke, 1999-07-27 + * The `%a' format refers to an argument of `haddr_t' type + * instead of `haddr_t*' and the return value is correct. *------------------------------------------------------------------------- */ int HDfprintf(FILE *stream, const char *fmt, ...) { - int n=0, nout = 0; - int fwidth, prec; - int zerofill; - int leftjust; - int plussign; - int ldspace; - int prefix; - char modifier[8]; - int conv; - char *rest, format_templ[128]; - const char *s; - va_list ap; + int n=0, nout = 0; + int fwidth, prec; + int zerofill; + int leftjust; + int plussign; + int ldspace; + int prefix; + char modifier[8]; + int conv; + char *rest, format_templ[128]; + const char *s; + va_list ap; assert (stream); assert (fmt); va_start (ap, fmt); while (*fmt) { - fwidth = prec = 0; - zerofill = 0; - leftjust = 0; - plussign = 0; - prefix = 0; - ldspace = 0; - modifier[0] = '\0'; - - if ('%'==fmt[0] && '%'==fmt[1]) { - HDputc ('%', stream); - fmt += 2; - nout++; - } else if ('%'==fmt[0]) { - s = fmt + 1; - - /* Flags */ - while(HDstrchr ("-+ #", *s)) { - switch(*s) { + fwidth = prec = 0; + zerofill = 0; + leftjust = 0; + plussign = 0; + prefix = 0; + ldspace = 0; + modifier[0] = '\0'; + + if ('%'==fmt[0] && '%'==fmt[1]) { + HDputc ('%', stream); + fmt += 2; + nout++; + } else if ('%'==fmt[0]) { + s = fmt + 1; + + /* Flags */ + while(HDstrchr ("-+ #", *s)) { + switch(*s) { case '-': leftjust = 1; break; @@ -155,61 +155,61 @@ HDfprintf(FILE *stream, const char *fmt, ...) case '#': prefix = 1; break; - } /* end switch */ /*lint !e744 Switch statement doesn't _need_ default */ - s++; - } /* end while */ - - /* Field width */ - if (HDisdigit (*s)) { - zerofill = ('0'==*s); - fwidth = (int)HDstrtol (s, &rest, 10); - s = rest; - } else if ('*'==*s) { - fwidth = va_arg (ap, int); - if (fwidth<0) { - leftjust = 1; - fwidth = -fwidth; - } - s++; - } - - /* Precision */ - if ('.'==*s) { - s++; - if (HDisdigit (*s)) { - prec = (int)HDstrtol (s, &rest, 10); - s = rest; - } else if ('*'==*s) { - prec = va_arg (ap, int); - s++; - } - if (prec<1) prec = 1; - } - - /* Extra type modifiers */ - if (HDstrchr ("ZHhlqLI", *s)) { - switch (*s) { + } /* end switch */ /*lint !e744 Switch statement doesn't _need_ default */ + s++; + } /* end while */ + + /* Field width */ + if (HDisdigit (*s)) { + zerofill = ('0'==*s); + fwidth = (int)HDstrtol (s, &rest, 10); + s = rest; + } else if ('*'==*s) { + fwidth = va_arg (ap, int); + if (fwidth<0) { + leftjust = 1; + fwidth = -fwidth; + } + s++; + } + + /* Precision */ + if ('.'==*s) { + s++; + if (HDisdigit (*s)) { + prec = (int)HDstrtol (s, &rest, 10); + s = rest; + } else if ('*'==*s) { + prec = va_arg (ap, int); + s++; + } + if (prec<1) prec = 1; + } + + /* Extra type modifiers */ + if (HDstrchr ("ZHhlqLI", *s)) { + switch (*s) { /*lint --e{506} Don't issue warnings about constant value booleans */ /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ - case 'H': - if (sizeof(hsize_t)0) - sprintf (format_templ+HDstrlen(format_templ), "%d", fwidth); - if (prec>0) - sprintf (format_templ+HDstrlen(format_templ), ".%d", prec); - if (*modifier) - sprintf (format_templ+HDstrlen(format_templ), "%s", modifier); - sprintf (format_templ+HDstrlen(format_templ), "%c", conv); - - - /* Conversion */ - switch (conv) { - case 'd': - case 'i': - if (!HDstrcmp(modifier, "h")) { - short x = (short)va_arg (ap, int); - n = fprintf (stream, format_templ, x); - } else if (!*modifier) { - int x = va_arg (ap, int); - n = fprintf (stream, format_templ, x); - } else if (!HDstrcmp (modifier, "l")) { - long x = va_arg (ap, long); - n = fprintf (stream, format_templ, x); - } else { - int64_t x = va_arg(ap, int64_t); - n = fprintf (stream, format_templ, x); - } - break; - - case 'o': - case 'u': - case 'x': - case 'X': - if (!HDstrcmp (modifier, "h")) { - unsigned short x = (unsigned short)va_arg (ap, unsigned int); - n = fprintf (stream, format_templ, x); - } else if (!*modifier) { - unsigned int x = va_arg (ap, unsigned int); /*lint !e732 Loss of sign not really occuring */ - n = fprintf (stream, format_templ, x); - } else if (!HDstrcmp (modifier, "l")) { - unsigned long x = va_arg (ap, unsigned long); /*lint !e732 Loss of sign not really occuring */ - n = fprintf (stream, format_templ, x); - } else { - uint64_t x = va_arg(ap, uint64_t); /*lint !e732 Loss of sign not really occuring */ - n = fprintf (stream, format_templ, x); - } - break; - - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - if (!HDstrcmp (modifier, "h")) { - float x = (float) va_arg (ap, double); - n = fprintf (stream, format_templ, x); - } else if (!*modifier || !HDstrcmp (modifier, "l")) { - double x = va_arg (ap, double); - n = fprintf (stream, format_templ, x); - } else { - /* - * Some compilers complain when `long double' and - * `double' are the same thing. - */ + break; + } + s++; + } + + /* Conversion */ + conv = *s++; + + /* Create the format template */ + sprintf (format_templ, "%%%s%s%s%s%s", + leftjust?"-":"", plussign?"+":"", + ldspace?" ":"", prefix?"#":"", zerofill?"0":""); + if (fwidth>0) + sprintf (format_templ+HDstrlen(format_templ), "%d", fwidth); + if (prec>0) + sprintf (format_templ+HDstrlen(format_templ), ".%d", prec); + if (*modifier) + sprintf (format_templ+HDstrlen(format_templ), "%s", modifier); + sprintf (format_templ+HDstrlen(format_templ), "%c", conv); + + + /* Conversion */ + switch (conv) { + case 'd': + case 'i': + if (!HDstrcmp(modifier, "h")) { + short x = (short)va_arg (ap, int); + n = fprintf (stream, format_templ, x); + } else if (!*modifier) { + int x = va_arg (ap, int); + n = fprintf (stream, format_templ, x); + } else if (!HDstrcmp (modifier, "l")) { + long x = va_arg (ap, long); + n = fprintf (stream, format_templ, x); + } else { + int64_t x = va_arg(ap, int64_t); + n = fprintf (stream, format_templ, x); + } + break; + + case 'o': + case 'u': + case 'x': + case 'X': + if (!HDstrcmp (modifier, "h")) { + unsigned short x = (unsigned short)va_arg (ap, unsigned int); + n = fprintf (stream, format_templ, x); + } else if (!*modifier) { + unsigned int x = va_arg (ap, unsigned int); /*lint !e732 Loss of sign not really occuring */ + n = fprintf (stream, format_templ, x); + } else if (!HDstrcmp (modifier, "l")) { + unsigned long x = va_arg (ap, unsigned long); /*lint !e732 Loss of sign not really occuring */ + n = fprintf (stream, format_templ, x); + } else { + uint64_t x = va_arg(ap, uint64_t); /*lint !e732 Loss of sign not really occuring */ + n = fprintf (stream, format_templ, x); + } + break; + + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + if (!HDstrcmp (modifier, "h")) { + float x = (float) va_arg (ap, double); + n = fprintf (stream, format_templ, x); + } else if (!*modifier || !HDstrcmp (modifier, "l")) { + double x = va_arg (ap, double); + n = fprintf (stream, format_templ, x); + } else { + /* + * Some compilers complain when `long double' and + * `double' are the same thing. + */ #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - long double x = va_arg (ap, long double); - n = fprintf (stream, format_templ, x); + long double x = va_arg (ap, long double); + n = fprintf (stream, format_templ, x); #else - double x = va_arg (ap, double); - n = fprintf (stream, format_templ, x); + double x = va_arg (ap, double); + n = fprintf (stream, format_templ, x); #endif - } - break; + } + break; - case 'a': + case 'a': { - haddr_t x = va_arg (ap, haddr_t); /*lint !e732 Loss of sign not really occuring */ - if (H5F_addr_defined(x)) { - sprintf(format_templ, "%%%s%s%s%s%s", - leftjust?"-":"", plussign?"+":"", - ldspace?" ":"", prefix?"#":"", - zerofill?"0":""); - if (fwidth>0) - sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); + haddr_t x = va_arg (ap, haddr_t); /*lint !e732 Loss of sign not really occuring */ + if (H5F_addr_defined(x)) { + sprintf(format_templ, "%%%s%s%s%s%s", + leftjust?"-":"", plussign?"+":"", + ldspace?" ":"", prefix?"#":"", + zerofill?"0":""); + if (fwidth>0) + sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); /*lint --e{506} Don't issue warnings about constant value booleans */ /*lint --e{774} Don't issue warnings boolean within 'if' always evaluates false/true */ - if (sizeof(x)==H5_SIZEOF_INT) { - HDstrcat(format_templ, "u"); - } else if (sizeof(x)==H5_SIZEOF_LONG) { - HDstrcat(format_templ, "lu"); - } else if (sizeof(x)==H5_SIZEOF_LONG_LONG) { - HDstrcat(format_templ, H5_PRINTF_LL_WIDTH); - HDstrcat(format_templ, "u"); - } - n = fprintf(stream, format_templ, x); - } else { - HDstrcpy(format_templ, "%"); - if (leftjust) + if (sizeof(x)==H5_SIZEOF_INT) { + HDstrcat(format_templ, "u"); + } else if (sizeof(x)==H5_SIZEOF_LONG) { + HDstrcat(format_templ, "lu"); + } else if (sizeof(x)==H5_SIZEOF_LONG_LONG) { + HDstrcat(format_templ, H5_PRINTF_LL_WIDTH); + HDstrcat(format_templ, "u"); + } + n = fprintf(stream, format_templ, x); + } else { + HDstrcpy(format_templ, "%"); + if (leftjust) HDstrcat(format_templ, "-"); - if (fwidth) - sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); - HDstrcat(format_templ, "s"); - fprintf(stream, format_templ, "UNDEF"); - } - } - break; - - case 'c': + if (fwidth) + sprintf(format_templ+HDstrlen(format_templ), "%d", fwidth); + HDstrcat(format_templ, "s"); + fprintf(stream, format_templ, "UNDEF"); + } + } + break; + + case 'c': { - char x = (char)va_arg (ap, int); - n = fprintf (stream, format_templ, x); - } - break; + char x = (char)va_arg (ap, int); + n = fprintf (stream, format_templ, x); + } + break; - case 's': - case 'p': + case 's': + case 'p': { - char *x = va_arg (ap, char*); /*lint !e64 Type mismatch not really occuring */ - n = fprintf (stream, format_templ, x); - } - break; + char *x = va_arg (ap, char*); /*lint !e64 Type mismatch not really occuring */ + n = fprintf (stream, format_templ, x); + } + break; - case 'n': + case 'n': format_templ[HDstrlen(format_templ)-1] = 'u'; n = fprintf (stream, format_templ, nout); - break; + break; case 't': { @@ -379,18 +379,18 @@ HDfprintf(FILE *stream, const char *fmt, ...) } break; - default: - HDfputs (format_templ, stream); - n = (int)HDstrlen (format_templ); - break; - } - nout += n; - fmt = s; - } else { - HDputc (*fmt, stream); - fmt++; - nout++; - } + default: + HDfputs (format_templ, stream); + n = (int)HDstrlen (format_templ); + break; + } + nout += n; + fmt = s; + } else { + HDputc (*fmt, stream); + fmt++; + nout++; + } } va_end (ap); return nout; @@ -398,43 +398,43 @@ HDfprintf(FILE *stream, const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: HDstrtoll + * Function: HDstrtoll * - * Purpose: Converts the string S to an int64_t value according to the - * given BASE, which must be between 2 and 36 inclusive, or be - * the special value zero. + * Purpose: Converts the string S to an int64_t value according to the + * given BASE, which must be between 2 and 36 inclusive, or be + * the special value zero. * - * The string must begin with an arbitrary amount of white space - * (as determined by isspace(3c)) followed by a single optional + * The string must begin with an arbitrary amount of white space + * (as determined by isspace(3c)) followed by a single optional * `+' or `-' sign. If BASE is zero or 16 the string may then - * include a `0x' or `0X' prefix, and the number will be read in - * base 16; otherwise a zero BASE is taken as 10 (decimal) - * unless the next character is a `0', in which case it is taken - * as 8 (octal). - * - * The remainder of the string is converted to an int64_t in the - * obvious manner, stopping at the first character which is not - * a valid digit in the given base. (In bases above 10, the - * letter `A' in either upper or lower case represetns 10, `B' - * represents 11, and so forth, with `Z' representing 35.) - * - * If REST is not null, the address of the first invalid - * character in S is stored in *REST. If there were no digits - * at all, the original value of S is stored in *REST. Thus, if - * *S is not `\0' but **REST is `\0' on return the entire string - * was valid. - * - * Return: Success: The result. - * - * Failure: If the input string does not contain any - * digits then zero is returned and REST points - * to the original value of S. If an overflow - * or underflow occurs then the maximum or - * minimum possible value is returned and the - * global `errno' is set to ERANGE. If BASE is - * incorrect then zero is returned. - * - * Programmer: Robb Matzke + * include a `0x' or `0X' prefix, and the number will be read in + * base 16; otherwise a zero BASE is taken as 10 (decimal) + * unless the next character is a `0', in which case it is taken + * as 8 (octal). + * + * The remainder of the string is converted to an int64_t in the + * obvious manner, stopping at the first character which is not + * a valid digit in the given base. (In bases above 10, the + * letter `A' in either upper or lower case represetns 10, `B' + * represents 11, and so forth, with `Z' representing 35.) + * + * If REST is not null, the address of the first invalid + * character in S is stored in *REST. If there were no digits + * at all, the original value of S is stored in *REST. Thus, if + * *S is not `\0' but **REST is `\0' on return the entire string + * was valid. + * + * Return: Success: The result. + * + * Failure: If the input string does not contain any + * digits then zero is returned and REST points + * to the original value of S. If an overflow + * or underflow occurs then the maximum or + * minimum possible value is returned and the + * global `errno' is set to ERANGE. If BASE is + * incorrect then zero is returned. + * + * Programmer: Robb Matzke * Thursday, April 9, 1998 * * Modifications: @@ -444,13 +444,13 @@ HDfprintf(FILE *stream, const char *fmt, ...) int64_t HDstrtoll(const char *s, const char **rest, int base) { - int64_t sign=1, acc=0; - hbool_t overflow = FALSE; + int64_t sign=1, acc=0; + hbool_t overflow = FALSE; errno = 0; if (!s || (base && (base<2 || base>36))) { - if (rest) *rest = s; - return 0; + if (rest) *rest = s; + return 0; } /* Skip white space */ @@ -458,51 +458,51 @@ HDstrtoll(const char *s, const char **rest, int base) /* Optional minus or plus sign */ if ('+'==*s) { - s++; + s++; } else if ('-'==*s) { - sign = -1; - s++; + sign = -1; + s++; } /* Zero base prefix */ if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { - base = 16; - s += 2; + base = 16; + s += 2; } else if (0==base && '0'==*s) { - base = 8; - s++; + base = 8; + s++; } else if (0==base) { - base = 10; + base = 10; } /* Digits */ while ((base<=10 && *s>='0' && *s<'0'+base) || - (base>10 && ((*s>='0' && *s<='9') || - (*s>='a' && *s<'a'+base-10) || - (*s>='A' && *s<'A'+base-10)))) { - if (!overflow) { - int64_t digit = 0; - if (*s>='0' && *s<='9') digit = *s - '0'; - else if (*s>='a' && *s<='z') digit = (*s-'a')+10; - else digit = (*s-'A')+10; - - if (acc*base+digit < acc) { - overflow = TRUE; - } else { - acc = acc*base + digit; - } - } - s++; + (base>10 && ((*s>='0' && *s<='9') || + (*s>='a' && *s<'a'+base-10) || + (*s>='A' && *s<'A'+base-10)))) { + if (!overflow) { + int64_t digit = 0; + if (*s>='0' && *s<='9') digit = *s - '0'; + else if (*s>='a' && *s<='z') digit = (*s-'a')+10; + else digit = (*s-'A')+10; + + if (acc*base+digit < acc) { + overflow = TRUE; + } else { + acc = acc*base + digit; + } + } + s++; } /* Overflow */ if (overflow) { - if (sign>0) { - acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; - } else { - acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); - } - errno = ERANGE; + if (sign>0) { + acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; + } else { + acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); + } + errno = ERANGE; } /* Return values */ @@ -513,20 +513,20 @@ HDstrtoll(const char *s, const char **rest, int base) /*------------------------------------------------------------------------- - * Function: HDrand/HDsrand + * Function: HDrand/HDsrand * - * Purpose: Wrapper function for rand. If rand_r exists on this system, - * use it. + * Purpose: Wrapper function for rand. If rand_r exists on this system, + * use it. * - * Wrapper function for srand. If rand_r is available, it will keep - * track of the seed locally instead of using srand() which modifies - * global state and can break other programs. + * Wrapper function for srand. If rand_r is available, it will keep + * track of the seed locally instead of using srand() which modifies + * global state and can break other programs. * - * Return: Success: Random number from 0 to RAND_MAX + * Return: Success: Random number from 0 to RAND_MAX * - * Failure: Cannot fail. + * Failure: Cannot fail. * - * Programmer: Leon Arber + * Programmer: Leon Arber * March 6, 2006. * *------------------------------------------------------------------------- @@ -548,17 +548,17 @@ void HDsrand(unsigned int seed) /*------------------------------------------------------------------------- - * Function: HDremove_all + * Function: HDremove_all * - * Purpose: Wrapper function for remove on VMS systems + * Purpose: Wrapper function for remove on VMS systems * - * This function deletes all versions of a file + * This function deletes all versions of a file * - * Return: Success: 0; + * Return: Success: 0; * - * Failure: -1 + * Failure: -1 * - * Programmer: Elena Pourmal + * Programmer: Elena Pourmal * March 22, 2006 * *------------------------------------------------------------------------- @@ -584,13 +584,13 @@ HDremove_all(const char *fname) #endif /*------------------------------------------------------------------------- - * Function: Wgettimeofday + * Function: Wgettimeofday * - * Purpose: Wrapper function for gettimeofday on Windows systems + * Purpose: Wrapper function for gettimeofday on Windows systems * - * This function can get the time as well as a timezone + * This function can get the time as well as a timezone * - * Return: 0 + * Return: 0 * * This implementation is taken from the Cygwin source distribution at * src/winsup/mingw/mingwex/gettimeofday.c @@ -599,12 +599,12 @@ HDremove_all(const char *fname) * Danny Smith * and released in the public domain. * - * Programmer: Scott Wegner + * Programmer: Scott Wegner * May 19, 2009 * *------------------------------------------------------------------------- */ -#ifdef _WIN32 +#ifdef H5_HAVE_VISUAL_STUDIO /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosecond units */ #define _W32_FT_OFFSET (116444736000000000ULL) @@ -638,6 +638,27 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) Do not set errno on error. */ return 0; } + +#ifdef H5_HAVE_WINSOCK_H +#pragma comment(lib, "advapi32.lib") +#endif + +#define WloginBuffer_count 256 +static char Wlogin_buffer[WloginBuffer_count]; + +char* +Wgetlogin() +{ + +#ifdef H5_HAVE_WINSOCK_H + long bufferCount = WloginBuffer_count; + if (GetUserName(Wlogin_buffer, &bufferCount) == 0) + return (Wlogin_buffer); + else +#endif /* H5_HAVE_WINSOCK_H */ + return NULL; +} + #endif @@ -645,16 +666,16 @@ Wgettimeofday(struct timeval *tv, struct timezone *tz) * Function: H5_build_extpath * * Purpose: To build the path for later searching of target file for external - * link. This path can be either: + * link. This path can be either: * 1. The absolute path of NAME * or * 2. The current working directory + relative path of NAME * - * Return: Success: 0 - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * - * Programmer: Vailin Choi - * April 2, 2008 + * Programmer: Vailin Choi + * April 2, 2008 * *------------------------------------------------------------------------- */ @@ -692,23 +713,23 @@ H5_build_extpath(const char *name, char **extpath/*out*/) if(NULL == (new_name = (char *)H5MM_strdup(name))) HGOTO_ERROR(H5E_INTERNAL, H5E_NOSPACE, FAIL, "memory allocation failed") - /* - * Windows: name[0-1] is ":" - * Get current working directory on the drive specified in NAME - * Unix: does not apply + /* + * Windows: name[0-1] is ":" + * Get current working directory on the drive specified in NAME + * Unix: does not apply * OpenVMS: does not apply - */ + */ if(CHECK_ABS_DRIVE(name)) { drive = name[0] - 'A' + 1; retcwd = HDgetdcwd(drive, cwdpath, MAX_PATH_LEN); HDstrcpy(new_name, &name[2]); } /* end if */ - /* - * Windows: name[0] is a '/' or '\' - * Get current drive - * Unix: does not apply + /* + * Windows: name[0] is a '/' or '\' + * Get current drive + * Unix: does not apply * OpenVMS: does not apply - */ + */ else if(CHECK_ABS_PATH(name) && (0 != (drive = HDgetdrive()))) { sprintf(cwdpath, "%c:%c", (drive+'A'-1), name[0]); retcwd = cwdpath; @@ -764,9 +785,9 @@ H5_build_extpath(const char *name, char **extpath/*out*/) done: /* Release resources */ if(cwdpath) - H5MM_xfree(cwdpath); + H5MM_xfree(cwdpath); if(new_name) - H5MM_xfree(new_name); + H5MM_xfree(new_name); FUNC_LEAVE_NOAPI(ret_value) } /* H5_build_extpath() */ diff --git a/src/H5win32defs.h b/src/H5win32defs.h index a428899..5daef23 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -23,7 +23,7 @@ * */ -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API typedef struct _stati64 h5_stat_t; typedef __int64 h5_stat_size_t; @@ -33,41 +33,21 @@ typedef __int64 h5_stat_size_t; #define HDdup(F) _dup(F) #define HDfdopen(N,S) _fdopen(N,S) #define HDfileno(F) _fileno(F) -#if _MSC_VER > 1310 /* Newer than VS.NET 2003 */ #define HDftruncate(F,L) _chsize_s(F,L) -#else -#define HDftruncate(F,L) chsize(F,L) -#endif #define HDfstat(F,B) _fstati64(F,B) #define HDisatty(F) _isatty(F) -#define HDlstat(S,B) _lstati64(S,B) -#define HDstat(S,B) _stati64(S,B) #define HDgetcwd(S,Z) _getcwd(S,Z) #define HDgetdcwd(D,S,Z) _getdcwd(D,S,Z) - -struct timezone { - int tz_minuteswest; - int tz_dsttime; -}; - -#ifdef __cplusplus - extern "C" { -#endif /* __cplusplus */ -H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#ifdef __cplusplus - } -#endif /* __cplusplus */ -#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) - #define HDgetdrive() _getdrive() #define HDlseek(F,O,W) _lseeki64(F,O,W) -#define HDoff_t __int64 -#define HDmemset(X,C,Z) memset((void*)(X),C,Z) +#define HDlstat(S,B) _lstati64(S,B) #define HDmkdir(S,M) _mkdir(S) +#define HDoff_t __int64 #define HDopen(S,F,M) _open(S,F|_O_BINARY,M) #define HDread(F,M,Z) _read(F,M,Z) #define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2)) #define HDsleep(S) Sleep(S*1000) +#define HDstat(S,B) _stati64(S,B) #define HDstrcasecmp(A,B) _stricmp(A,B) #define HDstrtoull(S,R,N) _strtoui64(S,R,N) #define HDstrdup(S) _strdup(S) @@ -77,11 +57,34 @@ H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); #define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A) #define HDwrite(F,M,Z) _write(F,M,Z) +#ifdef H5_HAVE_VISUAL_STUDIO +/* + * The (void*) cast just avoids a compiler warning in H5_HAVE_VISUAL_STUDIO + */ +#define HDmemset(X,C,Z) memset((void*)(X),C,Z) + +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; + +#ifdef __cplusplus + extern "C" { +#endif /* __cplusplus */ + H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); + H5_DLL char* Wgetlogin(); +#ifdef __cplusplus + } +#endif /* __cplusplus */ +#define HDgettimeofday(V,Z) Wgettimeofday(V,Z) +#define HDgetlogin() Wgetlogin() + +#endif /* H5_HAVE_VISUAL_STUDIO */ + /* Non-POSIX functions */ /* Don't use actual pthread_self on Windows because the return * type cannot be cast as a ulong like other systems. */ #define HDpthread_self_ulong() ((unsigned long)GetCurrentThreadId()) - -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ diff --git a/test/flush2.c b/test/flush2.c index 5675856..da41415 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -17,10 +17,10 @@ * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Purpose: This is the second half of a two-part test that makes sure - * that a file can be read after an application crashes as long - * as the file was flushed first. This half tries to read the - * file created by the first half. + * Purpose: This is the second half of a two-part test that makes sure + * that a file can be read after an application crashes as long + * as the file was flushed first. This half tries to read the + * file created by the first half. */ #include "h5test.h" @@ -31,19 +31,19 @@ const char *FILENAME[] = { NULL }; -static double the_data[100][100]; +static double the_data[100][100]; /*------------------------------------------------------------------------- - * Function: check_dset + * Function: check_dset * - * Purpose: Part 2 of a two-part H5Fflush() test, checks if the data in a dataset - * is what it is supposed to be. + * Purpose: Part 2 of a two-part H5Fflush() test, checks if the data in a dataset + * is what it is supposed to be. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: 1 + * Failure: 1 * - * Programmer: Leon Arber + * Programmer: Leon Arber * Oct. 4, 2006. * *------------------------------------------------------------------------- @@ -51,10 +51,10 @@ static double the_data[100][100]; static int check_dset(hid_t file, const char* name) { - hid_t space, dset; - hsize_t ds_size[2] = {100, 100}; - double error; - size_t i, j; + hid_t space, dset; + hsize_t ds_size[2] = {100, 100}; + double error; + size_t i, j; /* Open the dataset */ if((dset = H5Dopen2(file, name, H5P_DEFAULT)) < 0) goto error; @@ -64,24 +64,24 @@ check_dset(hid_t file, const char* name) /* Read some data */ if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, - the_data) < 0) goto error; + the_data) < 0) goto error; for(i = 0; i < (size_t)ds_size[0]; i++) - for(j = 0; j < (size_t)ds_size[1]; j++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - error = fabs(the_data[i][j] - (double)(hssize_t)i / ((hssize_t)j + 1)); - if(error > 0.0001) { - H5_FAILED(); - printf(" dset[%lu][%lu] = %g\n", - (unsigned long)i, (unsigned long)j, the_data[i][j]); - printf(" should be %g\n", - (double)(hssize_t)i/(hssize_t)(j+1)); - goto error; - } - } + for(j = 0; j < (size_t)ds_size[1]; j++) { + /* + * The extra cast in the following statement is a bug workaround + * for the Win32 version 5.0 compiler. + * 1998-11-06 ptl + */ + error = fabs(the_data[i][j] - (double)(hssize_t)i / ((hssize_t)j + 1)); + if(error > 0.0001) { + H5_FAILED(); + printf(" dset[%lu][%lu] = %g\n", + (unsigned long)i, (unsigned long)j, the_data[i][j]); + printf(" should be %g\n", + (double)(hssize_t)i/(hssize_t)(j+1)); + goto error; + } + } if(H5Dclose(dset) < 0) goto error; return 0; @@ -91,15 +91,15 @@ error: /*------------------------------------------------------------------------- - * Function: check_file + * Function: check_file * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: 1 + * Failure: 1 * - * Programmer: Leon Arber + * Programmer: Leon Arber * Sept. 26, 2006. * *------------------------------------------------------------------------- @@ -107,9 +107,9 @@ error: static int check_file(char* filename, hid_t fapl, int flag) { - hid_t file, groups, grp; - char name[1024]; - int i; + hid_t file, groups, grp; + char name[1024]; + int i; if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error; if(check_dset(file, "dset")) goto error; @@ -117,9 +117,9 @@ check_file(char* filename, hid_t fapl, int flag) /* Open some groups */ if((groups = H5Gopen2(file, "some_groups", H5P_DEFAULT)) < 0) goto error; for(i = 0; i < 100; i++) { - sprintf(name, "grp%02u", (unsigned)i); - if((grp = H5Gopen2(groups, name, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + sprintf(name, "grp%02u", (unsigned)i); + if((grp = H5Gopen2(groups, name, H5P_DEFAULT)) < 0) goto error; + if(H5Gclose(grp) < 0) goto error; } /* end for */ /* Check to see if that last added dataset in the third file is accessible @@ -137,20 +137,20 @@ error: /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: 1 + * Failure: 1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 23, 1998 * * Modifications: - * Leon Arber - * Sept. 26, 2006, expand to check for case where the was file not flushed. + * Leon Arber + * Sept. 26, 2006, expand to check for case where the was file not flushed. * *------------------------------------------------------------------------- */ @@ -159,7 +159,7 @@ main(void) { hid_t fapl; H5E_auto2_t func; - char name[1024]; + char name[1024]; h5_reset(); fapl = h5_fileaccess(); @@ -186,7 +186,7 @@ main(void) PASSED() else { -#if defined _WIN32 && defined _HDF5USEDLL_ +#if defined H5_HAVE_WIN32_API && defined _HDF5USEDLL_ SKIPPED(); puts(" DLL will flush the file even when calling _exit, skip this test temporarily"); #elif defined H5_VMS @@ -209,7 +209,7 @@ main(void) PASSED() else { -#if defined _WIN32 && defined _HDF5USEDLL_ +#if defined H5_HAVE_WIN32_API && defined _HDF5USEDLL_ SKIPPED(); puts(" DLL will flush the file even when calling _exit, skip this test temporarily"); #elif defined H5_VMS diff --git a/test/h5test.c b/test/h5test.c index 02bbf22..f8c3d9c 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -17,11 +17,11 @@ * Programmer: Robb Matzke * Thursday, November 19, 1998 * - * Purpose: Provides support functions for most of the hdf5 tests cases. + * Purpose: Provides support functions for most of the hdf5 tests cases. * */ -#undef NDEBUG /*override -DNDEBUG */ +#undef NDEBUG /*override -DNDEBUG */ #include #include #include "h5test.h" @@ -32,35 +32,33 @@ #define H5G_TESTING #include "H5Gpkg.h" -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API #include -#include -#include -#endif /* _WIN32 */ +#endif /* H5_HAVE_WIN32_API */ /* * Define these environment variables or constants to influence functions in * this test support library. The environment variable is used in preference * to the cpp constant. If neither is defined then use some default value. * - * HDF5_DRIVER: This string describes what low level file driver to - * use for HDF5 file access. The first word in the - * value is the name of the driver and subsequent data - * is interpreted according to the driver. See - * h5_fileaccess() for details. - * - * HDF5_PREFIX: A string to add to the beginning of all serial test - * file names. This can be used to run tests in a - * different file system (e.g., "/tmp" or "/tmp/myname"). - * The prefix will be separated from the base file name - * by a slash. See h5_fixname() for details. - * - * HDF5_PARAPREFIX: A string to add to the beginning of all parallel test - * file names. This can be used to tell MPIO what driver - * to use (e.g., "gfs:", "ufs:", or "nfs:") or to use a - * different file system (e.g., "/tmp" or "/tmp/myname"). - * The prefix will be separated from the base file name - * by a slash. See h5_fixname() for details. + * HDF5_DRIVER: This string describes what low level file driver to + * use for HDF5 file access. The first word in the + * value is the name of the driver and subsequent data + * is interpreted according to the driver. See + * h5_fileaccess() for details. + * + * HDF5_PREFIX: A string to add to the beginning of all serial test + * file names. This can be used to run tests in a + * different file system (e.g., "/tmp" or "/tmp/myname"). + * The prefix will be separated from the base file name + * by a slash. See h5_fixname() for details. + * + * HDF5_PARAPREFIX: A string to add to the beginning of all parallel test + * file names. This can be used to tell MPIO what driver + * to use (e.g., "gfs:", "ufs:", or "nfs:") or to use a + * different file system (e.g., "/tmp" or "/tmp/myname"). + * The prefix will be separated from the base file name + * by a slash. See h5_fixname() for details. * */ /* @@ -72,7 +70,7 @@ #ifndef HDF5_PARAPREFIX #define HDF5_PARAPREFIX "" #endif -char *paraprefix = NULL; /* for command line option para-prefix */ +char *paraprefix = NULL; /* for command line option para-prefix */ #ifdef H5_HAVE_PARALLEL MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ #endif @@ -84,13 +82,13 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ * These are the letters that are appended to the file name when generating * names for the split and multi drivers. They are: * - * m: All meta data when using the split driver. - * s: The userblock, superblock, and driver info block - * b: B-tree nodes - * r: Dataset raw data - * g: Global heap - * l: local heap (object names) - * o: object headers + * m: All meta data when using the split driver. + * s: The userblock, superblock, and driver info block + * b: B-tree nodes + * r: Dataset raw data + * g: Global heap + * l: local heap (object names) + * o: object headers */ static const char *multi_letters = "msbrglo"; @@ -98,16 +96,16 @@ static herr_t h5_errors(hid_t estack, void *client_data); /*------------------------------------------------------------------------- - * Function: h5_errors + * Function: h5_errors * - * Purpose: Displays the error stack after printing "*FAILED*". + * Purpose: Displays the error stack after printing "*FAILED*". * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke - * Wednesday, March 4, 1998 + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 * * Modifications: * @@ -123,50 +121,50 @@ h5_errors(hid_t estack, void UNUSED *client_data) /*------------------------------------------------------------------------- - * Function: h5_cleanup + * Function: h5_cleanup * - * Purpose: Cleanup temporary test files. - * base_name contains the list of test file names. - * The file access property list is also closed. + * Purpose: Cleanup temporary test files. + * base_name contains the list of test file names. + * The file access property list is also closed. * - * Return: Non-zero if cleanup actions were performed; zero otherwise. + * Return: Non-zero if cleanup actions were performed; zero otherwise. * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * May 28, 1998 * * Modifications: - * Albert Cheng, 2000-09-09 - * Added the explicite base_name argument to replace the - * global variable FILENAME. + * Albert Cheng, 2000-09-09 + * Added the explicite base_name argument to replace the + * global variable FILENAME. * *------------------------------------------------------------------------- */ int h5_cleanup(const char *base_name[], hid_t fapl) { - char filename[1024]; - char temp[2048]; - int i, j; - int retval=0; - hid_t driver; + char filename[1024]; + char temp[2048]; + int i, j; + int retval=0; + hid_t driver; if (GetTestCleanup()){ - for (i = 0; base_name[i]; i++) { - if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) - continue; + for (i = 0; base_name[i]; i++) { + if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) + continue; driver = H5Pget_driver(fapl); - if (driver == H5FD_FAMILY) { - for (j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); + if (driver == H5FD_FAMILY) { + for (j = 0; /*void*/; j++) { + HDsnprintf(temp, sizeof temp, filename, j); - if (HDaccess(temp, F_OK) < 0) + if (HDaccess(temp, F_OK) < 0) break; - HDremove(temp); - } - } else if (driver == H5FD_CORE) { + HDremove(temp); + } + } else if (driver == H5FD_CORE) { hbool_t backing; /* Whether the core file has backing store */ H5Pget_fapl_core(fapl,NULL,&backing); @@ -175,21 +173,21 @@ h5_cleanup(const char *base_name[], hid_t fapl) if(backing) HDremove(filename); - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", - filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ - } - } else { - HDremove(filename); - } - } - - retval = 1; + } else if (driver == H5FD_MULTI) { + H5FD_mem_t mt; + assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + HDsnprintf(temp, sizeof temp, "%s-%c.h5", + filename, multi_letters[mt]); + HDremove(temp); /*don't care if it fails*/ + } + } else { + HDremove(filename); + } + } + + retval = 1; } H5Pclose(fapl); @@ -198,13 +196,13 @@ h5_cleanup(const char *base_name[], hid_t fapl) /*------------------------------------------------------------------------- - * Function: h5_reset + * Function: h5_reset * - * Purpose: Reset the library by closing it. + * Purpose: Reset the library by closing it. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: @@ -230,7 +228,7 @@ h5_reset(void) */ #ifdef OLD_WAY { - char filename[1024]; + char filename[1024]; /* * Cause the library to emit some diagnostics early so they don't @@ -238,12 +236,12 @@ h5_reset(void) */ sprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid()); H5E_BEGIN_TRY { - hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); - hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(grp); - H5Fclose(file); - HDunlink(filename); + hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, + H5P_DEFAULT); + hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(grp); + H5Fclose(file); + HDunlink(filename); } H5E_END_TRY; } #endif /* OLD_WAY */ @@ -251,34 +249,34 @@ h5_reset(void) /*------------------------------------------------------------------------- - * Function: h5_fixname + * Function: h5_fixname * - * Purpose: Create a file name from a file base name like `test' and - * return it through the FULLNAME (at most SIZE characters - * counting the null terminator). The full name is created by - * prepending the contents of HDF5_PREFIX (separated from the - * base name by a slash) and appending a file extension based on - * the driver supplied, resulting in something like - * `ufs:/u/matzke/test.h5'. + * Purpose: Create a file name from a file base name like `test' and + * return it through the FULLNAME (at most SIZE characters + * counting the null terminator). The full name is created by + * prepending the contents of HDF5_PREFIX (separated from the + * base name by a slash) and appending a file extension based on + * the driver supplied, resulting in something like + * `ufs:/u/matzke/test.h5'. * - * Return: Success: The FULLNAME pointer. + * Return: Success: The FULLNAME pointer. * - * Failure: NULL if BASENAME or FULLNAME is the null - * pointer or if FULLNAME isn't large enough for - * the result. + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, November 19, 1998 * * Modifications: - * Robb Matzke, 1999-08-03 - * Modified to use the virtual file layer. + * Robb Matzke, 1999-08-03 + * Modified to use the virtual file layer. * - * Albert Cheng, 2000-01-25 - * Added prefix for parallel test files. + * Albert Cheng, 2000-01-25 + * Added prefix for parallel test files. * - * Albert Cheng, 2003-05-08 - * Changed the default parallel prefix back to NULL but added + * Albert Cheng, 2003-05-08 + * Changed the default parallel prefix back to NULL but added * an explanation remark of $HDF5_PARAPREFIX. *------------------------------------------------------------------------- */ @@ -290,7 +288,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) char *ptr, last = '\0'; size_t i, j; hid_t driver = -1; - int isppdriver = 0; /* if the driver is MPI parallel */ + int isppdriver = 0; /* if the driver is MPI parallel */ if (!base_name || !fullname || size < 1) return NULL; @@ -299,20 +297,20 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* figure out the suffix */ if (H5P_DEFAULT != fapl) { - if ((driver = H5Pget_driver(fapl)) < 0) + if ((driver = H5Pget_driver(fapl)) < 0) return NULL; - if (H5FD_FAMILY == driver) - suffix = "%05d.h5"; - else if (H5FD_MULTI == driver) - suffix = NULL; + if (H5FD_FAMILY == driver) + suffix = "%05d.h5"; + else if (H5FD_MULTI == driver) + suffix = NULL; } /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX * could be of value -1 if it is not defined. */ isppdriver = H5P_DEFAULT != fapl && - (H5FD_MPIO==driver || H5FD_MPIPOSIX==driver); + (H5FD_MPIO==driver || H5FD_MPIPOSIX==driver); /* Check HDF5_NOCLEANUP environment setting. * (The #ifdef is needed to prevent compile failure in case MPI is not @@ -320,12 +318,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if (isppdriver){ #ifdef H5_HAVE_PARALLEL - if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) - SetTestNoCleanup(); + if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) + SetTestNoCleanup(); #endif /* H5_HAVE_PARALLEL */ }else{ - if (HDgetenv("HDF5_NOCLEANUP")) - SetTestNoCleanup(); + if (HDgetenv("HDF5_NOCLEANUP")) + SetTestNoCleanup(); } /* Check what prefix to use for test files. Process HDF5_PARAPREFIX and @@ -336,52 +334,52 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if (isppdriver){ #ifdef H5_HAVE_PARALLEL - /* + /* * For parallel: * First use command line option, then the environment * variable, then try the constant - */ + */ static int explained = 0; - prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); + prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); - if (!prefix && !explained) { - /* print hint by process 0 once. */ - int mpi_rank; + if (!prefix && !explained) { + /* print hint by process 0 once. */ + int mpi_rank; - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if (mpi_rank == 0) - printf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. E.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); + if (mpi_rank == 0) + printf("*** Hint ***\n" + "You can use environment variable HDF5_PARAPREFIX to " + "run parallel test files in a\n" + "different directory or to add file type prefix. E.g.,\n" + " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" + " export HDF5_PARAPREFIX\n" + "*** End of Hint ***\n"); - explained = TRUE; + explained = TRUE; #ifdef HDF5_PARAPREFIX prefix = HDF5_PARAPREFIX; #endif /* HDF5_PARAPREFIX */ - } + } #endif /* H5_HAVE_PARALLEL */ } else { - /* + /* * For serial: * First use the environment variable, then try the constant - */ - prefix = HDgetenv("HDF5_PREFIX"); + */ + prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX - if (!prefix) + if (!prefix) prefix = HDF5_PREFIX; #endif /* HDF5_PREFIX */ } /* Prepend the prefix value to the base name */ if (prefix && *prefix) { - if (isppdriver){ + if (isppdriver){ /* This is a parallel system */ char *subdir; @@ -441,18 +439,18 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return NULL; } } else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; + /* Buffer is too small */ + return NULL; } else { - HDstrcpy(fullname, base_name); + HDstrcpy(fullname, base_name); } /* Append a suffix */ if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) return NULL; - HDstrcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ @@ -468,19 +466,19 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /*------------------------------------------------------------------------- - * Function: h5_rmprefix + * Function: h5_rmprefix * - * Purpose: This "removes" the MPIO driver prefix part of the file name - * by returning a pointer that points at the non-prefix component + * Purpose: This "removes" the MPIO driver prefix part of the file name + * by returning a pointer that points at the non-prefix component * part of the file name. E.g., - * Input Return - * pfs:/scratch1/dataX /scratch1/dataX - * /scratch2/dataY /scratch2/dataY - * Note that there is no change to the original file name. + * Input Return + * pfs:/scratch1/dataX /scratch1/dataX + * /scratch2/dataY /scratch2/dataY + * Note that there is no change to the original file name. * - * Return: Success: a pointer at the non-prefix part. + * Return: Success: a pointer at the non-prefix part. * - * Programmer: Albert Cheng; Jun 1, 2006 + * Programmer: Albert Cheng; Jun 1, 2006 * *------------------------------------------------------------------------- */ @@ -490,26 +488,26 @@ h5_rmprefix(const char *filename) const char *ret_ptr; if ((ret_ptr = HDstrstr(filename, ":")) == NULL) - ret_ptr = filename; + ret_ptr = filename; else - ret_ptr++; + ret_ptr++; return(ret_ptr); } /*------------------------------------------------------------------------- - * Function: h5_fileaccess + * Function: h5_fileaccess * - * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER + * Purpose: Returns a file access template which is the default template + * but with a file driver set according to the constant or + * environment variable HDF5_DRIVER * - * Return: Success: A file access property list + * Return: Success: A file access property list * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, November 19, 1998 * * Modifications: @@ -519,8 +517,8 @@ h5_rmprefix(const char *filename) hid_t h5_fileaccess(void) { - const char *val = NULL; - const char *name; + const char *val = NULL; + const char *name; char s[1024]; hid_t fapl = -1; @@ -538,53 +536,53 @@ h5_fileaccess(void) if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + /* Unix read() and write() system calls */ + if (H5Pset_fapl_sec2(fapl)<0) return -1; } else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; + /* Standard C fread() and fwrite() system calls */ + if (H5Pset_fapl_stdio(fapl)<0) return -1; } else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1; + /* In-core temporary file with 1MB increment */ + if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1; } else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) - return -1; + /* Split meta data and raw data each using default driver */ + if (H5Pset_fapl_split(fapl, + "-m.h5", H5P_DEFAULT, + "-r.h5", H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { - memb_fapl[mt] = H5P_DEFAULT; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } /* end for */ - - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { - return -1; - } + /* Multi-file driver, general case of the split driver */ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][1024]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); + + HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { + memb_fapl[mt] = H5P_DEFAULT; + sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); + memb_name[mt] = sv[mt]; + memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); + } /* end for */ + + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, + memb_addr, FALSE)<0) { + return -1; + } } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ - /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + /* Family of files, each 1MB and using the default driver */ + if ((val=HDstrtok(NULL, " \t\n\r"))) + fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; } else if (!HDstrcmp(name, "log")) { unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; @@ -594,20 +592,20 @@ h5_fileaccess(void) log_flags = (unsigned)HDstrtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) - return -1; + return -1; } else if (!HDstrcmp(name, "direct")) { #ifdef H5_HAVE_DIRECT - /* Linux direct read() and write() system calls. Set memory boundary, file block size, - * and copy buffer size to the default values. */ - if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1; + /* Linux direct read() and write() system calls. Set memory boundary, file block size, + * and copy buffer size to the default values. */ + if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1; #endif } else if(!HDstrcmp(name, "latest")) { - /* use the latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + /* use the latest format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; } else { - /* Unknown driver */ - return -1; + /* Unknown driver */ + return -1; } return fapl; @@ -615,13 +613,13 @@ h5_fileaccess(void) /*------------------------------------------------------------------------- - * Function: h5_no_hwconv + * Function: h5_no_hwconv * - * Purpose: Turn off hardware data type conversions. + * Purpose: Turn off hardware data type conversions. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: @@ -636,13 +634,13 @@ h5_no_hwconv(void) /*------------------------------------------------------------------------- - * Function: h5_show_hostname + * Function: h5_show_hostname * - * Purpose: Show hostname. Show process ID if in MPI environment. + * Purpose: Show hostname. Show process ID if in MPI environment. * - * Return: void + * Return: void * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * 2002/04/22 * * Modifications: @@ -652,8 +650,8 @@ h5_no_hwconv(void) void h5_show_hostname(void) { - char hostname[80]; -#ifdef _WIN32 + char hostname[80]; +#ifdef H5_HAVE_WIN32_API WSADATA wsaData; int err; #endif @@ -661,21 +659,21 @@ h5_show_hostname(void) /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL { - int mpi_rank, mpi_initialized; - - MPI_Initialized(&mpi_initialized); - if (mpi_initialized){ - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - printf("MPI-process %d.", mpi_rank); - }else - printf("thread 0."); + int mpi_rank, mpi_initialized; + + MPI_Initialized(&mpi_initialized); + if (mpi_initialized){ + MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + printf("MPI-process %d.", mpi_rank); + }else + printf("thread 0."); } #elif defined(H5_HAVE_THREADSAFE) printf("thread %lu.", HDpthread_self_ulong()); #else printf("thread 0."); #endif -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API err = WSAStartup( MAKEWORD(2,2), &wsaData ); if ( err != 0 ) { @@ -699,13 +697,13 @@ h5_show_hostname(void) #endif #ifdef H5_HAVE_GETHOSTNAME if (gethostname(hostname, (size_t)80) < 0) - printf(" gethostname failed\n"); + printf(" gethostname failed\n"); else - printf(" hostname=%s\n", hostname); + printf(" hostname=%s\n", hostname); #else printf(" gethostname not supported\n"); #endif -#ifdef _WIN32 +#ifdef H5_HAVE_WIN32_API WSACleanup(); #endif } @@ -728,8 +726,8 @@ h5_show_hostname(void) int h5_set_info_object(void) { - char *envp; /* environment pointer */ - int ret_value=0; + char *envp; /* environment pointer */ + int ret_value=0; /* handle any MPI INFO hints via $HDF5_MPI_INFO */ if ((envp = getenv("HDF5_MPI_INFO")) != NULL){ @@ -816,39 +814,39 @@ h5_set_info_object(void) void h5_dump_info_object(MPI_Info info) { - char key[MPI_MAX_INFO_KEY+1]; - char value[MPI_MAX_INFO_VAL+1]; - int flag; - int i, nkeys; + char key[MPI_MAX_INFO_KEY+1]; + char value[MPI_MAX_INFO_VAL+1]; + int flag; + int i, nkeys; printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info, - MPI_MAX_INFO_VAL); + MPI_MAX_INFO_VAL); if (info==MPI_INFO_NULL){ - printf("object is MPI_INFO_NULL\n"); + printf("object is MPI_INFO_NULL\n"); } else { - MPI_Info_get_nkeys(info, &nkeys); - printf("object has %d items\n", nkeys); - for (i=0; i= 0) { - if(env == NULL) - env = (char*) HDmalloc(len+1); - else if(strlen(env) < len) - env = (char*) HDrealloc(env, len+1); - - MPI_Bcast(env, len, MPI_CHAR, root, comm); - env[len] = '\0'; - } - else { - if(env) - HDfree(env); - env = NULL; - } - } + MPI_Comm_rank(comm, &mpi_rank); + MPI_Comm_size(comm, &mpi_size); + assert(root < mpi_size); + + /* The root task does the getenv call + * and sends the result to the other tasks */ + if(mpi_rank == root) { + env = HDgetenv(name); + if(env) { + len = HDstrlen(env); + MPI_Bcast(&len, 1, MPI_INT, root, comm); + MPI_Bcast(env, len, MPI_CHAR, root, comm); + } + else { + /* len -1 indicates that the variable was not in the environment */ + len = -1; + MPI_Bcast(&len, 1, MPI_INT, root, comm); + } + } + else { + MPI_Bcast(&len, 1, MPI_INT, root, comm); + if(len >= 0) { + if(env == NULL) + env = (char*) HDmalloc(len+1); + else if(strlen(env) < len) + env = (char*) HDrealloc(env, len+1); + + MPI_Bcast(env, len, MPI_CHAR, root, comm); + env[len] = '\0'; + } + else { + if(env) + HDfree(env); + env = NULL; + } + } } #ifndef NDEBUG diff --git a/test/vfd.c b/test/vfd.c index d89d136..f6e9f06 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -76,9 +76,9 @@ const char *FILENAME[] = { static herr_t test_sec2(void) { - hid_t file = -1; - hid_t fapl = -1; - hid_t access_fapl = -1; + hid_t file = -1; + hid_t fapl = -1; + hid_t access_fapl = -1; char filename[1024]; int *fhandle = NULL; hsize_t file_size = 0; @@ -157,18 +157,18 @@ test_direct(void) { #ifdef H5_HAVE_DIRECT hid_t file=(-1), fapl, access_fapl = -1; - hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; + hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; char filename[1024]; int *fhandle=NULL; hsize_t file_size; - hsize_t dims1[2], dims2[1]; - size_t mbound; - size_t fbsize; - size_t cbsize; - int *points, *check, *p1, *p2; - int wdata2[DSET2_DIM] = {11,12,13,14}; - int rdata2[DSET2_DIM]; - int i, j, n; + hsize_t dims1[2], dims2[1]; + size_t mbound; + size_t fbsize; + size_t cbsize; + int *points, *check, *p1, *p2; + int wdata2[DSET2_DIM] = {11,12,13,14}; + int rdata2[DSET2_DIM]; + int i, j, n; #endif /*H5_HAVE_DIRECT*/ TESTING("DIRECT I/O file driver"); @@ -189,10 +189,10 @@ test_direct(void) if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) TEST_ERROR; if(mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE) - TEST_ERROR; + TEST_ERROR; if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0) - TEST_ERROR; + TEST_ERROR; H5E_BEGIN_TRY { file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); @@ -200,7 +200,7 @@ test_direct(void) if(file<0) { H5Pclose (fapl); SKIPPED(); - printf(" Probably the file system doesn't support Direct I/O\n"); + printf(" Probably the file system doesn't support Direct I/O\n"); return 0; } @@ -244,8 +244,8 @@ test_direct(void) /* Initialize the dset1 */ p1 = points; for(i = n = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - *p1++ = n++; + for(j = 0; j < DSET1_DIM2; j++) + *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; @@ -275,13 +275,13 @@ test_direct(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ /* Create the data space2. For data set 2, memory address and data size are not aligned. */ dims2[0] = DSET2_DIM; @@ -308,12 +308,12 @@ test_direct(void) /* Check that the values read are the same as the values written */ for(i = 0; i < DSET2_DIM; i++) - if(wdata2[i] != rdata2[i]) { - H5_FAILED(); - printf(" Read different values than written in data set 2.\n"); - printf(" At index %d\n", i); + if(wdata2[i] != rdata2[i]) { + H5_FAILED(); + printf(" Read different values than written in data set 2.\n"); + printf(" At index %d\n", i); TEST_ERROR; - } /* end if */ + } /* end if */ if(H5Sclose(space1) < 0) TEST_ERROR; @@ -326,9 +326,9 @@ test_direct(void) if(H5Fclose(file) < 0) TEST_ERROR; if(points) - free(points); + free(points); if(check) - free(check); + free(check); h5_cleanup(FILENAME, fapl); PASSED(); @@ -368,10 +368,10 @@ test_core(void) char filename[1024]; void *fhandle=NULL; hsize_t file_size; - int *points, *check, *p1, *p2; - hid_t dset1=-1, space1=-1; - hsize_t dims1[2]; - int i, j, n; + int *points, *check, *p1, *p2; + hid_t dset1=-1, space1=-1; + hsize_t dims1[2]; + int i, j, n; TESTING("CORE file driver"); @@ -433,8 +433,8 @@ test_core(void) /* Initialize the dset1 */ p1 = points; for(i = n = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - *p1++ = n++; + for(j = 0; j < DSET1_DIM2; j++) + *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; @@ -464,13 +464,13 @@ test_core(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ if(H5Dclose(dset1) < 0) TEST_ERROR; @@ -502,7 +502,7 @@ test_core(void) /* Reallocate memory for reading buffer. */ if(check) - free(check); + free(check); check = (int*)malloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)); @@ -514,13 +514,13 @@ test_core(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) @@ -538,9 +538,9 @@ test_core(void) if(H5Fclose(file) < 0) TEST_ERROR; if(points) - free(points); + free(points); if(check) - free(check); + free(check); h5_cleanup(FILENAME, fapl); @@ -1469,7 +1469,7 @@ error: static herr_t test_windows(void) { -#ifdef _WIN32 +#ifdef H5_HAVE_WINDOWS hid_t file = -1; hid_t fapl = -1; @@ -1478,16 +1478,16 @@ test_windows(void) int *fhandle = NULL; hsize_t file_size = 0; -#endif /*_WIN32*/ +#endif /*H5_HAVE_WINDOWS*/ TESTING("WINDOWS file driver"); -#ifndef _WIN32 +#ifndef H5_HAVE_WINDOWS SKIPPED(); return 0; -#else /*_WIN32*/ +#else /* H5_HAVE_WINDOWS */ /* Set property list and file name for WINDOWS driver. */ fapl = h5_fileaccess(); @@ -1540,7 +1540,7 @@ error: } H5E_END_TRY; return -1; -#endif /*_WIN32*/ +#endif /* H5_HAVE_WINDOWS */ } @@ -1579,9 +1579,9 @@ main(void) nerrors += test_windows() < 0 ? 1 : 0; if(nerrors) { - printf("***** %d Virtual File Driver TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); - return 1; + printf("***** %d Virtual File Driver TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + return 1; } printf("All Virtual File Driver tests passed.\n"); diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index cfed58b..232f3c1 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -25,7 +25,7 @@ /* Name of tool */ #define PROGRAMNAME "h5import" -#ifdef WIN32 +#ifdef H5_HAVE_WIN32_API #define READ_OPEN_FLAGS "rb" #else #define READ_OPEN_FLAGS "r" @@ -309,7 +309,7 @@ static int processDataFile(char *infile, struct Input *in, hid_t file_id) const char *err11 = "Error in reading string data.\n"; /*------------------------------------------------------------------------- - * special case for opening binary classes in WIN32 + * special case for opening binary classes in H5_HAVE_WIN32_API * "FP" denotes a floating point binary file, * "IN" denotes a signed integer binary file, * "UIN" denotes an unsigned integer binary file, diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c index 2869236..434cba7 100755 --- a/tools/h5import/h5importtest.c +++ b/tools/h5import/h5importtest.c @@ -16,7 +16,7 @@ #include #include "H5private.h" -#ifdef WIN32 +#ifdef H5_HAVE_WIN32_API #define OPEN_FLAGS "wb" #else #define OPEN_FLAGS "w" diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h index fbc976f..456ef1a 100755 --- a/windows/src/H5pubconf.h +++ b/windows/src/H5pubconf.h @@ -9,6 +9,12 @@ /* Define if the Windows virtual file driver should be compiled */ #define H5_HAVE_WINDOWS 1 +/* Define if on the Windows platform */ +#define H5_HAVE_WIN32_API 1 + +/* Define if using a Windows compiler (i.e. Visual Studio) */ +#define H5_HAVE_VISUAL_STUDIO 1 + /* Define if the Windows virtual file driver should use buffered IO functions */ /* #undef WINDOWS_USE_STDIO */ -- cgit v0.12