mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
Move macros timeradd() and friends from time.h to sys/time.h.
This commit is contained in:
committed by
Gregory Nutt
parent
7110634a38
commit
4350b0ba0c
@@ -11247,7 +11247,7 @@
|
|||||||
* waitpid: CRITICAL BUGFIX. Add a reference count to prevent waitpid
|
* waitpid: CRITICAL BUGFIX. Add a reference count to prevent waitpid
|
||||||
from using stale memory released by the waited-for task group
|
from using stale memory released by the waited-for task group
|
||||||
(2015-12-22).
|
(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
|
and timercmp() as macros. These are non-POSIX interfaces, but
|
||||||
included in most BSD deriviatives, included Linux. From Manuel Stühn
|
included in most BSD deriviatives, included Linux. From Manuel Stühn
|
||||||
(2015-12-23).
|
(2015-12-23).
|
||||||
|
|||||||
+1
-1
Submodule arch updated: 9775903683...623c2bd99d
@@ -48,6 +48,67 @@
|
|||||||
* Pre-processor Definitions
|
* 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
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -100,67 +100,6 @@
|
|||||||
# define localtime_r(c,r) gmtime_r(c,r)
|
# define localtime_r(c,r) gmtime_r(c,r)
|
||||||
#endif
|
#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
|
* Public Types
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user