Move macros timeradd() and friends from time.h to sys/time.h.

This commit is contained in:
Manuel Stühn 2015-12-24 07:09:39 -06:00 committed by Gregory Nutt
parent 7110634a38
commit 4350b0ba0c
4 changed files with 63 additions and 63 deletions

View File

@ -11247,7 +11247,7 @@
* 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(),
* sys/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

@ -1 +1 @@
Subproject commit 977590368311be209b384ccf611b4c00136472d2
Subproject commit 623c2bd99d8ad753f87ce4db271ffddf4bb1fd68

View File

@ -48,6 +48,67 @@
* Pre-processor Definitions
****************************************************************************/
/* The following are non-standard interfaces in the sense that they are not
* in POSIX.1-2001 nor are they specified at OpenGroup.org. These interfaces
* are present on most BSD derivatives, however, including Linux.
*/
/* void timeradd(FAR struct timeval *a, FAR struct timeval *b,
* FAR 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(FAR struct timeval *a, FAR struct timeval *b,
* FAR 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(FAR struct timeval *tvp); */
#define timerclear(tvp) \
do \
{ \
tvp)->tv_sec = 0; \
tvp)->tv_usec = 0; \
} \
while (0)
/* int timerisset(FAR struct timeval *tvp); */
#define timerisset(tvp) \
((tvp)->tv_sec != 0 || (tvp)->tv_usec != 0)
/* int timercmp(FAR struct timeval *a, FAR 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 Type Definitions
****************************************************************************/

View File

@ -100,67 +100,6 @@
# 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 nor are they specified at OpenGroup.org. These interfaces
* are present on most BSD derivatives, however, including Linux.
*/
/* void timeradd(FAR struct timeval *a, FAR struct timeval *b,
* FAR 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(FAR struct timeval *a, FAR struct timeval *b,
* FAR 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(FAR struct timeval *tvp); */
#define timerclear(tvp) \
do \
{ \
tvp)->tv_sec = 0; \
tvp)->tv_usec = 0; \
} \
while (0)
/* int timerisset(FAR struct timeval *tvp); */
#define timerisset(tvp) \
((tvp)->tv_sec != 0 || (tvp)->tv_usec != 0)
/* int timercmp(FAR struct timeval *a, FAR 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
********************************************************************************/