Mercurial > cpython-lru_cache-weakref
annotate Include/pytime.h @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 62b61abd02b8 |
| children | f8409b3d6449 |
| rev | line source |
|---|---|
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
64988
diff
changeset
|
1 #ifndef Py_LIMITED_API |
|
63757
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
2 #ifndef Py_PYTIME_H |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
3 #define Py_PYTIME_H |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
4 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
5 #include "pyconfig.h" /* include for defines */ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
6 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
7 /************************************************************************** |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
8 Symbols and macros to supply platform-independent interfaces to time related |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
9 functions and constants |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
10 **************************************************************************/ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
11 #ifdef __cplusplus |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
12 extern "C" { |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
13 #endif |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
14 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
15 #ifdef HAVE_GETTIMEOFDAY |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
16 typedef struct timeval _PyTime_timeval; |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
17 #else |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
18 typedef struct { |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
19 time_t tv_sec; /* seconds since Jan. 1, 1970 */ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
20 long tv_usec; /* and microseconds */ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
21 } _PyTime_timeval; |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
22 #endif |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
23 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
24 /* Similar to POSIX gettimeofday but cannot fail. If system gettimeofday |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
25 * fails or is not available, fall back to lower resolution clocks. |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
26 */ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
27 PyAPI_FUNC(void) _PyTime_gettimeofday(_PyTime_timeval *tp); |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
28 |
|
64988
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
29 #define _PyTime_ADD_SECONDS(tv, interval) \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
30 do { \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
31 tv.tv_usec += (long) (((long) interval - interval) * 1000000); \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
32 tv.tv_sec += (time_t) interval + (time_t) (tv.tv_usec / 1000000); \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
33 tv.tv_usec %= 1000000; \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
34 } while (0) |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
35 |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
36 #define _PyTime_INTERVAL(tv_start, tv_end) \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
37 ((tv_end.tv_sec - tv_start.tv_sec) + \ |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
38 (tv_end.tv_usec - tv_start.tv_usec) * 0.000001) |
|
0f8c2eb89f46
Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
Antoine Pitrou <solipsis@pitrou.net>
parents:
63951
diff
changeset
|
39 |
|
63757
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
40 /* Dummy to force linking. */ |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
41 PyAPI_FUNC(void) _PyTime_Init(void); |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
42 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
43 #ifdef __cplusplus |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
44 } |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
45 #endif |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
46 |
|
c16803bbd790
Issue #9079: Added _PyTime_gettimeofday(_PyTime_timeval *tp) to C API
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents:
diff
changeset
|
47 #endif /* Py_PYTIME_H */ |
|
66664
62b61abd02b8
Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents:
64988
diff
changeset
|
48 #endif /* Py_LIMITED_API */ |
