Skip to Content.
Sympa Menu

h5part - Re: [H5part] Patch#1 : Win32 compiler support

h5part AT lists.psi.ch

Subject: H5Part development and discussion

List archive

Re: [H5part] Patch#1 : Win32 compiler support


Chronological Thread 
  • From: John Biddiscombe <biddisco AT cscs.ch>
  • To: Achim Gsell <achim.gsell AT psi.ch>
  • Cc: h5part AT lists.psi.ch
  • Subject: Re: [H5part] Patch#1 : Win32 compiler support
  • Date: Thu, 10 May 2007 05:55:46 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/h5part/>
  • List-id: H5Part development and discussion <h5part.lists.psi.ch>


Emh, you forgot to attach the patch ...

Whoops. Here it is.

JB

Index: src/H5Block.c
===================================================================
--- src/H5Block.c (revision 2902)
+++ src/H5Block.c (working copy)
@@ -119,17 +119,17 @@
*/
if ( f->nprocs == 0 ) f->nprocs = 1;

- f->block = malloc( sizeof (*f->block) );
+ f->block = (H5BlockStruct*)malloc( sizeof (*f->block) );
if ( f->block == NULL ) {
return HANDLE_H5PART_NOMEM_ERR;
}
b = f->block;
memset ( b, 0, sizeof (*b) );
- b->user_layout = malloc ( f->nprocs * sizeof (b->user_layout[0]) );
+ b->user_layout = (H5BlockPartition*)malloc ( f->nprocs * sizeof
(b->user_layout[0]) );
if ( b->user_layout == NULL ) {
return HANDLE_H5PART_NOMEM_ERR;
}
- b->write_layout = malloc ( f->nprocs * sizeof (b->write_layout[0]) );
+ b->write_layout = (H5BlockPartition*)malloc ( f->nprocs * sizeof
(b->write_layout[0]) );
if ( b->write_layout == NULL ) {
return HANDLE_H5PART_NOMEM_ERR;
}
@@ -573,11 +573,12 @@
struct H5BlockPartition *q;
h5part_int64_t vol;
} *p_begin, *p_el, *p_max, *p_end, *p_save;
+ typedef struct list list;

memcpy ( b->write_layout, b->user_layout,
f->nprocs * sizeof (*f->block->user_layout) );

- p_begin = p_max = p_end = malloc ( sizeof ( *p_begin ) );
+ p_begin = p_max = p_end = (list*)malloc ( sizeof ( *p_begin ) );
if ( p_begin == NULL ) return HANDLE_H5PART_NOMEM_ERR;

memset ( p_begin, 0, sizeof ( *p_begin ) );
@@ -590,7 +591,7 @@
proc_q++, q++ ) {

if ( _have_ghostzone ( p, q ) ) {
- p_el = malloc ( sizeof ( *p_el ) );
+ p_el = (list*)malloc ( sizeof ( *p_el ) );
if ( p_el == NULL )
return HANDLE_H5PART_NOMEM_ERR;

Index: src/H5BlockTypes.h
===================================================================
--- src/H5BlockTypes.h (revision 2902)
+++ src/H5BlockTypes.h (working copy)
@@ -26,6 +26,9 @@
hid_t field_group_id;
};

+typedef struct H5BlockStruct H5BlockStruct;
+typedef struct H5BlockPartition H5BlockPartition;
+
#define H5PART_ERR_LAYOUT -100
#define H5PART_ERR_NOENT -101

Index: src/H5Part.c
===================================================================
--- src/H5Part.c (revision 2902)
+++ src/H5Part.c (working copy)
@@ -78,7 +78,6 @@
#include <stdlib.h>
#include <stdarg.h> /* va_arg - System dependent ?! */
#include <string.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <hdf5.h>
@@ -88,10 +87,28 @@
#include "H5PartPrivate.h"
#include "H5PartErrors.h"

+#ifndef WIN32
+ #include <unistd.h>
+ #define _h5set_errno(a) _errno = a
+ #define _h5get_errno() errno
+ static h5part_int64_t _errno = H5PART_SUCCESS;
+#else
+ #include <io.h>
+ #define open _open
+ #define close _close
+ #if _MSC_VER < 1400
+ #define _h5set_errno(a) errno = a
+ #define _h5get_errno() errno
+ #else
+ errno_t _h5err;
+ #define _h5set_errno(a) _set_errno(a)
+ errno_t _h5get_errno() { _get_errno(&_h5err); return _h5err; }
+ #endif
+#endif
+
/********* Private Variable Declarations *************/

-static unsigned _debug = 0;
-static h5part_int64_t _errno = H5PART_SUCCESS;
+static unsigned _debug = 0;
static h5part_error_handler _err_handler = H5PartReportErrorHandler;
static char *__funcname = "NONE";

@@ -125,7 +142,7 @@
HANDLE_H5PART_INIT_ERR;
return NULL;
}
- _errno = H5PART_SUCCESS;
+ _h5set_errno(H5PART_SUCCESS);
H5PartFile *f = NULL;

f = (H5PartFile*) malloc( sizeof (H5PartFile) );
@@ -158,7 +175,7 @@
goto error_cleanup;
}

- f->pnparticles = malloc (f->nprocs * sizeof (h5part_int64_t));
+ f->pnparticles = (h5part_int64_t*)malloc (f->nprocs * sizeof
(h5part_int64_t));
if (f->pnparticles == NULL) {
HANDLE_H5PART_NOMEM_ERR;
goto error_cleanup;
@@ -210,7 +227,7 @@
}
else if ( flags == H5PART_APPEND ) {
int fd = open (filename, O_RDONLY, 0);
- if ( (fd == -1) && (errno == ENOENT) ) {
+ if ( (fd == -1) && (_h5get_errno()==ENOENT) ) {
f->file = H5Fcreate(filename, H5F_ACC_TRUNC,
f->create_prop, f->access_prop);
f->empty = 1;
@@ -366,7 +383,7 @@

SET_FNAME ( "H5PartCloseFile" );
herr_t r = 0;
- _errno = H5PART_SUCCESS;
+ _h5set_errno(H5PART_SUCCESS);

CHECK_FILEHANDLE ( f );

@@ -419,7 +436,7 @@
}
free( f );

- return _errno;
+ return _h5get_errno();
}

/*============== File Writing Functions ==================== */
@@ -1380,7 +1397,7 @@
void *operator_data /*!< [in,out] data passed to the iterator */
) {

- struct _iter_op_data *data = operator_data;
+ struct _iter_op_data *data = (_iter_op_data*)operator_data;
herr_t herr;
H5G_stat_t objinfo;

@@ -2330,7 +2347,7 @@
H5PartGetErrno (
void
) {
- return _errno;
+ return _h5get_errno();
}

/*!
@@ -2349,14 +2366,14 @@
...
) {

- _errno = eno;
+ _h5set_errno(eno);
if ( _debug > 0 ) {
va_list ap;
va_start ( ap, fmt );
_H5Part_vprint_error ( fmt, ap );
va_end ( ap );
}
- return _errno;
+ return _h5get_errno();
}

/*!
@@ -2373,7 +2390,7 @@
...
) {

- _errno = eno;
+ _h5set_errno(eno);
if ( _debug > 0 ) {
va_list ap;
va_start ( ap, fmt );
@@ -2381,7 +2398,7 @@
vfprintf ( stderr, fmt, ap );
fprintf ( stderr, "\n" );
}
- exit (-_errno);
+ exit (-_h5get_errno());
}

/*!
@@ -2417,7 +2434,7 @@
const char *fmt,
va_list ap
) {
- char *fmt2 = malloc( strlen ( prefix ) +strlen ( fmt ) + strlen (
__funcname ) + 16 );
+ char *fmt2 = (char*)malloc( strlen ( prefix ) +strlen ( fmt ) +
strlen ( __funcname ) + 16 );
if ( fmt2 == NULL ) return;
sprintf ( fmt2, "%s: %s: %s\n", prefix, __funcname, fmt );
vfprintf ( stderr, fmt2, ap );
Index: src/H5PartPrivate.h
===================================================================
--- src/H5PartPrivate.h (revision 2902)
+++ src/H5PartPrivate.h (working copy)
@@ -21,6 +21,8 @@
char *pattern;
};

+typedef struct _iter_op_data _iter_op_data;
+
h5part_int64_t
_H5Part_set_step (
H5PartFile *f,
Index: src/H5PartTypes.h
===================================================================
--- src/H5PartTypes.h (revision 2902)
+++ src/H5PartTypes.h (working copy)
@@ -5,6 +5,12 @@
#ifndef _H5PARTTYPES_H_
#define _H5PARTTYPES_H_

+#ifdef _WIN32
+ typedef __int64 int64_t;
+ typedef int errno_t;
+#else
+ typedef int64_t errno_t;
+#endif

typedef int64_t h5part_int64_t;
typedef double h5part_float64_t;



Archive powered by MHonArc 2.6.19.

Top of Page