Skip to content

Win32 build #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/dummymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PyObject *PyInit__dummy(void) {
}
#else
PyMODINIT_FUNC
init_sort(void) {
init_dummy(void) {
Py_InitModule("_dummy", methods);
}
#endif
93 changes: 90 additions & 3 deletions numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,46 @@ parse_iso_8601_datetime(char *str, int len,
time_t rawtime = 0;
struct tm tm_;

#if defined(_WIN32) && defined(__GNUC__)
/* This is a quagmire in mingw... */
# if 0
struct tm * tm_ptr;
time(&rawtime);
/*
* MINGW supports neither localtime_s nor localtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = localtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime to "
"get a local time");
return -1;
}
tm_ = *tm_ptr;
# else
/*
* Hoping that directly calling the _gmtime64_s and _localtime_s
* functions will allow linking against different MSVC versions.
*/
npy_int64 rawtime64 = 0;
_time64(&rawtime64);
if (_localtime64_s(&tm_, &rawtime64) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to obtain local time "
"from localtime64_s");
return -1;
}
# endif
#elif defined(_WIN32)
time(&rawtime);
#if defined(_WIN32)
if (localtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to obtain local time "
"from localtime_s");
return -1;
}
#else
/* Other platforms may require something else */
time(&rawtime);
if (localtime_r(&rawtime, &tm_) == NULL) {
PyErr_SetString(PyExc_OSError, "Failed obtain local time "
"from localtime_r");
Expand Down Expand Up @@ -532,7 +563,35 @@ parse_iso_8601_datetime(char *str, int len,
}

/* gmtime converts a 'time_t' into a UTC 'struct tm' */
#if defined(_WIN32)
#if defined(_WIN32) && defined(__GNUC__)
/* This is a quagmire in mingw... */
# if 0
struct tm * tm_ptr;
/*
* MINGW supports neither gmtime_s nor gmtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = gmtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use gmtime to "
"get a UTC time");
goto error;
}
tm_ = *tm_ptr;
# else
/*
* Hoping that directly calling the _gmtime64_s and _localtime_s
* functions will allow linking against different MSVC versions.
*/
npy_int64 rawtime64 = rawtime;
if (_gmtime64_s(&tm_, &rawtime64) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to obtain UTC time "
"from _gmtime64_s");
goto error;
}
# endif
#elif defined(_WIN32)
if (gmtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to use gmtime_s to "
"get a UTC time");
Expand Down Expand Up @@ -884,7 +943,35 @@ make_iso_8601_datetime(npy_datetimestruct *dts, char *outstr, int outlen,
rawtime += dts->min * 60;

/* localtime converts a 'time_t' into a local 'struct tm' */
#if defined(_WIN32)
#if defined(_WIN32) && defined(__GNUC__)
/* This is a quagmire in mingw... */
# if 0
struct tm * tm_ptr;
/*
* MINGW supports neither localtime_s nor localtime_r, but
* supposedly uses thread-local storage, so this should
* be ok.
*/
tm_ptr = localtime(&rawtime);
if (tm_ptr == NULL) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime to "
"get a local time");
return -1;
}
tm_ = *tm_ptr;
# else
/*
* Hoping that directly calling the _gmtime64_s and _localtime_s
* functions will allow linking against different MSVC versions.
*/
npy_int64 rawtime64 = rawtime;
if (_localtime64_s(&tm_, &rawtime64) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to obtain local time "
"from _localtime64_s");
return -1;
}
# endif
#elif defined(_WIN32)
if (localtime_s(&tm_, &rawtime) != 0) {
PyErr_SetString(PyExc_OSError, "Failed to use localtime_s to "
"get a local time");
Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/umath/loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ TIMEDELTA_md_m_multiply(char **args, npy_intp *dimensions, npy_intp *steps, void
BINARY_LOOP {
const npy_timedelta in1 = *(npy_timedelta *)ip1;
const double in2 = *(double *)ip2;
if (in1 == NPY_DATETIME_NAT || isnan(in2)) {
if (in1 == NPY_DATETIME_NAT || npy_isnan(in2)) {
*((npy_timedelta *)op1) = NPY_DATETIME_NAT;
}
else {
Expand All @@ -1184,7 +1184,7 @@ TIMEDELTA_dm_m_multiply(char **args, npy_intp *dimensions, npy_intp *steps, void
BINARY_LOOP {
const double in1 = *(double *)ip1;
const npy_timedelta in2 = *(npy_timedelta *)ip2;
if (isnan(in1) || in2 == NPY_DATETIME_NAT) {
if (npy_isnan(in1) || in2 == NPY_DATETIME_NAT) {
*((npy_timedelta *)op1) = NPY_DATETIME_NAT;
}
else {
Expand Down Expand Up @@ -1220,7 +1220,7 @@ TIMEDELTA_md_m_divide(char **args, npy_intp *dimensions, npy_intp *steps, void *
}
else {
double result = in1 / in2;
if (isnan(result)) {
if (npy_isnan(result)) {
*((npy_timedelta *)op1) = NPY_DATETIME_NAT;
}
else {
Expand Down