gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36723 - in libmicrohttpd: . src/include src/microhttpd w32


From: gnunet
Subject: [GNUnet-SVN] r36723 - in libmicrohttpd: . src/include src/microhttpd w32/common
Date: Thu, 3 Dec 2015 12:53:15 +0100

Author: Karlson2k
Date: 2015-12-03 12:53:15 +0100 (Thu, 03 Dec 2015)
New Revision: 36723

Modified:
   libmicrohttpd/configure.ac
   libmicrohttpd/src/include/platform.h
   libmicrohttpd/src/microhttpd/connection.c
   libmicrohttpd/w32/common/MHD_config.h
Log:
connection.c: refactor get_date_string() for clarity, distinguish
different gmtime_s() forms, support C11 gmtime_s()

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2015-12-03 11:53:12 UTC (rev 36722)
+++ libmicrohttpd/configure.ac  2015-12-03 11:53:15 UTC (rev 36723)
@@ -450,18 +450,54 @@
        AC_DEFINE([[MHD_DONT_USE_PIPES]], [[1]], [Define to use pair of sockets 
instead of pipes for signaling])
 fi
 
-AC_CHECK_FUNCS_ONCE([accept4 memmem snprintf])
-AC_MSG_CHECKING([[for gmtime_s]])
-AC_LINK_IFELSE(
-  [AC_LANG_PROGRAM(
-    [[ #include <time.h>]], [[struct tm now; time_t t; time (&t); gmtime_s 
(&now, &t)]])
-  ],
+AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
+AC_CHECK_DECL([gmtime_s],
   [
-    AC_DEFINE([HAVE_GMTIME_S], [1], [Define to 1 if you have `gmtime_s' 
function (only for W32).])
-    AC_MSG_RESULT([[yes]])
-  ],
-  [AC_MSG_RESULT([[no]])
-  ])
+    AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
+    AC_LINK_IFELSE(
+        [ AC_LANG_PROGRAM(
+          [[ #define __STDC_WANT_LIB_EXT1__ 1
+             #include <time.h>
+             #ifdef __cplusplus
+             extern "C"
+             #endif
+             struct tm* gmtime_s(const time_t* time, struct tm* result);
+           ]], [[ 
+             struct tm res;
+             time_t t;
+             gmtime_s (&t, &res);
+          ]])
+        ],
+        [
+          AC_DEFINE([HAVE_C11_GMTIME_S], [1], [Define to 1 if you have the 
`gmtime_s' function in C11 form.])
+          AC_MSG_RESULT([[yes]])
+        ],
+        [
+          AC_MSG_RESULT([[no]])
+          AC_MSG_CHECKING([[whether gmtime_s is in W32 form]])
+          AC_LINK_IFELSE(
+            [ AC_LANG_PROGRAM(
+              [[ #include <time.h>
+                 #ifdef __cplusplus
+                 extern "C"
+                 #endif
+                 errno_t gmtime_s(struct tm* _tm, const time_t* time);
+              ]], [[ 
+                 struct tm res;
+                 time_t t;
+                 gmtime_s (&res, &t);
+              ]])
+            ],
+            [
+              AC_DEFINE([HAVE_W32_GMTIME_S], [1], [Define to 1 if you have the 
`gmtime_s' function in W32 form.])
+              AC_MSG_RESULT([[yes]])
+            ],
+            [AC_MSG_RESULT([[no]])
+            ])
+        ])
+  ], [], 
+  [[#define __STDC_WANT_LIB_EXT1__ 1
+    #include<time.h>]])
 
 
 AC_CHECK_DECLS([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], 
[SOCK_NONBLOCK is defined in a socket header])], [],

Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h        2015-12-03 11:53:12 UTC (rev 
36722)
+++ libmicrohttpd/src/include/platform.h        2015-12-03 11:53:15 UTC (rev 
36723)
@@ -81,6 +81,9 @@
 #if LINUX+0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && ! 
defined(_LARGEFILE64_SOURCE)
 #define _LARGEFILE64_SOURCE 1
 #endif
+#ifdef HAVE_C11_GMTIME_S
+#define __STDC_WANT_LIB_EXT1__ 1
+#endif /* HAVE_C11_GMTIME_S */
 
 #include <stdio.h>
 #include <stdlib.h>

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2015-12-03 11:53:12 UTC (rev 
36722)
+++ libmicrohttpd/src/microhttpd/connection.c   2015-12-03 11:53:15 UTC (rev 
36723)
@@ -768,28 +768,28 @@
   };
   struct tm now;
   time_t t;
-#if defined(_WIN32) && !defined(HAVE_GMTIME_S) && !defined(__CYGWIN__)
+#if !defined(HAVE_C11_GMTIME_S) && !defined(HAVE_W32_GMTIME_S) && 
!defined(HAVE_GMTIME_R)
   struct tm* pNow;
 #endif
 
   date[0] = 0;
   time (&t);
-#if !defined(_WIN32)
-  if (NULL != gmtime_r (&t, &now))
-    {
-#elif defined(HAVE_GMTIME_S)
-  if (0 == gmtime_s (&now, &t))
-    {
-#elif defined(__CYGWIN__)
-  if (NULL != gmtime_r (&t, &now))
-    {
+#if defined(HAVE_C11_GMTIME_S)
+  if (NULL == gmtime_s (&t, &now))
+    return;
+#elif defined(HAVE_W32_GMTIME_S)
+  if (0 != gmtime_s (&now, &t))
+    return;
+#elif defined(HAVE_GMTIME_R)
+  if (NULL == gmtime_r(&t, &now))
+    return;
 #else
   pNow = gmtime(&t);
-  if (NULL != pNow)
-    {
-      now = *pNow;
+  if (NULL == pNow)
+    return;
+  now = *pNow;
 #endif
-      sprintf (date,
+  sprintf (date,
              "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
              days[now.tm_wday % 7],
              (unsigned int) now.tm_mday,
@@ -798,7 +798,6 @@
              (unsigned int) now.tm_hour,
              (unsigned int) now.tm_min,
              (unsigned int) now.tm_sec);
-    }
 }
 
 

Modified: libmicrohttpd/w32/common/MHD_config.h
===================================================================
--- libmicrohttpd/w32/common/MHD_config.h       2015-12-03 11:53:12 UTC (rev 
36722)
+++ libmicrohttpd/w32/common/MHD_config.h       2015-12-03 11:53:15 UTC (rev 
36723)
@@ -65,8 +65,8 @@
 /* Define to 1 if you have the `_lseeki64' function. */
 #define HAVE___LSEEKI64 1
 
-/* Define to 1 if you have the `gmtime_s' function. */
-#define HAVE_GMTIME_S 1
+/* Define to 1 if you have the `gmtime_s' function in W32 form. */
+#define HAVE_W32_GMTIME_S 1
 
 #if _MSC_VER >= 1900 /* snprintf() supported natively since VS2015 */
 /* Define to 1 if you have the `snprintf' function. */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]