[med-svn] [libminc] 01/03: Somehow the hdf5 patch was lost :-(

Andreas Tille tille at debian.org
Thu Nov 30 17:53:52 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository libminc.

commit 3bf6e0db186cd862fbc670d2bf61bb6cf195cfa0
Author: Andreas Tille <tille at debian.org>
Date:   Thu Nov 30 17:04:38 2017 +0100

    Somehow the hdf5 patch was lost :-(
---
 debian/patches/fix-endian-issues-label-data.patch |   8 +-
 debian/patches/hdf5-1.10-support.patch            | 451 ++++++++++++++++++++++
 debian/patches/libhdf5-1.10.patch                 |  26 ++
 debian/patches/series                             |   1 +
 4 files changed, 480 insertions(+), 6 deletions(-)

diff --git a/debian/patches/fix-endian-issues-label-data.patch b/debian/patches/fix-endian-issues-label-data.patch
index db26a89..1039a32 100644
--- a/debian/patches/fix-endian-issues-label-data.patch
+++ b/debian/patches/fix-endian-issues-label-data.patch
@@ -8,8 +8,6 @@ Subject: [PATCH] Fix endian issues with label data.
  libsrc2/volume.c |  4 +--
  2 files changed, 66 insertions(+), 21 deletions(-)
 
-diff --git a/libsrc2/m2util.c b/libsrc2/m2util.c
-index a9367dc..5711208 100644
 --- a/libsrc2/m2util.c
 +++ b/libsrc2/m2util.c
 @@ -1343,33 +1343,80 @@ void miinit ( void )
@@ -109,7 +107,7 @@ index a9367dc..5711208 100644
    return ( 0 );
  }
  
-@@ -1380,9 +1427,9 @@ in order to facilitate conversions from the integer to the enumerated type.
+@@ -1380,9 +1427,9 @@ in order to facilitate conversions from
  void miinit_enum ( hid_t type_id )
  {
    H5Tregister ( H5T_PERS_SOFT, "i2e", H5T_NATIVE_INT, type_id,
@@ -121,11 +119,9 @@ index a9367dc..5711208 100644
    H5Tregister ( H5T_PERS_SOFT, "d2e", H5T_NATIVE_DOUBLE, type_id,
                  mi2_dbl_to_int );
    H5Tregister ( H5T_PERS_SOFT, "e2d", type_id, H5T_NATIVE_DOUBLE,
-diff --git a/libsrc2/volume.c b/libsrc2/volume.c
-index b951d14..be8b7d1 100644
 --- a/libsrc2/volume.c
 +++ b/libsrc2/volume.c
-@@ -1449,11 +1449,9 @@ int miopen_volume(const char *filename, int mode, mihandle_t *volume)
+@@ -1409,11 +1409,9 @@ int miopen_volume(const char *filename,
      break;
  
    case H5T_ENUM:
diff --git a/debian/patches/hdf5-1.10-support.patch b/debian/patches/hdf5-1.10-support.patch
new file mode 100644
index 0000000..99907b5
--- /dev/null
+++ b/debian/patches/hdf5-1.10-support.patch
@@ -0,0 +1,451 @@
+Description: don't assume hid_t === int since this is no longer true
+ in HDF5 1.10.
+ This is a backport of upstream commits d99dd01 and 92ba4fa related
+ to issue #74 [1].
+ .
+ [1] https://github.com/BIC-MNI/libminc/issues/74
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -45,7 +45,8 @@ struct m2_dim {
+ 
+ static struct m2_file {
+     struct m2_file *link;
+-    hid_t fd;
++    int   fd;                   /* our fake file id */
++    hid_t file_id;              /* actual hdf5 file id */
+     int wr_ok;                  /* non-zero if write OK */
+     int resolution;		/* Resolution setting. */
+     int nvars;
+@@ -74,18 +75,20 @@ hdf_id_check(int fd)
+ }
+ 
+ static struct m2_file *
+-hdf_id_add(int fd)
++hdf_id_add(hid_t file_id)
+ {
+     struct m2_file *new;
++    static unsigned short _id = 0;       /* at most 2^16 id's */
+ 
+     new = (struct m2_file *) malloc(sizeof (struct m2_file));
+     if (new != NULL) {
+-	new->fd = fd;
++        new->fd = HDF5_ID_MIN + _id++;
++        new->file_id = file_id;
+ 	new->resolution = 0;
+ 	new->nvars = 0;
+ 	new->ndims = 0;
+ 	new->link =_m2_list;
+-        new->grp_id = H5Gopen1(fd, MI2_GRPNAME);
++        new->grp_id = H5Gopen1(file_id, MI2_GRPNAME);
+         new->comp_type = MI2_COMP_UNKNOWN;
+         new->comp_param = 0;
+         new->chunk_type = MI2_CHUNK_UNKNOWN;
+@@ -99,7 +102,7 @@ hdf_id_add(int fd)
+     return (new);
+ }
+ 
+-static int 
++static int
+ hdf_id_del(int fd)
+ {
+     struct m2_file *curr, *prev;
+@@ -142,6 +145,7 @@ hdf_id_del(int fd)
+ 	    }
+ 
+             H5Gclose(curr->grp_id);
++            H5Fclose(curr->file_id);
+ 	    free(curr);
+ 	    return (MI_NOERROR);
+ 	}
+@@ -187,7 +191,7 @@ hdf_var_add(struct m2_file *file, const
+       strncpy(new->name, name, NC_MAX_NAME - 1);
+       strncpy(new->path, path, NC_MAX_NAME - 1);
+       new->is_cmpd = 0;
+-      new->dset_id = H5Dopen1(file->fd, path);
++      new->dset_id = H5Dopen1(file->file_id, path);
+       new->ftyp_id = H5Dget_type(new->dset_id);
+       new->mtyp_id = H5Tget_native_type(new->ftyp_id, H5T_DIR_ASCEND);
+       new->fspc_id = H5Dget_space(new->dset_id);
+@@ -490,7 +494,7 @@ hdf_attinq(int fd, int varid, const char
+       return (MI_ERROR);
+   }
+ 
+-  if (varid == NC_GLOBAL) {
++  if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+       var = NULL;
+       loc_id = file->grp_id;
+   } 
+@@ -591,7 +595,7 @@ hdf_attinq(int fd, int varid, const char
+ }
+ 
+ static int
+-hdf_put_dimorder(struct m2_file *file, int dst_id, int ndims, 
++hdf_put_dimorder(struct m2_file *file, hid_t dst_id, int ndims, 
+ 		 const int *dims_ptr)
+ {
+     int i;
+@@ -626,6 +630,9 @@ hdf_put_dimorder(struct m2_file *file, i
+     if (att_id >= 0) {
+ 	H5Awrite(att_id, typ_id, str_buf);
+     }
++    else {
++      fprintf(stderr, "Failed to create dimorder %lx\n", dst_id);
++    }
+   
+     H5Aclose(att_id);
+     H5Sclose(spc_id);
+@@ -634,7 +641,7 @@ hdf_put_dimorder(struct m2_file *file, i
+ }
+ 
+ static int 
+-hdf_get_dimorder(struct m2_file *file, int dst_id, int ndims, int *dims_ptr)
++hdf_get_dimorder(struct m2_file *file, hid_t dst_id, int ndims, int *dims_ptr)
+ {
+     char *str_ptr;
+     char *tmp_ptr;
+@@ -974,7 +981,7 @@ hdf_attget(int fd, int varid, const char
+         return (MI_ERROR);
+     }
+ 
+-    if (varid == NC_GLOBAL) {
++    if (varid == NC_GLOBAL || varid == MI_ROOTVARIABLE_ID) {
+         var = NULL;
+         loc_id = file->grp_id;
+     } 
+@@ -1120,11 +1127,11 @@ hdf_attput(int fd, int varid, const char
+             H5Pclose(new_plst_id);
+             H5Sclose(var->fspc_id);
+ 
+-            if (H5Gunlink(fd, var->path) < 0) {
++            if (H5Gunlink(file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+-            if (H5Gmove2(file->grp_id, temp, fd, var->path) < 0) {
++            if (H5Gmove2(file->grp_id, temp, file->file_id, var->path) < 0) {
+                 milog_message(MI_MSG_SNH);
+             }
+ 
+@@ -1196,7 +1203,7 @@ hdf_attput(int fd, int varid, const char
+     att_id = H5Acreate2(loc_id, attnm, ftyp_id, spc_id, H5P_DEFAULT, H5P_DEFAULT);
+     
+     if (att_id < 0)
+-        goto cleanup;
++      goto cleanup;
+ 
+     /* Save the value.
+     */
+@@ -1261,10 +1268,10 @@ int
+ hdf_vardef(int fd, const char *varnm, nc_type vartype, int ndims, 
+            const int *dimids)
+ {
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int spc_id = -1;
+-    int prp_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t spc_id = -1;
++    hid_t prp_id = -1;
+     int status = MI_ERROR;
+     int i;
+     long length;
+@@ -1392,7 +1399,7 @@ hdf_vardef(int fd, const char *varnm, nc
+     }
+     
+     H5E_BEGIN_TRY {
+-        dst_id = H5Dcreate2(fd, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
++        dst_id = H5Dcreate2(file->file_id, varpath, typ_id, spc_id, H5P_DEFAULT, prp_id, H5P_DEFAULT);
+     } H5E_END_TRY;
+ 
+     if (dst_id < 0) {
+@@ -1465,10 +1472,10 @@ hdf_varget(int fd, int varid, const long
+ 	   void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id = -1;
+-  int typ_id = -1;
+-  int fspc_id = -1;
+-  int mspc_id = -1;
++  hid_t dst_id = -1;
++  hid_t typ_id = -1;
++  hid_t fspc_id = -1;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -1560,8 +1567,8 @@ hdf_varget(int fd, int varid, const long
+ }
+ 
+ int 
+-hdf_varputg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_varputg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, const void *value)
+ {
+     int status = MI_ERROR;      /* Assume guilty */
+@@ -1577,10 +1584,10 @@ hdf_varputg(int fd, int varid, const lon
+ 
+     struct m2_var *varp;
+     struct m2_file *file;
+-    int dst_id = -1;
+-    int typ_id = -1;
+-    int fspc_id = -1;
+-    int mspc_id = -1;
++    hid_t dst_id = -1;
++    hid_t typ_id = -1;
++    hid_t fspc_id = -1;
++    hid_t mspc_id = -1;
+ 
+     if ((file = hdf_id_check(fd)) == NULL) {
+ 	return (MI_ERROR);
+@@ -1747,8 +1754,8 @@ hdf_varputg(int fd, int varid, const lon
+ }
+ 
+ int 
+-hdf_vargetg(int fd, int varid, const long *start, 
+-            const long *edges, const long *stride, 
++hdf_vargetg(int fd, int varid, const long *start,
++            const long *edges, const long *stride,
+             const long *map, void *value)
+ {
+     int status = MI_NOERROR;
+@@ -1910,10 +1917,10 @@ hdf_varput(int fd, int varid, const long
+ 	   const void *val_ptr)
+ {
+   int status = MI_ERROR;
+-  int dst_id;
+-  int typ_id;
+-  int fspc_id;
+-  int mspc_id = -1;
++  hid_t dst_id;
++  hid_t typ_id;
++  hid_t fspc_id;
++  hid_t mspc_id = -1;
+   int i;
+   int ndims;
+   hsize_t fstart[MAX_VAR_DIMS];
+@@ -2085,6 +2092,7 @@ herr_t hdf_copy_attr(hid_t in_id, const
+       * don't overwrite the existing value.
+       */
+      status = MI_NOERROR;
++     fprintf(stderr, "Failed to create attribute '%s'\n", attr_name);
+      goto cleanup;
+    }
+    
+@@ -2195,7 +2203,7 @@ hdf_open_dsets(struct m2_file *file, hid
+ int
+ hdf_open(const char *path, int mode)
+ {
+-    hid_t fd;
++    hid_t file_id;
+     hid_t grp_id;
+     hid_t dset_id;
+     struct m2_file *file;
+@@ -2210,28 +2218,28 @@ hdf_open(const char *path, int mode)
+ 
+             prp_id = H5Pcreate(H5P_FILE_ACCESS);
+             H5Pset_fapl_mmap(prp_id, 8192, 1);
+-            fd = H5Fopen(path, mode & 0x7FFF, prp_id);
++            file_id = H5Fopen(path, mode & 0x7FFF, prp_id);
+             H5Pclose(prp_id);
+         }
+         else {
+-            fd = H5Fopen(path, mode, H5P_DEFAULT);
++            file_id = H5Fopen(path, mode, H5P_DEFAULT);
+         }
+ #else
+-        fd = H5Fopen(path, mode, H5P_DEFAULT);
++        file_id = H5Fopen(path, mode, H5P_DEFAULT);
+ #endif
+     } H5E_END_TRY;
+ 
+-    if (fd < 0) {
++    if (file_id < 0) {
+       return (MI_ERROR);
+     }
+ 
+-    file = hdf_id_add(fd);	/* Add it to the list */
++    file = hdf_id_add(file_id);	/* Add it to the list */
+     file->wr_ok = (mode & H5F_ACC_RDWR) != 0;
+ 
+     /* Open the image variables.
+      */
+     H5E_BEGIN_TRY {
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image");
+         if (dset_id >= 0) {
+             hid_t type_id;
+             int is_compound = 0;
+@@ -2262,7 +2270,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+     
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-min");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-min");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemin, "/minc-2.0/image/0/image-min", 
+@@ -2270,7 +2278,7 @@ hdf_open(const char *path, int mode)
+             H5Dclose(dset_id);
+         }
+ 
+-        dset_id = H5Dopen1(fd, "/minc-2.0/image/0/image-max");
++        dset_id = H5Dopen1(file_id, "/minc-2.0/image/0/image-max");
+         if (dset_id >= 0) {
+             hdf_get_diminfo(dset_id, &ndims, dims);
+             hdf_var_add(file, MIimagemax, "/minc-2.0/image/0/image-max", 
+@@ -2281,16 +2289,16 @@ hdf_open(const char *path, int mode)
+ 
+     /* Open all of the datasets in the "dimensions" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/dimensions", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/dimensions", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/dimensions/", 1);
+     H5Gclose(grp_id);
+ 
+     /* Open all of the datasets in the "info" category.
+      */
+-    grp_id = H5Gopen2(fd, "/minc-2.0/info", H5P_DEFAULT);
++    grp_id = H5Gopen2(file_id, "/minc-2.0/info", H5P_DEFAULT);
+     hdf_open_dsets(file, grp_id, "/minc-2.0/info/", 0);
+     H5Gclose(grp_id);
+-    return (fd);
++    return (file->fd);
+ }
+ 
+ /** Create an HDF5 file. */
+@@ -2298,7 +2306,7 @@ int
+ hdf_create(const char *path, int cmode, struct mi2opts *opts_ptr)
+ {
+     hid_t grp_id;
+-    hid_t fd;
++    hid_t file_id;
+     hid_t tmp_id;
+     struct m2_file *file;
+     hid_t hdf_gpid;
+@@ -2319,10 +2327,10 @@ hdf_create(const char *path, int cmode,
+     H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);
+ 
+     H5E_BEGIN_TRY {
+-        fd = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
++        file_id = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
+     } H5E_END_TRY;
+-    if (fd < 0) {
+-      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, fd);
++    if (file_id < 0) {
++      fprintf(stderr, "Error creating HDF file '%s' with mode '%x', result %d\n", path, cmode, (int)file_id);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+     }
+@@ -2332,7 +2340,7 @@ hdf_create(const char *path, int cmode,
+     /* Create the default groups.
+      * Should we use a non-zero value for size_hint (parameter 3)???
+      */
+-    if ((grp_id = H5Gcreate2(fd, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
++    if ((grp_id = H5Gcreate2(file_id, MI2_GRPNAME, H5P_DEFAULT, hdf_gpid, H5P_DEFAULT)) < 0) {
+       fprintf(stderr, "Error creating groups on line %d\n", __LINE__);
+       H5Eprint1(stderr);
+       return (MI_ERROR);
+@@ -2369,7 +2377,7 @@ hdf_create(const char *path, int cmode,
+     H5Gclose(tmp_id);
+     H5Gclose(grp_id);
+ 
+-    file = hdf_id_add(fd);      /* Add it to the list */
++    file = hdf_id_add(file_id); /* Add it to the list */
+     if (file == NULL) {
+         fprintf(stderr, "Error adding ID to list.\n");
+         H5Eprint1(stderr);
+@@ -2384,7 +2392,7 @@ hdf_create(const char *path, int cmode,
+         file->chunk_type = opts_ptr->chunk_type;
+         file->chunk_param = opts_ptr->chunk_param;
+     }
+-    return ((int) fd);
++    return (file->fd);
+ }
+ 
+ int
+@@ -2392,7 +2400,6 @@ hdf_close(int fd)
+ {
+     hdf_dim_commit(fd);         /* Make sure all dimensions were saved. */
+     hdf_id_del(fd);		/* Delete it from the list. */
+-    H5Fclose(fd);
+     return (MI_NOERROR);
+ }
+ 
+@@ -2412,4 +2419,22 @@ hdf_access(const char *path)
+     return (status > 0);        /* Return non-zero if success */
+ }
+ 
++/*
++ * Flushes the hdf file to disk
++ */
++int 
++hdf_flush(int fd)
++{
++    struct m2_file *file;
++    if ((file = hdf_id_check(fd))!=NULL ) {
++        /* Commit the (entire) file to disk. */
++        if (H5Fflush(file->file_id, H5F_SCOPE_GLOBAL) < 0) {
++            return MI_ERROR;
++        }
++        return MI_NOERROR;
++    }
++    return MI_ERROR;
++}
++
++
+ #endif /* MINC2 defined */
+Index: libminc-2.3.00/libsrc/hdf_convenience.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.h
++++ libminc-2.3.00/libsrc/hdf_convenience.h
+@@ -49,4 +49,5 @@ extern int hdf_open(const char *path, in
+ extern int hdf_create(const char *path, int mode, struct mi2opts *opts_ptr);
+ extern int hdf_close(int fd);
+ extern int hdf_access(const char *path);
++extern int hdf_flush(int fd);
+ 
+Index: libminc-2.3.00/libsrc/minc_compat.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc_compat.c
++++ libminc-2.3.00/libsrc/minc_compat.c
+@@ -358,14 +358,9 @@ MI2redef(int fd)
+ MNCAPI int
+ MI2sync(int fd)
+ {
+-    if (MI2_ISH5OBJ(fd)) {
++    if (MI2_ISH5OBJ(fd) ) {
+         /* Commit the (entire) file to disk. */
+-        if (H5Fflush(fd, H5F_SCOPE_GLOBAL) < 0) {
+-            return (MI_ERROR);
+-        }
+-        else {
+-            return (MI_NOERROR);
+-        }
++        return hdf_flush(fd);
+     }
+     else {
+         return (ncsync(fd));
+Index: libminc-2.3.00/libsrc/minc.h
+===================================================================
+--- libminc-2.3.00.orig/libsrc/minc.h
++++ libminc-2.3.00/libsrc/minc.h
+@@ -617,7 +617,13 @@ struct mi2opts {
+     int chunk_param;
+ };
+ 
+-#define MI2_ISH5OBJ(x) (H5Iget_type(x) > 0)
++/* This is hackish in that it assumes that all NetCDF handles returned
++ * by ncopen/nccreate will be small integers. Historically this is
++ * true, but it could break someday. We used to use an HDF5 call, but
++ * that broke when HDF5 switched from 32 to 64 bits for hid_t.
++ */
++#define HDF5_ID_MIN 0x30000000
++#define MI2_ISH5OBJ(x) (x >= HDF5_ID_MIN)
+ 
+ MNCAPI int micreatex(const char *path, int cmode, struct mi2opts *opts_ptr);
+ 
diff --git a/debian/patches/libhdf5-1.10.patch b/debian/patches/libhdf5-1.10.patch
new file mode 100644
index 0000000..ee899d3
--- /dev/null
+++ b/debian/patches/libhdf5-1.10.patch
@@ -0,0 +1,26 @@
+Index: libminc-2.3.00/libsrc/hdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/hdf_convenience.c
++++ libminc-2.3.00/libsrc/hdf_convenience.c
+@@ -74,7 +74,7 @@ hdf_id_check(int fd)
+ }
+ 
+ static struct m2_file *
+-hdf_id_add(int fd)
++hdf_id_add(hid_t fd)
+ {
+     struct m2_file *new;
+ 
+Index: libminc-2.3.00/libsrc/netcdf_convenience.c
+===================================================================
+--- libminc-2.3.00.orig/libsrc/netcdf_convenience.c
++++ libminc-2.3.00/libsrc/netcdf_convenience.c
+@@ -595,7 +595,7 @@ MNCAPI int miopen(const char *path, int
+ #if MINC2
+ MNCAPI int micreatex(const char *path, int cmode, struct mi2opts *opts_ptr)
+ {
+-    int fd;
++    hid_t fd;
+ 
+     MI_SAVE_ROUTINE_NAME("micreate");
+ 
diff --git a/debian/patches/series b/debian/patches/series
index bcf470e..cdbd433 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@ fix-uselibminc-cmake
 use-system-nifti
 fix-endian-issues-label-data.patch
 Use-system-FindHDF5-CMake-module.patch
+hdf5-1.10-support.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/libminc.git



More information about the debian-med-commit mailing list