diff --git a/ChangeLog b/ChangeLog index 091fc549ce..44ef649360 100755 --- a/ChangeLog +++ b/ChangeLog @@ -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). diff --git a/arch b/arch index 362ac0b7d7..27b79f79b0 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 362ac0b7d75cabd5f2b1d4c051759a1bc748726b +Subproject commit 27b79f79b0f9a1929a21921fbb97a553d87886c9 diff --git a/configs b/configs index 1396fd342e..3042534b17 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 1396fd342ee0f6430de37047a7cbdf227b51eec3 +Subproject commit 3042534b17f48c84cf556ad691afe6f29e7e55bd diff --git a/include/time.h b/include/time.h index 0fd4b7611b..2e85f8e51c 100644 --- a/include/time.h +++ b/include/time.h @@ -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 ********************************************************************************/