time.h: Add timeradd(), timersub(), timerclear(), timerisset(), and timercmp() as macros. These are non-POSIX interfaces, but included in most BSD deriviatives, included Linux. From Manuel Stühn
This commit is contained in:
parent
86935ca2dc
commit
3002023798
@ -11247,4 +11247,8 @@
|
||||
* waitpid: CRITICAL BUGFIX. Add a reference count to prevent waitpid
|
||||
from using stale memory released by the waited-for task group
|
||||
(2015-12-22).
|
||||
* time.h: Add timeradd(), timersub(), timerclear(), timerisset(),
|
||||
and timercmp() as macros. These are non-POSIX interfaces, but
|
||||
included in most BSD deriviatives, included Linux. From Manuel Stühn
|
||||
(2015-12-23).
|
||||
|
||||
|
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 362ac0b7d75cabd5f2b1d4c051759a1bc748726b
|
||||
Subproject commit 27b79f79b0f9a1929a21921fbb97a553d87886c9
|
2
configs
2
configs
@ -1 +1 @@
|
||||
Subproject commit 1396fd342ee0f6430de37047a7cbdf227b51eec3
|
||||
Subproject commit 3042534b17f48c84cf556ad691afe6f29e7e55bd
|
@ -100,6 +100,63 @@
|
||||
# define localtime_r(c,r) gmtime_r(c,r)
|
||||
#endif
|
||||
|
||||
/* The following are non-standard interfaces in the sense that they are not
|
||||
* in POSIX.1-2001. These interfaces are present on most BSD derivatives,
|
||||
* however, including Linux.
|
||||
*/
|
||||
|
||||
/* void timeradd(struct timeval *a, struct timeval *b, struct timeval *res); */
|
||||
|
||||
#define timeradd(tvp, uvp, vvp) \
|
||||
do \
|
||||
{ \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec >= 1000000) \
|
||||
{ \
|
||||
(vvp)->tv_sec++; \
|
||||
(vvp)->tv_usec -= 1000000; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* void timersub(struct timeval *a, struct timeval *b, struct timeval *res); */
|
||||
|
||||
#define timersub(tvp, uvp, vvp) \
|
||||
do \
|
||||
{ \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) \
|
||||
{ \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* void timerclear(struct timeval *tvp); */
|
||||
|
||||
#define timerclear(tvp) \
|
||||
do \
|
||||
{ \
|
||||
tvp)->tv_sec = 0; \
|
||||
tvp)->tv_usec = 0; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* int timerisset(struct timeval *tvp); */
|
||||
|
||||
#define timerisset(tvp) \
|
||||
((tvp)->tv_sec != 0 || (tvp)->tv_usec != 0)
|
||||
|
||||
/* int timercmp(struct timeval *a, struct timeval *b, CMP); */
|
||||
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
|
||||
/********************************************************************************
|
||||
* Public Types
|
||||
********************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user