Fix localtime_s and asctime_s compatibility issue

This commit is contained in:
Erik van Pienbroek 2015-01-28 23:05:57 +01:00
parent 55b098074c
commit b3c1d3bb4f
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From c239923641ae52e6c99011c57bc35e86b38f6872 Mon Sep 17 00:00:00 2001
From: martell <martellmalone@gmail.com>
Date: Wed, 28 Jan 2015 20:54:58 +0000
Subject: [PATCH] Use a Guard defined by the spec and not _POSIX. This should
also guard from windows programs that assume the functions are unavailable
---
mingw-w64-headers/crt/time.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h
index b551a27..7b43fd8 100644
--- a/mingw-w64-headers/crt/time.h
+++ b/mingw-w64-headers/crt/time.h
@@ -261,7 +261,7 @@ struct timezone {
#pragma pack(pop)
-#if defined(_POSIX) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if defined(_POSIX_C_SOURCE) || defined(_POSIX_THREAD_SAFE_FUNCTIONS)
__forceinline struct tm *__cdecl localtime_r(const time_t *_Time, struct tm *_Tm) {
return localtime_s(_Tm, _Time) ? NULL : _Tm;
}
@@ -274,7 +274,7 @@ __forceinline char *__cdecl ctime_r(const time_t *_Time, char *_Str) {
__forceinline char *__cdecl asctime_r(const struct tm *_Tm, char * _Str) {
return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
}
-#endif /* _POSIX */
+#endif /* _POSIX_C_SOURCE */
/* Adding timespec definition. */
#include <sys/timeb.h>
--
2.2.2

View File

@ -22,7 +22,7 @@
Name: mingw-headers
Version: 4.0
Release: 0.1.%{pre}%{?dist}
Release: 0.2.%{pre}%{?dist}
Summary: Win32/Win64 header files
License: Public Domain and LGPLv2+ and ZPLv2.1
@ -46,6 +46,9 @@ Source0: http://downloads.sourceforge.net/mingw-w64/mingw-w64-v%{version}
# happening as the .idl files shouldn't be used by default
Patch0: mingw-headers-no-widl.patch
# Fix localtime_s and asctime_s compatibility issue
Patch1: 0001-Use-a-Guard-defined-by-the-spec-and-not-_POSIX.-This.patch
BuildArch: noarch
BuildRequires: mingw32-filesystem >= 95
@ -92,6 +95,7 @@ unzip %{S:0}
%endif
%patch0 -p0 -b .idl
%patch1 -p1 -b .posix_time
%build
@ -126,6 +130,9 @@ rm -f $RPM_BUILD_ROOT%{mingw64_includedir}/pthread_unistd.h
%changelog
* Wed Jan 28 2015 Erik van Pienbroek <epienbro@fedoraproject.org> - 4.0-0.2.rc1
- Fix localtime_s and asctime_s compatibility issue
* Mon Jan 26 2015 Erik van Pienbroek <epienbro@fedoraproject.org> - 4.0-0.1.rc1
- Update to 4.0rc1