clock_gettime

å称
     clock_gettime, clock_settime, clock_getres — æ¥ä»ã¨æå»ã®åå¾/è¨‐
     å®/精度ã®åå¾ããã

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <sys/time.h> int clock_gettime(clockid_t clock_id, struct timespec *tp)
     int clock_settime(clockid_t clock_id, const struct timespec *tp) int
     clock_getres(clockid_t clock_id, struct timespec *tp)

解説
     clock_gettime() 㨠clock_settime() 㯠clock_id ã§æå®ããã¯ããã¯ã®å¤ãåå¾ãè¨‐
     å®ãã¾ãã

     clock_id å¼æ°ã«ã¯ã次㮠4 ã¤ã®å¤ã®ãã¡ã® 1 ã¤ãæå®ãã¾ãã CLOCK_REALTIME
     ã¯æ®éã®æè¨ã®ããã«é²ãæéã CLOCK_MONOTONIC 㯠SI åä½ç³»ã®ç§ã§é²ãæéã
     CLOCK_VIRTUAL ã¯å¼ã³åºãããã»ã¹ã®ããã« CPU ãã¦ã¼ã¶ã¢ã¼ãã§
     å®è¡ããã¦ããã¨ãã«ã ãé²ãæéã CLOCK_PROF ã¯ãCPU
     ãã¦ã¼ã¶ã¢ã¼ãã¾ãã¯ã«ã¼ãã«ã¢ã¼ãã§å®è¡ããã¦ãã ã¨ãã«é²ãæéã§ãã

     tp ã«ãã£ã¦æãããæ§é ä½ã¯ <sys/time.h> åã§æ¬¡ã®ããã«å®ç¾©ããã¦ãã¾ãã

     struct timespec {
             time_t  tv_sec;         /* ç§ */
             long    tv_nsec;        /* ããç§ */
     };

     æå»ãè¨å®ã§ããã®ã¯ã¹ã¼ãã¦ã¼ã¶ã ãã§ãã ã·ã¹ãã ã®å®å¨æ§ã¬ãã« (securelevel) ã 1
     ãã大ããå ´å (init(8) ãåç§)ã æéã¯é²ãããã¨ã ããã§ãã¾ãã
     ãã®å¶éã¯ãæªæã®ããã¹ã¼ãã¦ã¼ã¶ããã¡ã¤ã«ã« ä»»æã®ã¿ã¤ã ã¹ã¿ã³ããè¨å®ããã®ãé²æ‐
     ¢ããããã®ãã®ã§ãã ããããã·ã¹ãã ãå®å¨ãªã¢ã¼ãã®æã§ãã adjtime(2)
     ã·ã¹ãã ã³ã¼ã«ã使ç¨ããã° ã·ã¹ãã æéãéããããã¨ãã§ãã¦ãã¾ãã¾ãã

     ã¯ããã¯ã®ç²¾åº¦ (ç´°ãã) ã¯ã clock_getres() ã·ã¹ãã ã³ã¼ã«ã«ãã£ã¦è¿ããã¾ãã
     ãã®å¤ã¯ã(é NULL ãã¤ã³ã¿) *tp åã«æ ¼ç´ããã¾ãã

æ»ãå¤
     Upon successful completion, the value 0 is returned; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.

ã¨ã©ã¼
     次ã®ã¨ã©ã¼ã³ã¼ãã errno ã«è¨å®ããã¾ã:

     [EINVAL]           clock_id å¼æ°ãæå¹ãªå¤ã§ã¯ããã¾ããã§ããã

     [EFAULT]           *tp å¼æ°ã¢ãã¬ã¹ãç¡å¹ãªã¡ã¢ãªãåç§ãã¦ãã¾ãã

     [EPERM]            ã¹ã¼ãã¦ã¼ã¶ä»¥å¤ã®ã¦ã¼ã¶ãæå»ãè¨å®ãããã¨ãã¾ããã

é¢é£é ç®
     date(1), adjtime(2), ctime(3), timed(8)

è¦æ ¼
     clock_gettime(), clock_settime() ããã³ clock_getres() ã·ã¹ãã ã³ã¼ã«ã¯ IEEE
     Std 1003.1b-1993 (“POSIX.1”) ã«é©åãã¦ãã¾ãã