summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2019-05-29 11:09:05 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2019-05-29 11:13:06 +0900
commitcd49ee71887cb2e7f2ca422fbc5c28f4bd92b3ca (patch)
tree55707bbd1a483c47a0794350b8593565544c6cd0
parentf7559364b1abe1dc664eed2c37d340a2af522127 (diff)
downloadlibgpg-error-cd49ee71887cb2e7f2ca422fbc5c28f4bd92b3ca.tar.gz
Detect to use strerror_s.
* configure.ac [mingw32*] (strerror_s): Detect. * src/strerror.c [HAVE_STRERROR_S] (system_strerror_r): Use strerror_s. -- GnuPG-bug-id: 4539 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--configure.ac3
-rw-r--r--src/strerror.c10
2 files changed, 12 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index a6526a9..d56f4c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,9 @@ AC_CHECK_HEADERS([stdlib.h locale.h stdint.h sys/select.h sys/time.h \
AC_FUNC_STRERROR_R
case "${host_os}" in
+ mingw32*)
+ AC_CHECK_FUNC([strerror_s])
+ ;;
solaris*)
# All versions of Solaris from 2.4 have a thread-safe strerror().
# Since Solaris 10, in addition strerror_r() exists.
diff --git a/src/strerror.c b/src/strerror.c
index b0efb3d..4cce17f 100644
--- a/src/strerror.c
+++ b/src/strerror.c
@@ -96,8 +96,16 @@ system_strerror_r (int no, char *buf, size_t buflen)
}
#endif /* STRERROR_R_CHAR_P */
+#elif defined (HAVE_STRERROR_S)
+/* Now the Windows version. */
-#else /* HAVE_STRERROR_H */
+static int
+system_strerror_r (int no, char *buf, size_t buflen)
+{
+ return strerror_s (buf, buflen, no);
+}
+
+#else /* ! HAVE_STRERROR_R && ! HAVE_STRERROR_S */
/* Without strerror_r(), we can still provide a non-thread-safe
version. Maybe we are even lucky and the system's strerror() is
already thread-safe. */