Skip to content

Commit

Permalink
Merge pull request #138 from HDFGroup/hdf5-1.10.2
Browse files Browse the repository at this point in the history
HDF.PInvoke 1.10.2
  • Loading branch information
gheber authored May 4, 2018
2 parents e07f5dd + 8248b10 commit 6aa3b0f
Show file tree
Hide file tree
Showing 24 changed files with 246 additions and 26 deletions.
8 changes: 0 additions & 8 deletions HDF5/H5ACpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ public struct cache_image_config_t
public hbool_t save_resize_status;

public int entry_ageout;

public cache_image_config_t(hbool_t generate_image_flg)
{
version = CURR_CACHE_IMAGE_CONFIG_VERSION;
generate_image = generate_image_flg;
save_resize_status = 0;
entry_ageout = CACHE_IMAGE__ENTRY_AGEOUT__MAX;
}
}
}
}
29 changes: 27 additions & 2 deletions HDF5/H5Fpublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,32 @@ public struct sect_info_t
public hsize_t size;
}

#endif
/// <summary>
/// Library's file format versions
/// </summary>
public enum libver_t
{
ERROR = -1,
/// <summary>
/// Use the earliest possible format for storing objects
/// </summary>
EARLIEST = 0,
/// <summary>
/// Use the latest v18 format for storing objects
/// </summary>
V18 = 1,
/// <summary>
/// Use the latest v110 format for storing objects
/// </summary>
V110 = 2,
/// <summary>
/// Use the latest possible format for storing objects
/// </summary>
LATEST = 2,
NBOUNDS
}

#else
/// <summary>
/// Library's file format versions
/// </summary>
Expand All @@ -334,6 +358,7 @@ public enum libver_t
/// </summary>
LATEST
}
#endif

#if HDF5_VER1_10

Expand Down Expand Up @@ -557,7 +582,7 @@ public extern static hid_t create
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public extern static ssize_t get_file_image
(hid_t file_id, IntPtr buf_ptr, ref IntPtr buf_len);
(hid_t file_id, IntPtr buf_ptr, IntPtr buf_len);

/// <summary>
/// Returns the size of an HDF5 file.
Expand Down
33 changes: 33 additions & 0 deletions HDF5/H5Ppublic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,23 @@ public static extern ssize_t get_virtual_dsetname
public static extern ssize_t get_virtual_filename
(hid_t dcpl_id, size_t index, [In][Out]StringBuilder name, size_t size);

/// <summary>
/// Retrieves prefix applied to VDS source file paths
/// See https://portal.hdfgroup.org/display/HDF5/H5P_GET_VIRTUAL_PREFIX
/// </summary>
/// <param name="dapl">Dataset access property list identifier.</param>
/// <param name="prefix">Prefix applied to VDS source file paths.</param>
/// <param name="size">Size of prefix buffer (including null terminator) in bytes.</param>
/// <returns>Returns the size of <paramref name="prefix"/> and the
/// prefix string will be stored in <paramref name="prefix"/> if
/// successful. Otherwise returns a negative value and the contents of
/// <paramref name="prefix"/> will be undefined.</returns>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Pget_virtual_prefix",
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern ssize_t get_virtual_prefix
(hid_t dapl, [In][Out]StringBuilder prefix, size_t size);

/// <summary>
/// Returns the maximum number of missing source files and/or datasets
/// with the printf-style names when getting the extent for an
Expand Down Expand Up @@ -3348,6 +3365,22 @@ public static extern herr_t set_virtual
(hid_t dcpl_id, hid_t vspace_id, string src_file_name,
string src_dset_name, hid_t src_space_id);

/// <summary>
/// Sets prefix to be applied to VDS source file paths.
/// See https://portal.hdfgroup.org/display/HDF5/H5P_SET_VIRTUAL_PREFIX
/// </summary>
/// <param name="dapl">Dataset access property list identifier.</param>
/// <param name="prefix">Prefix to be applied to VDS source file paths.</param>
/// <returns>Returns a non-negative value if successful;
/// otherwise returns a negative value.</returns>
/// /// <remarks>ASCII strings ONLY!</remarks>
[DllImport(Constants.DLLFileName, EntryPoint = "H5Pset_virtual_prefix",
CharSet = CharSet.Ansi,
CallingConvention = CallingConvention.Cdecl),
SuppressUnmanagedCodeSecurity, SecuritySafeCritical]
public static extern herr_t set_virtual_prefix
(hid_t dapl, string prefix);

/// <summary>
/// Sets the maximum number of missing source files and/or datasets
/// with the printf-style names when getting the extent of an unlimited
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ of .NET bindings for HDF5, not the [LCM](https://en.wikipedia.org/wiki/Least_com

| HDF5 Release Version | Assembly Version | Assembly File Version | Git Tag |
| ---------------------------------------------------------------------- | ---------------- | --------------------------------------------------------------- | ------- |
| [1.8.20](https://support.hdfgroup.org/HDF5/release/obtain518.html) | 1.8.20.0 | [1.8.20.0](https://www.nuget.org/packages/HDF.PInvoke/1.8.20.0) | v1.8.20.0 |
| [1.10.1](https://www.hdfgroup.org/HDF5/release/obtain5.html) | 1.10.1.0 | [1.10.1.0](https://www.nuget.org/packages/HDF.PInvoke/1.10.1.0) | v1.10.1.0 |
| [1.8.20](https://portal.hdfgroup.org/display/support/Downloads) | 1.8.20.0 | [1.8.20.0](https://www.nuget.org/packages/HDF.PInvoke/1.8.20.0) | v1.8.20.0 |
| [1.10.2](https://portal.hdfgroup.org/display/support/Downloads) | 1.10.2.0 | [1.10.2.0](https://www.nuget.org/packages/HDF.PInvoke/1.10.2.0) | v1.10.2.0 |

[How "stuff" is versioned.](../../wiki/Versioning-and-Releases)

Expand All @@ -30,7 +30,7 @@ To install the latest HDF.PInvoke 1.8, run the following command in the
To install the latest HDF.PInvoke 1.10, run the following command in the
[Package Manager Console](https://docs.nuget.org/docs/start-here/using-the-package-manager-console)
```
Install-Package HDF.PInvoke -Version 1.10.1.0
Install-Package HDF.PInvoke -Version 1.10.2.0
```

# Prerequisites
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
##### 1.10.2.0
* Updated native dependencies (HDF5 1.10.2)
* VDS H5P.[g,s]et_virtual_prefix
* Fixed H5F.get_file_image() declaration (thanks polivbr)

##### 1.8.20.0
* Updated native dependencies (HDF5 1.8.20)

Expand Down
8 changes: 4 additions & 4 deletions UnitTests/H5FTest/H5Fget_files_image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public void H5Fget_files_imageTest1()
Assert.IsTrue(file >= 0);

IntPtr buf_len = new IntPtr();
ssize_t size = H5F.get_file_image(file, IntPtr.Zero, ref buf_len);
ssize_t size = H5F.get_file_image(file, IntPtr.Zero, buf_len);
Assert.IsTrue(size.ToInt32() > 0);

IntPtr buf = H5.allocate_memory(new IntPtr(size.ToInt32()), 1);
Assert.IsTrue(buf != IntPtr.Zero);

Assert.IsTrue(H5F.get_file_image(file, IntPtr.Zero,
ref buf_len).ToInt32() > 0);
buf_len).ToInt32() > 0);

Assert.IsTrue(H5.free_memory(buf) >= 0);

Expand All @@ -64,14 +64,14 @@ public void H5Fget_files_imageTest2()
Assert.IsTrue(file >= 0);

IntPtr buf_len = new IntPtr();
ssize_t size = H5F.get_file_image(file, IntPtr.Zero, ref buf_len);
ssize_t size = H5F.get_file_image(file, IntPtr.Zero, buf_len);
Assert.IsTrue(size.ToInt32() > 0);

IntPtr buf = Marshal.AllocHGlobal((int) size);
Assert.IsTrue(buf != IntPtr.Zero);

Assert.IsTrue(H5F.get_file_image(file, IntPtr.Zero,
ref buf_len).ToInt32() > 0);
buf_len).ToInt32() > 0);

Marshal.FreeHGlobal(buf);

Expand Down
6 changes: 3 additions & 3 deletions UnitTests/H5PTest/H5Pget_mdc_image_config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public void H5Pget_mdc_image_configTest1()
hid_t fapl = H5P.create(H5P.FILE_ACCESS);
Assert.IsTrue(fapl >= 0);
H5AC.cache_image_config_t conf =
new H5AC.cache_image_config_t(0);
int sz = Marshal.SizeOf(conf.GetType());
IntPtr config_ptr = Marshal.AllocHGlobal(sz);
new H5AC.cache_image_config_t();
conf.version = H5AC.CURR_CACHE_IMAGE_CONFIG_VERSION;
IntPtr config_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(conf));
Marshal.StructureToPtr((H5AC.cache_image_config_t)conf,
config_ptr, false);
Assert.IsTrue(H5P.get_mdc_image_config(fapl, config_ptr) >= 0);
Expand Down
72 changes: 72 additions & 0 deletions UnitTests/H5PTest/H5Pglobals_test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HDF.PInvoke;

using hsize_t = System.UInt64;

#if HDF5_VER1_10
using hid_t = System.Int64;

namespace UnitTests
{
public partial class H5PTest
{
[TestMethod]
public void H5PglobalsTest1()
{
hsize_t[] dims = { 10, 10, 10 };
hsize_t[] max_dims = { H5S.UNLIMITED, H5S.UNLIMITED, H5S.UNLIMITED };
hid_t space = H5S.create_simple(3, dims, max_dims);

hid_t lcpl = H5P.create(H5P.LINK_CREATE);
Assert.IsTrue(H5P.set_create_intermediate_group(lcpl, 1) >= 0);

hid_t dcpl = H5P.create(H5P.DATASET_CREATE);
Assert.IsTrue(dcpl >= 0);
hsize_t[] chunk = { 64, 64, 64 };
Assert.IsTrue(H5P.set_chunk(dcpl, 3, chunk) >= 0);
Assert.IsTrue(H5P.set_deflate(dcpl, 9) >= 0);

hid_t dset = H5D.create(m_v0_test_file, "A/B/C", H5T.IEEE_F32BE,
space, lcpl, dcpl);
Assert.IsTrue(dset >= 0);

hid_t plist = H5D.get_create_plist(dset);
Assert.IsTrue(H5D.layout_t.CHUNKED == H5P.get_layout(plist));
Assert.IsTrue(H5P.close(plist) >= 0);

Assert.IsTrue(H5D.close(dset) >= 0);

dset = H5D.create(m_v2_test_file, "A/B/C", H5T.IEEE_F32BE,
space, lcpl, dcpl);
Assert.IsTrue(dset >= 0);

plist = H5D.get_create_plist(dset);
Assert.IsTrue(H5D.layout_t.CHUNKED == H5P.get_layout(plist));
Assert.IsTrue(H5P.close(plist) >= 0);

Assert.IsTrue(H5D.close(dset) >= 0);

Assert.IsTrue(H5P.close(dcpl) >= 0);
Assert.IsTrue(H5P.close(lcpl) >= 0);
Assert.IsTrue(H5S.close(space) >= 0);
}
}
}

#endif
22 changes: 16 additions & 6 deletions UnitTests/H5PTest/H5Pset_mdc_image_config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ public void H5Pset_mdc_image_configTest1()
{
hid_t fapl = H5P.create(H5P.FILE_ACCESS);
Assert.IsTrue(fapl >= 0);
H5AC.cache_image_config_t conf =
new H5AC.cache_image_config_t(0);
int sz = Marshal.SizeOf(conf.GetType());
IntPtr config_ptr = Marshal.AllocHGlobal(sz);
Marshal.StructureToPtr((H5AC.cache_image_config_t)conf,
config_ptr, false);

Assert.IsTrue(H5P.set_libver_bounds(fapl, H5F.libver_t.LATEST) >= 0);

H5AC.cache_image_config_t conf = new H5AC.cache_image_config_t();
conf.version = H5AC.CURR_CACHE_IMAGE_CONFIG_VERSION;
conf.entry_ageout = H5AC.CACHE_IMAGE__ENTRY_AGEOUT__NONE;

IntPtr config_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(conf));
Marshal.StructureToPtr(conf, config_ptr, false);

H5AC.cache_image_config_t conf1 = new H5AC.cache_image_config_t();

conf1 = (H5AC.cache_image_config_t)Marshal.PtrToStructure(
config_ptr, typeof(H5AC.cache_image_config_t));

//Assert.IsTrue(H5P.set_mdc_image_config(fapl, config_ptr) >= 0);

Assert.IsTrue(H5P.close(fapl) >= 0);
Marshal.FreeHGlobal(config_ptr);
}
Expand Down
49 changes: 49 additions & 0 deletions UnitTests/H5PTest/H5Pset_virtual_prefix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HDF.PInvoke;

using hsize_t = System.UInt64;

#if HDF5_VER1_10
using hid_t = System.Int64;

namespace UnitTests
{
public partial class H5PTest
{
[TestMethod]
public void H5Pset_virtual_prefixTest1()
{
hid_t dapl = H5P.create(H5P.DATASET_ACCESS);
Assert.IsTrue(dapl >= 0);
string prefix = "foo";
Assert.IsTrue(H5P.set_virtual_prefix(dapl, prefix) >= 0);

StringBuilder sb = new StringBuilder(4);
IntPtr size = new IntPtr(4);
Assert.IsTrue(H5P.get_virtual_prefix(dapl, sb, size).ToInt32() == 3);

Assert.IsTrue(H5P.close(dapl) >= 0);
}
}
}

#endif
32 changes: 32 additions & 0 deletions UnitTests/H5SWMRTest/H5DOappend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,38 @@ public void H5DOappendTestSWMR1()
Assert.IsTrue(H5P.close(dcpl) >= 0);
Assert.IsTrue(H5S.close(dsp) >= 0);
}

[TestMethod]
public void H5DOappendTestSWMR2()
{
hsize_t[] dims = { 0 };
hsize_t[] maxdims = { H5S.UNLIMITED };
hsize_t[] chunk_dims = { 10 };
uint[] cbuf = { 123, 456, 789 };

hid_t dsp = H5S.create_simple(1, dims, maxdims);
Assert.IsTrue(dsp >= 0);

hid_t dcpl = H5P.create(H5P.DATASET_CREATE);
Assert.IsTrue(dcpl >= 0);
Assert.IsTrue(H5P.set_chunk(dcpl, 1, chunk_dims) >= 0);

hid_t dst = H5D.create(m_v3_test_file_no_swmr, "dset1",
H5T.NATIVE_UINT, dsp, H5P.DEFAULT, dcpl, H5P.DEFAULT);
Assert.IsTrue(dst >= 0);

GCHandle hnd = GCHandle.Alloc(cbuf, GCHandleType.Pinned);

Assert.IsTrue(
H5DO.append(dst, H5P.DEFAULT, 0, new IntPtr(3),
H5T.NATIVE_UINT, hnd.AddrOfPinnedObject()) >= 0);

hnd.Free();

Assert.IsTrue(H5D.close(dst) >= 0);
Assert.IsTrue(H5P.close(dcpl) >= 0);
Assert.IsTrue(H5S.close(dsp) >= 0);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@
<Compile Include="H5PLTest\H5PLTest.cs" />
<Compile Include="H5PLTest\H5PLsize.cs" />
<Compile Include="H5PTest\H5Pget_mdc_image_config.cs" />
<Compile Include="H5PTest\H5Pglobals_test.cs" />
<Compile Include="H5PTest\H5Pset_evict_on_close.cs" />
<Compile Include="H5PTest\H5Pset_mdc_image_config.cs" />
<Compile Include="H5PTest\H5Pset_userblock.cs" />
<Compile Include="H5PTest\H5Pset_virtual_prefix.cs" />
<Compile Include="H5PTest\H5PTest.cs" />
<Compile Include="H5RTest\H5Rget_obj_type.cs" />
<Compile Include="H5RTest\H5Rdereference.cs" />
Expand Down
Binary file modified native/HDF5 1.10/bin32/hdf5.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin32/hdf5.pdb
Binary file not shown.
Binary file modified native/HDF5 1.10/bin32/hdf5_hl.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin32/hdf5_hl.pdb
Binary file not shown.
Binary file modified native/HDF5 1.10/bin32/szip.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin32/zlib.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/hdf5.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/hdf5.pdb
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/hdf5_hl.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/hdf5_hl.pdb
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/szip.dll
Binary file not shown.
Binary file modified native/HDF5 1.10/bin64/zlib.dll
Binary file not shown.

0 comments on commit 6aa3b0f

Please sign in to comment.