*** pyport.h 2001/12/25 19:07:38 2.41 --- pyport.h 2002/01/20 20:15:51 *************** *** 95,100 **** --- 95,101 ---- * WRAPPER FOR and/or * ********************************************/ + #ifndef DONT_HAVE_TIME_H #ifdef TIME_WITH_SYS_TIME #include #include *************** *** 105,110 **** --- 106,112 ---- #include #endif /* !HAVE_SYS_TIME_H */ #endif /* !TIME_WITH_SYS_TIME */ + #endif /* !DONT_HAVE_TIME_H */ /****************************** *************** *** 265,274 **** * in non-overflow cases. * X is evaluated more than once. */ ! #define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ (X) == Py_HUGE_VAL || \ (X) == -Py_HUGE_VAL)) /* Py_SET_ERANGE_ON_OVERFLOW(x) * If a libm function did not set errno, but it looks like the result * overflowed, set errno to ERANGE. Set errno to 0 before calling a libm --- 267,283 ---- * in non-overflow cases. * X is evaluated more than once. */ ! ! #ifndef MS_WINCE ! #define Py_OVERFLOWED(X) ((X) != 0.0 && (Py_GetErrno() == ERANGE || \ (X) == Py_HUGE_VAL || \ (X) == -Py_HUGE_VAL)) + #else + #define Py_OVERFLOWED(X) ((X) != 0.0 && ( \ + (X) == Py_HUGE_VAL || \ + (X) == -Py_HUGE_VAL)) + #endif /* Py_SET_ERANGE_ON_OVERFLOW(x) * If a libm function did not set errno, but it looks like the result * overflowed, set errno to ERANGE. Set errno to 0 before calling a libm *************** *** 277,288 **** --- 286,337 ---- * This isn't reliable. See Py_OVERFLOWED comments. * X is evaluated more than once. */ + #ifndef MS_WINCE #define Py_SET_ERANGE_IF_OVERFLOW(X) \ do { \ if (errno == 0 && ((X) == Py_HUGE_VAL || \ (X) == -Py_HUGE_VAL)) \ errno = ERANGE; \ } while(0) + + #else + #define Py_SET_ERANGE_IF_OVERFLOW(X) \ + do { \ + if (GetLastError() == 0 && ((X) == Py_HUGE_VAL || \ + (X) == -Py_HUGE_VAL)) \ + SetLastError(1); \ + } while(0) + /* ERANGE is not a defined error code on MS_WINCE, so we're just testing to see + if GetLastError is non-zero later on anyway. + */ + #endif + + + /************************************************************************** + Most platforms have a per-thread "last error code", commonly called errno. + + However some platforms do not expose this value as a variable. Rather, the value + is retrieved and set using a function. + + The following macros should be used to reference the "last error code", rather + than referencing errno directly. + + + Py_SetErrno(x) set the last error code to a specific value + Py_GetErrno() retrieve the last error code + **************************************************************************/ + + #ifndef MS_WINCE + #define Py_SetErrno(X) errno = (X) + #else + #define Py_SetErrno(X) SetLastError((X)) + #endif + + #ifndef MS_WINCE + #define Py_GetErrno() (errno) + #else + #define Py_GetErrno() GetLastError() + #endif