Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33dec5f

Browse files
87charris
authored andcommitted
ENH: Incorporated review advice and changed macro hack to MinGW hint.
When doing the typedef change, it conflicted with existing typedefs. I realized that MinGW did not know which MSVC runtime it would link with, but it had conditional definitions for MSVC 8 and up, which can be activated by defining __MSVCRT_VERSION__. So I added it to the compiler macros, which made the fallback hack and extra typedef unnecessary.
1 parent ab23371 commit 33dec5f

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

numpy/core/src/multiarray/datetime_strings.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212

1313
#include <time.h>
1414

15-
#if defined(_WIN32) && \
16-
defined(__GNUC__) && \
17-
(defined(NPY_MINGW_USE_CUSTOM_MSVCR) | \
18-
defined(NPY_MINGW_USE_64BIT_MSVCR))
19-
#define time_t __time64_t
20-
#endif
21-
2215
#define NPY_NO_DEPRECATED_API
2316
#define _MULTIARRAYMODULE
2417
#include <numpy/arrayobject.h>
@@ -55,14 +48,6 @@ get_localtime(NPY_TIME_T *ts, struct tm *tms)
5548
func_name = "_localtime64_s";
5649
goto fail;
5750
}
58-
#elif defined(__GNUC__) && defined(NPY_MINGW_USE_64BIT_MSVCR)
59-
struct tm *tms_tmp;
60-
tms_tmp = _localtime64(ts);
61-
if (tms_tmp == NULL) {
62-
func_name = "_localtime64";
63-
goto fail;
64-
}
65-
memcpy((void*)tms, (void*)tms_tmp, sizeof(struct tm));
6651
#else
6752
struct tm *tms_tmp;
6853
tms_tmp = localtime(ts);
@@ -108,14 +93,6 @@ get_gmtime(NPY_TIME_T *ts, struct tm *tms)
10893
func_name = "_gmtime64_s";
10994
goto fail;
11095
}
111-
#elif defined(__GNUC__) && defined(NPY_MINGW_USE_64BIT_MSVCR)
112-
struct tm *tms_tmp;
113-
tms_tmp = _gmtime64(ts);
114-
if (tms_tmp == NULL) {
115-
func_name = "_gmtime64";
116-
goto fail;
117-
}
118-
memcpy((void*)tms, (void*)tms_tmp, sizeof(struct tm));
11996
#else
12097
struct tm *tms_tmp;
12198
tms_tmp = gmtime(ts);

numpy/distutils/mingw32ccompiler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ def __init__ (self,
9191
build_import_library()
9292

9393
# Check for custom msvc runtime library on Windows. Build if it doesn't exist.
94-
if build_msvcr_library() | build_msvcr_library(debug=True):
94+
msvcr_success = build_msvcr_library()
95+
msvcr_dbg_success = build_msvcr_library(debug=True)
96+
if msvcr_success or msvcr_dbg_success:
9597
# add preprocessor statement for using customized msvcr lib
9698
self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
97-
# Else do a check if the current runtime version is >= VS2005
98-
elif int(msvc_runtime_library().lstrip('msvcr')) >= 80:
99-
# add preprocessor statement to use 64-bit fallback
100-
self.define_macro('NPY_MINGW_USE_64BIT_MSVCR')
99+
100+
# Define the MSVC version as hint for MinGW
101+
msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr'))
102+
self.define_macro('__MSVCRT_VERSION__', msvcr_version)
101103

102104
# **changes: eric jones 4/11/01
103105
# 2. increased optimization and turned off all warnings

0 commit comments

Comments
 (0)