EN JA
TIMERADD(3)
TIMERADD(3) FreeBSD Library Functions Manual TIMERADD(3)

名称

timeradd, timersub, timerclear, timerisset, timercmptimeval の操作

書式

#include < sys/time.h>

void
timeradd( struct timeval *a, struct timeval *b, struct timeval *res);

void
timersub( struct timeval *a, struct timeval *b, struct timeval *res);

void
timerclear( struct timeval *tvp);

int
timerisset( struct timeval *tvp);

int
timercmp( struct timeval *a, struct timeval *b, CMP);

解説

これらのマクロは gettimeofday(2)settimeofday(2) 呼び出しを使用して timeval 構造体を操作を提供します。構造体は次のように < sys/time.h> で定義されています。

struct timeval { 
 long tv_sec;  /* 1970年 1 月 1 日からの秒数 */ 
 long tv_usec; /* とマイクロ秒 */ 
};

timeradd() は ab に格納された時間情報を加算し、結果の timevalres に格納します。結果は res->tv_usec の値が常に 1,000,000 (1 秒) 未満となるように単純化されます。

timersub() は a から b に格納された時間情報を減算して、結果の timevalres に格納します。

timerclear() は tvp を (エポック) 1970 年 1 月 1 日真夜中 (0 時) に初期化します。

timerisset() は tvp がエポック以外の任意の時間の値に設定されているなら、真を返します。

timercmp() は、 CMP で与えられている比較オペレータを使用して ab を比較して、比較の結果を返します。訳注: CMP には >, >=, <, <= などの比較演算子を直接指定します。

関連項目

gettimeofday(2)

歴史

マクロ timeradd() ファミリは、 NetBSD 1.1 から取り込まれ、 FreeBSD 2.2.6 で登場しました。
August 11, 1999 FreeBSD