1 .\" Copyright (c) 2007 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" 2007-07-31, mtk, Created
25 .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
26 .\" all rights reserved.
27 .\" Translated 2007-10-16, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.66
28 .\" Updated 2009-04-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.20
30 .TH TIMERADD 3 2010-02-25 "Linux" "Linux Programmer's Manual"
33 .\"O timeradd, timersub, timercmp, timerclear, timerisset \- timeval operations
34 timeradd, timersub, timercmp, timerclear, timerisset \- timeval ¤ÎÁàºî
38 .B #include <sys/time.h>
40 .BI "void timeradd(struct timeval *" a ", struct timeval *" b ,
41 .BI " struct timeval *" res );
43 .BI "void timersub(struct timeval *" a ", struct timeval *" b ,
44 .BI " struct timeval *" res );
46 .BI "void timerclear(struct timeval *" tvp );
48 .BI "int timerisset(struct timeval *" tvp );
50 .BI "int timercmp(struct timeval *" a ", struct timeval *" b ", " CMP );
54 .\"O Feature Test Macro Requirements for glibc (see
55 .\"O .BR feature_test_macros (7)):
56 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
57 .RB ( feature_test_macros (7)
61 .\"O All functions shown above:
66 .\"O The macros are provided to operate on
68 .\"O structures, defined in
72 ¹½Â¤ÂΤòÁàºî¤¹¤ë¤¿¤á¤Î¥Þ¥¯¥í¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë¡£
76 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
81 .\"O time_t tv_sec; /* seconds */
82 .\"O suseconds_t tv_usec; /* microseconds */
83 time_t tv_sec; /* ÉÃ */
84 suseconds_t tv_usec; /* ¥Þ¥¤¥¯¥íÉà */
90 .\"O adds the time values in
94 .\"O and places the sum in the
98 .\"O The result is normalized such that
100 .\"O has a value in the range 0 to 999,999.
106 ¤Î»þ¹ïÃͤò²Ã»»¤·¡¢¤½¤Î¹ç·×¤ò
110 ¹½Â¤ÂΤ˳ÊǼ¤¹¤ë¡£·ë²Ì¤Ï¡¢
112 ¤ÎÃͤ¬ 0 ¤«¤é 999,999 ¤ÎÈϰϤËÆþ¤ë¤è¤¦¤ËÀµµ¬²½¤µ¤ì¤ë¡£
115 .\"O subtracts the time value in
117 .\"O from the time value in
119 .\"O and places the result in the
123 .\"O The result is normalized such that
124 .\"O .I res\->tv_usec
125 .\"O has a value in the range 0 to 999,999.
131 ¤Î»þ¹ïÃͤò¸º»»¤·¡¢¤½¤Î·ë²Ì¤ò
135 ¹½Â¤ÂΤ˳ÊǼ¤¹¤ë¡£·ë²Ì¤Ï¡¢
137 ¤ÎÃͤ¬ 0 ¤«¤é 999,999 ¤ÎÈϰϤËÆþ¤ë¤è¤¦¤ËÀµµ¬²½¤µ¤ì¤ë¡£
139 .\"O .BR timerclear ()
142 .\"O structure pointed to by
144 .\"O so that it represents the Epoch: 1970-01-01 00:00:00 +0000 (UTC).
150 ¹½Â¤ÂΤò 0 ¤ÇËä¤á¤ë¡£
153 ¹½Â¤ÂΤϡ¢»þ¹ïµª¸µ (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) ¤òɽ¤¹¡£
155 .\"O .BR timerisset ()
156 .\"O returns true (nonzero) if either field of the
158 .\"O structure pointed to by
160 .\"O contains a nonzero value.
166 ¹½Â¤ÂΤΤ¤¤º¤ì¤«°ìÊý¤Î¥Õ¥£¡¼¥ë¥É¤Ë 0 °Ê³°¤ÎÃͤ¬Æþ¤Ã¤Æ¤¤¤ì¤Ð¡¢
170 .\"O compares the timer values in
174 .\"O using the comparison operator
176 .\"O and returns true (nonzero) or false (0) depending on
177 .\"O the result of the comparison.
185 ¤ò»È¤Ã¤ÆÈæ³Ó¤·¡¢Èæ³Ó·ë²Ì¤Ë´ð¤Å¤¡¢¿¿ (0 °Ê³°) ¤«µ¶ (0) ¤òÊÖ¤¹¡£
186 .\"O Some systems (but not Linux/glibc),
190 .\"O .\" HP-UX, Tru64, Irix have a definition like:
191 .\"O .\"#define timercmp(tvp, uvp, cmp) \
192 .\"O .\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \
193 .\"O .\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
202 (Linux/glibc ¤Ï¤½¤¦¤Ç¤Ï¤Ê¤¤¤¬)
203 ¤¤¤¯¤Ä¤«¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
206 .\" HP-UX, Tru64, Irix ¤Ç¤Ï°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
207 .\"#define timercmp(tvp, uvp, cmp) \
208 .\" ((tvp)->tv_sec cmp (uvp)->tv_sec || \
209 .\" (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
215 ¤ò»ØÄꤹ¤ë¤ÈÀµ¤·¤¯Æ°ºî¤·¤Ê¤¤¡£
216 .\"O portable applications can instead use
217 °Ü¿¢À¤¬É¬Íפʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢
218 Âå¤ï¤ê¤Ë°Ê²¼¤ò»È¤¦¤³¤È¡£
223 .\"O .SH RETURN VALUE
225 .\"O .BR timerisset ()
228 .\"O return true (nonzero) or false (0).
232 ¤Ï¡¢¿¿ (0 °Ê³°) ¤«µ¶ (0) ¤òÊÖ¤¹¡£
236 .\"O No errors are defined.
237 ¥¨¥é¡¼¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
238 .\"O .SH CONFORMING TO
240 .\"O Not in POSIX.1-2001.
241 .\"O Present on most BSD derivatives.
242 POSIX.1-2001 ¤Ë¤Ï¤Ê¤¤¡£
243 ¤Û¤È¤ó¤É¤Î BSD ͳÍè¤Î¥·¥¹¥Æ¥à¤Ë¤Ï¸ºß¤¹¤ë¡£
246 .BR gettimeofday (2),