Răsfoiți Sursa

Add support for native snprintf() on W32.

Evgeny Grin (Karlson2k) 10 ani în urmă
părinte
comite
738ba14cc9
3 a modificat fișierele cu 13 adăugiri și 4 ștergeri
  1. 1 1
      configure.ac
  2. 7 3
      src/include/platform_interface.h
  3. 5 0
      w32/common/MHD_config.h

+ 1 - 1
configure.ac

@@ -450,7 +450,7 @@ if test "x$enable_socketpair" = "xyes"; then
 	AC_DEFINE([[MHD_DONT_USE_PIPES]], [[1]], [Define to use pair of sockets instead of pipes for signaling])
 fi
 
-AC_CHECK_FUNCS_ONCE([memmem accept4])
+AC_CHECK_FUNCS_ONCE([accept4 memmem snprintf])
 AC_MSG_CHECKING([[for gmtime_s]])
 AC_LINK_IFELSE(
   [AC_LANG_PROGRAM(

+ 7 - 3
src/include/platform_interface.h

@@ -73,11 +73,15 @@
 #endif
 
 /* Platform-independent snprintf name */
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#if defined(HAVE_SNPRINTF)
 #define MHD_snprintf_ snprintf
-#else
+#else  /* ! HAVE_SNPRINTF */
+#if defined(_WIN32)
 #define MHD_snprintf_ W32_snprintf
-#endif
+#else  /* ! _WIN32*/
+#error Your platform does not support snprintf() and MHD does not know how to emulate it on your platform.
+#endif /* ! _WIN32*/
+#endif /* ! HAVE_SNPRINTF */
 
 
 /**

+ 5 - 0
w32/common/MHD_config.h

@@ -68,6 +68,11 @@
 /* Define to 1 if you have the `gmtime_s' function. */
 #define HAVE_GMTIME_S 1
 
+#if _MSC_VER >= 1900 /* snprintf() supported natively since VS2015 */
+/* Define to 1 if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+#endif
+
 
 /* *** Headers information *** */
 /* Not really important as not used by code currently */