diff options
author | hangenuit@gmail.com <hangenuit@gmail.com> | 2011-09-17 18:26:16 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-10-04 11:29:32 -0600 |
commit | 33dec5f3d364eccc9ee8d9e88a8710cea9ee94ec (patch) | |
tree | 8133900b425e8f91404f0d2b955abc84224213df | |
parent | ab2337159de0335e47d4b535fe558c7017c190bc (diff) | |
download | numpy-33dec5f3d364eccc9ee8d9e88a8710cea9ee94ec.tar.gz |
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.
-rw-r--r-- | numpy/core/src/multiarray/datetime_strings.c | 23 | ||||
-rw-r--r-- | numpy/distutils/mingw32ccompiler.py | 12 |
2 files changed, 7 insertions, 28 deletions
diff --git a/numpy/core/src/multiarray/datetime_strings.c b/numpy/core/src/multiarray/datetime_strings.c index 3a3243c27..97d170230 100644 --- a/numpy/core/src/multiarray/datetime_strings.c +++ b/numpy/core/src/multiarray/datetime_strings.c @@ -12,13 +12,6 @@ #include <time.h> -#if defined(_WIN32) && \ - defined(__GNUC__) && \ - (defined(NPY_MINGW_USE_CUSTOM_MSVCR) | \ - defined(NPY_MINGW_USE_64BIT_MSVCR)) -#define time_t __time64_t -#endif - #define NPY_NO_DEPRECATED_API #define _MULTIARRAYMODULE #include <numpy/arrayobject.h> @@ -55,14 +48,6 @@ get_localtime(NPY_TIME_T *ts, struct tm *tms) func_name = "_localtime64_s"; goto fail; } - #elif defined(__GNUC__) && defined(NPY_MINGW_USE_64BIT_MSVCR) - struct tm *tms_tmp; - tms_tmp = _localtime64(ts); - if (tms_tmp == NULL) { - func_name = "_localtime64"; - goto fail; - } - memcpy((void*)tms, (void*)tms_tmp, sizeof(struct tm)); #else struct tm *tms_tmp; tms_tmp = localtime(ts); @@ -108,14 +93,6 @@ get_gmtime(NPY_TIME_T *ts, struct tm *tms) func_name = "_gmtime64_s"; goto fail; } - #elif defined(__GNUC__) && defined(NPY_MINGW_USE_64BIT_MSVCR) - struct tm *tms_tmp; - tms_tmp = _gmtime64(ts); - if (tms_tmp == NULL) { - func_name = "_gmtime64"; - goto fail; - } - memcpy((void*)tms, (void*)tms_tmp, sizeof(struct tm)); #else struct tm *tms_tmp; tms_tmp = gmtime(ts); diff --git a/numpy/distutils/mingw32ccompiler.py b/numpy/distutils/mingw32ccompiler.py index 3e32c6362..02fef9680 100644 --- a/numpy/distutils/mingw32ccompiler.py +++ b/numpy/distutils/mingw32ccompiler.py @@ -91,13 +91,15 @@ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler): build_import_library() # Check for custom msvc runtime library on Windows. Build if it doesn't exist. - if build_msvcr_library() | build_msvcr_library(debug=True): + msvcr_success = build_msvcr_library() + msvcr_dbg_success = build_msvcr_library(debug=True) + if msvcr_success or msvcr_dbg_success: # add preprocessor statement for using customized msvcr lib self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR') - # Else do a check if the current runtime version is >= VS2005 - elif int(msvc_runtime_library().lstrip('msvcr')) >= 80: - # add preprocessor statement to use 64-bit fallback - self.define_macro('NPY_MINGW_USE_64BIT_MSVCR') + + # Define the MSVC version as hint for MinGW + msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr')) + self.define_macro('__MSVCRT_VERSION__', msvcr_version) # **changes: eric jones 4/11/01 # 2. increased optimization and turned off all warnings |