ntp_adjtime

å称
     ntp_adjtime — NTP ãã¼ã¢ã³ã¢ããªã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹

æ¸å¼
     <sys/types.h> <sys/timex.h> int ntp_adjtime(struct timex *tp)

解説
     ntp_adjtime() ã·ã¹ãã ã³ã¼ã«ã¯ Network Time Protocol (ãããã¯ã¼ã¯ã¿ã¤ã ãã‐
     ãã³ã«) ãã¼ã¢ã³ ntpd(8) ã®ããã®ã«ã¼ãã«ã¤ã³ã¿ãã§ã¼ã¹ã¨ãã¦ä½¿ç¨ããã¾ãã timex
     æ§é ä½ã®ç¹å®ã®ãã£ã¼ã«ãã¯ã status ã¯ã¼ãã® STA_NANO
     ãããã®ç¶æã«å¾ã£ã¦ããã¤ã¯ãç§ã¾ãã¯ããç§ã«å¤æããã¾ãã

     FreeBSD ã«ã¼ãã«ã®ä¸ã§ã¯ã ntp_adjtime() ããã³ ntp_gettime(2)
     ã·ã¹ãã ã³ã¼ã«ã¯ã©ã¡ãã®å解è½ã使ç¨ãããã決å®ããããã«ãã¾ãã¯
     ããä¸æ¹ãé¸æããããã«ããã¤ã§ã使ç¨ãããã¨ãå¯è½ã§ãã é¸æãããå解è½ã¯ã ntp_gettime()
     ããã³ ntp_adjtime() ã·ã¹ãã ã³ã¼ã«ã®ä¸‐
     ã®ç¹å®ã®ãã£ã¼ã«ãã®ã¹ã±ã¼ãªã³ã°ã«å½±é¿ãåã¼ãã¾ãã

     ãã® API ã¯é常ã«è¤éã§ãç¶æããããã¨ã«æ³¨æãã¦ãã ããã ã¦ã¼ã¶ã¯ãã¯ããã« ntpd(8)
     ã®ã½ã¼ã¹ãå¾¹åºçã«åå³ãããã¨ãªãã«ãä¿®æ£ã試ã¿ãã¹ãã§ã¯ããã¾ããã

     /*
      * NTP ãã¼ã¢ã³ã¤ã³ã¿ãã§ã¼ã¹ (ntp_adjtime()) - CPU ã¯ããã¯çºæ¯å¨ã®
      * å¶å¾¡è¦ç´ã¨ç¶æã®æ±ºå®ã®ããã«ä½¿ç¨ããã¾ãã
      *
      * 注æ: offset, precision ããã³ jitter ã¡ã³ã㯠STA_NANO ã 0 ã§ããã°
      * ãã¤ã¯ãç§ã§ãããã§ãªããã°ããç§ã§ãã
      */
     struct timex {
             unsigned int modes;     /* ã¯ããã¯ã¢ã¼ãããã (wo) */
             long    offset;         /* æå»ãªãã»ãã (ns/us) (rw) */
             long    freq;           /* å¨æ³¢æ°ãªãã»ãã (PPM åä½) (rw) */
             long    maxerror;       /* æ大誤差 (us) (rw) */
             long    esterror;       /* æ¨å®èª¤å·® (us) (rw) */
             int     status;         /* ã¯ããã¯ç¶æããã (rw) */
             long    constant;       /* ãã¼ã«éé (log2 s) (rw) */
             long    precision;      /* æå»ã®ç²¾åº¦ (ns/us) (ro) */
             long    tolerance;      /* ã¯ããã¯å¨æ³¢æ°ã®å¬å·® (PPM åä½) (ro) */
             /*
              * 以ä¸ã®èªã¿åãå°ç¨ã®æ§é ä½ã¡ã³ãã¯ãã«ã¼ãã«åã« PPS
              * ã·ã°ãã«å¶å¾¡è¦ç´ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ããã¦ããå ´åã®ã¿
              * å®è£ããã¾ãããããã¯ãã¼ã¿ããªãã£ãä¿è¨¼ããããã«ãå¨ã¦ã®
              * ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã«å«ã¾ãã¾ãã
              */
             long    ppsfreq;        /* PPS å¨æ³¢æ° (PPM åä½) (ro) */
             long    jitter;         /* PPS ã¸ãã¿ (ns/us) (ro) */
             int     shift;          /* åç¶æé (s) (ã·ãã) (ro) */
             long    stabil;         /* PPS å®å®æ§ (PPM åä½) (ro) */
             long    jitcnt;         /* è¶éããã¸ãã¿å¶é (ro) */
             long    calcnt;         /* 測å®éé (ro) */
             long    errcnt;         /* 測å®èª¤å·® (ro) */
             long    stbcnt;         /* è¶éããå®å®æ§å¶é (ro) */
     };

     æåãã¦å®äºããã¨ãã«ã¯ã ntp_adjtime() 㯠tp å¼æ°ã«ç¾å¨ã®ã¯ããã¯ã®ç¶æãå¥ãã¾ãã

æ»ãå¤
     æåæã«ã¯å®äºããã¯ããã¯ç¶æãè¿ããã¾ãã ããã§ãªããã°ã-1 ãè¿ããã°ãã¼ãã«å¤æ° errno
     ããã®ã¨ã©ã¼ã示ãããã«è¨å®ããã¾ãã

     èµ·ããããã¯ããã¯ã®ç¶æã¯ä»¥ä¸ã®ã¨ããã§ã:

     TIME_OK     å¨ã¦ã OK ã§ãéç§ã®è¦åãããã¾ããã
     TIME_INS    éç§æ¿å¥ã®è¦åã§ãã
     TIME_DEL    éç§åé¤ã®è¦åã§ãã
     TIME_OOP    éç§ã®çµéä¸ã§ãã
     TIME_WAIT   éç§ãçºçãã¾ããã
     TIME_ERROR  ã¯ããã¯ãåæãã¦ãã¾ããã

ã¨ã©ã¼
     ntp_gettime() ã·ã¹ãã ã³ã¼ã«ã¯ãå¼ã³åºãå´ãååãªãã¼ããã·ã§ã³ãæã£ã¦ããªãå ´åã«ã
     EPERM ãè¿ããã¨ãããã¾ãã

é¢é£é ç®
     ntp_gettime(2), ntpd(8)

ä½è
     ãã®ããã¥ã¢ã«ãã¼ã¸ã¯ Tom Rhodes <trhodes@FreeBSD.org> ãæ¸ãã¾ããã