summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5system.c50
-rw-r--r--src/H5win32defs.h26
2 files changed, 74 insertions, 2 deletions
diff --git a/src/H5system.c b/src/H5system.c
index 5205d08..4aada77 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -932,6 +932,56 @@ Wnanosleep(uint64_t nanosec)
FUNC_LEAVE_NOAPI_VOID
} /* end Wnanosleep() */
+
+/*-------------------------------------------------------------------------
+ * Function: Wllround, Wllroundf, Wlround, Wlroundf, Wround, Wroundf
+ *
+ * Purpose: Wrapper function for round functions for use with VS2012
+ * and earlier.
+ *
+ * Return: The rounded value that was passed in.
+ *
+ * Programmer: Dana Robinson
+ * December 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+long long
+Wllround(double arg)
+{
+ return (long long)(arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5));
+}
+
+long long
+Wllroundf(float arg)
+{
+ return (long long)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F));
+}
+
+long
+Wlround(double arg)
+{
+ return (long)(arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5));
+}
+
+long
+Wlroundf(float arg)
+{
+ return (long)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F));
+}
+
+double
+Wround(double arg)
+{
+ return arg < 0.0 ? HDceil(arg - 0.5) : HDfloor(arg + 0.5);
+}
+
+float
+Wroundf(float arg)
+{
+ return arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F);
+}
+
#endif /* H5_HAVE_WIN32_API */
diff --git a/src/H5win32defs.h b/src/H5win32defs.h
index 662b97b..33d37b6 100644
--- a/src/H5win32defs.h
+++ b/src/H5win32defs.h
@@ -75,11 +75,21 @@ struct timezone {
#if (_MSC_VER < 1900)
struct timespec
{
- time_t tv_sec; // Seconds - >= 0
- long tv_nsec; // Nanoseconds - [0, 999999999]
+ time_t tv_sec; // Seconds - >= 0
+ long tv_nsec; // Nanoseconds - [0, 999999999]
};
#endif /* MSC_VER < 1900 */
+/* The round functions do not exist in VS2012 and earlier */
+#if (_MSC_VER <= 1700)
+#define HDllround(V) Wllround(V)
+#define HDllroundf(V) Wllroundf(V)
+#define HDlround(V) Wlround(V)
+#define HDlroundf(V) Wlroundf(V)
+#define HDround(V) Wround(V)
+#define HDroundf(V) Wroundf(V)
+#endif /* MSC_VER < 1700 */
+
#endif /* H5_HAVE_VISUAL_STUDIO */
@@ -92,6 +102,18 @@ extern "C" {
H5_DLL char* Wgetlogin(void);
H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...);
H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap);
+
+ /* Round functions only needed for VS2012 and earlier.
+ * They are always built to ensure they don't go stale and
+ * can be deleted (along with their #defines, above) when we
+ * drop VS2012 support.
+ */
+ H5_DLL long long Wllround(double arg);
+ H5_DLL long long Wllroundf(float arg);
+ H5_DLL long Wlround(double arg);
+ H5_DLL long Wlroundf(float arg);
+ H5_DLL double Wround(double arg);
+ H5_DLL float Wroundf(float arg);
#ifdef __cplusplus
}
#endif /* __cplusplus */