From bcb587dcc2305763546acd8e3303240530cd20cf Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Thu, 28 Jun 2001 16:23:13 -0500 Subject: [svn-r4081] Purpose: [is this a bug fix? feature? ...] Description: [describe the bug, or describe the new feature, etc] Solution: [details about the changes, algorithm, etc...] [Please as detail as you can since your own explanation is better than others guessing it from the code.] Platforms tested: [machines you have tested the changed version. This is absolute important. Test it out on at least two or three different platforms such as Big-endian-32bit (SUN/IRIX), little-endian-32(LINUX) and 64-bit (IRIX64/UNICOS/DEC-ALPHA) would be good.] --- src/H5.c | 2 + src/H5FDdpss.c | 21 +---------- src/H5FDgass.c | 19 +--------- src/H5FDlog.c | 23 ++---------- src/H5FDsec2.c | 26 +------------ src/H5FDsrb.c | 8 +--- src/H5FDstdio.c | 5 +-- src/H5Oefl.c | 2 +- src/H5Omtime.c | 4 +- src/H5Ppublic.h | 3 ++ src/H5private.h | 93 +++++++++++++++++++++++++++++++++++++++++------ test/enum.c | 6 +++ test/flush1.c | 13 ++++++- test/iopipe.c | 11 ++++++ test/overhead.c | 23 +++++++++--- test/testhdf5.c | 4 +- test/titerate.c | 18 ++++----- tools/lib/h5tools.c | 10 ++++- tools/lib/h5tools_utils.c | 2 +- 19 files changed, 163 insertions(+), 130 deletions(-) diff --git a/src/H5.c b/src/H5.c index b5f1ef0..6e24e63 100644 --- a/src/H5.c +++ b/src/H5.c @@ -36,7 +36,9 @@ #endif /* We need this on Irix64 even though we've included stdio.h as documented */ +#if !defined __MWERKS__ FILE *fdopen(int fd, const char *mode); +#endif #define PABLO_MASK H5_mask diff --git a/src/H5FDdpss.c b/src/H5FDdpss.c index 6edc6c4..31e576e 100644 --- a/src/H5FDdpss.c +++ b/src/H5FDdpss.c @@ -51,26 +51,7 @@ typedef struct H5FD_dpss_t { haddr_t eof; /* end of file; current file size */ } H5FD_dpss_t; - -/*** FIXME: is this really needed here ? ***/ -/* - * This driver supports systems that have the lseek64() function by defining - * 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_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). - */ -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif + /* * These macros check for overflow of various quantities. These macros diff --git a/src/H5FDgass.c b/src/H5FDgass.c index b72e263..9a31822 100644 --- a/src/H5FDgass.c +++ b/src/H5FDgass.c @@ -53,24 +53,7 @@ typedef struct H5FD_gass_t { } H5FD_gass_t; -/* - * This driver supports systems that have the lseek64() function by defining - * 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_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). - */ -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif + /* * These macros check for overflow of various quantities. These macros diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 22060e8..6454e24 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -103,24 +103,7 @@ typedef struct H5FD_log_t { #endif } H5FD_log_t; -/* - * This driver supports systems that have the lseek64() function by defining - * 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_seek: The function which adjusts the current file position, - * either lseek() or lseek64(). - */ -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif + /* * These macros check for overflow of various quantities. These macros @@ -449,7 +432,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, file->op = OP_UNKNOWN; #ifdef WIN32 filehandle = _get_osfhandle(fd); - results = GetFileInformationByHandle(filehandle, &fileinfo); + results = GetFileInformationByHandle((HANDLE)filehandle, &fileinfo); file->fileindexhi = fileinfo.nFileIndexHigh; file->fileindexlo = fileinfo.nFileIndexLow; #else @@ -958,7 +941,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd while (size>0) { do { assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ - nbytes = HDwrite(file->fd, buf, (size_t)size); + nbytes = HDwrite(file->fd, (void*)buf, (size_t)size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 4c9f967..847b8fd 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -75,30 +75,6 @@ typedef struct H5FD_sec2_t { #endif } H5FD_sec2_t; -/* - * This driver supports systems that have the lseek64() function by defining - * 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_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 -#elif defined WIN32 -# define file_offset_t __int64 -# define file_seek _lseeki64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif - /* * These macros check for overflow of various quantities. These macros @@ -659,7 +635,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had while (size>0) { do { assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ - nbytes = HDwrite(file->fd, buf, (size_t)size); + nbytes = HDwrite(file->fd, (void*) buf, (size_t)size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ diff --git a/src/H5FDsrb.c b/src/H5FDsrb.c index ac38b65..a345b39 100644 --- a/src/H5FDsrb.c +++ b/src/H5FDsrb.c @@ -20,13 +20,7 @@ static hid_t H5FD_SRB_g = 0; #ifdef H5_HAVE_SRB -#ifdef H5_HAVE_LSEEK64 -# define file_offset_t off64_t -# define file_seek lseek64 -#else -# define file_offset_t off_t -# define file_seek lseek -#endif + /* * These macros check for overflow of various quantities. These macros diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 48784fd..3ed0181 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -17,10 +17,7 @@ #ifdef H5_HAVE_UNISTD_H #include #endif -#ifdef WIN32 -#include -#include -#endif + #include "hdf5.h" diff --git a/src/H5Oefl.c b/src/H5Oefl.c index b16a267..7288ec6 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -537,7 +537,7 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr, "unable to seek in external raw data file"); } to_write = MIN(efl->slot[i].size-skip, size); - if ((size_t)HDwrite (fd, buf, to_write)!=to_write) { + if ((size_t)HDwrite (fd, (void*)buf, to_write)!=to_write) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file"); } diff --git a/src/H5Omtime.c b/src/H5Omtime.c index 12b5049..632d85b 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -13,7 +13,7 @@ #include "H5MMprivate.h" #include "H5Oprivate.h" -#if defined WIN32 +#if defined (WIN32) && !defined (__MWERKS__) #include #include #endif @@ -145,7 +145,7 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p, } the_time -= tz.tz_minuteswest*60 - (tm.tm_isdst?3600:0); } -#elif defined WIN32 +#elif defined WIN32 && !defined __MWERKS__ { struct timeb timebuffer; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 2ec2ef4..8d5d8da 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -20,6 +20,7 @@ /* Default Template for creation, access, etc. templates */ #define H5P_DEFAULT 0 +#include /* Public headers needed by this file */ #include "H5public.h" #include "H5Ipublic.h" @@ -226,3 +227,5 @@ __DLL__ herr_t H5Pget_sieve_buf_size(hid_t fapl_id, hsize_t *size/*out*/); } #endif #endif + + diff --git a/src/H5private.h b/src/H5private.h index 7fc963e..256a22c 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -9,6 +9,10 @@ * 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. + * + * Modifications: Pedro Vicente , June 2001 + * WIN32 modifications + * */ #ifndef _H5private_H #define _H5private_H @@ -130,27 +134,93 @@ # include #endif + +#ifdef WIN32 + /* - * Win32 is severely broken when it comes to ANSI-C and Posix.1 compliance. + * we need this from + * HDF5 is currently supported on _X86_ + * including has the side effect of introducing thousands of Windows GUI + * macros and type declarations to the compilation environment, so we don't include it */ -#ifdef H5_HAVE_IO_H -# include + +#if !defined(_68K_) && !defined(_MPPC_) && !defined(_PPC_) && !defined(_ALPHA_) && !defined(_MIPS_) && !defined(_X86_) && defined(_M_IX86) +#define _X86_ #endif -#ifdef H5_HAVE_WINDOWS_H -# include + +#include +#include +#include + +/* H5_inline */ + +/* remove any previous defs made by configure in unix */ +#ifdef H5_inline +# undef H5_inline #endif -#ifdef WIN32 -# include -# include -# include +/* +The inline keywords allows the compiler to insert a copy of +the function body into each place the function is called +inline is now in C but in the C99 standard and not the old C89 version so +MS doesn't recognize it yet (as of April 2001) +*/ +#if defined(__MWERKS__) || defined(__cplusplus) +# define H5_inline inline +# else +# define H5_inline +#endif + +/* Metroworks doesn't define off_t. */ +#ifdef __MWERKS__ +typedef long off_t; +/* Metroworks does not define EINTR in */ +# define EINTR 4 #endif +/*__MWERKS__*/ + +#endif +/*WIN32*/ + +/* + * This driver supports systems that have the lseek64() function by defining + * 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_seek: The function which adjusts the current file position, + * either lseek() or lseek64(). + */ +/* adding for windows NT file system support. */ +/* pvn: added __MWERKS__ support. */ + +#ifdef H5_HAVE_LSEEK64 +# define file_offset_t off64_t +# define file_seek lseek64 +#elif defined (WIN32) +# ifdef __MWERKS__ +# define file_offset_t off_t +# define file_seek lseek +# else /*MSVC*/ +# define file_offset_t __int64 +# define file_seek _lseeki64 +# endif +#else +# define file_offset_t off_t +# define file_seek lseek +#endif + #ifndef F_OK # define F_OK 00 # define W_OK 02 # define R_OK 04 #endif + + + /* * Pablo support files. */ @@ -719,7 +789,7 @@ __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 +#if defined (__MWERKS__) #define HDstrdup(S) _strdup(S) #else @@ -1059,5 +1129,6 @@ __DLL__ intn H5TN_term_interface(void); __DLL__ intn H5T_term_interface(void); __DLL__ intn H5Z_term_interface(void); - #endif + + diff --git a/test/enum.c b/test/enum.c index a0a2e6f..4be6139 100644 --- a/test/enum.c +++ b/test/enum.c @@ -207,7 +207,13 @@ test_tr1(hid_t file) if (H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE))<0) goto error; if (H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK))<0) goto error; + +#ifndef __MWERKS__ assert(sizeof(c_e1)==sizeof(int)); +#else + printf( "\n sizeof(c_e1)=%d ,sizeof(int) %d ", sizeof(c_e1),sizeof(int) ); +#endif + if ((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error; if (H5Tenum_insert(f_type, "RED", CPTR(ival, 105))<0) goto error; if (H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104))<0) goto error; diff --git a/test/flush1.c b/test/flush1.c index c1017c5..c543bcf 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -13,6 +13,15 @@ */ #include "h5test.h" + +#if defined __MWERKS__ +#include +# define EXIT(a) __exit(a) +#else +# define EXIT(a) _exit(a) +#endif + + const char *FILENAME[] = { "flush", NULL @@ -88,10 +97,10 @@ main(void) PASSED(); fflush(stdout); fflush(stderr); - _exit(0); + EXIT(0); return 0; error: - _exit(1); + EXIT(1); return 1; } diff --git a/test/iopipe.c b/test/iopipe.c index fc50012..d8f6247 100644 --- a/test/iopipe.c +++ b/test/iopipe.c @@ -41,6 +41,17 @@ # include #endif + +#if defined (__MWERKS__) +#ifdef H5_HAVE_SYS_TIMEB +#undef H5_HAVE_SYS_TIMEB +#endif +#ifdef H5_HAVE_SYSTEM +#undef H5_HAVE_SYSTEM +#endif +#endif + + #ifdef H5_HAVE_SYS_TIMEB # include #endif diff --git a/test/overhead.c b/test/overhead.c index 3e2d5fc..721c686 100644 --- a/test/overhead.c +++ b/test/overhead.c @@ -207,7 +207,10 @@ test(fill_t fill_style, const double splits[], if ((mspace=H5Screate_simple(1, ch_size, ch_size))<0) goto error; if ((dset=H5Dcreate(file, "chunked", H5T_NATIVE_INT, fspace, dcpl))<0) goto error; + +#if !defined( __MWERKS__) if ((fd=open(FILE_NAME_1, O_RDONLY))<0) goto error; +#endif for (i=1; i<=cur_size[0]; i++) { @@ -243,6 +246,7 @@ test(fill_t fill_style, const double splits[], } /* Determine overhead */ +#if !defined( __MWERKS__) if (verbose) { if (H5Fflush(file, H5F_SCOPE_LOCAL)<0) goto error; if (fstat(fd, &sb)<0) goto error; @@ -255,6 +259,7 @@ test(fill_t fill_style, const double splits[], (unsigned long)i, (double)(hssize_t)(sb.st_size-i*sizeof(int))/(hssize_t)i); } +#endif } H5Dclose(dset); @@ -283,17 +288,21 @@ test(fill_t fill_style, const double splits[], case FILL_ALL: abort(); } + +#if !defined( __MWERKS__) if (fstat(fd, &sb)<0) goto error; - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ + printf("%-7s %8.3f\n", sname, (double)(hssize_t)(sb.st_size-cur_size[0]*sizeof(int))/ (hssize_t)cur_size[0]); +#endif + } + +#if !defined( __MWERKS__) close(fd); +#endif + return 0; error: @@ -303,7 +312,11 @@ test(fill_t fill_style, const double splits[], H5Pclose(dcpl); H5Fclose(file); free(had); + +#if !defined( __MWERKS__) close(fd); +#endif + return 1; } diff --git a/test/testhdf5.c b/test/testhdf5.c index 2ab6f51..8c1d4e7 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -140,9 +140,7 @@ main(int argc, char *argv[]) int Cache = 1; uintn major, minor, release; -#if defined __MWERKS__ - argc = ccommand(&argv); -#endif + #if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) /* Un-buffer the stdout and stderr */ diff --git a/test/titerate.c b/test/titerate.c index 9fd70f3..b7aa25c 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -24,7 +24,7 @@ #include "hdf5.h" -#define FILE "titerate.h5" +#define FILE_NAME "titerate.h5" /* Number of datasets for group iteration test */ #define NDATASETS 50 @@ -118,7 +118,7 @@ static void test_iter_group(void) MESSAGE(5, ("Testing Group Iteration Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); datatype = H5Tcopy(H5T_NATIVE_INT); @@ -133,7 +133,7 @@ static void test_iter_group(void) CHECK(dataset, FAIL, "H5Dcreate"); /* Keep a copy of the dataset names around for later */ - dnames[i]=strdup(name); + dnames[i]=HDstrdup(name); CHECK(dnames[i], NULL, "strdup"); ret=H5Dclose(dataset); @@ -154,7 +154,7 @@ static void test_iter_group(void) qsort(dnames,NDATASETS,sizeof(char *),iter_strcmp); /* Iterate through the datasets in the root group in various ways */ - file=H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file=H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fopen"); /* Test all objects in group, when callback always returns 0 */ @@ -262,7 +262,7 @@ static void test_iter_attr(void) MESSAGE(5, ("Testing Attribute Iteration Functionality\n")); /* Create the test file with the datasets */ - file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); datatype = H5Tcopy(H5T_NATIVE_INT); @@ -280,7 +280,7 @@ static void test_iter_attr(void) CHECK(attribute, FAIL, "H5Acreate"); /* Keep a copy of the attribute names around for later */ - anames[i]=strdup(name); + anames[i]=HDstrdup(name); CHECK(anames[i], NULL, "strdup"); ret=H5Aclose(attribute); @@ -301,7 +301,7 @@ static void test_iter_attr(void) CHECK(ret, FAIL, "H5Fclose"); /* Iterate through the attributes on the dataset in various ways */ - file=H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + file=H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fopen"); dataset=H5Dopen(file, "Dataset"); @@ -438,7 +438,7 @@ static void test_iter_group_large(void) MESSAGE(5, ("Testing Large Group Iteration Functionality\n")); /* Create file */ - file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file, FAIL, "H5Fcreate"); /* Create dataspace for datasets */ @@ -555,6 +555,6 @@ test_iterate(void) void cleanup_iterate(void) { - remove(FILE); + remove(FILE_NAME); } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 2341c7f..202d70b 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -18,6 +18,9 @@ #include "hdf5.h" #include "H5private.h" + + + /* * The output functions need a temporary buffer to hold a piece of the * dataset while it's being printed. This constant sets the limit on the @@ -564,8 +567,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, for (; count > 0; sset->start[ctx.ndims - 1] += sset->stride[ctx.ndims - 1], count--) { /* calculate the potential number of elements we're going to print */ - H5Sselect_hyperslab(f_space, H5S_SELECT_SET, sset->start, sset->stride, - sset->count, sset->block); + H5Sselect_hyperslab(f_space, H5S_SELECT_SET, + (hssize_t*)sset->start, + (hsize_t*)sset->stride, + (hsize_t*)sset->count, + (hsize_t*)sset->block); sm_nelmts = H5Sget_select_npoints(f_space); /* diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index a6050ca..baaebc4 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -612,7 +612,7 @@ set_tableflag(table_t *table, int idx) char * get_objectname(table_t *table, int idx) { - return strdup(table->objs[idx].objname); + return HDstrdup(table->objs[idx].objname); } -- cgit v0.12