TIMERADD

Section: Linux Programmer's Manual (3)
Updated: 2017-09-15
Index JM Home Page
 

名前

timeradd, timersub, timercmp, timerclear, timerisset - timeval の操作  

書式

#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);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

All functions shown above:
    Since glibc 2.19:
        _DEFAULT_SOURCE
    Glibc 2.19 and earlier:
        _BSD_SOURCE  

説明

timeval 構造体を操作するためのマクロが提供されている。 timeval 構造体は <sys/time.h> で以下のように定義されている。

struct timeval {
    time_t      tv_sec;     /* 秒 */
    suseconds_t tv_usec;    /* マイクロ秒 */ };

timeradd() は、 ab の時刻値を加算し、その合計を res により参照される timeval 構造体に格納する。結果は、 res->tv_usec の値が 0 から 999,999 の範囲に入るように正規化される。

timersub() は、 a の時刻値から b の時刻値を減算し、その結果を res により参照される timeval 構造体に格納する。結果は、 res->tv_usec の値が 0 から 999,999 の範囲に入るように正規化される。

timerclear() は tvp により参照される timeval 構造体を 0 で埋める。 0 で埋められた timeval 構造体は、時刻紀元 (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) を表す。

timerisset() は、 tvp により参照される timeval 構造体のいずれか一方のフィールドに 0 以外の値が入っていれば、 真 (0 以外) を返す。

timercmp() は ab の時刻値を比較演算子 CMP を使って比較し、比較結果に基づき、真 (0 以外) か偽 (0) を返す。 (Linux/glibc はそうではないが) いくつかのシステムでは、 timercmp() の実装がおかしく、 CMP>=, <=, == を指定すると正しく動作しない。 移植性が必要なアプリケーションでは、 代わりに以下を使うこと。


    !timercmp(..., <)
    !timercmp(..., >)
    !timercmp(..., !=)  

返り値

timerisset() と timercmp() は、真 (0 以外) か偽 (0) を返す。  

エラー

エラーは定義されていない。  

準拠

POSIX.1 にはない。 ほとんどの BSD 由来のシステムには存在する。  

関連項目

gettimeofday(2), time(7)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

timeval, struct, timercmp, TIMERADD, res, 参照, 時刻, tvp, timerisset, usec

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
エラー
準拠
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:42 GMT, June 11, 2022