Fixed timegm usage incompatible with mingw, reverted to mktime in case mingw is detected
authorEdouard Tisserant
Wed, 28 Nov 2012 11:52:03 +0900
changeset 709 bca119630cf6
parent 708 6cc8255ecfe4
child 710 e9bb0ed80471
Fixed timegm usage incompatible with mingw, reverted to mktime in case mingw is detected
lib/iec_std_lib.h
--- a/lib/iec_std_lib.h	Fri Nov 16 01:02:54 2012 +0100
+++ b/lib/iec_std_lib.h	Wed Nov 28 11:52:03 2012 +0900
@@ -224,6 +224,12 @@
   return ts;
 }
 
+#ifdef __MINGW32__
+#define TIMEGM mktime
+#else
+#define TIMEGM timegm
+#endif
+
 static inline IEC_TIMESPEC __date_to_timespec(int day, int month, int year) {
   IEC_TIMESPEC ts;
   struct tm broken_down_time;
@@ -237,7 +243,7 @@
   broken_down_time.tm_year = year - 1900;  /* number of years since 1900 */
   broken_down_time.tm_isdst = -1; /* disable daylight savings time */
   
-  epoch_seconds = timegm(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
+  epoch_seconds = TIMEGM(&broken_down_time); /* determine number of seconds since the epoch, i.e. Jan 1st 1970 */
 
   if ((time_t)(-1) == epoch_seconds)
     __iec_error();