diff options
author | Larry Hastings <larry@hastings.org> | 2015-03-30 08:50:00 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2015-03-30 08:50:00 (GMT) |
commit | 09dab7a87eaa7115eeaf73016d65f2f835e25986 (patch) | |
tree | 04a83c1cfce64d3418a245feae7fee445e510949 /Include | |
parent | 736240399e469a4134dac32a340feca5395baa28 (diff) | |
parent | 45cff0c0e6c4a31ed3b5b88ee803320862fbd43a (diff) | |
download | cpython-09dab7a87eaa7115eeaf73016d65f2f835e25986.zip cpython-09dab7a87eaa7115eeaf73016d65f2f835e25986.tar.gz cpython-09dab7a87eaa7115eeaf73016d65f2f835e25986.tar.bz2 |
Merge 3.5.0a3 release engineering changes back into trunk.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/fileutils.h | 8 | ||||
-rw-r--r-- | Include/pytime.h | 104 |
2 files changed, 56 insertions, 56 deletions
diff --git a/Include/fileutils.h b/Include/fileutils.h index 93a9297..4fd3172 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -41,12 +41,16 @@ struct _Py_stat_struct { PyAPI_FUNC(int) _Py_fstat( int fd, - struct _Py_stat_struct *stat); + struct _Py_stat_struct *status); + +PyAPI_FUNC(int) _Py_fstat_noraise( + int fd, + struct _Py_stat_struct *status); #endif /* Py_LIMITED_API */ PyAPI_FUNC(int) _Py_stat( PyObject *path, - struct stat *statbuf); + struct stat *status); #ifndef Py_LIMITED_API PyAPI_FUNC(int) _Py_open( diff --git a/Include/pytime.h b/Include/pytime.h index 0ff009a..1f14d6d 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -13,45 +13,26 @@ functions and constants extern "C" { #endif -#ifdef HAVE_GETTIMEOFDAY -typedef struct timeval _PyTime_timeval; +#ifdef PY_INT64_T +/* _PyTime_t: Python timestamp with subsecond precision. It can be used to + store a duration, and so indirectly a date (related to another date, like + UNIX epoch). */ +typedef PY_INT64_T _PyTime_t; +#define _PyTime_MIN PY_LLONG_MIN +#define _PyTime_MAX PY_LLONG_MAX #else -typedef struct { - time_t tv_sec; /* seconds since Jan. 1, 1970 */ - long tv_usec; /* and microseconds */ -} _PyTime_timeval; +# error "_PyTime_t need signed 64-bit integer type" #endif -/* Structure used by time.get_clock_info() */ -typedef struct { - const char *implementation; - int monotonic; - int adjustable; - double resolution; -} _Py_clock_info_t; - -/* Similar to POSIX gettimeofday but cannot fail. If system gettimeofday - * fails or is not available, fall back to lower resolution clocks. - */ -PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp); - typedef enum { - /* Round towards zero. */ - _PyTime_ROUND_DOWN=0, - /* Round away from zero. - For example, used for timeout to wait "at least" N seconds. */ - _PyTime_ROUND_UP, /* Round towards minus infinity (-inf). For example, used to read a clock. */ - _PyTime_ROUND_FLOOR + _PyTime_ROUND_FLOOR=0, + /* Round towards infinity (+inf). + For example, used for timeout to wait "at least" N seconds. */ + _PyTime_ROUND_CEILING } _PyTime_round_t; -/* Convert a number of seconds, int or float, to time_t. */ -PyAPI_FUNC(int) _PyTime_ObjectToTime_t( - PyObject *obj, - time_t *sec, - _PyTime_round_t); - /* Convert a time_t to a PyLong. */ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( time_t sec); @@ -60,6 +41,12 @@ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( PyAPI_FUNC(time_t) _PyLong_AsTime_t( PyObject *obj); +/* Convert a number of seconds, int or float, to time_t. */ +PyAPI_FUNC(int) _PyTime_ObjectToTime_t( + PyObject *obj, + time_t *sec, + _PyTime_round_t); + /* Convert a number of seconds, int or float, to a timeval structure. usec is in the range [0; 999999] and rounded towards zero. For example, -1.2 is converted to (-2, 800000). */ @@ -78,22 +65,6 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec( long *nsec, _PyTime_round_t); -/* Initialize time. - Return 0 on success, raise an exception and return -1 on error. */ -PyAPI_FUNC(int) _PyTime_Init(void); - -/****************** NEW _PyTime_t API **********************/ - -#ifdef PY_INT64_T -/* _PyTime_t: Python timestamp with subsecond precision. It can be used to - store a duration, and so indirectly a date (related to another date, like - UNIX epoch). */ -typedef PY_INT64_T _PyTime_t; -#define _PyTime_MIN PY_LLONG_MIN -#define _PyTime_MAX PY_LLONG_MAX -#else -# error "_PyTime_t need signed 64-bit integer type" -#endif /* Create a timestamp from a number of nanoseconds (C long). */ PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns); @@ -121,11 +92,17 @@ PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t); /* Convert a timestamp to a timeval structure (microsecond resolution). tv_usec is always positive. - Return -1 if the conversion overflowed, return 0 on success. */ + Raise an exception and return -1 if the conversion overflowed, + return 0 on success. */ PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t, struct timeval *tv, _PyTime_round_t round); +/* Similar to _PyTime_AsTimeval(), but don't raise an exception on error. */ +PyAPI_FUNC(int) _PyTime_AsTimeval_noraise(_PyTime_t t, + struct timeval *tv, + _PyTime_round_t round); + #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE) /* Convert a timestamp to a timespec structure (nanosecond resolution). tv_nsec is always positive. @@ -134,12 +111,10 @@ PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts); #endif /* Get the current time from the system clock. - * Fill clock information if info is not NULL. - * Raise an exception and return -1 on error, return 0 on success. - */ -PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( - _PyTime_t *t, - _Py_clock_info_t *info); + + The function cannot fail. _PyTime_Init() ensures that the system clock + works. */ +PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void); /* Get the time of a monotonic clock, i.e. a clock that cannot go backwards. The clock is not affected by system clock updates. The reference point of @@ -150,6 +125,23 @@ PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( is available and works. */ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void); + +/* Structure used by time.get_clock_info() */ +typedef struct { + const char *implementation; + int monotonic; + int adjustable; + double resolution; +} _Py_clock_info_t; + +/* Get the current time from the system clock. + * Fill clock information if info is not NULL. + * Raise an exception and return -1 on error, return 0 on success. + */ +PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( + _PyTime_t *t, + _Py_clock_info_t *info); + /* Get the time of a monotonic clock, i.e. a clock that cannot go backwards. The clock is not affected by system clock updates. The reference point of the returned value is undefined, so that only the difference between the @@ -163,6 +155,10 @@ PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo( _Py_clock_info_t *info); +/* Initialize time. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) _PyTime_Init(void); + #ifdef __cplusplus } #endif |