.\" Copyright (c) 2007 by Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" 2007-07-31, mtk, Created .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2007-10-16, Akihiro MOTOKI , LDP v2.66 .\" Updated 2009-04-24, Akihiro MOTOKI , LDP v3.20 .\" .TH TIMERADD 3 2010\-02\-25 Linux "Linux Programmer's Manual" .SH 名前 timeradd, timersub, timercmp, timerclear, timerisset \- timeval の操作 .SH 書式 .nf \fB#include \fP \fBvoid timeradd(struct timeval *\fP\fIa\fP\fB, struct timeval *\fP\fIb\fP\fB,\fP \fB struct timeval *\fP\fIres\fP\fB);\fP \fBvoid timersub(struct timeval *\fP\fIa\fP\fB, struct timeval *\fP\fIb\fP\fB,\fP \fB struct timeval *\fP\fIres\fP\fB);\fP \fBvoid timerclear(struct timeval *\fP\fItvp\fP\fB);\fP \fBint timerisset(struct timeval *\fP\fItvp\fP\fB);\fP \fBint timercmp(struct timeval *\fP\fIa\fP\fB, struct timeval *\fP\fIb\fP\fB, \fP\fICMP\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp 上記の全ての関数: _BSD_SOURCE .SH 説明 \fItimeval\fP 構造体を操作するためのマクロが提供されている。 \fItimeval\fP 構造体は \fI\fP で以下のように定義されている。 .sp .in +4n .nf struct timeval { time_t tv_sec; /* 秒 */ suseconds_t tv_usec; /* マイクロ秒 */ }; .fi .in .PP \fBtimeradd\fP() は、 \fIa\fP と \fIb\fP の時刻値を加算し、その合計を \fIres\fP により参照される \fItimeval\fP 構造体に格納する。結果は、 \fIres\->tv_usec\fP の値が 0 から 999,999 の範囲に入るように正規化される。 \fBtimersub\fP() は、 \fIa\fP の時刻値から \fIb\fP の時刻値を減算し、その結果を \fIres\fP により参照される \fItimeval\fP 構造体に格納する。結果は、 \fIres\->tv_usec\fP の値が 0 から 999,999 の範囲に入るように正規化される。 \fBtimerclear\fP() は \fItvp\fP により参照される \fItimeval\fP 構造体を 0 で埋める。 0 で埋められた \fItimeval\fP 構造体は、時刻紀元 (Epoch; 1970\-01\-01 00:00:00 +0000 (UTC)) を表す。 \fBtimerisset\fP() は、 \fItvp\fP により参照される \fItimeval\fP 構造体のいずれか一方のフィールドに 0 以外の値が入っていれば、 真 (0 以外) を返す。 .\" HP-UX, Tru64, Irix have a definition like: .\"#define timercmp(tvp, uvp, cmp) \ .\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \ .\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) \fBtimercmp\fP() は \fIa\fP と \fIb\fP の時刻値を比較演算子 \fICMP\fP を使って比較し、比較結果に基づき、真 (0 以外) か偽 (0) を返す。 (Linux/glibc はそうではないが) いくつかのシステムでは、 \fBtimercmp\fP() の実装がおかしく、 \fICMP\fP に \fI>=\fP, \fI<=\fP, \fI==\fP を指定すると正しく動作しない。 移植性が必要なアプリケーションでは、 代わりに以下を使うこと。 !timercmp(..., <) !timercmp(..., >) !timercmp(..., !=) .SH 返り値 \fBtimerisset\fP() と \fBtimercmp\fP() は、真 (0 以外) か偽 (0) を返す。 .SH エラー エラーは定義されていない。 .SH 準拠 POSIX.1\-2001 にはない。 ほとんどの BSD 由来のシステムには存在する。 .SH 関連項目 \fBgettimeofday\fP(2), \fBtime\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。