Revert "Evil: remove localtime_r as mingw-w64 defines it when _POSIX_C_SOURCE is...
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 8 May 2019 13:00:47 +0000 (14:00 +0100)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 30 May 2019 08:17:49 +0000 (17:17 +0900)
This reverts commit a4c44e5e744dba15dfe512668127906afd4b6dba.

this breaks on osx it seems... :(

configure.ac
meson.build
src/lib/evil/evil_macro_wrapper.h
src/lib/evil/evil_time.c
src/lib/evil/evil_time.h

index 9661c15..7d0bd56 100755 (executable)
@@ -265,7 +265,6 @@ case "$host_vendor" in
    ;;
 esac
 
-AC_DEFINE([_POSIX_C_SOURCE], [1], [Define the POSIX version])
 AC_SUBST([MODULE_ARCH])
 AC_DEFINE_UNQUOTED([MODULE_ARCH], ["${MODULE_ARCH}"], ["Module architecture"])
 AC_DEFINE_UNQUOTED([SHARED_LIB_SUFFIX], ["${MODULE_EXT}"], [Suffix for shared objects])
index 0512ec0..cecd9a1 100644 (file)
@@ -96,7 +96,6 @@ add_global_arguments(dev_cflags, language: 'cpp')
 foreach lang : ['c', 'objc', 'cpp']
   add_global_arguments('-DHAVE_CONFIG_H=1', language: lang)
   add_global_arguments('-D_GNU_SOURCE=1', language: lang)
-  add_global_arguments('-D_POSIX_C_SOURCE=1', language: lang)
   add_global_arguments('-DEFL_BETA_API_SUPPORT=1', language: lang)
   add_global_arguments('-DNEED_RUN_IN_TREE=1', language: lang)
   add_global_arguments('-DEFL_BUILD=1', language: lang)
index cd650e5..19e68d3 100644 (file)
 #define mkdir(dirname, mode) evil_mkdir(dirname, mode)
 
 /*
+ * evil_time.h
+ */
+
+/**
+ * @def localtime_r(t, r)
+ *
+ * Wrapper around evil_localtime_r().
+ */
+#ifdef localtime_r
+# undef localtime_r
+#endif
+#define localtime_r(t, r) evil_localtime_r(t, r)
+
+/*
  * evil_unistd.h
  */
 
index 90b6369..76c5a58 100644 (file)
 #include "evil_macro_wrapper.h"
 #include "evil_private.h"
 
+struct tm *
+evil_localtime_r(const time_t *timep, struct tm *result)
+{
+   __time64_t t = *timep;
+
+   _localtime64_s(result, &t);
+
+   return result;
+}
+
 /*
  * strptime
  * based on http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD
index 00f538c..34607de 100644 (file)
@@ -2,9 +2,6 @@
 #define __EVIL_TIME_H__
 
 
-#include <time.h>
-
-
 /**
  * @file evil_time.h
  * @brief The file that provides functions ported from Unix in time.h.
 
 
 /**
+ * @brief Convert the calendar time to broken-time representation in a
+ * user supplied data.
+ *
+ * @param timep The calender time.
+ * @param result The broken-down time representation.
+ * @return The broken-down time representation.
+ *
+ * This function converts the calendar time @p timep to a broken-time
+ * representation. The result is stored in the buffer  @p result
+ * supplied by the user. If @p timep or @p result are @c NULL, or if
+ * an error occurred, this function returns @c NULL and the values in
+ * @p result might be undefined. Otherwise it returns @p result.
+ *
+ * Conformity: Non applicable.
+ *
+ * Supported OS: Windows XP.
+ */
+EAPI struct tm *evil_localtime_r(const time_t *timep, struct tm *result);
+
+/**
  * @brief Convert a string representation of time to a time tm structure .
  *
  * @param buf The string to convert.