summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-03-23 11:19:53 (GMT)
committerGitHub <noreply@github.com>2021-03-23 11:19:53 (GMT)
commit69f3cde9365a1190f624586e7e9736b7b4df55f1 (patch)
tree319fe29f6b453cbae2f5a5c9aa0b3782885d6959 /src
parent99c0f504a27164d74b2c8e2d4d6afa597ba5ca7b (diff)
downloadhdf5-69f3cde9365a1190f624586e7e9736b7b4df55f1.zip
hdf5-69f3cde9365a1190f624586e7e9736b7b4df55f1.tar.gz
hdf5-69f3cde9365a1190f624586e7e9736b7b4df55f1.tar.bz2
Updates HSYS_GOTO_ERROR to emit GetLastError() values on Win32 (#492)
* Committing clang-format changes * Updates H5SYS_GOTO_ERROR to emit Win32's GetLastError() * Committing clang-format changes * Format source changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/H5Eprivate.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index 58010a3..c3c440f 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -111,6 +111,7 @@ typedef struct H5E_t H5E_t;
/* Retrieve the error code description string and push it onto the error
* stack.
*/
+#ifndef H5_HAVE_WIN32_API
#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \
{ \
int myerrno = errno; \
@@ -129,6 +130,35 @@ typedef struct H5E_t H5E_t;
HGOTO_ERROR(majorcode, minorcode, retcode, "%s, errno = %d, error message = '%s'", str, myerrno, \
HDstrerror(myerrno)); \
}
+#else /* H5_HAVE_WIN32_API */
+/* On Windows we also emit the result of GetLastError(). This call returns a DWORD, which is always a
+ * 32-bit unsigned type. Note that on Windows, either errno or GetLastError() (but probably not both) will
+ * be useful depending on whether a C/POSIX or Win32 call failed. The other value will likely be zero,
+ * though I wouldn't count on that.
+ */
+#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str) \
+ { \
+ int myerrno = errno; \
+ DWORD win_error = GetLastError(); \
+ /* Other projects may rely on the description format to get the errno and any changes should be \
+ * considered as an API change \
+ */ \
+ HDONE_ERROR(majorcode, minorcode, retcode, \
+ "%s, errno = %d, error message = '%s', Win32 GetLastError() = %" PRIu32 "", str, \
+ myerrno, HDstrerror(myerrno), win_error); \
+ }
+#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str) \
+ { \
+ int myerrno = errno; \
+ DWORD win_error = GetLastError(); \
+ /* Other projects may rely on the description format to get the errno and any changes should be \
+ * considered as an API change \
+ */ \
+ HGOTO_ERROR(majorcode, minorcode, retcode, \
+ "%s, errno = %d, error message = '%s', Win32 GetLastError() = %" PRIu32 "", str, \
+ myerrno, HDstrerror(myerrno), win_error); \
+ }
+#endif /* H5_HAVE_WIN32_API */
#ifdef H5_HAVE_PARALLEL
/*